/* CacheSleuth Share styles. Refined brand: slate + teal + amber accent.
   Hand-written, no Tailwind build. Dark mode via .dark on <html> (toggled +
   defaulted from prefers-color-scheme in app.js). Every element, including the
   new brand header, three-segment theme switch, toasts, footer bar, and preview
   panes, is styled here in both light and dark. */

:root {
  --brand-50:#f1f6f6; --brand-100:#dde9eb; --brand-200:#bfd4d8; --brand-300:#94b6bd;
  --brand-400:#67919c; --brand-500:#4a7682; --brand-600:#3e616d; --brand-700:#365059;
  --brand-800:#314451; --brand-900:#2c3a45; --brand-950:#1a2530;
  --accent-400:#f6b02e; --accent-500:#e89318; --accent-600:#cc7110;

  --bg: #f1f5f9;            /* slate-100 */
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border: #e2e8f0;       /* slate-200 */
  --border-strong: #cbd5e1;/* slate-300 */
  --text: #1e293b;         /* slate-800 */
  --text-muted: #64748b;   /* slate-500 */
  --primary: var(--brand-700);
  --primary-hover: var(--brand-600);
  --on-primary: #ffffff;
  --bar-bg: #e2e8f0;
  --bar-fill: var(--brand-500);
  --amber-bg: #fef7e7;
  --amber-border: #f4d58a;
  --error-bg: #fef2f2; --error-text: #b91c1c; --error-border:#fecaca;
  --success: #15803d;
  --toast-bg: #1e293b; --toast-text: #f1f5f9;
  --focus: var(--brand-400);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 10px 30px rgba(15,23,42,.07);
  --shadow-sm: 0 1px 2px rgba(15,23,42,.08);
}

html.dark {
  --bg: #0b1220;
  --surface: #111a2b;
  --surface-2: #0e1626;
  --surface-3: #16223a;
  --border: #22304a;
  --border-strong: #33456a;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --primary: var(--brand-500);
  --primary-hover: var(--brand-400);
  --on-primary: #0b1220;
  --bar-bg: #1e293b;
  --bar-fill: var(--brand-400);
  --amber-bg: #241c0c;
  --amber-border: #5c4718;
  --error-bg: #2a1414; --error-text: #fca5a5; --error-border:#5b2020;
  --success: #4ade80;
  --toast-bg: #f1f5f9; --toast-text: #0b1220;
  --focus: var(--brand-300);
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 12px 34px rgba(0,0,0,.45);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }

/* Shared icon sizing */
svg { display: block; }
.btn-ico { width: 18px; height: 18px; flex: 0 0 auto; }

/* ===========================================================================
   Header / brand
   =========================================================================== */
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 22px; max-width: 760px; width: 100%; margin: 0 auto;
}
.brand {
  display: flex; align-items: center; gap: 12px; text-decoration: none;
  color: var(--text); min-width: 0;
}
.brand-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: 0 0 auto;
  border-radius: 11px;
  box-shadow: 0 4px 12px rgba(46,74,86,.28), inset 0 1px 0 rgba(255,255,255,.18);
}
.brand-logo-svg { width: 40px; height: 40px; border-radius: 11px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; }
.brand-tagline { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.header-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

/* ===========================================================================
   Theme switch: three-segment pill, all icons always visible.
   =========================================================================== */
.theme-switch {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border);
  box-shadow: inset 0 1px 2px rgba(15,23,42,.06);
}
html.dark .theme-switch { box-shadow: inset 0 1px 2px rgba(0,0,0,.4); }
.theme-seg {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; margin: 0;
  border: 1px solid transparent; border-radius: 999px;
  background: transparent; color: var(--text-muted); cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s, transform .06s;
}
.theme-seg svg { width: 17px; height: 17px; }
.theme-seg:hover { color: var(--text); }
.theme-seg[aria-checked="true"] {
  background: var(--surface); color: var(--primary);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
html.dark .theme-seg[aria-checked="true"] { color: var(--brand-300); }
.theme-seg:active { transform: scale(.92); }
.theme-seg:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ===========================================================================
   Main
   =========================================================================== */
.app-main {
  flex: 1 0 auto; width: 100%; max-width: 760px; margin: 0 auto;
  padding: 6px 22px 44px;
}

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; margin-bottom: 18px;
}

/* Drop zone: premium inset feel */
.drop-zone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  padding: 40px 20px; text-align: center; cursor: pointer;
  background: var(--surface-2);
  box-shadow: inset 0 2px 10px rgba(15,23,42,.05);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
html.dark .drop-zone { box-shadow: inset 0 2px 12px rgba(0,0,0,.35); }
.drop-zone:hover, .drop-zone:focus, .drop-zone.drag-over {
  border-color: var(--brand-400); background: var(--brand-50); outline: none;
}
html.dark .drop-zone:hover, html.dark .drop-zone.drag-over { background: var(--surface-3); }
.drop-zone.drag-over { box-shadow: inset 0 2px 14px rgba(74,118,130,.22); }
.drop-zone:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.drop-zone:active { transform: scale(.995); }
.drop-icon { font-size: 30px; color: var(--brand-500); line-height: 1; }
.drop-title { font-weight: 600; margin-top: 8px; }
.drop-hint { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* File list */
.file-list { margin-top: 14px; }
.file-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.file-row:last-child { border-bottom: none; }
.file-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.file-size { color: var(--text-muted); font-size: 13px; white-space: nowrap; }
.file-btns { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.file-remove {
  background: none; border: none; color: var(--text-muted); font-size: 20px;
  cursor: pointer; line-height: 1; padding: 0 6px; border-radius: 6px;
}
.file-remove:hover { color: var(--error-text); }
.file-remove:active { transform: scale(.9); }
.file-remove:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.file-total { padding-top: 12px; color: var(--text-muted); font-size: 13px; font-weight: 600; }

/* Controls */
.controls { margin-top: 20px; display: grid; gap: 14px; }
.field { display: flex; align-items: center; gap: 10px; }
.field-label { font-size: 14px; color: var(--text-muted); min-width: 130px; }
.checkbox-field { align-items: flex-start; }
.checkbox-field span { font-size: 14px; }
.select, .input-num {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 11px; font-size: 14px; font-family: inherit;
}
.input-num { width: 82px; }
.select:focus, .input-num:focus { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--brand-400); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand-600); margin: 0; flex: 0 0 auto; }

.turnstile-box { margin-top: 16px; }

/* ===========================================================================
   Buttons + press states
   =========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  border-radius: var(--radius-sm); padding: 11px 18px; border: 1px solid transparent;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .06s;
  color: var(--text);
}
.btn:disabled { opacity: .55; cursor: default; }
.btn:not(:disabled):active { transform: translateY(1px) scale(.985); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.btn-primary { background: var(--primary); color: var(--on-primary); margin-top: 18px; width: 100%; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); margin-top: 12px; }
.btn-secondary:hover:not(:disabled) { border-color: var(--brand-400); background: var(--surface-2); }
.btn-link { background: none; color: var(--primary); border: none; padding: 8px 0; margin-top: 10px; }
.btn-link:hover { text-decoration: underline; }

/* Icon-only buttons (per-file preview / download / preview close) */
.btn-icon {
  padding: 8px; width: 38px; height: 38px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
}
.btn-icon:hover:not(:disabled) { color: var(--primary); border-color: var(--brand-400); background: var(--surface); }
.btn-icon.active { color: var(--primary); border-color: var(--brand-400); background: var(--brand-50); }
html.dark .btn-icon.active { background: var(--surface-3); color: var(--brand-300); }
.btn-icon.loading { opacity: .6; cursor: progress; }

/* Copy button: swaps to a check + "Copied" on success */
.copy-btn { margin-top: 0; width: auto; white-space: nowrap; flex: 0 0 auto; }
.copy-btn.copied { background: var(--success); color: #fff; border-color: var(--success); }
html.dark .copy-btn.copied { color: #0b1220; }
.copy-label { line-height: 1; }

/* ===========================================================================
   Progress
   =========================================================================== */
.progress-box { margin-top: 18px; display: grid; gap: 10px; }
.prog-row { display: flex; align-items: center; gap: 10px; }
.prog-name { flex: 0 0 40%; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { flex: 1 1 auto; height: 8px; background: var(--bar-bg); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--bar-fill); border-radius: 999px; transition: width .1s linear; }
.total-fill { background: var(--accent-500); }
.prog-total .prog-name { font-weight: 600; }
.prog-total-text { font-size: 13px; color: var(--text-muted); }

/* ===========================================================================
   Result: amber hero share-link box
   =========================================================================== */
.result-box { margin-top: 18px; }
.result-title { font-weight: 700; font-size: 16px; margin-bottom: 10px; }
.link-row {
  display: flex; gap: 8px; align-items: stretch;
  background: var(--amber-bg); border: 1px solid var(--amber-border);
  padding: 10px; border-radius: var(--radius); box-shadow: inset 0 1px 2px rgba(0,0,0,.04);
}
.link-input {
  flex: 1 1 auto; min-width: 0;
  font-family: 'JetBrains Mono', Menlo, monospace; font-size: 13px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; overflow: hidden; text-overflow: ellipsis;
}
.link-input:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.upload-note { color: var(--accent-600); font-size: 13px; margin-top: 10px; }
html.dark .upload-note { color: var(--accent-400); }

/* ===========================================================================
   Download / seed
   =========================================================================== */
.download-info { color: var(--text-muted); font-size: 13px; margin: 14px 0; }
.download-actions { margin-top: 6px; }
.wait-note { color: var(--text-muted); font-size: 14px; }
.seed-status { font-size: 14px; margin-bottom: 10px; }
.peer-list { display: grid; gap: 8px; }
.peer-row { display: flex; align-items: center; gap: 10px; }
.peer-name { flex: 0 0 40%; font-size: 13px; }

/* ===========================================================================
   Preview panes
   =========================================================================== */
.preview-pane {
  margin: 4px 0 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); overflow: hidden; box-shadow: var(--shadow-sm);
}
.preview-bar {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-3);
}
.preview-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-close { width: 32px; height: 32px; padding: 6px; }
.preview-note { padding: 12px 14px; color: var(--text-muted); font-size: 13px; }
.preview-img { display: block; max-width: 100%; max-height: 60vh; margin: 0 auto; object-fit: contain; }
.preview-audio { display: block; width: 100%; padding: 14px; }
.preview-video { display: block; max-width: 100%; max-height: 60vh; margin: 0 auto; background: #000; }
.preview-text {
  margin: 0; padding: 14px 16px; max-height: 60vh; overflow: auto;
  font-family: 'JetBrains Mono', Menlo, monospace; font-size: 12.5px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; color: var(--text); background: var(--surface);
}
.preview-pdf { display: block; width: 100%; height: 70vh; border: 0; background: #fff; }
.preview-openpdf { margin-top: 0; }

/* ===========================================================================
   Error region + toasts
   =========================================================================== */
.error-region {
  background: var(--error-bg); color: var(--error-text); border: 1px solid var(--error-border);
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px; font-size: 14px;
}

.toast-region {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 1000; pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  pointer-events: auto;
  background: var(--toast-bg); color: var(--toast-text);
  border-radius: 999px; padding: 10px 18px; font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(15,23,42,.28);
  opacity: 0; transform: translateY(12px);
  transition: opacity .25s ease, transform .25s ease;
  max-width: 100%; text-align: center;
}
.toast-shown { opacity: 1; transform: translateY(0); }
.toast-hide { opacity: 0; transform: translateY(8px); }
.toast-error { background: #b91c1c; color: #fff; }
.toast-success::before { content: '\2713  '; }
.toast-error::before { content: '\26A0  '; }

/* ===========================================================================
   FAQ
   =========================================================================== */
.faq { margin-top: 8px; }
/* The whole FAQ is one outer collapsible (.faq-section), starting collapsed;
   its summary (.faq-heading) is the disclosure. Native <details> collapse is
   broken in the target browser, so drive .faq-inner off [open] explicitly. */
.faq-heading {
  font-size: 18px; font-weight: 700; letter-spacing: -.01em; color: var(--text);
  cursor: pointer; list-style: none; position: relative;
  padding: 4px 34px 4px 4px; border-radius: 8px;
  transition: background .12s, color .12s;
}
.faq-heading::-webkit-details-marker { display: none; }
.faq-heading::after {
  content: '+'; position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 22px; font-weight: 400; color: var(--text-muted); line-height: 1;
}
.faq-section[open] > .faq-heading::after { content: '\2212'; }
.faq-section[open] > .faq-heading { margin-bottom: 4px; }
.faq-heading:hover { color: var(--primary); background: var(--surface-2); }
.faq-heading:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.faq-section > .faq-inner { display: none; }
.faq-section[open] > .faq-inner { display: block; }
.faq-item { border-top: 1px solid var(--border); }
.faq-item:first-of-type { border-top: none; }
.faq-q {
  cursor: pointer; font-weight: 600; font-size: 15px; padding: 14px 30px 14px 8px;
  position: relative; list-style: none; color: var(--text); border-radius: 8px;
  transition: background .12s, color .12s;
}
.faq-q::-webkit-details-marker { display: none; }
.faq-q::after {
  content: '+'; position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 20px; font-weight: 400; color: var(--text-muted); line-height: 1;
}
.faq-item[open] > .faq-q::after { content: '\2212'; } /* minus sign */
.faq-q:hover { color: var(--primary); background: var(--surface-2); }
.faq-q:active { background: var(--surface-3); }
.faq-q:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* Drive answer visibility explicitly from [open]: the target browser does not
   natively hide closed <details> content. Verified live. */
.faq-item > .faq-a { display: none; }
.faq-item[open] > .faq-a { display: block; }
.faq-a { color: var(--text-muted); font-size: 14px; line-height: 1.6; padding: 0 8px 16px; }

/* ===========================================================================
   Footer: a genuine composed bar (top hairline, faint surface tint, brand +
   nav). Full width; contents constrained to the same 760px column.
   =========================================================================== */
.site-footer {
  flex: 0 0 auto; width: 100%; margin-top: 20px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}
.footer-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
  width: 100%; max-width: 760px; margin: 0 auto;
  padding: 18px 22px 22px;
  color: var(--text-muted); font-size: 13px;
}
.footer-brand { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.footer-lock { display: inline-flex; color: var(--brand-500); flex: 0 0 auto; }
.footer-lock svg { width: 15px; height: 15px; }
html.dark .footer-lock { color: var(--brand-400); }
.footer-text { color: var(--text-muted); }
.footer-nav { display: inline-flex; align-items: center; gap: 16px; flex: 0 0 auto; }
.footer-link { color: var(--primary); text-decoration: none; font-weight: 600; white-space: nowrap; }
.footer-link:hover { text-decoration: underline; }
.footer-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ===========================================================================
   Legal / privacy page: readable long-form typography.
   =========================================================================== */
.legal { max-width: 720px; margin: 6px auto 0; }
.legal-back {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--primary); text-decoration: none; font-size: 14px; font-weight: 600;
  margin-bottom: 18px; padding: 4px 2px; border-radius: 6px;
}
.legal-back:hover { text-decoration: underline; }
.legal-back:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.legal-back .btn-ico { width: 16px; height: 16px; }
.legal-title { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 4px; }
.legal-updated { color: var(--text-muted); font-size: 13px; margin: 0 0 24px; }
.legal-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 20px 22px; margin-bottom: 16px;
}
.legal-h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 12px; }
.legal-body { color: var(--text); font-size: 14.5px; line-height: 1.65; }
.legal-body p { margin: 0 0 12px; }
.legal-body p:last-child { margin-bottom: 0; }
.legal-body ul { margin: 0; padding-left: 20px; display: grid; gap: 10px; }
.legal-body li { line-height: 1.6; }
.legal-note { color: var(--text-muted); font-size: 14px; margin: 0; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ===========================================================================
   Responsive (down to 360px) + reduced motion
   =========================================================================== */
/* Footer stacks its brand + nav, centered, on narrow viewports. */
@media (max-width: 560px) {
  .footer-inner { flex-direction: column; align-items: center; text-align: center; gap: 12px; }
  .footer-brand { justify-content: center; }
}
@media (max-width: 480px) {
  .field { flex-wrap: wrap; }
  .field-label { min-width: 0; flex: 1 0 100%; }
  .prog-name, .peer-name { flex-basis: 32%; }
  .app-header, .app-main { padding-left: 14px; padding-right: 14px; }
  .footer-inner { padding-left: 14px; padding-right: 14px; }
  .link-row { flex-direction: column; }
  .copy-btn { width: 100%; justify-content: center; }
  .panel { padding: 18px; }
  .legal-section { padding: 18px; }
}
@media (max-width: 420px) {
  .brand-tagline { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .001ms !important; animation-duration: .001ms !important; }
  .toast { transition: opacity .2s ease; transform: none; }
  .toast-shown { transform: none; }
  .toast-hide { transform: none; }
  .btn:not(:disabled):active, .theme-seg:active, .faq-q:active, .drop-zone:active { transform: none; }
}
