/* HTML Hoster — light theme */
:root {
  color-scheme: light only;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --border: #e2e8f0;
  --border-2: #cbd5e1;
  --accent: #2563eb;
  --accent-600: #1d4ed8;
  --accent-50: #eff6ff;
  --accent-100: #dbeafe;
  --danger: #dc2626;
  --danger-600: #b91c1c;
  --danger-50: #fef2f2;
  --warn-50: #fffbeb;
  --warn-200: #fde68a;
  --warn-800: #92400e;
  --ok: #059669;
  --ok-50: #ecfdf5;
  --ok-200: #a7f3d0;
  --ring: 0 0 0 3px rgba(37, 99, 235, .18);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 30px -10px rgba(15, 23, 42, .25);
  --r: 12px;
  --r-sm: 8px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 14.5px/1.55 var(--font); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2 { margin: 0; letter-spacing: -.015em; color: var(--text); }
h1 { font-size: 20px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
p { margin: 0; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); border: 1px solid var(--border); padding: 0 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }
.sr-copy { position: fixed; top: -1000px; left: -1000px; opacity: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: none; box-shadow: var(--ring); }

.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(255, 255, 255, .85); backdrop-filter: saturate(180%) blur(10px);
          -webkit-backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; font-size: 15px; letter-spacing: -.01em; border-radius: 6px; }
.brand img { border-radius: 7px; display: block; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.session-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: #047857; background: var(--ok-50);
                border: 1px solid var(--ok-200); padding: 3px 10px; border-radius: 999px; font-weight: 500; }
.session-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }

.container { max-width: 1120px; margin: 0 auto; padding: 32px 20px 64px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); }
.card-head { margin-bottom: 20px; }
.card-head .muted { margin-top: 4px; font-size: 13.5px; }

/* ---------- Auth ---------- */
.auth { display: grid; place-items: center; min-height: calc(100vh - 180px); }
.auth-card { width: 100%; max-width: 400px; padding: 32px; text-align: left; box-shadow: var(--shadow-lg); }
.auth-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-50); color: var(--accent); margin-bottom: 18px; }
.auth-icon .i { width: 22px; height: 22px; }
.auth-card > .muted { margin: 6px 0 22px; font-size: 13.5px; }
.auth-card .btn-block { margin-top: 18px; }
.fine { margin-top: 18px; font-size: 12px; color: var(--faint); line-height: 1.5; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 24px; align-items: start; }
.upload { padding: 24px; position: sticky; top: 84px; }
.library { padding: 0; overflow: hidden; }

/* ---------- Forms ---------- */
.label { display: block; font-size: 13px; font-weight: 550; color: var(--text-2); margin: 18px 0 6px; }
.label .optional { font-weight: 400; color: var(--faint); margin-left: 4px; }
.input {
  width: 100%; height: 40px; padding: 0 12px; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-2); border-radius: var(--r-sm); box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: #94a3b8; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, .15); }
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.help { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.help-right { text-align: right; }
.help.is-error { color: var(--danger); }
.help.is-warn { color: var(--warn-800); }
.field-error { font-size: 13px; color: var(--danger); margin-top: 8px; }

.input-group { display: flex; align-items: stretch; border: 1px solid var(--border-2); border-radius: var(--r-sm); background: var(--surface);
               box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; overflow: hidden; }
.input-group:hover { border-color: #94a3b8; }
.input-group:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.input-group.is-invalid { border-color: var(--danger); }
.input-group .input { border: 0; box-shadow: none !important; border-radius: 0; min-width: 0; flex: 1; }
.input-prefix { display: flex; align-items: center; padding: 0 1px 0 12px; color: var(--muted); font-family: var(--mono); font-size: 13px; white-space: nowrap; background: var(--surface); }
.slug-group .input { font-family: var(--mono); font-size: 13px; }
.slug-group .input { padding-left: 1px; }
.input-addon { border: 0; background: transparent; color: var(--muted); padding: 0 12px; cursor: pointer; display: grid; place-items: center; }
.input-addon:hover { color: var(--text); }
.input-addon[aria-pressed="true"] { color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  --h: 40px;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--h); padding: 0 16px;
  font: inherit; font-weight: 550; font-size: 14px; line-height: 1; white-space: nowrap; text-decoration: none; cursor: pointer;
  border-radius: var(--r-sm); border: 1px solid transparent; transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  user-select: none;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-sm { --h: 32px; padding: 0 12px; font-size: 13px; }
.btn-icon { width: var(--h); padding: 0; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(37, 99, 235, .3), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover:not(:disabled) { background: var(--accent-600); }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-2); box-shadow: var(--shadow-sm); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: #94a3b8; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: #f1f5f9; color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-600); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-50); color: var(--danger); }
.spinner { display: none; width: 15px; height: 15px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.btn.is-loading { pointer-events: none; }
.btn.is-loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Access (view code) ---------- */
.access { border: 0; padding: 0; margin: 0; min-width: 0; }
.access legend { padding: 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 0; padding: 3px; background: #f1f5f9; border-radius: 10px; border: 1px solid var(--border); }
.seg-opt { position: relative; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 10px; border-radius: 7px;
           font-size: 13px; font-weight: 550; color: var(--muted); cursor: pointer; text-align: center; transition: background .15s, color .15s, box-shadow .15s; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt .i { width: 15px; height: 15px; }
.seg-opt:hover { color: var(--text); }
.seg-opt:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(15, 23, 42, .1), 0 0 0 1px var(--border); }
.seg-opt:has(input:focus-visible) { box-shadow: var(--ring); }
.code-row { margin-top: 10px; }
.mono { font-family: var(--mono); font-size: 13px; }
.text-addon { font: inherit; font-size: 13px; font-weight: 550; color: var(--accent); border-left: 1px solid var(--border) !important; padding: 0 14px; }
.text-addon:hover { background: var(--accent-50); color: var(--accent-600); }
.label-tight { margin-top: 0; }
.badge-lock { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; padding: 1px 8px 1px 6px; border-radius: 999px; vertical-align: 1px;
              background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; font-size: 11.5px; font-weight: 600; }
.badge-lock .i { width: 12px; height: 12px; }
.success-code { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface);
                border: 1px solid var(--ok-200); font-size: 13px; color: var(--text-2); }
.success-code > span { display: inline-flex; align-items: center; gap: 6px; flex: 1 1 100%; color: #c2410c; font-weight: 550; }
.success-code > span .i { width: 15px; height: 15px; }
.success-code code { font-size: 14px; flex: 1; padding: 4px 8px; }
.pi-edit .access { margin-top: 4px; }

/* ---------- Dropzone ---------- */
.dropzone { border: 1.5px dashed var(--border-2); border-radius: var(--r); background: var(--surface-2); cursor: pointer;
            transition: border-color .15s, background .15s; outline: none; }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-50); }
.dropzone:focus-visible { border-color: var(--accent); box-shadow: var(--ring); }
.dropzone.has-file { border-style: solid; border-color: var(--border); background: var(--surface); cursor: default; }
.dropzone.is-invalid { border-color: var(--danger); background: var(--danger-50); }
.dz-empty { padding: 28px 16px; text-align: center; }
.dz-empty p { margin-top: 2px; }
.dz-icon { width: 40px; height: 40px; border-radius: 10px; margin: 0 auto 10px; display: grid; place-items: center; background: var(--surface);
           border: 1px solid var(--border); color: var(--accent); box-shadow: var(--shadow-sm); }
.link-like { color: var(--accent); font-weight: 550; }
.dz-file { display: flex; align-items: center; gap: 12px; padding: 12px; }
.file-badge { flex-shrink: 0; width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; background: #fff7ed;
              color: #c2410c; font: 700 10.5px/1 var(--mono); letter-spacing: .03em; border: 1px solid #fed7aa; }
.file-info { min-width: 0; flex: 1; }
.file-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Alerts ---------- */
.alert { margin-top: 16px; padding: 12px 14px; border-radius: var(--r-sm); font-size: 13.5px; display: grid; gap: 10px; }
.alert-warn { background: var(--warn-50); border: 1px solid var(--warn-200); color: var(--warn-800); }
.alert-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#uploadForm .btn-block { margin-top: 20px; }

/* ---------- Success ---------- */
.success { margin-top: 4px; padding: 16px; border-radius: var(--r); background: var(--ok-50); border: 1px solid var(--ok-200); display: grid; gap: 12px; }
.success-head { display: flex; align-items: center; gap: 8px; color: var(--ok); }
.success-head strong { color: #065f46; }
.copy-field { display: flex; flex-wrap: wrap; gap: 8px; }
.copy-field .input { flex: 1 1 100%; min-width: 0; font-family: var(--mono); font-size: 13px; background: var(--surface); }
.copy-field .btn { flex: 1; }
.success .btn-ghost { justify-self: start; }

/* ---------- Library ---------- */
.lib-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 20px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.lib-head .muted { margin-top: 2px; }
.count { display: inline-block; min-width: 22px; padding: 1px 7px; margin-left: 6px; border-radius: 999px; background: #f1f5f9; color: #475569;
         font-size: 12px; font-weight: 600; text-align: center; vertical-align: 2px; }
.count:empty { display: none; }
.lib-tools { display: flex; align-items: center; gap: 6px; flex: 1; justify-content: flex-end; min-width: 220px; }
.search { position: relative; flex: 1; max-width: 300px; }
.search .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 16px; height: 16px; pointer-events: none; }
.search .input { padding-left: 34px; height: 36px; }
.search .input::-webkit-search-cancel-button { cursor: pointer; }

.page-list { list-style: none; margin: 0; padding: 0; }
.page-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 16px 20px; border-bottom: 1px solid var(--border);
             transition: background .15s; }
.page-item:last-child { border-bottom: 0; }
.page-item:hover { background: var(--surface-2); }
.page-item.is-new { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--accent-50); } to { background: transparent; } }
.pi-link { font-weight: 600; color: var(--text); text-decoration: none; font-family: var(--mono); font-size: 13.5px; word-break: break-all; border-radius: 4px; }
.pi-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.pi-link .pi-path { color: var(--muted); font-weight: 500; }
.pi-meta { margin-top: 3px; display: flex; gap: 6px; min-width: 0; white-space: nowrap; }
.pi-meta span { flex-shrink: 0; }
.pi-meta .pi-file { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pi-meta span + span::before { content: "·"; margin-right: 6px; color: var(--faint); }
.pi-desc { margin-top: 8px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; font-size: 13.5px; }
.pi-desc.is-empty { color: var(--muted); font-style: italic; }
.pi-actions { display: flex; gap: 2px; align-self: start; opacity: .75; transition: opacity .15s; }
.page-item:hover .pi-actions, .pi-actions:focus-within { opacity: 1; }
.pi-actions .btn-icon { --h: 32px; }
.pi-actions .i { width: 16px; height: 16px; }
.pi-edit { margin-top: 10px; }
.pi-edit-actions { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.pi-edit-actions .pi-edit-count { margin-right: auto; }
.pi-confirm { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; padding: 10px 12px;
              border-radius: var(--r-sm); background: var(--danger-50); border: 1px solid #fecaca; color: #991b1b; font-size: 13px; }
.pi-confirm span { margin-right: auto; }

.state { padding: 56px 24px; text-align: center; color: var(--muted); }
.state-icon { width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 12px; display: grid; place-items: center; background: #f1f5f9; color: var(--faint); }
.state strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; }
.skeleton { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.skeleton div { height: 10px; border-radius: 6px; background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skeleton div + div { margin-top: 10px; width: 55%; }
.skeleton div:first-child { width: 35%; height: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Usage meters ---------- */
.usage { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 12px 20px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.meter-label { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.meter-label span:last-child { color: var(--text-2); font-variant-numeric: tabular-nums; }
.meter-track { height: 6px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.meter-fill { height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .4s ease; }
.meter-fill.warn { background: #d97706; }
.meter-fill.full { background: var(--danger); }
@media (max-width: 560px) { .usage { grid-template-columns: 1fr; gap: 10px; padding: 12px 16px; } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 50; display: grid; gap: 8px; width: min(360px, calc(100vw - 40px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 10px; background: #0f172a; color: #f8fafc;
         box-shadow: var(--shadow-lg); font-size: 13.5px; animation: toast-in .2s ease-out; }
.toast .i { width: 17px; height: 17px; margin-top: 1px; }
.toast.ok .i { color: #34d399; }
.toast.err { background: #7f1d1d; }
.toast.err .i { color: #fca5a5; }
.toast.out { animation: toast-out .2s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .upload { position: static; }
}
@media (max-width: 560px) {
  .container { padding: 20px 14px 48px; }
  .topbar-inner { padding: 10px 14px; }
  .session-pill { display: none; }
  .upload, .auth-card { padding: 20px; }
  .lib-head { padding: 16px; }
  .lib-tools { min-width: 0; width: 100%; }
  .search { max-width: none; }
  .page-item { padding: 14px 16px; grid-template-columns: minmax(0, 1fr); }
  .pi-actions { opacity: 1; margin: 4px 0 0 -8px; }
  .copy-field { flex-wrap: wrap; }
  .copy-field .input { flex-basis: 100%; }
  .copy-field .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
