/* Pied Piper. Dense, calm UI built for long reading sessions.
   Inter for interface text, Literata for story titles and prose.

   Spacing comes only from the --sp-* scale (4, 8, 12, 16, 24, 32, 48 px), type from --fs-*,
   and control heights are 24 / 28 / 32 / 40 px. Don't add one-off values: pick the nearest step. */

:root {
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-12: 48px;

  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 18px;
  --fs-2xl: 22px;
  --fs-3xl: 28px;

  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f2f1ed;
  --surface-3: #e9e8e3;
  --border: #e4e2dc;
  --border-strong: #cfcdc5;
  --text: #1b1c1e;
  --text-2: #4f5157;
  --text-3: #85878d;
  --accent: #c7362c;
  --accent-hover: #a82c23;
  --accent-soft: #fbebe9;
  --accent-text: #b02e25;
  --logo: #dc3636;
  --star: #f2a516;
  --star-empty: #dcdad3;
  --ok: #23824a;
  --ok-soft: #e6f4ec;
  --warn: #b26b00;
  --warn-soft: #fdf1dc;
  --info: #2563c4;
  --info-soft: #e8f0fd;
  --violet: #6d4bc3;
  --violet-soft: #f0ebfb;
  --shadow-sm: 0 1px 2px rgba(20, 20, 18, .06);
  --shadow: 0 1px 2px rgba(20, 20, 18, .05), 0 4px 16px rgba(20, 20, 18, .06);
  --shadow-lg: 0 12px 40px rgba(20, 20, 18, .18);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Literata', Georgia, 'Times New Roman', serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --topbar-h: 56px;
  --tabbar-h: 0px;
  --wrap: 1240px;
  --gutter: var(--sp-6);
  color-scheme: light;

  /* System box palette */
  --sys-bg: #eef4ff; --sys-border: #9dbaf0; --sys-text: #183a74; --sys-title: #1f4fa3;
  --sysg-bg: #fff7e3; --sysg-border: #e8c065; --sysg-text: #5e4205; --sysg-title: #9a6a00;
  --sysr-bg: #fdeeee; --sysr-border: #eba3a3; --sysr-text: #6e1818; --sysr-title: #b42323;
  --sysn-bg: #eaf7ef; --sysn-border: #95d0ab; --sysn-text: #164b2b; --sysn-title: #1d7a43;
  --sysp-bg: #f4eefe; --sysp-border: #c1a8f0; --sysp-text: #3d2276; --sysp-title: #6a3fc7;
  --sysx-bg: #f1f1ef; --sysx-border: #cfcdc6; --sysx-text: #34353a; --sysx-title: #505257;
}

:root.is-dark {
  --bg: #121315;
  --surface: #1a1b1e;
  --surface-2: #222326;
  --surface-3: #2b2c30;
  --border: #2c2d31;
  --border-strong: #3c3d42;
  --text: #e9e9eb;
  --text-2: #b0b2b8;
  --text-3: #7f828a;
  --accent: #e8574c;
  --accent-hover: #f26c62;
  --accent-soft: #3a1f1d;
  --accent-text: #f2847b;
  --logo: #e4b818;
  --star: #f5b335;
  --star-empty: #3a3b40;
  --ok: #4cc47e; --ok-soft: #173325;
  --warn: #e7a33c; --warn-soft: #3a2b12;
  --info: #6ea0f2; --info-soft: #18253c;
  --violet: #a98af0; --violet-soft: #271f3d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 16px rgba(0, 0, 0, .3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
  --sys-bg: #142033; --sys-border: #33558e; --sys-text: #cfe0ff; --sys-title: #8cb4ff;
  --sysg-bg: #2a2212; --sysg-border: #7a5d1c; --sysg-text: #f4e2b4; --sysg-title: #f1c25c;
  --sysr-bg: #2c1616; --sysr-border: #7c2e2e; --sysr-text: #f6cfcf; --sysr-title: #ff8a8a;
  --sysn-bg: #132a1d; --sysn-border: #2e6e47; --sysn-text: #c9efd8; --sysn-title: #6fd99a;
  --sysp-bg: #21183a; --sysp-border: #5b3f9a; --sysp-text: #e2d6ff; --sysp-title: #b99bff;
  --sysx-bg: #222326; --sysx-border: #3c3d42; --sysx-text: #d4d5d9; --sysx-title: #a9abb1;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + var(--sp-3)); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-md)/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent-text); }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-md); }
p { margin: 0 0 var(--sp-3); }
p:last-child { margin-bottom: 0; }
small, .small { font-size: var(--fs-xs); }
.muted { color: var(--text-3); }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); border: 1px solid var(--border); padding: 0 var(--sp-1); border-radius: 4px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: var(--sp-2); z-index: 100; background: var(--surface); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-xs); }
.skip:focus { left: var(--sp-2); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: var(--sp-6) var(--gutter) var(--sp-12); }
.icon { flex-shrink: 0; vertical-align: -0.15em; }
.push-right { margin-left: auto !important; }
.row-gap { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.center { justify-content: center; }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.pad { padding: var(--sp-4); }
.strong { font-weight: 600; }
.danger { color: var(--accent-text) !important; }
.mono { font-family: var(--mono); }

/* ---------- Logo ---------- */
.logo { display: block; height: 26px; width: auto; color: var(--logo); }
.logo-lg { height: 48px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { max-width: var(--wrap); margin: 0 auto; height: var(--topbar-h); display: flex; align-items: center; gap: var(--sp-4); padding: 0 var(--gutter); }
.brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: 700; font-size: var(--fs-lg); letter-spacing: -0.02em; flex-shrink: 0; }
.brand:hover { color: inherit; }
.mainnav { display: flex; gap: var(--sp-1); }
.mainnav a { display: flex; align-items: center; height: 32px; padding: 0 var(--sp-3); border-radius: var(--radius-sm); font-weight: 500; color: var(--text-2); }
.mainnav a:hover { background: var(--surface-2); color: var(--text); }
.mainnav a.is-active { color: var(--text); background: var(--surface-2); }
.topsearch { flex: 1; max-width: 420px; position: relative; display: flex; align-items: center; margin-left: auto; }
.topsearch .icon { position: absolute; left: var(--sp-3); color: var(--text-3); pointer-events: none; }
.topsearch input[type="search"] { width: 100%; height: 36px; min-height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); padding: 0 var(--sp-3) 0 var(--sp-8); }
.topsearch input[type="search"]:focus { background: var(--surface); border-color: var(--border-strong); }
.topbar-actions { display: flex; align-items: center; gap: var(--sp-1); }
.iconbtn { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-sm); border: 0; background: none; color: var(--text-2); }
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.badge { position: absolute; top: var(--sp-1); right: 2px; min-width: 18px; height: 18px; padding: 0 var(--sp-1); border-radius: 9px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); }
.badge-inline { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 var(--sp-1); border-radius: 10px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }
.avatar-btn { list-style: none; cursor: pointer; padding: var(--sp-1); border-radius: 50%; display: grid; }
.avatar-btn::-webkit-details-marker { display: none; }
.only-mobile { display: none; }

/* ---------- Menus ---------- */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; z-index: 50; top: calc(100% + var(--sp-2)); left: 0; min-width: 208px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: var(--sp-2); display: flex; flex-direction: column;
}
.menu-right { left: auto; right: 0; }
.menu-panel > a, .menu-panel > button, .menu-panel > form > button {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; height: 36px; text-align: left;
  padding: 0 var(--sp-3); border-radius: var(--radius-xs); border: 0; background: none; color: var(--text); font-size: var(--fs-md); white-space: nowrap;
}
.menu-panel > a:hover, .menu-panel > button:hover, .menu-panel > form > button:hover { background: var(--surface-2); color: var(--text); }
.menu-panel > a.is-active { background: var(--surface-2); font-weight: 600; }
.menu-panel .icon { color: var(--text-3); }
.menu-panel > a.menu-head { height: auto; padding: var(--sp-2) var(--sp-3) var(--sp-3); }
.menu-head span:not(.avatar) { display: flex; flex-direction: column; line-height: 1.25; }
.menu-head small { color: var(--text-3); }
.menu-sep { height: 1px; background: var(--border); margin: var(--sp-2) var(--sp-1); }
.theme-switch { display: flex; gap: var(--sp-1); padding: var(--sp-1); margin: 0 var(--sp-1) var(--sp-2); background: var(--surface-2); border-radius: var(--radius-sm); }
.theme-switch button { flex: 1; display: grid; place-items: center; height: 28px; border: 0; background: none; border-radius: var(--radius-xs); color: var(--text-2); font-size: var(--fs-xs); font-weight: 500; }
.theme-switch button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.theme-switch-lg { max-width: 360px; margin: 0; }
.theme-switch-lg button { height: 32px; display: flex; gap: var(--sp-2); justify-content: center; align-items: center; font-size: var(--fs-md); }

/* ---------- Buttons ---------- */
.btn {
  --h: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: var(--h); padding: 0 var(--sp-4); border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 550; font-size: var(--fs-md); line-height: 1; white-space: nowrap; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
  user-select: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-secondary.is-on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent-text); }
.btn-ghost { background: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost.is-on { color: var(--accent-text); }
.btn-danger { background: #b4271d; color: #fff; }
.btn-danger:hover { background: #8f1e17; color: #fff; }
.btn-sm { --h: 32px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn-xs { --h: 28px; padding: 0 var(--sp-2); font-size: var(--fs-xs); gap: var(--sp-1); border-radius: var(--radius-xs); }
.btn-icon { padding: 0; width: var(--h); }
.btn-block { width: 100%; }
.btn.is-disabled { opacity: .45; pointer-events: none; }
.btn .count:empty { display: none; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent-text); font-weight: 500; font-size: inherit; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn.is-on { color: var(--text-3); }
form.inline { display: inline; }

/* ---------- Chips, pills, tags ---------- */
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-1); height: 28px; padding: 0 var(--sp-3); border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; white-space: nowrap;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-active { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip-sm { height: 24px; padding: 0 var(--sp-2); font-size: var(--fs-xs); border-radius: 12px; background: var(--surface-2); border-color: transparent; }
.pill { display: inline-flex; align-items: center; gap: var(--sp-1); height: 20px; padding: 0 var(--sp-2); border-radius: 10px; background: var(--surface-2); color: var(--text-2); font-size: 11px; font-weight: 600; white-space: nowrap; }
.pill-accent { background: var(--accent-soft); color: var(--accent-text); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.status { display: inline-flex; align-items: center; height: 20px; padding: 0 var(--sp-2); border-radius: 4px; font-size: 11px; font-weight: 650; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; }
.status-ongoing { background: var(--ok-soft); color: var(--ok); }
.status-completed { background: var(--info-soft); color: var(--info); }
.status-hiatus { background: var(--warn-soft); color: var(--warn); }
.status-inactive, .status-dropped { background: var(--surface-2); color: var(--text-3); }
.status-stub { background: var(--violet-soft); color: var(--violet); }

/* Tag filter: selected tags plus the "+" panel (browse, home, search) */
.tag-filter { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.tag-filter .chip.is-active, .results-head .chip { padding-right: var(--sp-2); }
.tag-filter .chip .icon, .results-head .chip .icon { opacity: .75; }
.chip-excluded { border-style: dashed; color: var(--text-3); text-decoration: line-through; }
.chip-add { padding-left: var(--sp-2); border-style: dashed; border-color: var(--border-strong); cursor: pointer; list-style: none; user-select: none; }
.chip-add::-webkit-details-marker { display: none; }
.tag-add[open] .chip-add { border-style: solid; border-color: var(--text-3); color: var(--text); }
.tag-add-panel { position: absolute; z-index: 40; left: 0; top: calc(100% + var(--sp-2)); width: min(600px, 100%); padding: var(--sp-3); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.tag-add-search[type="search"] { margin-bottom: var(--sp-2); }
.tag-add-list { display: flex; flex-wrap: wrap; gap: var(--sp-1); max-height: min(320px, 50vh); overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.tag-add-list li { display: inline-flex; border-radius: var(--radius-xs); background: var(--surface-2); }
.tag-add-list a { display: inline-flex; align-items: center; height: 28px; padding: 0 var(--sp-2); border-radius: var(--radius-xs); font-size: var(--fs-sm); color: var(--text-2); }
.tag-add-list a:hover { background: var(--surface-3); color: var(--text); }
.tag-add-none { margin: var(--sp-1) 0 0; font-size: var(--fs-sm); color: var(--text-3); }
.tag-filter-clear { font-size: var(--fs-sm); color: var(--text-3); }
.tag-filter-clear:hover { color: var(--text); }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + var(--sp-2)); transform: translateX(-50%);
  width: max-content; max-width: 240px; padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); z-index: 30;
  background: var(--text); color: var(--surface); font-size: var(--fs-xs); line-height: 1.4; font-weight: 400; white-space: normal; pointer-events: none;
  box-shadow: var(--shadow);
}

/* ---------- Stars ---------- */
.stars {
  --size: 16px;
  display: inline-block; width: calc(var(--size) * 5); height: var(--size); flex-shrink: 0;
  background: linear-gradient(90deg, var(--star) var(--pct, 0%), var(--star-empty) var(--pct, 0%));
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.2l2.9 6.3 6.9.7-5.2 4.6 1.5 6.8L12 17.1l-6.1 3.5 1.5-6.8L2.2 9.2l6.9-.7z'/%3E%3C/svg%3E") 0 0 / var(--size) var(--size) repeat-x;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.2l2.9 6.3 6.9.7-5.2 4.6 1.5 6.8L12 17.1l-6.1 3.5 1.5-6.8L2.2 9.2l6.9-.7z'/%3E%3C/svg%3E") 0 0 / var(--size) var(--size) repeat-x;
}
.stars-sm { --size: 12px; }
.stars-lg { --size: 24px; }
.mini-rating { display: inline-flex; align-items: center; gap: var(--sp-1); font-weight: 600; color: var(--text); }
.mini-rating .icon { color: var(--star); fill: var(--star); }

.star-input { border: 0; padding: 0; margin: 0; display: inline-flex; align-items: center; gap: 0; }
.star-input input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.star-input label { width: 16px; height: 32px; cursor: pointer; background: var(--star-empty); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.2l2.9 6.3 6.9.7-5.2 4.6 1.5 6.8L12 17.1l-6.1 3.5 1.5-6.8L2.2 9.2l6.9-.7z'/%3E%3C/svg%3E") no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.2l2.9 6.3 6.9.7-5.2 4.6 1.5 6.8L12 17.1l-6.1 3.5 1.5-6.8L2.2 9.2l6.9-.7z'/%3E%3C/svg%3E") no-repeat; -webkit-mask-size: 32px 32px; mask-size: 32px 32px; }
.star-input label.half-l { -webkit-mask-position: 0 0; mask-position: 0 0; }
.star-input label.half-r { -webkit-mask-position: -16px 0; mask-position: -16px 0; margin-right: var(--sp-1); }
.star-input label.is-lit { background: var(--star); }
.star-input input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 1px; }
.star-input .star-value { margin-left: var(--sp-2); font-weight: 650; min-width: 2.2em; font-variant-numeric: tabular-nums; }
.rf-sub .star-input label { width: 12px; height: 24px; -webkit-mask-size: 24px 24px; mask-size: 24px 24px; }
.rf-sub .star-input label.half-r { -webkit-mask-position: -12px 0; mask-position: -12px 0; }

/* ---------- Cards, sections, pages ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); min-height: 56px; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2, .card-head h3 { display: flex; align-items: baseline; gap: var(--sp-2); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.section-head h2 { display: flex; align-items: center; gap: var(--sp-2); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-3) var(--sp-6); margin-bottom: var(--sp-6); flex-wrap: wrap; }
.page-head h1 { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.page-head h1 .icon { color: var(--accent); }
.page-head p { margin: var(--sp-1) 0 0; }
.crumb { display: inline-flex; align-items: center; gap: var(--sp-1); color: var(--text-3); font-size: var(--fs-sm); font-weight: 500; margin-bottom: var(--sp-2); }
.empty { text-align: center; padding: var(--sp-8) var(--sp-6); color: var(--text-2); }
.empty .icon { color: var(--text-3); margin: 0 auto var(--sp-2); }
.empty h3 { margin-bottom: var(--sp-2); color: var(--text); }
.empty p { max-width: 440px; margin: 0 auto var(--sp-3); }
.empty-inline { color: var(--text-3); font-size: var(--fs-sm); }
.notice-line { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); background: var(--surface-2); border-radius: var(--radius-sm); color: var(--text-2); font-size: var(--fs-sm); }
.notice-line a { color: var(--accent-text); font-weight: 600; }
.split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
/* Cards stacked directly on a page (stats, chapter management) are spaced like the rest of the page. */
main > .card + .card, main > .card + .split-2, main > .split-2 + .card { margin-top: var(--sp-4); }

/* ---------- Covers ---------- */
.cover { width: 100%; height: auto; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 4px; background: var(--surface-3); box-shadow: 0 0 0 1px rgba(0, 0, 0, .06), 0 2px 6px rgba(0, 0, 0, .12); }

/* ---------- Story rows (rankings, search, library, profiles) ---------- */
.list-card > * + * { border-top: 1px solid var(--border); }
.frow { --cover: 80px; display: grid; grid-template-columns: var(--cover) minmax(0, 1fr); gap: var(--sp-4); padding: var(--sp-4); align-items: start; }
.frow:has(.frow-rank) { grid-template-columns: 24px var(--cover) minmax(0, 1fr); }
.frow-rank { font-weight: 700; font-size: var(--fs-lg); line-height: 24px; text-align: center; color: var(--text-3); font-variant-numeric: tabular-nums; }
.frow-rank.is-top { color: var(--accent); }
.frow-cover { display: block; }
.frow-body { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-1); }
.frow-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; min-height: 24px; }
.frow-title { font-family: var(--serif); font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.005em; line-height: 1.3; }
.frow-by { color: var(--text-2); font-size: var(--fs-sm); }
.frow-by a { font-weight: 550; color: var(--text); }
.frow-by a:hover { color: var(--accent-text); }
.frow-stats { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-4); font-size: var(--fs-xs); color: var(--text-2); }
.frow-stats > span { display: inline-flex; align-items: center; gap: var(--sp-1); }
.frow-stats .icon { color: var(--text-3); }
.stat-rating { gap: var(--sp-2) !important; }
.stat-rating b { color: var(--text); font-weight: 650; }
.stat-rating .stat-star { display: none; color: var(--star); fill: var(--star); }
.frow-metric { color: var(--accent-text) !important; font-weight: 600; }
.frow-metric .icon { color: var(--accent-text) !important; }
.frow-tags { display: flex; flex-wrap: wrap; gap: var(--sp-1); max-height: 52px; overflow: hidden; margin-top: var(--sp-1); }
.frow-tags:empty { display: none; }
.frow-synopsis { color: var(--text-2); font-size: var(--fs-sm); line-height: 1.5; margin: var(--sp-1) 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.frow-latest { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--text-2); margin-top: var(--sp-1); min-width: 0; }
.frow-latest span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.frow-latest time { color: var(--text-3); flex-shrink: 0; }
.lib-progress { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-3); margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 1px dashed var(--border); }

/* ---------- Compact story lines (home panels, story sidebar) ---------- */
.flines { list-style: none; margin: 0; padding: 0; }
.fline { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: var(--sp-3); align-items: center; padding: var(--sp-2) var(--sp-4); }
.fline + .fline { border-top: 1px solid var(--border); }
.fline-cover { display: block; }
.fline-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fline-title { font-family: var(--serif); font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fline-meta { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; }
.fline-meta > * { overflow: hidden; text-overflow: ellipsis; }
.fline-meta > :first-child { flex-shrink: 1; }
.fline-meta > :not(:first-child) { flex-shrink: 0; }
.fline-meta a { color: var(--text-2); font-weight: 550; }
.fline-meta a:hover { color: var(--accent-text); }
.fline-rating { display: inline-flex; align-items: center; gap: var(--sp-1); color: var(--text); font-weight: 600; }
.fline-rating .icon { color: var(--star); fill: var(--star); }
.fline-unread { color: var(--accent-text); font-weight: 600; }
/* Home page rows: a real cover, the stats and a two-line blurb, so each row fills its panel. */
.fline-detail { --cover: 64px; grid-template-columns: var(--cover) minmax(0, 1fr); align-items: start; gap: var(--sp-4); padding: var(--sp-4); }
.fline-detail .fline-body { gap: var(--sp-1); }
.fline-detail .fline-title { font-size: var(--fs-lg); line-height: 24px; }
.fline-detail .fline-meta { font-size: var(--fs-sm); }
.fline-stats { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); color: var(--text-3); }
.fline-stats > span { display: inline-flex; align-items: center; gap: var(--sp-1); white-space: nowrap; }
.fline-blurb { margin: 0; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Home ---------- */
.panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.panel { overflow: hidden; }
.panel-wide { margin-bottom: var(--sp-4); }
.panel-wide .flines { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel-wide .fline + .fline { border-top: 0; }
.panel-wide .fline:nth-child(n + 3) { border-top: 1px solid var(--border); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); height: 48px; padding: 0 var(--sp-4); border-bottom: 1px solid var(--border); }
.panel-head h2 { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-lg); }
.panel-head h2 .icon { color: var(--accent); }
.panel-more { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-sm); font-weight: 550; color: var(--text-3); }
.panel-empty { margin: 0; padding: var(--sp-6) var(--sp-4); color: var(--text-3); font-size: var(--fs-sm); text-align: center; }

/* ---------- Browse ---------- */
.browse-layout { display: grid; grid-template-columns: 208px minmax(0, 1fr); gap: var(--sp-6); align-items: start; }
.list-nav { position: sticky; top: calc(var(--topbar-h) + var(--sp-4)); display: flex; flex-direction: column; gap: 2px; }
.list-nav a { display: flex; align-items: center; gap: var(--sp-3); height: 36px; padding: 0 var(--sp-3); border-radius: var(--radius-sm); border: 1px solid transparent; color: var(--text-2); font-weight: 500; }
.list-nav a .icon { color: var(--text-3); }
.list-nav a:hover { background: var(--surface-2); color: var(--text); }
.list-nav a.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); border-color: var(--border); }
.list-nav a.is-active .icon { color: var(--accent); }
.list-menu { display: none; }
.next-link { display: flex; justify-content: center; margin-top: var(--sp-4); }
.next-link .btn { gap: var(--sp-2); }

/* ---------- Pager ---------- */
.pager { display: flex; justify-content: center; align-items: center; gap: var(--sp-1); margin-top: var(--sp-4); flex-wrap: wrap; }
.pager a, .pager span { display: inline-flex; align-items: center; gap: var(--sp-1); min-width: 32px; height: 32px; padding: 0 var(--sp-3); border-radius: var(--radius-sm); justify-content: center; font-weight: 550; font-size: var(--fs-sm); }
.pager a { background: var(--surface); border: 1px solid var(--border); }
.pager a:hover { border-color: var(--border-strong); color: var(--text); }
.pager .is-current { background: var(--text); color: var(--surface); }
.pager .is-disabled { color: var(--text-3); opacity: .5; }
.pager .pager-gap { min-width: 16px; padding: 0; color: var(--text-3); }
.card .pager { margin: 0; padding: var(--sp-4); border-top: 1px solid var(--border); }

/* ---------- Forms ---------- */
input[type="text"], input[type="email"], input[type="search"], input[type="number"], input[type="datetime-local"], input:not([type]), select, textarea {
  width: 100%; min-height: 40px; padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); outline: none; transition: border-color .12s, box-shadow .12s;
}
/* Text fields show focus with their own border and ring, so they never also get the generic outline. */
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2385878d' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right var(--sp-3) center; padding-right: var(--sp-8); }
input.input-sm, select.input-sm { min-height: 32px; height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-sm); width: auto; }
.card-head input[type="search"].input-sm { width: 208px; }
select.input-sm { padding-right: var(--sp-8); background-position: right var(--sp-2) center; }
input[type="color"] { width: 100%; height: 40px; padding: var(--sp-1); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
input[type="file"] { font-size: var(--fs-sm); color: var(--text-2); }
input[type="file"]::file-selector-button { font: inherit; font-weight: 550; height: 32px; padding: 0 var(--sp-3); margin-right: var(--sp-3); border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; }
.field { display: flex; flex-direction: column; gap: var(--sp-2); border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 600; font-size: var(--fs-sm); padding: 0; }
.field > legend { margin-bottom: var(--sp-2); }
.field small { font-weight: 400; }
.field-status { color: var(--text-3); }
.field-status[data-state="ok"] { color: var(--ok); }
.field-status[data-state="error"] { color: var(--accent-text); }
.input-prefix { display: flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.input-prefix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-prefix span { padding-left: var(--sp-3); color: var(--text-3); }
.input-prefix input { border: 0; box-shadow: none !important; padding-left: var(--sp-1); }
.check { display: flex; align-items: flex-start; gap: var(--sp-2); font-size: var(--fs-md); cursor: pointer; }
.check input, .radio-list input, .switch input, .check-chip input { accent-color: var(--accent); }
.check input { margin: 3px 0 0; }
.radio-list { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.radio-list label { display: flex; gap: var(--sp-2); align-items: center; cursor: pointer; }
.switch { display: flex; align-items: center; gap: var(--sp-3); cursor: pointer; font-size: var(--fs-md); }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 10px; background: var(--border-strong); position: relative; flex-shrink: 0; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }
.check-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.check-chip { position: relative; cursor: pointer; }
.check-chip input { position: absolute; opacity: 0; inset: 0; pointer-events: none; }
.check-chip span { display: inline-flex; align-items: center; height: 28px; padding: 0 var(--sp-3); border-radius: 14px; border: 1px solid var(--border-strong); background: var(--surface); font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); transition: all .12s; }
.check-chip:hover span { border-color: var(--text-3); color: var(--text); }
.check-chip input:checked + span { background: var(--text); border-color: var(--text); color: var(--surface); }
.check-chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg { display: inline-flex; padding: var(--sp-1); gap: var(--sp-1); background: var(--surface-2); border-radius: var(--radius-sm); }
.seg a, .seg button, .seg label { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); height: 28px; padding: 0 var(--sp-3); border-radius: var(--radius-xs); font-size: var(--fs-sm); font-weight: 550; color: var(--text-2); border: 0; background: none; cursor: pointer; white-space: nowrap; }
.seg a:hover, .seg button:hover, .seg label:hover { color: var(--text); }
.seg .is-active, .seg label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg label input { position: absolute; opacity: 0; pointer-events: none; }
.seg-full { display: flex; }
.seg-full > * { flex: 1; }
.form-narrow { max-width: 560px; }
.kv { display: grid; gap: 0; margin: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.kv > div { display: flex; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); }
.kv > div + div { border-top: 1px solid var(--border); }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 550; text-align: right; }
.copy-field { display: flex; gap: var(--sp-2); }
.copy-field input { min-height: 32px; height: 32px; font-size: var(--fs-xs); color: var(--text-2); background: var(--surface-2); }

/* Tag picker */
.tag-picker { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.tag-picker-head { display: flex; align-items: flex-start; gap: var(--sp-2); padding: var(--sp-2); }
.tag-picker-selected { display: flex; flex-wrap: wrap; gap: var(--sp-1); flex: 1; min-width: 0; }
.tag-picker-count { margin-left: auto; line-height: 28px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); white-space: nowrap; }
.tag-picker.is-maxed .tag-picker-count { color: var(--accent-text); }
.tag-picker-selected button { display: inline-flex; align-items: center; gap: var(--sp-1); height: 28px; padding: 0 var(--sp-2) 0 var(--sp-3); border-radius: 14px; border: 0; background: var(--text); color: var(--surface); font-size: var(--fs-xs); font-weight: 550; }
.tag-picker-filter { border: 0 !important; border-bottom: 1px solid var(--border) !important; border-radius: 0 !important; box-shadow: none !important; }
.tag-picker-list { display: flex; flex-wrap: wrap; gap: var(--sp-1); max-height: 280px; overflow-y: auto; padding: var(--sp-2); }
.tp-opt { position: relative; cursor: pointer; }
.tp-opt input { position: absolute; opacity: 0; pointer-events: none; }
.tp-opt span { display: inline-flex; align-items: center; height: 28px; padding: 0 var(--sp-2); border-radius: var(--radius-xs); background: var(--surface-2); font-size: var(--fs-xs); color: var(--text-2); }
.tp-opt:hover span { color: var(--text); background: var(--surface-3); }
.tp-opt input:checked + span { background: var(--text); color: var(--surface); }
.tp-opt input:focus-visible + span { outline: 2px solid var(--accent); }
.tp-opt input:disabled + span { opacity: .45; cursor: default; }

/* Profile links editor */
.link-rows { display: flex; flex-direction: column; gap: var(--sp-2); }
.link-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1.6fr) 40px; gap: var(--sp-2); align-items: center; }
.icon-pick { position: relative; }
.icon-pick > summary { list-style: none; }
.icon-pick > summary::-webkit-details-marker { display: none; }
.icon-pick-panel { position: absolute; z-index: 30; top: calc(100% + var(--sp-1)); left: 0; display: grid; grid-template-columns: repeat(2, 160px); gap: var(--sp-1); max-height: min(360px, 60vh); overflow-y: auto; padding: var(--sp-2); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.icon-pick-panel label { display: flex; align-items: center; gap: var(--sp-2); height: 32px; padding: 0 var(--sp-2); border-radius: var(--radius-xs); color: var(--text-2); font-size: var(--fs-sm); white-space: nowrap; cursor: pointer; }
.icon-pick-panel label:hover { background: var(--surface-2); color: var(--text); }
.icon-pick-panel input { position: absolute; opacity: 0; pointer-events: none; }
.icon-pick-panel label:has(input:checked) { background: var(--text); color: var(--surface); }
.icon-pick-panel label:has(input:focus-visible) { outline: 2px solid var(--accent); }

/* ---------- Story page ---------- */
.fic-hero { display: grid; grid-template-columns: 192px minmax(0, 1fr); gap: var(--sp-6); margin-bottom: var(--sp-4); }
.fic-cover .cover { border-radius: var(--radius-xs); box-shadow: 0 0 0 1px rgba(0, 0, 0, .06), 0 10px 30px rgba(0, 0, 0, .18); }
.fic-info { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.fic-badges { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.fic-title { font-family: var(--serif); font-size: clamp(26px, 3.4vw, 34px); font-weight: 650; line-height: 1.15; letter-spacing: -0.015em; }
.fic-author { color: var(--text-2); display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.fic-author > a { font-weight: 600; color: var(--text); }
.fic-tags { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.fic-tags .chip { position: relative; }
.fic-stats { display: flex; flex-wrap: wrap; gap: var(--sp-2) 0; margin: 0; }
.fic-stat { padding: 0 var(--sp-4); border-left: 1px solid var(--border); }
.fic-stat:first-child { padding-left: 0; border-left: 0; }
.fic-stat dt { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 650; color: var(--text-3); }
.fic-stat dd { margin: var(--sp-1) 0 0; display: flex; flex-direction: column; }
.fic-stat dd b { font-size: var(--fs-xl); font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.fic-stat dd small { color: var(--text-3); }
.fic-stat-rating dd a { display: flex; align-items: center; gap: var(--sp-2); }
.fic-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.fic-actions form { display: contents; }
.fic-tabs { position: sticky; top: var(--topbar-h); z-index: 20; display: flex; gap: var(--sp-1); background: var(--bg); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-4); }
.fic-tabs a { display: flex; align-items: center; gap: var(--sp-2); height: 44px; padding: 0 var(--sp-3); font-weight: 600; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.fic-tabs a:hover, .fic-tabs a.is-active { color: var(--text); border-bottom-color: var(--accent); }
.count { font-size: 11px; font-weight: 650; color: var(--text-3); background: var(--surface-2); border-radius: 10px; padding: 2px var(--sp-2); }
.fic-layout { display: grid; grid-template-columns: minmax(0, 1fr) 304px; gap: var(--sp-6); align-items: start; }
.fic-main { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.fic-side { display: flex; flex-direction: column; gap: var(--sp-4); position: sticky; top: calc(var(--topbar-h) + 60px); }
.fic-side .card.pad:has(.flines) { padding: var(--sp-4) 0 var(--sp-2); }
.fic-side .card.pad:has(.flines) .side-title { padding: 0 var(--sp-4); margin-bottom: var(--sp-2); }
.synopsis { font-family: var(--serif); font-size: var(--fs-lg); line-height: 1.65; color: var(--text); }
.synopsis p { margin-bottom: var(--sp-3); }
.fic-about { display: flex; flex-direction: column; gap: var(--sp-4); }
.warnings { display: flex; gap: var(--sp-2); align-items: flex-start; padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); font-size: var(--fs-sm); }
.warnings .icon { margin-top: 2px; }
[data-clamp].is-clamped { position: relative; max-height: var(--clamp-h, 9.5em); overflow: hidden; }
[data-clamp].is-clamped::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3em; background: linear-gradient(transparent, var(--surface)); }
.clamp-toggle { border: 0; background: none; color: var(--accent-text); font-weight: 600; padding: var(--sp-1) 0 0; font-size: var(--fs-sm); }
.chapter-list { list-style: none; margin: 0; padding: 0; }
.chapter-list li a { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto auto; gap: var(--sp-3); align-items: center; min-height: 40px; padding: var(--sp-2) var(--sp-4); }
.chapter-list li + li { border-top: 1px solid var(--border); }
.chapter-list li a:hover { background: var(--surface-2); color: inherit; }
.ch-num { color: var(--text-3); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.ch-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.chapter-list .is-read .ch-title { color: var(--text-3); font-weight: 400; }
.chapter-list .is-current { box-shadow: inset 3px 0 0 var(--accent); }
.ch-read { color: var(--ok); display: grid; }
.ch-date { color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; }
.chapter-list .vol-head { padding: var(--sp-3) var(--sp-4) var(--sp-2); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); background: var(--surface-2); }
.fic-reviews { display: flex; flex-direction: column; gap: var(--sp-4); }
.review-summary { display: grid; grid-template-columns: auto 1fr auto; gap: var(--sp-6); align-items: center; }
.rs-score { text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--sp-1); }
.rs-big { font-size: 40px; font-weight: 750; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.rs-dist { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.rs-bar { display: grid; grid-template-columns: 32px 1fr 40px; gap: var(--sp-2); align-items: center; font-size: var(--fs-xs); }
.rs-bar > span:first-child { color: var(--text-2); font-weight: 550; }
.rs-bar > span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.bar { display: block; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--star); border-radius: 4px; }
.rs-subs { margin: 0; display: flex; flex-direction: column; gap: var(--sp-1); }
.rs-subs > div { display: grid; grid-template-columns: 80px auto 32px; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }
.rs-subs dt { color: var(--text-2); }
.rs-subs dd { margin: 0; display: contents; }
.rs-subs dd b { font-size: var(--fs-xs); text-align: right; }
.rs-subs > .muted { display: block; text-align: right; }
.rate-box h3 { margin-bottom: var(--sp-1); }
.rf-top { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.rf-more { margin-top: var(--sp-3); }
.rf-more > summary { cursor: pointer; color: var(--accent-text); font-weight: 600; display: inline-flex; gap: var(--sp-2); align-items: center; list-style: none; padding: var(--sp-1) 0; }
.rf-more > summary::-webkit-details-marker { display: none; }
.rf-more[open] { display: flex; flex-direction: column; gap: var(--sp-3); }
.rf-subs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2) var(--sp-6); padding: var(--sp-3); background: var(--surface-2); border-radius: var(--radius-sm); }
.rf-subs > p { grid-column: 1 / -1; margin: 0; }
.rf-sub { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-sm); font-weight: 550; }
.rf-actions { display: flex; gap: var(--sp-2); align-items: center; margin-top: var(--sp-3); }
.rf-review { margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.rf-review .rf-actions { margin-top: 0; }
.review { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); }
.card > .review + .review { border-top: 1px solid var(--border); }
.review-head { display: flex; align-items: center; gap: var(--sp-3); }
.review-cover { width: 32px; flex-shrink: 0; }
.review-who { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; font-size: var(--fs-xs); }
.review-name { font-weight: 650; font-size: var(--fs-md); }
.review-score { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); font-weight: 700; }
.review-subs { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); margin: 0; font-size: var(--fs-xs); }
.review-subs > div { display: flex; gap: var(--sp-2); align-items: center; }
.review-subs dt { color: var(--text-3); }
.review-subs dd { margin: 0; display: flex; }
.review-title { font-size: var(--fs-lg); font-family: var(--serif); }
.review-body { color: var(--text); }
.review-actions { display: flex; align-items: center; gap: var(--sp-1); flex-wrap: wrap; margin-left: calc(var(--sp-2) * -1); }
.author-reply { padding: var(--sp-3) var(--sp-4); border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.author-reply-head { font-size: var(--fs-xs); font-weight: 650; color: var(--text-3); margin-bottom: var(--sp-1); display: flex; gap: var(--sp-1); align-items: center; }
.inline-form > summary { list-style: none; }
.inline-form > summary::-webkit-details-marker { display: none; }
.inline-form[open] { flex-basis: 100%; order: 5; padding-left: var(--sp-2); }
.inline-form form { margin-top: var(--sp-2); }
.prose-sm { font-size: var(--fs-md); line-height: 1.6; overflow-wrap: anywhere; }
.prose-sm p { margin: 0 0 var(--sp-2); }
.prose-sm p:last-child { margin-bottom: 0; }
.prose-sm blockquote { margin: 0 0 var(--sp-2); padding: 2px 0 2px var(--sp-3); border-left: 3px solid var(--border-strong); color: var(--text-2); }
.prose-sm a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }
.spoiler { background: var(--text); color: transparent; border-radius: 3px; cursor: pointer; padding: 0 2px; transition: color .15s, background .15s; }
.spoiler.is-revealed { background: var(--surface-2); color: inherit; cursor: auto; }
.author-card-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.author-card-head span:not(.avatar) { display: flex; flex-direction: column; line-height: 1.25; }
.fic-dates { display: flex; flex-direction: column; gap: var(--sp-1); margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.fic-dates div { display: flex; align-items: center; gap: var(--sp-2); }
.side-title { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin-bottom: var(--sp-3); }

/* ---------- Avatars ---------- */
.avatar { --s: 32px; width: var(--s); height: var(--s); border-radius: 50%; flex-shrink: 0; object-fit: cover; display: inline-grid; place-items: center; font-weight: 650; font-size: calc(var(--s) * .42); color: #fff; background: hsl(var(--h, 210) 42% 46%); user-select: none; }
img.avatar { width: auto; }

/* ---------- Reader ---------- */
html[data-page="reader"] { --rw: 700px; --rs: 19px; --rl: 1.75; --rp: 1.05em; --rf: var(--serif); }
.is-reader .topbar { display: none; }
.readbar { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); transition: transform .22s ease; }
.readbar.is-hidden { transform: translateY(-100%); }
.readbar-inner { max-width: 1000px; margin: 0 auto; height: 52px; display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-3); }
.readbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.readbar-fic { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readbar-ch { font-size: var(--fs-xs); color: var(--text-3); }
.readbar-actions { display: flex; gap: var(--sp-1); }
.readprogress { height: 2px; background: transparent; }
.readprogress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }
.preview-banner { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); flex-wrap: wrap; padding: var(--sp-2) var(--sp-4); background: var(--warn-soft); color: var(--warn); font-size: var(--fs-sm); font-weight: 550; }
.preview-banner a { text-decoration: underline; }
.reader { max-width: calc(var(--rw) + var(--sp-6) * 2); margin: 0 auto; padding: var(--sp-8) var(--sp-6) var(--sp-3); }
.reader-head { text-align: center; margin-bottom: var(--sp-8); }
.reader-title { font-family: var(--serif); font-size: clamp(24px, 4vw, 32px); font-weight: 650; margin-bottom: var(--sp-3); line-height: 1.2; letter-spacing: -0.01em; }
.reader-meta { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--sp-1) 0; color: var(--text-3); font-size: var(--fs-sm); }
.reader-meta > span + span::before { content: '·'; margin: 0 var(--sp-2); }
.reader-meta a { color: var(--text-2); font-weight: 550; }
.author-note { margin: 0 0 var(--sp-6); padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); background: var(--surface-2); font-size: var(--fs-md); color: var(--text-2); border: 1px dashed var(--border-strong); }
.chapter-content + .author-note { margin: var(--sp-8) 0 0; }
.author-note-head { font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin-bottom: var(--sp-2); display: flex; align-items: center; gap: var(--sp-2); }
.chapter-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--sp-3); margin: var(--sp-8) 0 var(--sp-6); }
.chapter-nav > :first-child { justify-self: start; }
.chapter-nav > :last-child { justify-self: end; }
.caught-up { text-align: center; }
.caught-up h3 { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.caught-up .icon { color: var(--ok); }
.caught-up p { color: var(--text-2); }
.caught-up .row-gap { justify-content: center; margin-top: var(--sp-3); }
.caught-up form { display: contents; }

/* Chapter prose and LitRPG blocks (sized in em so they follow the reader's text size) */
.chapter-content { font-family: var(--rf, var(--serif)); font-size: var(--rs, 18px); line-height: var(--rl, 1.75); color: var(--text); overflow-wrap: break-word; hyphens: manual; }
.chapter-content > * { margin: 0 0 var(--rp, 1.05em); }
.chapter-content p { margin: 0 0 var(--rp, 1.05em); }
html[data-indent="1"] .reader .chapter-content > p + p:not(.notice):not(.ta-center):not(.ta-right) { text-indent: 1.6em; }
html[data-indent="1"] .reader .chapter-content > p { margin-bottom: calc(var(--rp, 1em) * .35); }
html[data-justify="1"] .reader .chapter-content p:not(.notice):not(.ta-center):not(.ta-right) { text-align: justify; }
.chapter-content h2, .chapter-content h3 { font-family: inherit; margin: 1.6em 0 .7em; line-height: 1.3; }
.chapter-content h2 { font-size: 1.3em; }
.chapter-content h3 { font-size: 1.1em; }
.chapter-content a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }
.chapter-content blockquote { margin-left: 0; margin-right: 0; padding: .2em 0 .2em 1.1em; border-left: 3px solid var(--border-strong); font-style: italic; color: var(--text-2); }
.chapter-content blockquote p:last-child { margin-bottom: 0; }
.chapter-content ul, .chapter-content ol { padding-left: 1.4em; }
.chapter-content li { margin-bottom: .3em; }
.chapter-content hr { border: 0; height: auto; margin: 1.8em 0; text-align: center; overflow: visible; }
.chapter-content hr::after { content: '*\2003*\2003*'; font-size: 1em; color: var(--text-3); letter-spacing: .1em; }
.chapter-content .ta-center { text-align: center; text-indent: 0 !important; }
.chapter-content .ta-right { text-align: right; text-indent: 0 !important; }
.chapter-content code { font-family: var(--mono); font-size: .8em; font-weight: 600; padding: .08em .38em; border-radius: 4px; background: var(--sys-bg); color: var(--sys-title); border: 1px solid color-mix(in srgb, var(--sys-border) 60%, transparent); white-space: nowrap; }
.chapter-content .notice { font-family: var(--mono); font-size: .8em; font-weight: 600; text-align: center; text-indent: 0 !important; color: var(--sys-title); letter-spacing: .01em; margin: 1.1em 0; }
.chapter-content .sys {
  --b: var(--sys-bg); --bd: var(--sys-border); --t: var(--sys-text); --tt: var(--sys-title);
  font-family: var(--mono); font-size: .8em; line-height: 1.6; color: var(--t); background: var(--b);
  border: 1px solid var(--bd); border-left-width: 4px; border-radius: var(--radius-sm); padding: .9em 1.15em; margin: 1.5em 0;
}
.chapter-content .sys p { margin: 0 0 .35em; text-indent: 0 !important; text-align: left !important; }
.chapter-content .sys p:last-child { margin-bottom: 0; }
.chapter-content .sys .ta-center { text-align: center !important; }
.chapter-content .sys .sys-title { font-weight: 700; color: var(--tt); text-transform: uppercase; letter-spacing: .06em; font-size: .92em; margin-bottom: .55em; padding-bottom: .45em; border-bottom: 1px solid color-mix(in srgb, var(--bd) 70%, transparent); }
.chapter-content .sys code { background: color-mix(in srgb, var(--surface) 55%, transparent); color: var(--tt); border-color: color-mix(in srgb, var(--bd) 60%, transparent); font-size: .95em; }
.chapter-content .sys-gold { --b: var(--sysg-bg); --bd: var(--sysg-border); --t: var(--sysg-text); --tt: var(--sysg-title); }
.chapter-content .sys-red { --b: var(--sysr-bg); --bd: var(--sysr-border); --t: var(--sysr-text); --tt: var(--sysr-title); }
.chapter-content .sys-green { --b: var(--sysn-bg); --bd: var(--sysn-border); --t: var(--sysn-text); --tt: var(--sysn-title); }
.chapter-content .sys-purple { --b: var(--sysp-bg); --bd: var(--sysp-border); --t: var(--sysp-text); --tt: var(--sysp-title); }
.chapter-content .sys-gray { --b: var(--sysx-bg); --bd: var(--sysx-border); --t: var(--sysx-text); --tt: var(--sysx-title); }
.table-wrap { overflow-x: auto; margin: 1.5em 0; -webkit-overflow-scrolling: touch; }
.chapter-content .sys .table-wrap { margin: .4em 0; }
.chapter-content table { border-collapse: collapse; font-family: var(--mono); font-size: .78em; line-height: 1.45; min-width: min(100%, 320px); margin: 0 auto; background: var(--surface); color: var(--text); border-radius: var(--radius-xs); overflow: hidden; box-shadow: 0 0 0 1px var(--border-strong); }
.chapter-content .sys table { width: 100%; background: transparent; color: inherit; box-shadow: none; font-size: 1em; }
.chapter-content th, .chapter-content td { padding: .45em .9em; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.chapter-content .sys th, .chapter-content .sys td { border-bottom-color: color-mix(in srgb, var(--bd) 50%, transparent); padding: .3em .6em .3em 0; }
.chapter-content tr:last-child > * { border-bottom: 0; }
.chapter-content thead th { background: var(--surface-2); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: .9em; color: var(--text-2); }
.chapter-content .sys thead th { background: transparent; color: var(--tt); border-bottom: 1px solid var(--bd); }
.chapter-content tbody th { font-weight: 600; color: var(--text-2); white-space: nowrap; }
.chapter-content .sys tbody th { color: var(--tt); }
.chapter-content td.ta-center, .chapter-content th.ta-center { text-align: center; }
.chapter-content td.ta-right, .chapter-content th.ta-right { text-align: right; }
.chapter-content strong { font-weight: 650; }

/* Reader themes (applied to the whole reading page) */
html[data-reader-theme="sepia"][data-page="reader"] { --bg: #f4ecd8; --surface: #fbf5e6; --surface-2: #ece2ca; --surface-3: #e3d7bb; --border: #e2d6b9; --border-strong: #cdbf9e; --text: #3b2f1e; --text-2: #5c4c35; --text-3: #8a785d; --star-empty: #d9cba9; color-scheme: light; }
html.is-dark[data-reader-theme="black"][data-page="reader"] { --bg: #000; --surface: #0b0b0c; --surface-2: #151517; --surface-3: #1e1e21; --border: #1f2023; --border-strong: #2e2f33; --text: #d6d6d8; --text-2: #a3a4a9; --text-3: #75777d; }
.font-literata { font-family: 'Literata', serif !important; }
.font-merriweather { font-family: 'Merriweather', serif !important; }
.font-inter { font-family: 'Inter', sans-serif !important; }
.font-atkinson { font-family: 'Atkinson Hyperlegible', sans-serif !important; }

/* ---------- Comments ---------- */
/* Follow, Follow author, Favorite and Read later, between the chapter and its comments. */
.chapter-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-2); max-width: calc(var(--rw, 700px) + var(--sp-6) * 2); margin: 0 auto var(--sp-6); padding: 0 var(--sp-6); }
.chapter-actions form { display: contents; }
.comments { max-width: calc(var(--rw, 700px) + var(--sp-6) * 2); margin: 0 auto var(--sp-8); padding: var(--sp-6); border-top: 1px solid var(--border); }
.comments-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.comments-head h2 { display: flex; align-items: baseline; gap: var(--sp-2); }
.comment-form { display: flex; gap: var(--sp-3); align-items: flex-start; margin-bottom: var(--sp-6); }
.comment-form-main { flex: 1; display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.comment-form-actions { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); }
.replying-to { font-size: var(--fs-sm); color: var(--text-2); }
.thread { padding: var(--sp-3) 0; }
.thread + .thread { border-top: 1px solid var(--border); }
.thread .pager { justify-content: flex-start; margin-left: calc(34px + var(--sp-3)); }
.thread-back { display: inline-flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); color: var(--accent-text); font-weight: 600; font-size: var(--fs-sm); }
.comment { display: flex; gap: var(--sp-3); }
.comment-main { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; font-size: var(--fs-sm); }
.comment-name { font-weight: 650; }
.comment-body { margin-top: var(--sp-1); }
.comment-actions { display: flex; align-items: center; gap: var(--sp-1); margin: var(--sp-1) 0 0 calc(var(--sp-2) * -1); }
.comment-edit { margin-top: var(--sp-2); }
.replies { margin: var(--sp-3) 0 0 calc(34px + var(--sp-3)); display: flex; flex-direction: column; gap: var(--sp-3); padding-left: var(--sp-3); border-left: 2px solid var(--border); }
.replies-more { align-self: flex-start; color: var(--accent-text); font-weight: 600; font-size: var(--fs-sm); }
.comment.is-highlight { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { background: var(--accent-soft); } 100% { background: transparent; } }

/* ---------- Dialogs ---------- */
.dialog { border: 0; padding: var(--sp-6); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(440px, calc(100vw - var(--sp-6))); max-height: calc(100vh - var(--sp-12)); }
.dialog::backdrop { background: rgba(10, 10, 12, .45); backdrop-filter: blur(2px); }
.dialog h3 { font-size: var(--fs-lg); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin: calc(var(--sp-2) * -1) calc(var(--sp-2) * -1) var(--sp-3) 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); }
.dialog-side { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(384px, 100vw); border-radius: 0; overflow-y: auto; display: none; flex-direction: column; gap: var(--sp-4); }
.dialog-side[open] { display: flex; animation: slidein .2s ease; }
@keyframes slidein { from { transform: translateX(32px); opacity: 0; } }
.toc-list { list-style: none; margin: 0 calc(var(--sp-6) * -1); padding: 0; overflow-y: auto; }
.toc-list a { display: flex; gap: var(--sp-3); min-height: 40px; padding: var(--sp-2) var(--sp-6); align-items: center; }
.toc-list a:hover { background: var(--surface-2); color: inherit; }
.toc-list .is-current a { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.rs-group { display: flex; flex-direction: column; gap: var(--sp-2); }
.rs-label { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); display: flex; justify-content: space-between; }
.rs-label output { text-transform: none; letter-spacing: 0; color: var(--text-2); font-weight: 600; }
.rs-toggles { gap: var(--sp-3); }
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--sp-2); }
.swatch { display: flex; flex-direction: column; align-items: center; gap: var(--sp-1); padding: var(--sp-2) 0; border-radius: var(--radius-sm); border: 2px solid var(--border); font-family: var(--serif); font-weight: 600; font-size: var(--fs-lg); }
.swatch small { font-family: var(--ui); font-size: 11px; font-weight: 500; }
.swatch.is-active { border-color: var(--accent); }
.swatch-auto { background: linear-gradient(135deg, #fff 50%, #1a1b1e 50%); color: #888; }
.swatch-light { background: #fff; color: #1b1c1e; }
.swatch-sepia { background: #f4ecd8; color: #3b2f1e; }
.swatch-dark { background: #1a1b1e; color: #e9e9eb; }
.swatch-black { background: #000; color: #d6d6d8; }
.seg-full button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
input[type="range"] { width: 100%; accent-color: var(--accent); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); top: calc(var(--topbar-h) + var(--sp-3)); display: flex; flex-direction: column; gap: var(--sp-2); width: min(480px, calc(100vw - var(--sp-6))); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4); border-radius: var(--radius); background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); font-weight: 500; animation: toastin .25s ease; }
.toast .icon { color: #5bd38d; }
.toast-error { background: #a3261d; color: #fff; }
.toast-error .icon { color: #fff; }
.toast span { flex: 1; }
.toast-x { border: 0; background: none; color: inherit; opacity: .7; display: grid; padding: var(--sp-1); }
.toast.is-leaving { opacity: 0; transform: translateY(-8px); transition: all .25s; }
@keyframes toastin { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- Tabs / toolbar ---------- */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-4); overflow-x: auto; scrollbar-width: none; }
.tabs a { display: flex; gap: var(--sp-2); align-items: center; height: 40px; padding: 0 var(--sp-3); font-weight: 600; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.is-active { color: var(--text); border-bottom-color: var(--accent); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); flex-wrap: wrap; }

/* ---------- Search ---------- */
.search-bar { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.search-field { flex: 1; position: relative; display: flex; align-items: center; }
.search-field .icon { position: absolute; left: var(--sp-3); color: var(--text-3); }
.search-field input[type="search"] { height: 44px; padding-left: 40px; font-size: var(--fs-lg); border-radius: var(--radius); }
.search-bar .btn { --h: 44px; }
.search-layout { display: grid; grid-template-columns: 304px minmax(0, 1fr); gap: var(--sp-6); align-items: start; }
.filters { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); position: sticky; top: calc(var(--topbar-h) + var(--sp-4)); max-height: calc(100vh - var(--topbar-h) - var(--sp-8)); overflow-y: auto; }
.filters-toggle { display: flex; align-items: center; gap: var(--sp-2); height: 48px; padding: 0 var(--sp-4); font-weight: 650; cursor: pointer; list-style: none; border-bottom: 1px solid var(--border); }
.filters-toggle::-webkit-details-marker { display: none; }
.filters-body { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-4); }
.filter-block h4 { font-size: var(--fs-sm); margin-bottom: var(--sp-2); }
.filters .tag-picker-list { max-height: 176px; }
.filters .tag-picker-head:has([data-selected]:empty) { display: none; }
.filter-block .check-chip span { height: 28px; font-size: var(--fs-xs); padding: 0 var(--sp-3); }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.filter-grid .field > span { font-size: var(--fs-xs); }
.filter-grid input, .filter-grid select { min-height: 32px; height: 32px; padding-top: 0; padding-bottom: 0; font-size: var(--fs-sm); }
.filter-actions { display: flex; gap: var(--sp-2); }
.results-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); font-weight: 600; }
.results-head > span:first-child { margin-right: var(--sp-2); }
.author-hits { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.author-hit { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-1) var(--sp-3) var(--sp-1) var(--sp-1); border-radius: 24px; background: var(--surface); border: 1px solid var(--border); }
.author-hit span:not(.avatar) { display: flex; flex-direction: column; line-height: 1.2; font-size: var(--fs-sm); }
.author-hit small { color: var(--text-3); }
.tag-directory-search { max-width: 420px; margin-bottom: var(--sp-4); }
.tag-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: var(--sp-2); margin: 0; padding: 0; list-style: none; }
.tag-card { display: flex; flex-direction: column; gap: var(--sp-1); height: 100%; padding: var(--sp-3); border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.tag-card:hover { border-color: var(--border-strong); color: inherit; box-shadow: var(--shadow); }
.tag-card.is-empty { opacity: .65; }
.tag-card-name { font-weight: 650; }
.tag-card-desc { font-size: var(--fs-xs); color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tag-card-count { font-size: var(--fs-xs); color: var(--text-3); margin-top: auto; }

/* ---------- Library / people / notifications ---------- */
.person-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); }
.person-name { font-weight: 650; }
.notif-list { overflow: hidden; }
.notif { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); }
.notif + .notif { border-top: 1px solid var(--border); }
.notif:hover { background: var(--surface-2); color: inherit; }
.notif.is-unread { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
.notif-cover { width: 32px; flex-shrink: 0; }
.notif-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.notif-text .icon { color: var(--text-3); margin-right: var(--sp-1); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }

/* ---------- Profile ---------- */
.profile-head { display: grid; grid-template-columns: auto 1fr auto; gap: var(--sp-6); margin-bottom: var(--sp-4); align-items: start; }
.profile-info h1 { font-family: var(--serif); font-size: var(--fs-3xl); }
.profile-bio { margin-top: var(--sp-2); max-width: 680px; color: var(--text-2); }
.profile-links { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-3) 0 0; padding: 0; list-style: none; }
.profile-links a { display: inline-flex; align-items: center; gap: var(--sp-2); height: 28px; padding: 0 var(--sp-3); border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: var(--fs-sm); font-weight: 550; }
.profile-links a:hover { border-color: var(--border-strong); color: var(--text); }
.profile-links .icon { color: var(--text-3); }
.profile-stats { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-6); margin: var(--sp-4) 0 0; }
.profile-stats dt { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 650; }
.profile-stats dd { margin: 0; font-weight: 700; font-size: var(--fs-xl); }
.profile-actions { display: flex; gap: var(--sp-2); align-items: center; }
.profile-actions form { display: contents; }
.profile-invite { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 400px); gap: var(--sp-2) var(--sp-6); align-items: center; margin-bottom: var(--sp-4); }
.profile-invite h3 { margin-bottom: var(--sp-1); }
.profile-invite p { margin: 0; }

/* ---------- Messages ---------- */
.pm { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: var(--sp-4); height: calc(100vh - var(--topbar-h) - var(--sp-12)); min-height: 480px; }
.pm-inbox { display: flex; flex-direction: column; overflow: hidden; }
.pm-list { list-style: none; margin: 0; padding: var(--sp-2); overflow-y: auto; flex: 1; }
.pm-list a { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2); border-radius: var(--radius-sm); }
.pm-list a:hover { background: var(--surface-2); color: inherit; }
.pm-list a.is-active { background: var(--surface-2); }
.pm-list-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pm-list-top { display: flex; justify-content: space-between; gap: var(--sp-2); }
.pm-snippet { font-size: var(--fs-sm); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-list .is-unread .pm-snippet { color: var(--text); font-weight: 550; }
.pm-older { display: flex; align-items: center; justify-content: center; gap: var(--sp-1); height: 44px; border-top: 1px solid var(--border); color: var(--accent-text); font-weight: 600; font-size: var(--fs-sm); }
.pm-thread { display: flex; flex-direction: column; overflow: hidden; }
.pm-empty { margin: auto; }
.pm-head { display: flex; align-items: center; gap: var(--sp-2); height: 56px; padding: 0 var(--sp-4); border-bottom: 1px solid var(--border); }
.pm-who { display: flex; align-items: center; gap: var(--sp-3); }
.pm-who span:not(.avatar) { display: flex; flex-direction: column; line-height: 1.2; }
.pm-back { display: none; }
.pm-messages { flex: 1; overflow-y: auto; padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); }
.pm-earlier { align-self: center; color: var(--accent-text); font-weight: 600; font-size: var(--fs-sm); margin-bottom: var(--sp-2); }
.pm-day { align-self: center; font-size: 11px; font-weight: 600; color: var(--text-3); padding: var(--sp-2) 0 var(--sp-1); }
.pm-msg { max-width: min(78%, 560px); align-self: flex-start; display: flex; flex-direction: column; }
.pm-msg.is-mine { align-self: flex-end; align-items: flex-end; }
.pm-bubble { padding: var(--sp-2) var(--sp-3); border-radius: 16px 16px 16px 4px; background: var(--surface-2); line-height: 1.5; overflow-wrap: anywhere; }
.pm-bubble p { margin: 0 0 var(--sp-1); }
.pm-bubble p:last-child { margin: 0; }
.is-mine .pm-bubble { background: var(--accent); color: #fff; border-radius: 16px 16px 4px 16px; }
.is-mine .pm-bubble a { color: #fff; }
.pm-meta { font-size: 11px; color: var(--text-3); padding: 2px var(--sp-2); }
.pm-meta .linkbtn { font-size: 11px; color: var(--text-3); }
.pm-start { text-align: center; margin: auto; }
.pm-compose { display: flex; gap: var(--sp-2); align-items: flex-end; padding: var(--sp-3); border-top: 1px solid var(--border); }
.pm-compose textarea { min-height: 40px; max-height: 160px; resize: none; border-radius: 20px; padding: var(--sp-2) var(--sp-4); }
.pm-compose .btn { border-radius: 50%; }
.pm-thread > .notice-line { margin: var(--sp-3); }

/* ---------- Author tools ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(152px, 1fr)); gap: var(--sp-3); margin: 0 0 var(--sp-6); }
.kpis > div { padding: var(--sp-3) var(--sp-4); }
.kpis dt { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }
.kpis dd { margin: var(--sp-1) 0 0; font-size: var(--fs-2xl); font-weight: 750; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.write-grid { display: grid; grid-template-columns: minmax(0, 1fr) 336px; gap: var(--sp-6); align-items: start; }
.write-grid aside { display: flex; flex-direction: column; gap: var(--sp-4); }
.wfic { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: var(--sp-4); padding: var(--sp-4); }
.wfic-body { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.feedback-list { overflow: hidden; }
.fb { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); }
.fb + .fb { border-top: 1px solid var(--border); }
.fb:hover { background: var(--surface-2); color: inherit; }
.fb-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: var(--fs-sm); }
.fb-text { color: var(--text-2); }
.tips ul { margin: var(--sp-2) 0 var(--sp-3); padding-left: var(--sp-4); color: var(--text-2); font-size: var(--fs-sm); display: flex; flex-direction: column; gap: var(--sp-2); }
.tips a { color: var(--accent-text); font-weight: 600; font-size: var(--fs-sm); }
.fform { display: grid; grid-template-columns: minmax(0, 1fr) 304px; gap: var(--sp-6); align-items: start; }
.fform-side { position: sticky; top: calc(var(--topbar-h) + var(--sp-4)); }
.cover-preview { width: 152px; margin: 0 auto; }
.cover-placeholder { display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: var(--sp-4) var(--sp-3); text-align: center; background: radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--ac) 30%, transparent), transparent 60%), var(--bg-c, #2b3a4a); color: #fff; font-family: Georgia, serif; font-weight: 700; text-transform: uppercase; font-size: var(--fs-lg); line-height: 1.2; }
.cover-placeholder small { color: var(--ac); font-family: var(--ui); font-size: 10px; letter-spacing: .15em; font-weight: 500; }
/* The chosen motif, drawn like the generated cover: an outline in the accent colour. */
.cover-motif { flex: 1; min-height: 0; width: 64%; margin: var(--sp-2) 0; fill: none; stroke: var(--ac); stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; }
.cover-motif g:not(.is-on) { display: none; }
.danger-zone { margin-top: var(--sp-4); border-color: color-mix(in srgb, #b4271d 35%, var(--border)); }
.danger-zone summary { cursor: pointer; color: var(--accent-text); font-weight: 600; }
.danger-zone form { margin-top: var(--sp-3); }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 650; padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table td .pill { margin-left: var(--sp-1); }
.w-grip { width: 32px; padding-right: 0 !important; }
.grip { cursor: grab; color: var(--text-3); display: grid; }
.ch-table tr.is-dragging { opacity: .4; }
.ch-table tr.drop-before td { box-shadow: inset 0 2px 0 var(--accent); }
.state { display: inline-flex; align-items: center; gap: var(--sp-1); height: 20px; padding: 0 var(--sp-2); border-radius: 4px; font-size: var(--fs-xs); font-weight: 650; white-space: nowrap; }
.state-pub { background: var(--ok-soft); color: var(--ok); }
.state-sched { background: var(--info-soft); color: var(--info); }
.state-draft { background: var(--surface-2); color: var(--text-2); }
.vol-list { list-style: none; padding: 0; margin: var(--sp-3) 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.vol-list li { display: flex; gap: var(--sp-2); align-items: center; }
.vol-list form { display: flex; gap: var(--sp-2); align-items: center; }
#volumes > h3 { margin-bottom: var(--sp-1); }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.legend { display: flex; gap: var(--sp-2) var(--sp-3); align-items: center; font-size: var(--fs-xs); color: var(--text-3); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: calc(var(--sp-2) * -1); }
.lg-views { background: var(--accent); }
.lg-release { background: var(--info); }
.bars { display: flex; align-items: flex-end; gap: var(--sp-1); height: 160px; }
.bars-sm { height: 88px; }
.bar-col { flex: 1; height: 100%; display: flex; align-items: flex-end; position: relative; }
.bar-col:hover .bar-v { opacity: .8; }
.bar-v { display: block; width: 100%; min-height: 2px; background: var(--accent); border-radius: 3px 3px 0 0; }
.bar-f { background: var(--ok); }
.has-release::after { content: ''; position: absolute; bottom: calc(var(--sp-2) * -1); left: 50%; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--info); }
.bars-axis { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-3); margin-top: var(--sp-3); }
.dist-h { display: flex; flex-direction: column; gap: var(--sp-1); margin-top: var(--sp-3); }
.retention { display: flex; align-items: center; gap: var(--sp-2); min-width: 120px; }
.retention .bar { flex: 1; }
.retention .bar > span { background: var(--accent); }

/* ---------- Editor ---------- */
body.is-editor { --rs: 18px; --rl: 1.75; --rf: var(--serif); }
.is-editor .topbar { display: none; }
.editor-bar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: var(--sp-3); height: 56px; padding: 0 var(--sp-4); background: var(--surface); border-bottom: 1px solid var(--border); }
.editor-bar-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.editor-bar-title > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.editor-status { font-weight: 650; }
.editor-count { margin-left: auto; white-space: nowrap; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 304px; gap: var(--sp-6); max-width: var(--wrap); margin: 0 auto; padding: var(--sp-4) var(--gutter) var(--sp-12); align-items: start; }
.editor-main { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.editor-title { font-family: var(--serif); font-size: var(--fs-3xl) !important; font-weight: 650; border: 0 !important; background: transparent !important; padding: var(--sp-2) 0 !important; box-shadow: none !important; border-radius: 0 !important; border-bottom: 1px solid var(--border) !important; }
.editor-note summary { cursor: pointer; color: var(--text-3); font-size: var(--fs-sm); font-weight: 600; display: flex; gap: var(--sp-2); align-items: center; padding: var(--sp-1) 0; list-style: none; }
.editor-note summary::-webkit-details-marker { display: none; }
.editor-note textarea { margin-top: var(--sp-2); }
.toolbar-wrap { position: sticky; top: 56px; z-index: 30; background: var(--bg); padding: var(--sp-2) 0; }
.etoolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: var(--sp-1); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.etoolbar > button, .etoolbar .table-tools > button, .tmenu > summary { min-width: 32px; height: 32px; padding: 0 var(--sp-2); border: 0; border-radius: var(--radius-xs); background: none; color: var(--text-2); font-size: var(--fs-md); display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); white-space: nowrap; }
.etoolbar > button:hover, .etoolbar .table-tools > button:hover, .tmenu > summary:hover { background: var(--surface-2); color: var(--text); }
.etoolbar > button.is-active { background: var(--surface-3); color: var(--text); }
.etoolbar select { width: auto; }
/* Toolbar tips open below the buttons: the toolbar sticks to the top of the screen. */
.etoolbar [data-tip] { position: relative; }
.etoolbar [data-tip]:hover::after, .etoolbar [data-tip]:focus-visible::after { top: calc(100% + var(--sp-2)); bottom: auto; }
.form-error { margin: 0; color: var(--accent-text); font-weight: 600; }
.tbtn-wide { font-size: var(--fs-xs) !important; font-weight: 600; }
.tsep { width: 1px; height: 20px; background: var(--border); margin: 0 var(--sp-1); }
.table-tools { display: inline-flex; align-items: center; gap: 2px; }
.table-tools button { font-size: var(--fs-xs) !important; font-family: var(--mono); }
.sys-swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--sys-bg); border: 1px solid var(--sys-border); border-left: 3px solid var(--sys-border); display: inline-block; }
.sys-swatch.sys-gold { background: var(--sysg-bg); border-color: var(--sysg-border); }
.sys-swatch.sys-green { background: var(--sysn-bg); border-color: var(--sysn-border); }
.sys-swatch.sys-red { background: var(--sysr-bg); border-color: var(--sysr-border); }
.sys-swatch.sys-purple { background: var(--sysp-bg); border-color: var(--sysp-border); }
.sys-swatch.sys-gray { background: var(--sysx-bg); border-color: var(--sysx-border); }
.editor-surface { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-height: 60vh; }
.editor-content { min-height: 60vh; padding: var(--sp-8) clamp(16px, 5vw, 48px); outline: none; }
.editor-content:empty::before { content: 'Start writing, or paste from Google Docs…'; color: var(--text-3); }
.editor-content .sys { position: relative; }
.editor-content table { min-width: 260px; }
.editor-content td, .editor-content th { min-width: 60px; }
.editor-source { display: none; width: 100%; min-height: 60vh; border: 0 !important; box-shadow: none !important; font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.6; padding: var(--sp-6) !important; background: transparent !important; border-radius: var(--radius) !important; }
.editor-page.is-source .editor-content { display: none; }
.editor-page.is-source .editor-source { display: block; }
.editor-hint { margin: 0; }
.editor-side { position: sticky; top: calc(56px + var(--sp-4)); display: flex; flex-direction: column; gap: var(--sp-4); }
.mini-demo { --rs: 14px; }
.mini-demo .sys { margin: 0 0 var(--sp-2); }

/* ---------- Auth / misc pages ---------- */
.auth-page { display: grid; place-items: center; padding: var(--sp-12) 0; min-height: 60vh; }
.auth-card { width: min(420px, 100%); padding: var(--sp-8); text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--sp-4); }
.auth-card.stack { align-items: stretch; text-align: left; }
.auth-card.stack > h1 { align-self: center; text-align: center; }
.auth-card.stack > h1 + .muted { text-align: center; }
.auth-card h1 { font-size: var(--fs-2xl); }
.btn-google { --h: 44px; width: 100%; background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); font-weight: 600; gap: var(--sp-3); }
.btn-google:hover { background: var(--surface-2); color: var(--text); }
.google-signin { width: 100%; display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.google-button { width: 100%; min-height: 44px; display: flex; justify-content: center; }
/* Google's button frame paints an opaque white page behind itself when the page uses a dark colour scheme. */
.google-button iframe { color-scheme: light; }
.devnote-inline { font-size: var(--fs-xs); color: var(--warn); background: var(--warn-soft); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); display: flex; gap: var(--sp-2); text-align: left; }
.gate-icon { align-self: center; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: var(--fs-2xl); background: var(--accent-soft); color: var(--accent-text); }
.error-page { text-align: center; padding: var(--sp-12) 0; max-width: 520px; margin: 0 auto; }
.error-code { font-size: 64px; font-weight: 800; color: var(--surface-3); line-height: 1; margin-bottom: var(--sp-2); letter-spacing: -0.03em; }
.error-page h1 { margin-bottom: var(--sp-2); }
.error-page .row-gap { margin-top: var(--sp-6); }
.error-detail { text-align: left; font-size: var(--fs-xs); background: var(--surface-2); padding: var(--sp-3); border-radius: var(--radius-sm); white-space: pre-wrap; }
.doc { max-width: 760px; margin: 0 auto; }
.doc h1 { font-family: var(--serif); font-size: var(--fs-3xl); margin-bottom: var(--sp-3); }
.doc h2 { margin: var(--sp-8) 0 var(--sp-2); font-size: var(--fs-xl); }
.doc .lead { font-size: var(--fs-lg); color: var(--text-2); }
.doc ul { padding-left: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-2); }
.doc .demo { --rs: 16px; padding: var(--sp-4) var(--sp-6); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin: var(--sp-3) 0; }
.inline-demo { --rs: 16px; }
.report-item { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); }
.report-item + .report-item { border-top: 1px solid var(--border); }
.report-target { margin: 0; padding: var(--sp-2) var(--sp-3); border-left: 3px solid var(--border-strong); background: var(--surface-2); border-radius: 0 var(--radius-xs) var(--radius-xs) 0; font-size: var(--fs-sm); }
.report-target a { color: var(--accent-text); font-weight: 600; }
.report-item form { display: inline; }
.avatar-edit { display: flex; align-items: center; gap: var(--sp-4); }

/* Simulated Google chooser */
body.is-bare { background: #f0f4f9; color: #1f1f1f; }
:root.is-dark body.is-bare { background: #131314; color: #e3e3e3; }
.gsim { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--sp-6) var(--sp-3); font-family: Arial, 'Helvetica Neue', sans-serif; }
.gsim-card { width: min(448px, 100%); background: #fff; color: #1f1f1f; border-radius: 28px; padding: var(--sp-8) var(--sp-8) var(--sp-6); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
:root.is-dark .gsim-card { background: #1e1f20; color: #e3e3e3; }
.gsim-banner { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); background: #fef7e0; color: #7a5600; padding: var(--sp-2) var(--sp-3); border-radius: var(--radius); margin: calc(var(--sp-3) * -1) calc(var(--sp-3) * -1) var(--sp-6); font-family: var(--ui); }
.gsim-logo { margin-bottom: var(--sp-4); }
.gsim h1 { font-size: 26px; font-weight: 400; font-family: Arial, sans-serif; letter-spacing: 0; }
.gsim-sub { margin: var(--sp-2) 0 var(--sp-6); font-size: 15px; }
.gsim-accounts { list-style: none; margin: 0 calc(var(--sp-3) * -1); padding: 0; border-top: 1px solid #e0e0e0; }
.gsim-accounts li { border-bottom: 1px solid #e0e0e0; }
.gsim-accounts button { width: 100%; display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-3); border: 0; background: none; text-align: left; color: inherit; }
.gsim-accounts button:hover { background: rgba(11, 87, 208, .06); }
.gsim-accounts button > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.gsim-accounts b { font-weight: 500; font-size: var(--fs-md); }
.gsim-accounts small { color: #5f6368; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gsim-other { margin-top: var(--sp-2); }
.gsim-other summary { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-3) 0; cursor: pointer; font-weight: 500; list-style: none; }
.gsim-other summary::-webkit-details-marker { display: none; }
.gsim-other form { padding: var(--sp-1) 0 var(--sp-2); }
.gsim-other input { border-radius: 4px; border-color: #747775; background: transparent; }
.btn-gblue { --h: 40px; background: #0b57d0; color: #fff; border-radius: 20px; align-self: flex-end; padding: 0 var(--sp-6); }
.btn-gblue:hover { background: #0a4fbd; color: #fff; }
.gsim-foot { font-size: var(--fs-xs); color: #5f6368; margin-top: var(--sp-4); }
.gsim-back { margin-top: var(--sp-4); font-size: var(--fs-sm); color: #5f6368; font-family: var(--ui); }

/* ---------- Footer & mobile tab bar ---------- */
.footer { border-top: 1px solid var(--border); background: var(--surface); }
.footer-inner { padding-top: var(--sp-4); padding-bottom: var(--sp-4); }
.footer-links { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); font-size: var(--fs-sm); color: var(--text-2); }
.footer .devnote { padding-top: 0; padding-bottom: var(--sp-4); font-size: var(--fs-xs); color: var(--warn); }
.tabbar { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .write-grid { grid-template-columns: minmax(0, 1fr) 304px; }
  .fic-layout { grid-template-columns: minmax(0, 1fr) 264px; }
}
@media (max-width: 960px) {
  .mainnav { display: none; }
  .write-grid, .fic-layout, .fform, .editor-layout, .search-layout { grid-template-columns: minmax(0, 1fr); }
  .fic-side, .fform-side, .editor-side, .filters { position: static; }
  .filters { max-height: none; }
  .browse-layout { grid-template-columns: minmax(0, 1fr); }
  .list-nav { display: none; }
  .list-menu { display: block; }
  .review-summary { grid-template-columns: auto 1fr; }
  .rs-subs { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .panels, .panel-wide .flines { grid-template-columns: minmax(0, 1fr); }
  .panel-wide .fline:nth-child(n + 2) { border-top: 1px solid var(--border); }
}
@media (max-width: 720px) {
  :root { --topbar-h: 52px; --tabbar-h: 56px; --gutter: var(--sp-4); }
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  body.is-reader, body.is-editor, body.is-bare { padding-bottom: 0; }
  .wrap { padding-top: var(--sp-4); padding-bottom: var(--sp-8); }
  .topbar-inner { padding: 0 var(--sp-2) 0 var(--sp-4); gap: var(--sp-2); }
  .topsearch { display: none; }
  .only-mobile { display: inline-grid; }
  .topbar-actions { margin-left: auto; }
  .tabbar {
    display: flex; position: fixed; z-index: 45; bottom: 0; left: 0; right: 0;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 550; color: var(--text-3); }
  .tabbar a.is-active { color: var(--accent); }
  .footer { display: none; }
  .toasts { top: auto; bottom: calc(var(--tabbar-h) + var(--sp-3) + env(safe-area-inset-bottom)); }
  .is-reader .toasts, .is-editor .toasts { bottom: var(--sp-4); }
  h1 { font-size: 20px; }
  .page-head { margin-bottom: var(--sp-4); align-items: flex-start; }
  .page-head > div:first-child { flex: 1; min-width: 0; }
  .frow { --cover: 64px; gap: var(--sp-3); padding: var(--sp-3); }
  .frow:has(.frow-rank) { grid-template-columns: 20px var(--cover) minmax(0, 1fr); }
  .frow-rank { font-size: var(--fs-md); }
  .frow-title { font-size: var(--fs-lg); }
  .frow-stats { gap: var(--sp-1) var(--sp-3); }
  .frow-stats .stars { display: none; }
  .stat-rating .stat-star { display: block; }
  .stat-rating { gap: var(--sp-1) !important; }
  .frow-stats .frow-chapters { display: none; }
  .frow-tags { max-height: 24px; }
  .fline { padding: var(--sp-2) var(--sp-3); gap: var(--sp-3); }
  .fline-detail { --cover: 56px; gap: var(--sp-3); padding: var(--sp-3); }
  .fline-stats .fline-words { display: none; }
  .panel-head { padding: 0 var(--sp-3); }
  .split-2, .grid-2, .filter-grid { grid-template-columns: minmax(0, 1fr); }
  .fic-hero { grid-template-columns: 112px minmax(0, 1fr); gap: var(--sp-4); }
  .fic-title { font-size: var(--fs-2xl); }
  .fic-stats { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3) 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-3) 0; }
  .fic-stat, .fic-stat:first-child { padding: 0 var(--sp-3); border-left: 0; }
  .fic-stat:nth-child(3n + 2), .fic-stat:nth-child(3n + 3) { border-left: 1px solid var(--border); }
  .fic-stat dd b { font-size: var(--fs-lg); }
  .fic-stat-rating .stars { display: none; }
  .fic-info { display: contents; }
  .fic-hero > .fic-cover { grid-row: span 5; }
  .fic-badges, .fic-title, .fic-author, .fic-tags { grid-column: 2; }
  .fic-stats, .fic-actions { grid-column: 1 / -1; }
  .fic-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }
  .fic-actions > .btn-primary { grid-column: 1 / -1; --h: 44px; }
  .fic-actions .btn-secondary { padding: 0 var(--sp-2); font-size: var(--fs-sm); }
  .fic-tabs { margin: 0 calc(var(--gutter) * -1) var(--sp-3); padding: 0 var(--sp-2); }
  .chapter-list li a { grid-template-columns: 28px minmax(0, 1fr) auto; padding: var(--sp-2) var(--sp-3); }
  .card-head input[type="search"].input-sm { width: 100%; }
  .ch-date { display: none; }
  .review-summary { grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); }
  .rs-score { flex-direction: row; justify-content: center; gap: var(--sp-3); }
  .rs-big { font-size: 32px; }
  .rf-subs { grid-template-columns: minmax(0, 1fr); }
  .review { padding: var(--sp-3); }
  .reader { padding: var(--sp-6) var(--sp-4) var(--sp-2); }
  .reader-head { margin-bottom: var(--sp-6); }
  .chapter-nav .btn span { display: none; }
  .chapter-nav .btn { padding: 0 var(--sp-4); }
  .chapter-nav > .btn-primary span, .chapter-nav > .btn-secondary:first-child span { display: inline; }
  .comments { padding: var(--sp-4); }
  .replies { margin-left: var(--sp-4); padding-left: var(--sp-3); }
  .thread .pager { margin-left: var(--sp-4); }
  .comment-form > .avatar { display: none; }
  .hide-sm { display: none !important; }
  .profile-head { grid-template-columns: auto 1fr; gap: var(--sp-4); }
  .profile-actions { grid-column: 1 / -1; }
  .profile-avatar { --s: 64px !important; }
  .profile-invite { grid-template-columns: minmax(0, 1fr); }
  .pm { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - var(--sp-8)); }
  body.is-messages { padding-bottom: 0; }
  .is-messages .tabbar { display: none; }
  .is-messages .pm { height: calc(100dvh - var(--topbar-h) - var(--sp-8)); }
  .pm.has-thread .pm-inbox { display: none; }
  .pm:not(.has-thread) .pm-thread { display: none; }
  .pm-back { display: inline-grid; }
  .pm-msg { max-width: 86%; }
  .link-row { grid-template-columns: 40px minmax(0, 1fr) 40px; }
  .link-row > input[name$="[url]"] { grid-column: 2; }
  .link-row > [data-remove-link] { grid-column: 3; grid-row: 1; }
  .editor-bar { padding: 0 var(--sp-2); gap: var(--sp-2); }
  .editor-bar-title > span:first-child { display: none; }
  .editor-count { display: none; }
  .editor-layout { padding: var(--sp-3) var(--sp-3) var(--sp-12); }
  .editor-content { padding: var(--sp-4); }
  .toolbar-wrap { margin: 0 calc(var(--sp-3) * -1); padding: var(--sp-1) var(--sp-2); }
  .etoolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .wfic { grid-template-columns: 52px minmax(0, 1fr); gap: var(--sp-3); padding: var(--sp-3); }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpis dd { font-size: var(--fs-xl); }
  .gsim-card { padding: var(--sp-8) var(--sp-6) var(--sp-6); border-radius: 20px; }
  .dialog { padding: var(--sp-4); }
  .dialog-side { width: 100vw; }
  .toc-list { margin: 0 calc(var(--sp-4) * -1); }
  .toc-list a { padding: var(--sp-2) var(--sp-4); }
  .search-bar .btn { display: none; }
  .auth-card { padding: var(--sp-6); }
}
@media (max-width: 380px) {
  .fic-hero { grid-template-columns: 96px minmax(0, 1fr); }
}
@media (hover: none) {
  [data-tip]:hover::after { display: none; }
}
@media print {
  .topbar, .readbar, .tabbar, .footer, .comments, .chapter-nav { display: none !important; }
}
