/* Loose-Notes: graphite on paper-white, a ruled-paper drop zone, a green highlighter
   behind the words that matter. Tokens and components come from the Loose-Notes design
   system (OpenDesign); the page layout follows its reference page. */

:root {
  color-scheme: light;

  --bg: #FBFBF9;
  --surface: #FFFFFF;
  --surface-warm: #F1F2EE;
  --surface-hover: #F5F6F2;
  --rule: #DCE4EE;
  --rule-margin: #F2C6C6;

  --fg: #202428;
  --fg-2: #3F454B;
  --muted: #5C636B;
  --fg-inverted: #FBFBF9;

  --accent: #202428;
  --accent-on: #FBFBF9;
  --accent-hover: #353A40;
  --highlight: #C4F07A;
  --highlight-soft: #E6F9C6;

  --border: #DADDD8;
  --border-soft: #E8EAE5;
  --border-strong: #9AA0A6;
  --focus: #2F5BD3;
  --ring-focus: 0 0 0 3px rgba(47, 91, 211, 0.30);

  --success: #1E7A3C;
  --danger: #B3261E;
  --danger-subtle: #FCE9E7;

  --font-sans: "Figtree", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;

  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-4xl: clamp(40px, 6vw, 64px);
  --leading-body: 1.6;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --control-h: 44px;

  --elev-raised: 0 1px 2px rgba(32, 36, 40, 0.05), 0 6px 20px rgba(32, 36, 40, 0.05);
  --elev-modal: 0 24px 56px rgba(32, 36, 40, 0.20);

  --motion-fast: 120ms;
}

@media (prefers-reduced-motion: reduce) {
  :root { --motion-fast: 0ms; }
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 var(--text-base)/var(--leading-body) var(--font-sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.help { font-size: var(--text-sm); color: var(--muted); }
.link { color: var(--focus); text-underline-offset: 3px; }

/* Highlighter: a marker stroke behind words, slightly uneven */
.hl { background: none; color: inherit; padding: 0 .12em; margin: 0 -.06em; box-shadow: inset 0 -0.42em 0 var(--highlight); border-radius: 2px 6px 3px 5px; }

/* Buttons: graphite for the action; a highlighter edge appears on hover */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--control-h); padding: 0 18px; border-radius: var(--radius-md); border: 1px solid transparent; font: 600 var(--text-base)/1 var(--font-sans); white-space: nowrap; cursor: pointer; transition: background var(--motion-fast), border-color var(--motion-fast), box-shadow var(--motion-fast); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.btn-primary { background: var(--accent); color: var(--accent-on); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 3px 0 var(--highlight); }
.btn-secondary { background: var(--surface); color: var(--fg); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--fg); }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-sm { height: 36px; padding: 0 12px; font-size: var(--text-sm); }
.btn[disabled] { background: var(--surface-warm); color: var(--muted); box-shadow: none; cursor: progress; transform: none; }

/* Page */
.col { width: min(720px, 100% - 32px); margin: 0 auto; }
header.top { display: flex; align-items: center; justify-content: space-between; padding: 20px 0; }
.brand { display: flex; }
.brand img { display: block; height: 34px; width: auto; }
.hero { padding: 56px 0 36px; display: grid; gap: 16px; }
.hero h1 { font-size: var(--text-4xl); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
.hero p { font-size: var(--text-lg); color: var(--fg-2); max-width: 52ch; }
.privacy { display: inline-flex; align-items: center; gap: 8px; font-size: var(--text-sm); font-weight: 600; color: var(--success); }
.hint { margin-top: 12px; text-align: center; }
footer { padding: 32px 0 48px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: var(--text-sm); color: var(--muted); border-top: 1px solid var(--border-soft); margin-top: 32px; }

/* Drop zone: ruled paper with a red margin line */
.drop { position: relative; display: grid; justify-items: center; gap: 10px; padding: 48px 24px 44px; border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); text-align: center; cursor: pointer; transition: background var(--motion-fast), border-color var(--motion-fast);
  background-color: var(--surface);
  background-image: linear-gradient(90deg, transparent 47px, var(--rule-margin) 47px 49px, transparent 49px), repeating-linear-gradient(180deg, transparent 0 31px, var(--rule) 31px 32px); }
.drop:hover, .drop.over { border-color: var(--fg); background-color: var(--highlight-soft); }
.drop:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.drop .icon { width: 36px; height: 36px; stroke-width: 1.5; }
.drop b { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.01em; }
.drop span { color: var(--muted); font-size: var(--text-sm); }

/* Results */
.results { display: grid; gap: 20px; padding: 40px 0 24px; }
.results > .head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.results > .head h2 { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.015em; }
.books { display: grid; gap: 20px; }

/* Notebook group */
.book { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-lg); box-shadow: var(--elev-raised); overflow: hidden; }
.book > header { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--border-soft); }
.book > header:last-child { border-bottom: 0; }
.book .cover { display: grid; place-items: center; width: 40px; height: 48px; border-radius: 4px 8px 8px 4px; background: var(--fg); color: var(--fg-inverted); box-shadow: inset 4px 0 0 rgba(255, 255, 255, .18); flex: none; }
.book .cover.reading { background: var(--surface-warm); color: var(--fg-2); box-shadow: none; }
.book .cover.failed { background: var(--danger-subtle); color: var(--danger); box-shadow: none; }
.book .grow { flex: 1; min-width: 0; }
.book h3 { font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book header p { font-size: var(--text-sm); color: var(--muted); }
.book .error { padding: 16px 20px; color: var(--danger); font-size: var(--text-sm); }
.reading { display: grid; gap: 10px; padding: 18px 20px; }

/* File row */
.file { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 12px 20px; border-top: 1px solid var(--border-soft); }
.file:first-child { border-top: 0; }
.file:hover { background: var(--surface-hover); }
.file .kind { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--surface-warm); color: var(--fg-2); overflow: hidden; }
.file .kind img { width: 100%; height: 100%; object-fit: cover; }
.file .name { display: block; max-width: 100%; padding: 0; border: 0; background: none; font: 600 var(--text-base)/1.4 var(--font-sans); color: var(--fg); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.file .name:hover { text-decoration: underline; text-underline-offset: 3px; }
.file .name:focus-visible { outline: none; box-shadow: var(--ring-focus); border-radius: 4px; }
.file .sub { display: flex; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--muted); }
.file .size { font: 500 var(--text-sm) var(--font-mono); color: var(--muted); }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--fg); cursor: pointer; }
.icon-btn:hover { border-color: var(--fg); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }

/* Type tag: a word and an icon, no rainbow */
.type { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--radius-pill); background: var(--surface-warm); color: var(--fg-2); font-size: var(--text-xs); font-weight: 600; }
.type .icon { width: 13px; height: 13px; }

/* Progress */
.progress { height: 6px; border-radius: 3px; background: var(--surface-warm); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--fg); border-radius: 3px; transition: width var(--motion-fast); }

/* Preview: full-screen, the file centred, name and size in mono underneath */
.preview { width: min(960px, 100% - 32px); max-height: calc(100% - 32px); padding: 0; border: 0; border-radius: var(--radius-lg); background: var(--surface); color: var(--fg); box-shadow: var(--elev-modal); }
.preview::backdrop { background: rgba(32, 36, 40, 0.74); }
.preview-body { display: grid; place-items: center; background: var(--fg); min-height: 200px; }
.preview-body img { display: block; max-width: 100%; max-height: calc(100vh - 180px); object-fit: contain; }
.preview-body audio { width: calc(100% - 48px); margin: 48px 0; }
.preview-foot { display: flex; align-items: center; gap: 12px; padding: 16px 20px; }
.preview-foot .grow { flex: 1; min-width: 0; }
.preview-foot .name { font: 500 var(--text-sm) var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-foot .size { font: 400 var(--text-xs) var(--font-mono); color: var(--muted); }

@media (max-width: 640px) {
  .hero { padding: 32px 0 28px; }
  .file { grid-template-columns: auto minmax(0, 1fr) auto; }
  .file .size { display: none; }
  .book > header { flex-wrap: wrap; }
  .book > header .btn { width: 100%; }
  .preview-foot { flex-wrap: wrap; }
  .preview-foot .grow { flex-basis: 100%; }
}
