/* Ænima/design — the library set as a book's index.
   Bright stock, black ink, hairline rules; blood red only where you can act. */

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/static/schibsted-latin.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/static/schibsted-latin-ext.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/static/schibsted-italic-latin.woff2") format("woff2");
  font-weight: 400 900;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/static/schibsted-italic-latin-ext.woff2") format("woff2");
  font-weight: 400 900;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --font: "Schibsted Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --paper: #fcfcfb;
  --ink: #121211;
  --ink-2: #474743;
  --ink-3: #686863;
  --ink-4: #b9b9b3;
  --rule: #e6e6e2;
  --rule-2: #d0d0ca;
  --wash: #f2f2ef;
  /* Dried-blood red: dark enough to read as ink at a glance, red the moment
     you look at it. Danger is a brighter scarlet so the two never blur. */
  --accent: #9b0a12;
  --accent-deep: #70060c;
  --accent-wash: rgb(155 10 18 / 0.07);
  --on-accent: #ffffff;
  --danger: #d4321f;
  /* Favicons sit on a light tile in both themes so dark logos stay legible. */
  --tile: #fcfcfb;
  /* The reversed plate (bulk bar): ink ground, paper type. */
  --plate-line: #3b3b38;
  --plate-field: #1e1e1c;
  --plate-hover: #2a2a27;
  --plate-muted: #9d9d97;
  --plate-danger: #ff9b8f;
  --scrim: rgb(18 18 17 / 0.12);
  --veil: rgb(252 252 251 / 0.88);

  --t-body: 0.9375rem;
  --t-small: 0.8125rem;
  --t-see: clamp(1.25rem, 1.6vw, 1.5rem);
  --t-chapter: clamp(2.5rem, 4.4vw, 4rem);
  --t-head: clamp(3.25rem, 5.6vw, 5.5rem);
  --t-ae: clamp(6.5rem, 10.5vw, 10rem);

  --front: 300px;
  --hang: clamp(72px, 7.4vw, 118px);
  --see-h: 76px;
  --gutter: clamp(20px, 3vw, 44px);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow: 0 1px 2px rgb(18 18 17 / 0.05), 0 24px 64px -12px rgb(18 18 17 / 0.16);

  color-scheme: light;
  accent-color: var(--accent);
}

/* Dark: the same index printed in reverse, near-white type on true black. The blood red
   lifts until it reads as red on black; the plate turns to paper. Set by
   boot.js from the stored choice, or the system setting until one is made. */
:root[data-theme="dark"] {
  --paper: #000000;
  --ink: #f6f5f1;
  --ink-2: #d9d8d2;
  --ink-3: #aeada6;
  --ink-4: #5e5e5e;
  --rule: #282828;
  --rule-2: #444444;
  --wash: #121212;
  --accent: #ff2d34;
  --accent-deep: #ff5a5f;
  --accent-wash: rgb(255 45 52 / 0.12);
  --on-accent: #000000;
  --danger: #ffa14a;
  --tile: #efeee9;
  --plate-line: #c9c8c1;
  --plate-field: #f6f5f1;
  --plate-hover: #dddcd5;
  --plate-muted: #6b6a64;
  --plate-danger: #a3161c;
  --scrim: rgb(0 0 0 / 0.7);
  --veil: rgb(0 0 0 / 0.9);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 24px 64px -12px rgb(0 0 0 / 0.6);
  color-scheme: dark;
}

/* Switching themes cross-fades instead of snapping. */
.theme-switching *, .theme-switching *::before, .theme-switching *::after {
  transition: background-color 0.35s var(--ease), color 0.35s var(--ease), border-color 0.35s var(--ease) !important;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--see-h) + 16px);
  scrollbar-color: var(--ink-4) transparent;
  scrollbar-width: thin;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--t-body)/1.5 var(--font);
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent); color: var(--on-accent); }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
h1, h2, h3, p, dl, dd, ol, ul { margin: 0; }
ol, ul { list-style: none; padding: 0; }
i, em { font-style: italic; }
input, textarea { caret-color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.num { font-variant-numeric: tabular-nums lining-nums; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ico {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ico-s { width: 13px; height: 13px; }

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 2px 5px;
  border: 1px solid var(--rule-2);
  border-radius: 3px;
  font: 600 11px/1.3 var(--font);
  color: var(--ink-3);
  text-align: center;
}

/* ---- Frame ------------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: var(--front) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---- Front matter (left column) ----------------------------------------- */

.front {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 34px;
  padding: 26px 28px 0;
  border-right: 1px solid var(--rule);
  background: var(--paper);
  scrollbar-width: none;
}
.front::-webkit-scrollbar { display: none; }

.mark { display: flex; flex-direction: column; gap: 14px; }
.mark:hover { color: var(--ink); }
.mark-ae {
  display: block;
  font-size: var(--t-ae);
  font-weight: 800;
  line-height: 0.74;
  letter-spacing: -0.04em;
  margin-left: -0.05em;
  padding-top: 0.06em;
}
.ae-intro .mark-ae { animation: ae-set 1.1s var(--ease) both; }
.mark:hover .mark-ae { color: var(--accent); transition: color 0.4s var(--ease); }
.mark-word { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }
.mark-word span { font-weight: 400; color: var(--ink-3); }

@keyframes ae-set {
  from { clip-path: inset(100% 0 0 0); transform: translateY(18%); }
  to { clip-path: inset(0 0 0 0); transform: none; }
}

.front-count { margin-top: -26px; color: var(--ink-3); font-size: var(--t-small); }

.front-part { display: flex; flex-direction: column; gap: 10px; }
.front-head { font-size: var(--t-small); font-style: italic; font-weight: 500; color: var(--ink-3); }
.front-head-row { display: flex; align-items: baseline; justify-content: space-between; }
.front-add { font-size: var(--t-small); font-weight: 550; color: var(--accent); }
.front-add:hover { text-decoration: underline; text-underline-offset: 0.22em; }

.pins { display: flex; flex-direction: column; gap: 3px; }
.pins a {
  display: block;
  padding: 2px 0;
  font-size: 0.875rem;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toc-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 0;
  font-size: 0.875rem;
  color: var(--ink-2);
}
.toc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-row .ico-s { align-self: center; color: var(--ink-3); width: 11px; height: 11px; }
.toc-dots { flex: 1; min-width: 12px; border-bottom: 1px dotted var(--rule-2); transform: translateY(-3px); }
.toc-num { font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: var(--t-small); }
.toc-row:hover .toc-name { color: var(--accent); }
.toc-row.is-here { color: var(--ink); font-weight: 650; }
.toc-row.is-here .toc-num { color: var(--ink); }
.toc-row.is-here .toc-dots { border-bottom-color: var(--ink); border-bottom-style: solid; }
.d1 { padding-left: 14px; }
.d2 { padding-left: 28px; }
.d3 { padding-left: 42px; }
.d4 { padding-left: 56px; }
.d5 { padding-left: 70px; }

.facets { display: flex; flex-direction: column; gap: 8px; font-size: 0.875rem; line-height: 1.55; }
.facet dt { display: inline; font-style: italic; color: var(--ink-3); margin-right: 6px; text-transform: lowercase; }
.facet dt::first-letter { text-transform: uppercase; }
.facet dd { display: inline; color: var(--ink-2); }
.facet-link sup, .subs sup { font-size: 0.68em; color: var(--ink-3); margin-left: 1px; font-variant-numeric: tabular-nums; }
.facet-link.is-on { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.22em; }
.facet-link.is-on sup { color: var(--accent); }
.sep { color: var(--ink-3); }

/* Stays in view at the bottom while the folders and tags scroll. */
.front-foot {
  position: sticky;
  bottom: 0;
  z-index: 1;
  padding-bottom: 22px;
  background: var(--paper);
  margin-top: auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-size: var(--t-small);
}
.who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-name { font-weight: 650; }
.who-role { color: var(--ink-3); }
.foot-links { display: flex; align-items: center; gap: 14px; color: var(--ink-2); }
.theme-toggle { width: 28px; height: 28px; margin: -6px -6px -6px 0; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }

/* ---- Buttons ----------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: var(--paper);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.25s var(--ease);
}
.button:active { transform: translateY(1px); }
.button-act { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.button-act:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: var(--on-accent); }
.button-act .ico { stroke-width: 1.8; }
.button-wide { width: 100%; justify-content: space-between; }

.text-button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  cursor: pointer;
}
.text-button:hover, .text-link:hover { color: var(--accent); }
.text-link { color: var(--accent); font-size: 0.875rem; font-weight: 550; }
.text-link:hover { text-decoration: underline; text-underline-offset: 0.22em; }
.text-danger { color: var(--ink-3); }
.text-danger:hover { color: var(--danger); }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--ink-2);
  cursor: pointer;
}
.icon-button:hover { background: var(--wash); color: var(--ink); }

/* ---- The see line (search) --------------------------------------------- */

.page { min-width: 0; padding: 0 var(--gutter) 120px; }

.see {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--see-h);
  margin: 0 calc(var(--gutter) * -1);
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.see-form { flex: 1; display: flex; align-items: baseline; gap: 12px; min-width: 0; position: relative; }
.see-label { font-size: var(--t-see); font-style: italic; color: var(--ink-3); flex-shrink: 0; }
.see-form input {
  flex: 1;
  min-width: 0;
  padding: 6px 0;
  border: 0;
  background: none;
  outline: none;
  font-size: var(--t-see);
  font-weight: 550;
  letter-spacing: -0.015em;
}
.see-form input::placeholder { color: var(--ink-3); font-weight: 400; }
.see-form input::-webkit-search-cancel-button { display: none; }
.see-form:focus-within .see-label { color: var(--accent); }
.see-key { align-self: center; }
.see-form:focus-within .see-key { visibility: hidden; }
.palette-button { display: flex; gap: 4px; padding: 4px; border: 0; background: none; cursor: pointer; }
.palette-button:hover kbd { border-color: var(--ink); color: var(--ink); }
.front-toggle { display: none; }

/* ---- Chapter (folder heading) ------------------------------------------ */

.chapter { padding: 44px 0 6px; display: flex; flex-direction: column; gap: 12px; max-width: 74ch; }
.trail { display: flex; flex-wrap: wrap; gap: 6px; font-size: var(--t-small); color: var(--ink-3); }
.chapter-title {
  font-size: var(--t-chapter);
  font-weight: 750;
  line-height: 0.98;
  letter-spacing: -0.04em;
  text-wrap: balance;
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}
.subs { color: var(--ink-2); font-size: 1rem; line-height: 1.6; }
.subs i { color: var(--ink-3); margin-right: 4px; }
.subs a { font-weight: 550; }
.chapter-actions { display: flex; gap: 22px; }

.state-private {
  font-size: var(--t-small);
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0;
  color: var(--ink-3);
  padding-bottom: 1px;
  border-bottom: 1px dashed var(--ink-3);
}
.chapter-title .state-private { font-size: 1rem; }

/* ---- The index --------------------------------------------------------- */

.index-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 30px 0 0;
}
.index-count { color: var(--ink-3); font-size: var(--t-small); }
.index-count .num { color: var(--ink); font-weight: 650; }
.sorts { display: flex; gap: 18px; font-size: var(--t-small); }
.sort { color: var(--ink-3); padding-bottom: 2px; border-bottom: 1px solid transparent; }
.sort.is-on { color: var(--ink); font-weight: 650; border-bottom-color: var(--ink); }
a.sort:hover { color: var(--accent); }

/* The rail's column is reserved even when the rail is absent (Recent, Best
   match), so dates and actions keep their x in every order. */
.index { display: grid; grid-template-columns: minmax(0, 1fr) 26px; gap: 20px; }

/* A–Z: each letter hangs in the left margin beside its entries, like a
   book index, and stays put while its section scrolls. */
.group {
  display: grid;
  grid-template-columns: var(--hang) minmax(0, 1fr);
  margin-top: 28px;
}
.head {
  position: sticky;
  top: calc(var(--see-h) + 10px);
  align-self: start;
  padding-top: 12px;
  font-size: var(--t-head);
  font-weight: 800;
  line-height: 0.78;
  letter-spacing: -0.04em;
}
/* Rows bleed 10px each side for their hover band; the rule bleeds with them. */
.entries { border-top: 1.5px solid var(--ink); margin: 0 -10px; }

/* Recent and best-match heads are short words in the same margin, so the
   entry column never moves when the order changes. */
.group-words .head { font-size: clamp(1.75rem, 2.6vw, 2.5rem); line-height: 0.86; letter-spacing: -0.035em; }
.head-sub { display: block; margin-top: 8px; font-size: var(--t-small); font-weight: 600; letter-spacing: 0; color: var(--ink-3); }

.entry {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  column-gap: 14px;
  align-items: baseline;
  padding: 13px 10px 14px;
  border-bottom: 1px solid var(--rule);
  transition: background 0.3s var(--ease);
}
.bulk-form .entry { grid-template-columns: 18px 22px minmax(0, 1fr) auto; }
.entry:hover { background: var(--wash); }
.entry.is-private { border-bottom-style: dashed; border-bottom-color: var(--rule-2); }
/* The keyboard cursor is a doubled rule above and below, like a ruled-off
   index line; hover is a wash. Checked rows carry a heavy ink rule. */
.entry.is-selected {
  background: var(--paper);
  box-shadow:
    inset 0 1px 0 var(--ink), inset 0 3px 0 var(--paper), inset 0 4px 0 var(--ink),
    inset 0 -1px 0 var(--ink), inset 0 -3px 0 var(--paper), inset 0 -4px 0 var(--ink);
}
.entry:has(.pick input:checked) { border-bottom: 2px solid var(--ink); padding-bottom: 13px; }
/* Next to the cursor the checked rule steps back, so the doubled rules stay equal. */
.entry:has(.pick input:checked):has(+ .entry.is-selected),
.entry.is-selected:has(.pick input:checked) { border-bottom: 1px solid var(--rule); padding-bottom: 14px; }

.glyph {
  align-self: start;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--rule-2);
  border-radius: 4px;
  background: var(--paper);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  overflow: hidden;
}
.glyph.has-icon { border-color: var(--rule); background: var(--tile); padding: 2px; }
.glyph img { width: 100%; height: 100%; object-fit: contain; display: block; }
.glyph.is-type .ico { width: 13px; height: 13px; }

.entry-text { min-width: 0; max-width: 78ch; }
.entry-title { font-weight: 650; letter-spacing: -0.01em; }
a.entry-title:hover { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
.entry-domain { margin-left: 0.55em; color: var(--ink-3); }
.entry-desc { display: block; margin-top: 2px; color: var(--ink-2); text-wrap: pretty; }
.entry-notes { display: block; margin-top: 4px; color: var(--ink-2); white-space: pre-line; }
.entry-notes i { color: var(--ink-3); margin-right: 4px; }
.entry-meta { display: block; margin-top: 5px; color: var(--ink-3); }
.entry-meta > * + *::before { content: "·"; margin: 0 0.6em; color: var(--ink-4); }
.entry-meta i { margin-right: 4px; }
.entry-in a, .see-link { color: var(--ink-2); }
.entry-in { white-space: nowrap; }
.see-facet { color: var(--ink-3); margin-right: 1px; }
/* Labels never part from what they label; lines break only at the separators. */
.see-link, .entry-see > i { white-space: nowrap; }
.entry-in a:hover, .see-link:hover { color: var(--accent); }
.see-link.is-on { color: var(--accent); text-decoration: underline; text-underline-offset: 0.22em; text-decoration-thickness: 1px; }
.entry-file { color: var(--accent); }
.entry-file .ico-s { margin-right: 4px; vertical-align: -1px; }
.entry-file:hover { text-decoration: underline; text-underline-offset: 0.22em; }

.entry-side {
  display: flex;
  align-items: center;
  gap: 12px;
  align-self: start;
  padding-top: 1px;
  color: var(--ink-3);
  font-size: var(--t-small);
  white-space: nowrap;
}
.entry-side time { min-width: 46px; text-align: right; }
.entry-edit { display: grid; place-items: center; width: 26px; height: 26px; margin: -4px -4px -4px 0; border-radius: 3px; color: var(--ink-3); opacity: 0; transition: opacity 0.2s var(--ease); }
.entry:hover .entry-edit, .entry.is-selected .entry-edit, .entry-edit:focus-visible { opacity: 1; }
.entry-edit:hover { background: var(--paper); color: var(--accent); }

.pick { display: grid; place-items: center; height: 20px; cursor: pointer; }

/* Checkboxes, drawn. */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  margin: 0;
  border: 1px solid var(--ink-3);
  border-radius: 2px;
  background: var(--paper);
  cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}
input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}
:root[data-theme="dark"] input[type="checkbox"]:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23000000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
/* Hidden until the row is hovered or a selection is under way. */
.pick input { opacity: 0; transition: opacity 0.15s var(--ease); }
.entry:hover .pick input, .entry.is-selected .pick input, .pick input:focus-visible,
.bulk-form:has(.pick input:checked) .pick input { opacity: 1; }

/* ---- Thumb index ------------------------------------------------------- */

.rail {
  position: sticky;
  top: calc(var(--see-h) + 22px);
  align-self: start;
  display: flex;
  flex-direction: column;
  margin-top: 22px;
  border-left: 1px solid var(--rule);
  touch-action: none;
  user-select: none;
}
.rail a, .rail span {
  display: grid;
  place-items: center;
  height: clamp(16px, 2.6vh, 22px);
  font-size: 11px;
  font-weight: 650;
  line-height: 1;
}
.rail span { color: var(--ink-4); }
.rail a { color: var(--ink); border-radius: 0 2px 2px 0; transition: background 0.2s var(--ease), color 0.2s var(--ease); }
.rail a:hover { color: var(--accent); }
.rail a.is-here { background: var(--ink); color: var(--paper); }

/* ---- Empty ------------------------------------------------------------- */

.blank { padding: 14vh 0 10vh; display: flex; flex-direction: column; align-items: flex-start; gap: 18px; max-width: 34ch; }
.blank-title { font-size: var(--t-chapter); font-weight: 750; line-height: 0.98; letter-spacing: -0.04em; text-wrap: balance; }
.blank-hint { font-size: 1rem; color: var(--ink-2); }
.blank .button { margin-top: 8px; }

/* ---- Bulk changes: the one reversed plate ------------------------------ */

.bulk-bar {
  position: sticky;
  bottom: 18px;
  z-index: 8;
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  margin-top: 22px;
  padding: 10px 12px 10px 18px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow);
}
.bulk-form:has(.pick input:checked) .bulk-bar { display: flex; animation: plate-in 0.35s var(--ease); }
@keyframes plate-in { from { opacity: 0; transform: translateY(10px); } }
.bulk-count { font-size: var(--t-small); font-weight: 650; min-width: 76px; }
.bulk-group { display: flex; align-items: center; gap: 6px; }
.bulk-bar input, .bulk-bar select {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--plate-line);
  border-radius: 3px;
  background: var(--plate-field);
  color: var(--paper);
  font-size: var(--t-small);
  min-width: 0;
}
.bulk-bar input { width: 132px; }
.bulk-bar input::placeholder { color: var(--plate-muted); }
.bulk-bar select { max-width: 170px; }
.bulk-btn {
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--plate-line);
  border-radius: 3px;
  background: none;
  color: var(--paper);
  font-size: var(--t-small);
  font-weight: 550;
  cursor: pointer;
}
.bulk-btn:hover { background: var(--plate-hover); border-color: var(--plate-muted); }
.bulk-danger { margin-left: auto; border-color: transparent; color: var(--plate-danger); }
.bulk-danger:hover { color: var(--paper); background: var(--danger); border-color: var(--danger); }

/* ---- Forms ------------------------------------------------------------- */

.sheet { display: flex; flex-direction: column; gap: 22px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1.5px solid var(--ink); }
.sheet-title { font-size: 1.75rem; font-weight: 750; letter-spacing: -0.035em; line-height: 1.1; padding-bottom: 12px; }
.sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 6px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: var(--t-small); font-weight: 600; color: var(--ink-2); }
.field-label i { font-weight: 400; color: var(--ink-3); margin-left: 4px; }
.field-hint { font-size: var(--t-small); color: var(--ink-3); }
.field input:not([type="checkbox"]):not([type="file"]), .field select, .field textarea {
  width: 100%;
  padding: 8px 0 9px;
  border: 0;
  border-bottom: 1px solid var(--rule-2);
  border-radius: 0;
  background-color: transparent;
  outline: none;
  font-size: 1rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.field textarea { resize: vertical; min-height: 44px; line-height: 1.5; }
.field input::placeholder, .field textarea::placeholder { color: var(--ink-3); }
.field input:focus:not([type="checkbox"]), .field select:focus, .field textarea:focus {
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 0 var(--accent);
}
.field input[readonly] { color: var(--ink-3); }
.field select, .inline-form select, .row-form select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%23686863' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 0 center;
  background-size: 14px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.checks { display: flex; flex-wrap: wrap; gap: 22px; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 0.9375rem; }

.current-file { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--rule); }
.current-file a { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
  padding: 18px;
  border: 1px dashed var(--rule-2);
  border-radius: 3px;
  color: var(--ink-2);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.25s var(--ease), background-color 0.25s var(--ease);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background-color: var(--accent-wash); color: var(--ink); }
.dropzone small { font-size: var(--t-small); color: var(--ink-3); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone.has-file { border-style: solid; border-color: var(--ink); color: var(--ink); font-weight: 550; }

.notice {
  padding: 10px 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  font-size: 0.9375rem;
}
.notice-error { color: var(--danger); border-top: 2px solid var(--danger); }

.stack { display: flex; flex-direction: column; gap: 20px; }
.narrow { max-width: 380px; }

/* ---- Drawer ------------------------------------------------------------ */

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(520px, 100vw);
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 26px 34px 34px;
  border: 0;
  border-left: 1px solid var(--rule-2);
  background: var(--paper);
  color: var(--ink);
  box-shadow: -32px 0 80px -24px var(--scrim);
  overflow-y: auto;
}
.drawer[open] { animation: drawer-in 0.42s var(--ease); }
.drawer::backdrop { background: var(--scrim); animation: fade 0.3s var(--ease); }
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* A form opened without JavaScript lands as a full page. */
.page > .sheet { max-width: 560px; padding-top: 34px; }

/* ---- Plates (users, account) ------------------------------------------- */

.plate { padding: 26px 0 30px; margin-top: 26px; border-top: 1.5px solid var(--ink); max-width: 820px; }
.plate-head { font-size: 1.25rem; font-weight: 750; letter-spacing: -0.02em; margin-bottom: 6px; }
.plate-hint { color: var(--ink-2); margin-bottom: 18px; }
.plate .notice { margin-bottom: 18px; }

.transfer { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 34px; }
.transfer-part { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.transfer-part .dropzone { align-self: stretch; margin-top: 0; }
.transfer-head { font-size: var(--t-small); font-weight: 600; color: var(--ink-2); }
@media (max-width: 720px) { .transfer { grid-template-columns: 1fr; gap: 26px; } }

.inline-form { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-end; }
.field-grow { flex: 1; min-width: 220px; }

.invite-link { margin-bottom: 20px; padding: 14px 16px; border: 1px solid var(--accent); border-radius: 3px; background: var(--accent-wash); }
.invite-link p { font-size: var(--t-small); font-weight: 600; color: var(--accent); margin-bottom: 8px; }
.invite-link input { width: 100%; padding: 6px 0; border: 0; background: none; font-size: 0.9375rem; outline: none; }

.rows { border-top: 1px solid var(--rule); }
.row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.row-main { flex: 1; min-width: 200px; font-weight: 650; }
.row-main .row-meta { font-weight: 400; margin-left: 6px; }
.row-meta { color: var(--ink-3); font-size: var(--t-small); }
.row-form select { height: 30px; padding-left: 0; border: 0; border-bottom: 1px solid var(--rule-2); background-color: transparent; font-size: var(--t-small); }

/* ---- Title page (log in, join, errors) --------------------------------- */

.title-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 400px);
  align-items: end;
  gap: clamp(32px, 6vw, 96px);
  padding: clamp(24px, 5vw, 72px);
}
.title-mark {
  font-size: clamp(12rem, 30vw, 30rem);
  font-weight: 800;
  line-height: 0.74;
  letter-spacing: -0.04em;
  margin-left: -0.06em;
  font-variant-numeric: tabular-nums;
}
.ae-intro .title-mark { animation: ae-set 1.2s var(--ease) both; }
.title-form { display: flex; flex-direction: column; gap: 20px; padding-bottom: 1.5vw; }
.title-side { display: flex; flex-direction: column; gap: 22px; }
.title-word { font-size: 1rem; font-weight: 700; }
.title-word span { font-weight: 400; color: var(--ink-3); }
.title-head { font-size: clamp(2rem, 3vw, 2.75rem); font-weight: 750; letter-spacing: -0.04em; line-height: 1; padding-bottom: 12px; border-bottom: 1.5px solid var(--ink); text-wrap: balance; }
.title-note { color: var(--ink-3); font-size: var(--t-small); }
.title-note strong { color: var(--ink); font-weight: 650; }
.title-form .button { margin-top: 6px; align-self: flex-start; }
.title-form .button-wide { align-self: stretch; }

/* ---- Feedback ---------------------------------------------------------- */

.drop-veil {
  position: fixed;
  inset: 14px;
  z-index: 40;
  display: none;
  place-items: center;
  border: 1.5px dashed var(--accent);
  border-radius: 8px;
  background: var(--veil);
  font-size: var(--t-chapter);
  font-weight: 750;
  letter-spacing: -0.04em;
  color: var(--accent);
  pointer-events: none;
}
.is-dragging .drop-veil { display: grid; animation: fade 0.2s var(--ease); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 50;
  transform: translateX(-50%);
  padding: 11px 18px;
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow);
  font-size: var(--t-small);
  font-weight: 550;
}

/* ---- Peek: the page's share image (or the picture itself) on hover ------ */

.peek {
  --x: 0px;
  --y: 0px;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 45;
  width: 340px;
  border: 1px solid var(--rule-2);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(var(--x), var(--y), 0) scale(0.96);
  transform-origin: 0 0;
  transition: opacity 0.22s var(--ease), transform 0.5s var(--ease);
}
.peek.is-on { opacity: 1; transform: translate3d(var(--x), var(--y), 0) scale(1); }
.peek-img { display: block; width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; background: var(--wash); }
.peek.is-picture .peek-img { aspect-ratio: auto; max-height: 380px; object-fit: contain; }
.peek-cap { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 12px 10px; border-top: 1px solid var(--rule); font-size: var(--t-small); }
.peek-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peek-domain { flex-shrink: 0; color: var(--ink-3); }
@media (hover: none), (pointer: coarse) { .peek { display: none; } }

/* ---- Command palette --------------------------------------------------- */

.palette {
  width: min(640px, calc(100vw - 32px));
  max-height: min(540px, calc(100dvh - 120px));
  margin: 11vh auto auto;
  padding: 0;
  border: 1px solid var(--rule-2);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.palette[open] { display: flex; flex-direction: column; animation: palette-in 0.3s var(--ease); }
.palette::backdrop { background: var(--scrim); animation: fade 0.25s var(--ease); }
@keyframes palette-in { from { transform: translateY(-8px); opacity: 0; } }

.palette-top { display: flex; align-items: baseline; gap: 12px; padding: 16px 20px; border-bottom: 1.5px solid var(--ink); }
.palette-top label { font-size: var(--t-see); font-style: italic; color: var(--accent); }
.palette-input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: var(--t-see); font-weight: 550; letter-spacing: -0.015em; }
.palette-input::placeholder { color: var(--ink-3); font-weight: 400; }
.palette-list { padding: 6px 8px 8px; overflow-y: auto; }
.palette-group { padding: 12px 10px 4px; font-size: var(--t-small); font-style: italic; color: var(--ink-3); }
.palette-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  cursor: pointer;
}
.palette-item[aria-selected="true"] { background: var(--wash); box-shadow: inset 0 1px 0 var(--ink), inset 0 -1px 0 var(--ink); }
.palette-item[aria-selected="true"] .palette-title { color: var(--accent); }
.palette-item img { width: 16px; height: 16px; object-fit: contain; }
.palette-glyph { display: grid; place-items: center; width: 20px; color: var(--ink-3); }
.palette-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-sub { font-size: var(--t-small); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.palette-empty { padding: 22px 10px; color: var(--ink-2); }
.palette-foot { display: flex; gap: 16px; padding: 9px 20px; border-top: 1px solid var(--rule); font-size: 11px; color: var(--ink-3); }

/* ---- Narrower screens -------------------------------------------------- */

@media (max-width: 1180px) {
  :root { --front: 256px; }
  .front { padding: 22px 22px 0; }
  .front-foot { padding-bottom: 18px; }
}

@media (max-width: 900px) {
  :root { --see-h: 64px; --gutter: 16px; }

  .app { grid-template-columns: minmax(0, 1fr); }
  .front {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(320px, 86vw);
    box-shadow: var(--shadow);
    transform: translateX(-102%);
    transition: transform 0.45s var(--ease);
  }
  .front-open .front { transform: none; }
  .front-toggle { display: inline-grid; flex-shrink: 0; margin-left: -8px; }
  .see { gap: 8px; }
  .see-key, .palette-button { display: none; }
  .see-label { font-size: 1.125rem; }
  .see .button-act { padding: 0 12px; height: 36px; font-size: var(--t-small); }

  :root { --hang: 46px; }
  .head { font-size: 2.5rem; }
  .see-form input { font-size: 1.125rem; }
  .index { grid-template-columns: minmax(0, 1fr) 20px; gap: 8px; }
  .entry, .bulk-form .entry { column-gap: 10px; }
  /* Checkboxes appear once a row is long-pressed. */
  .bulk-form:not(:has(.pick input:checked)) .pick { display: none; }
  .bulk-form:not(:has(.pick input:checked)) .entry { grid-template-columns: 22px minmax(0, 1fr) auto; }
  .group-words .head { font-size: 1.125rem; }
  .entry-side time { display: none; }
  .entry-edit { opacity: 1; }
  .entry-domain { display: block; margin-left: 0; }
  .bulk-bar { bottom: 10px; padding-left: 14px; }
  .bulk-bar input { width: 100px; }

  .title-page { grid-template-columns: 1fr; align-items: start; }
  .title-mark { font-size: clamp(9rem, 48vw, 16rem); }
}

@media (max-width: 520px) {
  :root { --hang: 34px; }
  .head { font-size: 2rem; }
  .group-words .head { font-size: 0.9375rem; }
  .head-sub { font-size: 11px; margin-top: 4px; }
  .see .button-act { width: 36px; padding: 0; font-size: 0; gap: 0; }
  .chapter-actions { flex-wrap: wrap; gap: 14px; }
  .palette-sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
