/* The web app (/app/). Dark by default (owner, 2026-11-13); colors are the Reading Room dark tokens
   whose values docs/design/design.css owns, and the composition is docs/design/index.html#web-app. */
:root {
  color-scheme: dark;
  --ground: #1c1b1a;
  --ground-deep: #100f0f;
  --surface: #282726;
  --surface-2: #343331;
  --divider: #403e3c;
  --ink: #fffcf0;
  --ink-2: #cecdc3;
  --ink-3: #b7b5ac;
  --accent: #5abdac;
  --accent-on: #100f0f;
  --failed-text: #e8705f;
  --warning: #dfb431;
  --pill: #403e3c;
  --card-edge: rgb(255 252 240 / 9%);
  --selection: rgb(90 189 172 / 28%);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-serif: "New York", ui-serif, "Iowan Old Style", Georgia, "Songti TC", serif;
  --radius: 14px;
}
:lang(ja) { --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif; }
* { box-sizing: border-box; }
html { text-autospace: normal; background: var(--ground); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font: 400 15px/1.55 var(--font-sans);
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
:lang(zh), :lang(ja) { word-break: keep-all; line-break: strict; }
h1, h2, button { text-wrap: balance; }
p, li, dd { text-wrap: pretty; }
a { color: var(--accent); }
.url { overflow-wrap: anywhere; word-break: normal; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Headings take focus only so a screen reader starts at the new screen. */
h1:focus { outline: none; }
[hidden] { display: none !important; }

/* Buttons */
.button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  font: 600 15px/1.3 var(--font-sans);
  cursor: pointer;
}
.button:disabled { cursor: wait; opacity: .6; }
.button.primary { background: var(--accent); color: var(--accent-on); }
.button.secondary { background: none; color: var(--ink); box-shadow: inset 0 0 0 1px var(--divider); }
.button.quiet { min-height: 32px; padding: 6px 14px; background: var(--surface-2); color: var(--ink); font-size: 14px; }
.button.danger { min-height: 32px; padding: 6px 4px; background: none; color: var(--failed-text); font-size: 14px; }
.button.danger.wide { width: 100%; justify-content: flex-start; min-height: 40px; padding: 0; font-size: 15px; }
.button svg { fill: currentColor; flex: none; }

/* Language */
#language { display: flex; flex-wrap: wrap; gap: 2px; }
#language button {
  appearance: none;
  border: 0;
  background: none;
  color: var(--ink-3);
  font: inherit;
  font-size: 13px;
  min-height: 32px;
  padding: 4px 8px;
  cursor: pointer;
}
#language button:hover { color: var(--ink); }
#language button:disabled { opacity: .5; cursor: wait; }

/* W1, W2 and failures: one centred column */
.signin, .consent {
  max-width: 600px;
  margin: 0 auto;
  padding: max(48px, 12vh) 16px 40px;
  text-align: center;
}
.signin { display: flex; flex-direction: column; justify-content: center; min-height: 100svh; max-width: 440px; padding: 64px 24px; }
.signin-brand { align-self: center; margin-bottom: 28px; border-radius: 16px; }
.signin .mark { display: block; width: 64px; height: 64px; border-radius: 16px; }
.signin h1 { margin: 0 0 12px; font: 600 28px/1.3 var(--font-sans); }
.signin .signin-tagline { margin: 0 0 32px; color: var(--ink-2); font: 400 17px/1.5 var(--font-serif); text-wrap: balance; }
.methods { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 360px; margin: 0 auto; }
.methods .button { width: 100%; border: 1px solid #747775; border-radius: 4px; min-height: 44px; font: 500 14px/20px var(--font-sans); }
.button.apple { background: #fff; color: #1f1f1f; }
.button.apple:hover:not(:disabled) { background: #f4f4f4; }
.button.apple:active:not(:disabled) { background: #e8e8e8; }
.methods .google { display: flex; align-items: center; justify-content: center; min-height: 44px; }
/* Google's outline control and its frame keep a light scheme on our dark page, without
   cropping the control or changing the SDK's personalized account rendering. */
.methods .google iframe { color-scheme: light; }
.methods .google > div > div:not([class]) { display: none; }
.methods .google[aria-busy="true"], .methods:has(button[aria-busy="true"]) .google { pointer-events: none; opacity: .6; }
.signin .account-note { margin: 24px 0 0; color: var(--ink-2); font-size: 14px; text-wrap: balance; }
.signin .fine { margin: 12px 0 0; color: var(--ink-3); font-size: 13px; text-wrap: balance; }
.signin .fine a { white-space: nowrap; text-underline-offset: .2em; }
.signin #language button { min-height: 44px; }
.signin .language-slot, .consent .language-slot { display: flex; justify-content: center; margin-top: 28px; }

.consent { text-align: left; max-width: 552px; }
.consent h1 { margin: 0 0 8px; text-align: center; font: 700 26px/1.3 var(--font-sans); }
.consent .intro { margin: 0 0 28px; text-align: center; color: var(--ink-2); }
.consent dl { margin: 0; display: grid; gap: 4px; padding: 18px 20px; border-radius: var(--radius); background: var(--surface); box-shadow: inset 0 0 0 1px var(--divider); }
.consent dt { font-weight: 600; margin-top: 18px; }
.consent dt:first-child { margin-top: 0; }
.consent dd { margin: 0; color: var(--ink-2); }
.consent .policy { margin: 28px 0 12px; text-align: center; }
.consent .actions { display: flex; flex-direction: column; gap: 8px; }
.consent .actions .button { width: 100%; }

/* Signed in: navigation beside the screen */
.app { min-height: 100vh; }
.side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 24px 14px 16px;
  border-right: 1px solid var(--divider);
  background: var(--ground-deep);
}
.brand { display: flex; align-items: center; gap: 10px; margin: 0 8px 20px; color: var(--ink); font: 700 19px/1 var(--font-serif); text-decoration: none; }
.brand img { border-radius: 7px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 15px;
  text-decoration: none;
}
.nav-item svg { width: 18px; height: 18px; fill: currentColor; }
.nav-item:hover { background: var(--surface); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--surface); color: var(--accent); font-weight: 600; }
.side .grow { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; margin: 0; padding: 14px 8px 4px; border-top: 1px solid var(--divider); color: var(--ink-2); font-size: 13px; min-width: 0; }
.who .address { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); color: var(--ink); font-size: 12px; font-weight: 600; }
.side .language-slot { padding: 6px 2px 0; }
.content { padding-block: var(--page-top) 40px; }
.content h1 { margin: 0; font: 700 28px/1.3 var(--font-sans); }

/* W3 and W4: Shore with the paste-a-link save */
.topbar { padding: 16px var(--page-inset); border-bottom: 1px solid var(--divider); }
.paste {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 560px;
  padding: 6px 6px 6px 14px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--divider);
}
.paste:focus-within { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px rgb(90 189 172 / .18); }
.paste > svg { width: 18px; height: 18px; fill: var(--ink-3); flex: none; }
.paste input {
  flex: 1;
  min-width: 0;
  min-height: 34px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  outline: none;
}
.paste input::placeholder { color: var(--ink-3); }
.status { margin: 10px 0 0; color: var(--failed-text); font-size: 14px; }
.settings .status[role="status"] { color: var(--ink-2); }
.popover {
  position: absolute;
  top: 70px;
  inset-inline: var(--page-inset);
  max-width: 520px;
  padding: 16px 16px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--divider), 0 18px 48px rgb(0 0 0 / .45);
  z-index: 2;
}
.popover h2 { margin: 0 0 10px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.popover .title { margin: 0 0 6px; font-size: 18px; font-weight: 600; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.popover .source { margin: 0 0 6px; color: var(--ink-2); font-size: 13px; }
.popover .kind { margin: 0; color: var(--ink-3); font-size: 13px; }
.popover .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.popover .actions .button { min-height: 36px; padding: 6px 16px; font-size: 14px; }
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  border-radius: 999px;
  background: var(--surface-2);
  box-shadow: 0 0 0 1px var(--divider), 0 12px 32px rgb(0 0 0 / .4);
  font-weight: 600;
  z-index: 3;
}
.toast:not(:has(button)) { padding-right: 18px; }
.toast .ok svg { fill: var(--accent); display: block; }
.toast > span { min-width: 0; }
.toast .button, .toast .ok { flex: none; }
.toast small { display: block; color: var(--ink-2); font-weight: 400; font-size: 12px; }

/* W7: Settings */
.settings h1 { margin-bottom: 8px; }
.group { margin-top: 28px; }
.group h2 { margin: 0 0 8px 4px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.list { margin: 0; padding: 0; list-style: none; border-radius: var(--radius); background: var(--surface); box-shadow: inset 0 0 0 1px var(--divider); }
.row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 16px; border-top: 1px solid var(--divider); }
.row:first-child { border-top: 0; }
.row.link { padding: 0; }
.row.link a { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 16px; color: inherit; text-decoration: none; }
.row .grow { flex: 1; min-width: 0; }
.row-title { display: block; }
.row small { display: block; color: var(--ink-2); font-size: 13px; }
.method { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--surface-2); }
.method svg { fill: var(--ink); }
.letter { font-weight: 700; font-size: 14px; }
.chevron { color: var(--ink-3); font-size: 20px; }
.here { flex: none; color: var(--accent); font-size: 13px; font-weight: 600; }
.button.switch { flex: none; position: relative; width: 50px; min-height: 30px; height: 30px; padding: 0; background: var(--divider); }
.button.switch .knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); transition: transform .2s ease; }
.button.switch[aria-checked="true"] { background: var(--accent); }
.button.switch[aria-checked="true"] .knob { transform: translateX(20px); }
@media (prefers-reduced-motion: reduce) { .button.switch .knob { transition: none; } }

/* Reader text arrives cut into words (library.js `readable`); lines break only between them. */
.phrase { word-break: keep-all; }
.card-title, .card .glance, .result-title, .lead { text-wrap: pretty; }

/* W3: the Shore list under the paste bar */
.shore-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 18px; }
.shore-head h1 { font: 600 30px/1.2 var(--font-serif); }
.seg { display: inline-flex; flex: none; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--card-edge); }
.seg button {
  appearance: none;
  min-height: 32px;
  padding: 6px 16px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink-3);
  font: 600 13px/1.4 var(--font-sans);
  white-space: nowrap;
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--pill); color: var(--ink); }
.cards, .results-list { margin: 0; padding: 0; list-style: none; }
.card {
  display: block;
  margin: 0 0 12px;
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--card-edge);
  color: var(--ink);
  text-decoration: none;
  transition: box-shadow .12s ease;
}
.card:hover { box-shadow: inset 0 0 0 1px var(--divider); }
.card > span { display: block; }
.card .who-line { margin: 0 0 4px; font: 600 17px/1.3 var(--font-serif); }
.card .card-title { margin: 0 0 8px; font: 400 19px/1.37 var(--font-serif); }
.card.is-read .card-title { color: var(--ink-2); }
.src { color: var(--ink-3); font-size: 13px; line-height: 1.4; }
.num { white-space: nowrap; }
.card .glance, .card .later-note { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; color: var(--ink-2); font-size: 15px; line-height: 1.4; }
.glance svg, .lead svg { flex: none; margin-top: 2px; fill: var(--accent); }
.card .later-note { color: var(--warning); font-size: 13px; align-items: center; }
.later-note svg { fill: currentColor; flex: none; }
.group-label { margin: 22px 0 10px; color: var(--ink-3); font-size: 13px; font-weight: 600; }
.quiet-note { margin: 16px 0; color: var(--ink-3); font-size: 14px; }
.empty { margin: 48px 0; text-align: center; color: var(--ink-2); }
.empty p { margin: 0 0 4px; }
.empty .empty-title, p.empty { color: var(--ink); font-size: 17px; font-weight: 600; }
.button.more { display: flex; margin: 16px auto 0; min-height: 40px; font-size: 14px; }

/* W6: search */
.search h1 { margin-bottom: 16px; }
.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--divider);
}
.search-field:focus-within { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px rgb(90 189 172 / .18); }
.search-field svg { fill: var(--ink-3); flex: none; }
.search-field input { flex: 1; min-width: 0; min-height: 46px; border: 0; background: none; color: var(--ink); font: 400 17px/1.3 var(--font-sans); outline: none; }
.search-field input::placeholder { color: var(--ink-3); }
.search .seg { margin: 0 0 10px; }
.result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--divider);
  color: var(--ink);
  text-decoration: none;
}
.result-title { font: 400 17px/1.4 var(--font-serif); }
.result .src { grid-column: 1; }
.result .badge { grid-column: 2; grid-row: 1 / span 2; align-self: start; padding: 3px 8px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--card-edge); color: var(--ink-3); font-size: 12px; font-weight: 600; white-space: nowrap; }
mark { background: var(--selection); color: inherit; border-radius: 3px; padding: 0 2px; }

/* W5: the item page */
.article { padding-block: var(--page-top) 32px; }
.crumbs { margin: 0 0 26px; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; color: var(--ink-3); font-size: 14px; text-decoration: none; }
.back svg { fill: currentColor; }
.back:hover { color: var(--ink); }
.article .author { margin: 0 0 6px; color: var(--ink-2); font: 600 17px/1.3 var(--font-serif); }
.article h1 { margin: 0 0 12px; font: 600 30px/1.27 var(--font-serif); }
.article .src a { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.article .src a svg { fill: currentColor; }
.lead { display: flex; gap: 10px; margin: 18px 0 26px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); box-shadow: inset 0 0 0 1px var(--card-edge); font-size: 17px; line-height: 1.47; }
.lead svg { margin-top: 3px; }
.article h2 { margin: 28px 0 10px; color: var(--ink-3); font-size: 13px; font-weight: 600; letter-spacing: .04em; }
.article p, .article li, .article blockquote { font: 400 17px/1.65 var(--font-serif); }
.article p { margin: 0 0 14px; }
.article ol, .article ul { margin: 0 0 14px; padding-left: 22px; }
.article .saved-text { color: var(--ink-2); }
.article .saved-text h3 { margin: 22px 0 10px; color: var(--ink); font: 600 19px/1.4 var(--font-serif); }
.article blockquote { margin: 0 0 14px; padding-left: 14px; border-left: 3px solid var(--divider); }
.divider { height: 1px; margin: 30px 0 0; background: var(--divider); }
.article .kept { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--divider); color: var(--ink-2); font: 400 14px/1.43 var(--font-sans); }
.kept svg { flex: none; margin-top: 2px; fill: var(--ink-3); }
.pillbar { display: flex; gap: 8px; padding: 6px; border-radius: 999px; background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: 0 0 0 1px var(--card-edge), 0 16px 44px rgb(0 0 0 / .55); pointer-events: auto; }
.pillbar .button { min-height: 40px; padding: 0 20px; }
.pillbar .button.secondary { box-shadow: none; background: var(--surface-2); }

/* W7: the AI output language */
.select { flex: none; max-width: 45%; min-height: 36px; padding: 6px 10px; border: 0; border-radius: 10px; background: var(--surface-2); color: var(--ink); font: inherit; font-size: 14px; }
.row label { display: block; }

/* Narrow windows: one column with the navigation on top */
@container reading-viewport (max-width: 760px) {
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--divider); }
  .brand { margin: 0 auto 0 4px; }
  .side .grow, .who { display: none; }
  .side .language-slot { order: 5; width: 100%; padding: 0; }
  .topbar { padding-block: 12px; }
  .popover { top: 64px; max-width: none; }
  .shore-head h1 { font-size: 26px; }
  .article h1 { font-size: 26px; }
}
@media (max-width: 400px) {
  .row, .row.link a { gap: 10px; padding-inline: 12px; }
}

/* W4/W5: the source preview remains readable while full text waits. */
.source-preview { margin: 20px 0 0; }
.source-preview:empty { display: none; }
.source-preview img { display: block; width: 100%; aspect-ratio: 1.91; object-fit: cover; border-radius: 12px; }
.source-preview figcaption { margin-top: 10px; color: var(--ink-2); font: 400 16px/1.6 var(--font-serif); }
.article .quiet-note { margin: 20px 0 16px; color: var(--ink-3); font: 400 14px/1.55 var(--font-sans); }

.article-source > .button,
.article-summary > .button,
.article-work > .button { margin: 4px 0 16px; }
.article-work:focus { outline-offset: 4px; }
.article-announcement {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.article .ai-setup { margin-block: 20px 16px; }
.article .ai-setup p { margin: 0; font: 400 17px/1.5 var(--font-sans); }
.article .ai-setup a { display: inline-flex; align-items: center; min-height: 44px; font-size: 15px; font-weight: 600; }
