:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --text: #1b1f2a;
  --muted: #667085;
  --border: #e3e6ee;
  --accent: #3b6ef5;
  --accent-text: #ffffff;
  --accent-soft: #e8eefe;
  --ok: #18794e;
  --ok-soft: #e3f5ec;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --bad: #c4321c;
  --bad-soft: #fde8e4;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #171a22;
    --surface-2: #1e222c;
    --text: #e7e9ee;
    --muted: #98a0b0;
    --border: #2a2f3b;
    --accent: #6b93ff;
    --accent-text: #0b1020;
    --accent-soft: #1d2740;
    --ok: #4cc38a;
    --ok-soft: #13291f;
    --warn: #e5b33d;
    --warn-soft: #2d2410;
    --bad: #ff7b66;
    --bad-soft: #321713;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Hebrew", Arial, sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
h2, h3 { margin: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand svg { width: 26px; height: 26px; }
.brand svg rect { fill: var(--accent); }
.brand svg path { stroke: var(--accent-text); stroke-width: 2; stroke-linecap: round; fill: none; }
.brand .arrow { color: var(--accent); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }

main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 96px; }
main:has(> #admin:not(.hidden)) { max-width: 1400px; } /* the dashboard tables are wide */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.section-title { font-size: 15px; color: var(--muted); font-weight: 600; margin: 28px 0 12px; text-transform: uppercase; letter-spacing: .04em; }

/* Upload */
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 36px 16px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop svg { width: 34px; height: 34px; stroke: var(--accent); stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.drop.has-file strong { color: var(--accent); }
.options { margin-top: 16px; }
.options summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin-top: 12px; }
.span2 { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.checks { display: flex; flex-direction: column; gap: 8px; justify-content: center; }
input, select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); padding: 0; }
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 16px; margin-top: 16px; }

button {
  font: inherit; border-radius: 8px; padding: 8px 16px; cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}
button:hover:not(:disabled) { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
button.ghost { border-color: transparent; background: transparent; }
button.danger { color: var(--bad); }
a.button { text-decoration: none; display: inline-block; }

.progress { flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.progress.indeterminate > div { width: 30%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { margin-left: -30%; } to { margin-left: 100%; } }

/* Jobs */
.jobs { display: flex; flex-direction: column; gap: 12px; }
.job { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; }
.job .name { font-weight: 600; overflow-wrap: anywhere; }
.job .sub { font-size: 13px; }
.job .buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.job .bar { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; font-size: 13px; }
.job .log { grid-column: 1 / -1; font: 12px/1.45 ui-monospace, Consolas, monospace; color: var(--muted);
  background: var(--surface-2); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; max-height: 9em; overflow: auto; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; margin-inline-start: 8px; vertical-align: 1px; }
.badge.queued, .badge.preparing, .badge.building { background: var(--accent-soft); color: var(--accent); }
.badge.review { background: var(--warn-soft); color: var(--warn); }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.failed { background: var(--bad-soft); color: var(--bad); }
.error { color: var(--bad); grid-column: 1 / -1; font-size: 14px; }
.empty { text-align: center; padding: 24px; }

/* Review */
.review-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.review-head h2 { font-size: 20px; overflow-wrap: anywhere; }
.meta { display: flex; gap: 20px; align-items: flex-start; }
.meta .grid { flex: 1; margin-top: 0; }
.cover { width: 120px; border-radius: 6px; border: 1px solid var(--border); flex-shrink: 0; }
.warnings { margin: 0; padding-inline-start: 18px; color: var(--warn); font-size: 13px; }
.table-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.table-head p { margin: 0; font-size: 13px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: start; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
td.c { text-align: center; }
td.num { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
td .title { width: 100%; min-width: 220px; }
td .snippet { font-size: 12px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
tr.front td .title::placeholder { font-style: italic; }
tr.sub td:nth-child(2) { padding-inline-start: 32px; }
tr.merged, tr.dropped { opacity: .45; }
tr.dropped .title { text-decoration: line-through; }
.sticky-actions {
  position: fixed; inset-inline: 0; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: 16px;
  padding: 12px 24px; background: var(--surface); border-top: 1px solid var(--border); z-index: 4;
}

/* Chapter editing */
.changes-box { grid-column: 1 / -1; font-size: 13px; }
.changes-box summary { cursor: pointer; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
tr.selected td { background: var(--accent-soft); }
tr.follower td .title { display: none; }
tr.follower .merged-into { font-size: 13px; color: var(--muted); }
.group-badge, .split-badge { display: inline-block; font-size: 12px; margin-top: 4px; margin-inline-end: 8px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; font-size: 12px; cursor: pointer; }
.preview-body .block { position: relative; }
.preview-body .block:hover { background: var(--surface-2); }
.preview-body .cut { position: absolute; inset-inline-end: -24px; top: 0; font: 12px system-ui, sans-serif; opacity: 0; border: 0; background: none; cursor: pointer; padding: 2px; }
.preview-body .block:hover .cut { opacity: .8; }
.split-line { display: flex; gap: 8px; align-items: center; margin: 1em 0; padding: 8px 10px; border: 1px dashed var(--accent); border-radius: 8px; font: 13px system-ui, sans-serif; text-indent: 0; }
.split-line input { flex: 1; }

/* EPUB review */
.search { width: 100%; margin-bottom: 12px; }
.cover-box { display: flex; flex-direction: column; align-items: center; gap: 8px; flex-shrink: 0; width: 140px; }
.nocover { width: 120px; height: 170px; border: 1px dashed var(--border); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.file-button { display: inline-block; cursor: pointer; font-size: 13px; color: var(--accent); flex-direction: row; text-align: center; }
button.small { font-size: 12px; padding: 4px 8px; }
.option-list { display: flex; flex-direction: column; }
.option { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.option:last-child { border-bottom: 0; }
.option input { margin-top: 3px; }
.option .label { font-weight: 600; color: var(--text); font-size: 14px; }
.option .help { grid-column: 2; font-size: 13px; color: var(--muted); }
.state { font-size: 12px; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.state.present { background: var(--ok-soft); color: var(--ok); }
.state.missing { background: var(--warn-soft); color: var(--warn); }
.state.optional { background: var(--surface-2); color: var(--muted); }
.changes { grid-column: 1 / -1; margin: 0; padding-inline-start: 18px; font-size: 13px; color: var(--muted); }

/* Preview dialog */
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  width: min(760px, calc(100vw - 32px)); max-height: 85vh; padding: 0; }
dialog::backdrop { background: rgba(0, 0, 0, .4); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.preview-body { padding: 8px 28px 28px; font-family: Georgia, "Times New Roman", "Noto Serif Hebrew", serif; font-size: 16px; line-height: 1.6; }
.preview-body p { margin: 0; text-indent: 1.4em; text-align: justify; }
.preview-body h1, .preview-body h2, .preview-body h3 { text-align: center; font-family: inherit; margin: 1.2em 0 .6em; }
.preview-body .note { font-size: 13px; border-top: 1px solid var(--border); margin-top: 1.5em; padding-top: .5em; text-indent: 0; }
.preview-body figure { margin: 1em 0; text-align: center; }
.preview-body img { max-width: 100%; max-height: 50vh; }
.preview-body .page { display: block; text-align: center; font: 11px system-ui, sans-serif; color: var(--muted); margin: .6em 0; text-indent: 0; }

@media (max-width: 700px) {
  .topbar { padding: 12px 16px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .meta { flex-direction: column; }
  .cover-box { width: auto; }
  .job { grid-template-columns: 1fr; }
  .job .buttons { justify-content: flex-start; }
  .sticky-actions { padding: 12px 16px; }
}

/* Account, sign-in */
.small { font-size: 12px; }
.account { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; }
.account .avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.account .who { display: flex; flex-direction: column; line-height: 1.2; font-size: 13px; max-width: 220px; }
.account .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter { width: 120px; height: 6px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; margin-top: 3px; }
.meter > div { height: 100%; background: var(--accent); border-radius: 999px; }
.meter.low > div { background: var(--warn); }
.topbar .chips { margin-inline-start: auto; }
.topbar .account:not(:empty) { margin-inline-start: 16px; }
.signin-card { max-width: 520px; margin: 48px auto; text-align: center; padding: 36px 28px; }
.signin-card h1 { font-size: 24px; margin: 0 0 10px; }
.google-button {
  display: inline-flex; align-items: center; gap: 12px; margin: 24px 0 16px; padding: 10px 18px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font-weight: 600;
}
.google-button:hover { background: var(--surface-2); }
.google-button svg { width: 20px; height: 20px; }
.footer { text-align: center; padding: 16px 16px 96px; }
.footer a { color: var(--muted); }

/* Dashboard */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); padding: 8px 14px; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { font-size: 13px; color: var(--muted); }
.tile .value { font-size: 26px; font-weight: 600; margin-top: 4px; }
.tile .note { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.hero .value { font-size: 48px; line-height: 1.1; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-bottom: 20px; }

/* Charts: single-series columns. Colours validated against the card surfaces (dataviz validator). */
.viz { --series-1: #2a78d6; --grid: #e1e0d9; --baseline: #c3c2b7; }
@media (prefers-color-scheme: dark) { .viz { --series-1: #3987e5; --grid: #2c2c2a; --baseline: #383835; } }
.viz .chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.viz h3 { font-size: 14px; margin: 0; }
.viz .total { font-size: 13px; color: var(--muted); }
.viz svg { width: 100%; height: 160px; display: block; margin-top: 8px; overflow: visible; }
.viz .gridline { stroke: var(--grid); stroke-width: 1; }
.viz .baseline { stroke: var(--baseline); stroke-width: 1; }
.viz .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz .bar { fill: var(--series-1); }
.viz .hit { fill: transparent; cursor: default; outline: none; }
.viz .hit:hover + .bar-hover, .viz .hit:focus + .bar-hover { opacity: 1; }
.viz .bar-hover { fill: none; stroke: var(--text); stroke-width: 1; opacity: 0; pointer-events: none; }
.viz .toggle { font-size: 12px; }
.viz table.data { margin-top: 8px; }
.tooltip {
  position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; box-shadow: 0 4px 16px rgba(0, 0, 0, .15); font-size: 12px;
}
.tooltip strong { display: block; font-size: 14px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: start; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .bar-col { width: 45%; }
.inline-bar { height: 10px; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 2px; }
.user-cell { display: flex; align-items: center; gap: 8px; min-width: 200px; }
.user-cell img { width: 24px; height: 24px; border-radius: 50%; }
.user-cell .email { font-size: 12px; color: var(--muted); }
.pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.denied, .pill.blocked, .pill.error, .pill.failed { background: var(--bad-soft); color: var(--bad); }
.pill.admin { background: var(--accent-soft); color: var(--accent); }
.row-actions { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.row-actions input { width: 72px; padding: 4px 6px; }
.row-actions button { padding: 4px 10px; font-size: 12px; }
.details { font: 11px/1.4 ui-monospace, Consolas, monospace; color: var(--muted); max-width: 260px; overflow-wrap: anywhere; }
@media (max-width: 700px) {
  .account .who { display: none; }
  .tile.hero .value { font-size: 36px; }
}

/* Privacy policy and terms */
a.brand { color: inherit; text-decoration: none; }
.legal { max-width: 720px; line-height: 1.6; }
.legal h1 { margin-bottom: 4px; }
.legal h2 { font-size: 18px; margin-top: 28px; }
.legal li { margin-bottom: 6px; }

/* Guests */
.guest-box { margin-top: 8px; }
.guest-box .or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 14px 0; }
.guest-box .or::before, .guest-box .or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.turnstile { display: flex; justify-content: center; margin-top: 12px; }
.turnstile:empty { display: none; }
