/* Textonomics. Search-first home (design 05) and grouped metrics (design 26). */
:root {
  --bg: #ffffff; --bg2: #f6f7f9; --ink: #14181f; --muted: #5b6472; --sub: #33404f;
  --line: #e1e4ea; --line2: #eef0f3; --card: #ffffff; --chip: #eef0f3;
  --accent: #2563eb; --bad: #b42318; --ok: #157347;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218; --bg2: #12161d; --ink: #eef0f4; --muted: #9aa3b2; --sub: #c3cad6;
    --line: #2a313c; --line2: #1f2530; --card: #171b23; --chip: #232a35;
    --accent: #7aa2ff; --bad: #ff8a80; --ok: #6fd39b;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; }
body.view-book { background: var(--bg2); }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; font: 600 12px/1.6 var(--font); text-align: center; color: var(--muted); background: var(--chip); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--ink); }

/* ---------- Brand ---------- */
.site { max-width: 1280px; margin: 0 auto; padding: 20px 36px 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; text-decoration: none; }
.brand .logo { width: 26px; height: 26px; display: grid; place-items: center; font-size: 15px; font-weight: 700; color: var(--bg); background: var(--ink); border-radius: 7px; }

/* ---------- Home / search (design 05) ---------- */
.home { max-width: 816px; margin: 0 auto; padding: 32px 24px 40px; display: flex; flex-direction: column; align-items: center; gap: 28px; }
.home h1 { font-size: 44px; line-height: 1.1; font-weight: 600; letter-spacing: -.02em; text-align: center; max-width: 720px; }
.search { display: flex; gap: 10px; width: 100%; max-width: 720px; }
.search input { flex: 1; min-width: 0; padding: 14px 18px; font-size: 17px; background: var(--bg); border: 2px solid var(--ink); border-radius: 14px; }
.search input::placeholder { color: var(--muted); }
.search .go { padding: 0 26px; font-weight: 600; font-size: 16px; color: var(--bg); background: var(--ink); border: 0; border-radius: 14px; }
.search .go:hover { opacity: .9; }
.hint { font-size: 13px; color: var(--muted); text-align: center; max-width: 720px; }
.hint .sep { margin: 0 .5em; opacity: .5; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip { padding: 6px 14px; font-size: 14px; background: var(--chip); border: 1px solid var(--line); border-radius: 99px; text-decoration: none; }
.chip:hover { border-color: var(--muted); }
.list { width: 100%; max-width: 720px; display: flex; flex-direction: column; gap: 12px; }
.label { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.label .link { letter-spacing: 0; text-transform: none; font-size: 13px; }
.card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.card:hover { border-color: var(--muted); }
.card:focus-within { border-color: var(--ink); }
.card-link { display: flex; gap: 16px; align-items: flex-start; padding: 18px; text-decoration: none; border-radius: 14px; }
.card-link:focus-visible { outline-offset: -3px; }
.num { flex: none; width: 28px; height: 28px; margin-top: 1px; display: grid; place-items: center; font-size: 13px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; }
.card:hover .num { color: var(--ink); border-color: var(--ink); }
.card-body { min-width: 0; flex: 1; }
.card-title { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.card-sub { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.card-stats { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 10px; font-size: 13px; color: var(--sub); }
.card-stats b { font-weight: 600; color: var(--ink); }
.card .x { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; display: grid; place-items: center; background: none; border: 0; border-radius: 8px; color: var(--muted); opacity: 0; font-size: 18px; line-height: 1; }
.card:hover .x, .card .x:focus-visible { opacity: 1; }
.card .x:hover { background: var(--chip); color: var(--ink); }
.note { padding: 18px; font-size: 14px; color: var(--sub); background: var(--card); border: 1px dashed var(--line); border-radius: 14px; }
.note.err { border-style: solid; border-color: var(--bad); }
.note b { color: var(--ink); }
.note .row { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; }
.pager { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }
.pager button { background: none; border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; color: var(--ink); }
.pager button[disabled] { opacity: .4; cursor: default; }
.skel { height: 84px; border-radius: 14px; background: linear-gradient(90deg, var(--chip), var(--line2), var(--chip)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.strip { width: 100%; max-width: 720px; margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 12px 40px; }
.strip div { font-size: 13px; color: var(--muted); }
.strip b { display: block; font-size: 20px; font-weight: 600; color: var(--ink); }

/* progress */
.prog { width: 100%; max-width: 720px; padding: 22px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; gap: 12px; }
.prog h2 { font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.bar { height: 8px; background: var(--chip); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--ink); border-radius: 99px; transition: width .2s; }
.prog .meta { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.prog button { align-self: flex-start; padding: 6px 14px; background: none; border: 1px solid var(--line); border-radius: 10px; }

/* ---------- Analytics (design 26) ---------- */
.book { max-width: 1280px; margin: 0 auto; padding: 28px 36px 40px; display: flex; flex-direction: column; gap: 16px; }
.bar-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; }
.bar-top .tools { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; font-size: 13px; color: var(--ink); text-decoration: none; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.btn:hover { border-color: var(--muted); }
.book-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.book-head h1 { font-size: 26px; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.book-head h1 span { font-size: 15px; font-weight: 400; color: var(--muted); }
.book-head .act { font-size: 13px; color: var(--muted); }
.byline { margin-top: -8px; font-size: 14px; color: var(--sub); }
.byline a { color: var(--muted); }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.gcard { position: relative; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.gcard:hover { border-color: var(--muted); }
.gcard:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.gcard .open { position: absolute; inset: 0; width: 100%; border: 0; background: none; border-radius: 12px; opacity: 0; }
.gcard .open:focus-visible { outline: none; }
.gh { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.gh > span:first-child { display: flex; align-items: center; gap: 8px; }
.gh .n { width: 20px; height: 20px; display: inline-grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; }
.gcard:hover .gh .n { color: var(--ink); border-color: var(--ink); }
.gh .c { color: var(--muted); font-weight: 400; }
.rows { font-size: 13px; color: var(--sub); }
.rows div { display: flex; justify-content: space-between; gap: 12px; line-height: 2.1; }
.rows span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows b { flex: none; max-width: 60%; text-align: right; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows b.na { color: var(--muted); font-weight: 400; }
.foot { font-size: 12px; color: var(--muted); max-width: 820px; }

/* ---------- Dialogs ---------- */
dialog { padding: 0; width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 32px); color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(15, 18, 24, .45); }
.dh { position: sticky; top: 0; z-index: 1; display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; background: var(--card); border-bottom: 1px solid var(--line); }
.dh h2 { font-size: 20px; font-weight: 600; }
.dh p { margin-top: 2px; font-size: 13px; color: var(--muted); }
.dh .grow { flex: 1; min-width: 0; }
.ib { width: 34px; height: 34px; flex: none; display: grid; place-items: center; background: none; border: 1px solid var(--line); border-radius: 10px; font-size: 16px; line-height: 1; }
.ib:hover { border-color: var(--muted); }
.db { overflow: auto; max-height: calc(100vh - 150px); padding: 4px 20px 20px; }
.m { padding: 14px 0; border-bottom: 1px solid var(--line2); }
.m:last-child { border-bottom: 0; }
.mt { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.mt .nm { font-size: 14px; font-weight: 500; }
.mt .vl { font-size: 15px; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.mt .vl.na { color: var(--muted); font-weight: 400; }
.est { margin-left: 6px; padding: 1px 6px; font-size: 10px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; vertical-align: 1px; }
.mn { margin-top: 4px; font-size: 13px; color: var(--muted); }
.m details { margin-top: 6px; }
.m summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.m summary:hover { color: var(--ink); }
.m table { width: 100%; margin-top: 6px; font-size: 13px; border-collapse: collapse; }
.m td { padding: 4px 0; border-top: 1px solid var(--line2); vertical-align: top; }
.m td:last-child { text-align: right; color: var(--sub); padding-left: 16px; overflow-wrap: anywhere; }
.up { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.up label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.up input[type=text], .up textarea { padding: 10px 12px; font-size: 14px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.up textarea { min-height: 140px; resize: vertical; }
.up .actions { display: flex; gap: 10px; align-items: center; }
.up .primary { padding: 10px 20px; font-weight: 600; color: var(--bg); background: var(--ink); border: 0; border-radius: 10px; }
.up .msg { font-size: 13px; color: var(--bad); }
.keys { width: 100%; margin: 4px 0 0; border-collapse: collapse; font-size: 14px; }
.keys td { padding: 8px 0; border-top: 1px solid var(--line2); }
.keys td:first-child { width: 150px; }

@media (max-width: 640px) {
  .home { padding: 36px 16px 28px; gap: 22px; }
  .home h1 { font-size: 32px; }
  .search { flex-direction: column; }
  .search .go { padding: 13px; }
  .book { padding: 20px 16px 32px; }
  .site { padding: 16px 16px 0; }
  .card .x { opacity: 1; }
  .mt { flex-direction: column; gap: 2px; }
  .mt .vl { text-align: left; }
}
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } .bar i { transition: none; } }
