/* Candalio web app — system fonts, light/dark tokens, responsive to phone width. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --text: #16181d;
  --muted: #5f6672;
  --border: #e1e4ea;
  --accent: #2f5bea;
  --accent-ink: #ffffff;
  --accent-soft: #e8eefe;
  --ok: #18794e;
  --ok-soft: #e3f4ea;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --bad: #c0392b;
  --bad-soft: #fbe7e5;
  --info: #2f5bea;
  --info-soft: #e8eefe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e222a;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --border: #2a2f39;
    --accent: #6d8dff;
    --accent-ink: #0b0d12;
    --accent-soft: #1d2640;
    --ok: #4cc38a;
    --ok-soft: #12291e;
    --warn: #f0b350;
    --warn-soft: #2e2412;
    --bad: #ff7b6e;
    --bad-soft: #321a18;
    --info: #6d8dff;
    --info-soft: #1d2640;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .2rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; margin: 0 0 .25rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.spacer { flex: 1; }
.mono { font-family: var(--mono); font-size: .85rem; }
.warn-text { color: var(--warn); }
.error-text, .danger-text { color: var(--bad) !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ----------------------------------------------------------------------------------------- shell */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); font-size: .75rem; font-weight: 800; }
.brand-lg { font-size: 1.4rem; margin-bottom: .25rem; }
.nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.nav-link { padding: .4rem .75rem; border-radius: 8px; color: var(--muted); white-space: nowrap; font-weight: 500; }
.nav-link:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.view { max-width: 1440px; margin: 0 auto; padding: 1.5rem; outline: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.head-actions, .row-end, .toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row-end { justify-content: flex-end; margin-top: .5rem; }
.toolbar { margin: 1rem 0 .75rem; }
.back { display: inline-block; font-size: .9rem; margin-bottom: .25rem; }
.eyebrow { text-transform: uppercase; font-size: .72rem; letter-spacing: .06em; color: var(--muted); margin: 0; font-weight: 600; }

/* ----------------------------------------------------------------------------------------- controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: .35rem .7rem; font-size: .88rem; }
.btn-xs { padding: .2rem .5rem; font-size: .8rem; border-radius: 6px; }
.btn-block { width: 100%; }
.input { width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
textarea.input { resize: vertical; line-height: 1.45; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.input-inline { width: auto; }
.input-search { max-width: 320px; }
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }
.field > span { font-weight: 500; }
.field .input { color: var(--text); font-size: .95rem; }
.field-wide { grid-column: 1 / -1; }
.check { display: inline-flex; gap: .4rem; align-items: center; cursor: pointer; }
.form-error { color: var(--bad); min-height: 1.2em; font-size: .9rem; }
.pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tone-ok { background: var(--ok-soft); color: var(--ok); }
.tone-warn { background: var(--warn-soft); color: var(--warn); }
.tone-bad { background: var(--bad-soft); color: var(--bad); }
.tone-info { background: var(--info-soft); color: var(--info); }
.chips { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
.chip { display: inline-block; padding: .1rem .5rem; border-radius: 6px; background: var(--surface-2); font-size: .78rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-on { background: var(--ok-soft); color: var(--ok); }
.chip-src { cursor: help; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
details.card > summary, details > summary { cursor: pointer; font-weight: 500; }
details.card[open] > summary { margin-bottom: .75rem; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.callout { padding: .75rem 1rem; border-radius: var(--radius); background: var(--warn-soft); color: var(--text); border: 1px solid var(--border); font-size: .92rem; margin-bottom: .9rem; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty h2 { color: var(--text); }
.empty .btn { margin-top: .75rem; }
.loading { display: flex; align-items: center; gap: .6rem; padding: 2rem; color: var(--muted); }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.plain-list { margin: .25rem 0; padding-left: 1.1rem; }
.quote { padding: .6rem .8rem; border-left: 3px solid var(--border); background: var(--surface-2); border-radius: 6px; }
.quote-new { border-left-color: var(--accent); }
.md h3 { margin-top: .9rem; }
.md h4 { margin: .7rem 0 .3rem; font-size: .95rem; }
.md ul { padding-left: 1.2rem; margin: .3rem 0 .6rem; }
.md code { font-family: var(--mono); font-size: .85em; background: var(--surface-2); padding: 0 .25rem; border-radius: 4px; }

/* ----------------------------------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: .8rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 2rem; box-shadow: var(--shadow); }

/* ----------------------------------------------------------------------------------------- dashboard */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .9rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-weight: 600; }
.stat-hint { color: var(--muted); font-size: .8rem; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .7rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.table td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.cell-title { font-weight: 600; }
.actions { white-space: nowrap; }
.actions .btn { margin-left: .3rem; }

/* ----------------------------------------------------------------------------------------- editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.editor-pane { min-width: 0; }
.editor[data-layout="wide"] { grid-template-columns: minmax(300px, 2.7fr) minmax(0, 7.3fr); }
.editor[data-layout="preview"] { grid-template-columns: 44px minmax(0, 1fr); }
.editor[data-layout="preview"] .editor-pane { display: none; }
.view.view-wide { max-width: none; }
.tabs-row { display: flex; align-items: flex-end; gap: .4rem; }
.tabs-row .tabs { flex: 1; min-width: 0; }
.collapse-editor { flex: none; margin-bottom: .9rem; }
.editor-rail { display: none; }
.editor[data-layout="preview"] .editor-rail { position: sticky; top: 72px; display: flex; flex-direction: column; align-items: center; gap: .6rem; width: 44px; height: calc(100vh - 150px); padding: .7rem 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--muted); font: inherit; cursor: pointer; }
.editor-rail:hover, .editor-rail:focus-visible { color: var(--accent); border-color: var(--accent); }
.rail-arrow { font-size: 1.3rem; line-height: 1; }
.rail-label { writing-mode: vertical-rl; font-weight: 600; letter-spacing: .04em; }
.layout-seg button { font-size: .82rem; }
.tabs { display: flex; gap: .2rem; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: .9rem; }
.tabs button { background: none; border: none; padding: .55rem .8rem; font: inherit; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-body { padding-bottom: 5rem; }
.bullets { display: flex; flex-direction: column; gap: .6rem; margin-top: .8rem; }
.bullet .input { font-size: .95rem; }
.bullet-bar, .fact-bar { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; margin-top: .25rem; }
.source-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.grid-skill { display: grid; grid-template-columns: 180px 1fr auto; gap: .5rem; align-items: start; }
.keywords { margin-bottom: .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .9rem; }
.keywords .chips { margin: .5rem 0; }
.savebar { position: sticky; bottom: 0; display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 -4px 16px rgba(0, 0, 0, .06); z-index: 5; flex-wrap: wrap; }
.preview-pane { position: sticky; top: 72px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.preview-head { display: flex; align-items: center; gap: .5rem; padding: .5rem .7rem; border-bottom: 1px solid var(--border); }
.pdf-frame { display: block; width: 100%; height: calc(100vh - 150px); border: 0; background: #525659; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: none; padding: .3rem .7rem; border-radius: 6px; font: inherit; font-size: .88rem; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.jd { white-space: pre-wrap; font: .88rem/1.5 var(--font); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; max-height: 60vh; overflow: auto; }
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: .3rem; display: flex; flex-direction: column; }
.menu-item { padding: .45rem .7rem; border-radius: 6px; color: var(--text); }
.menu-item:hover { background: var(--surface-2); text-decoration: none; }

/* ----------------------------------------------------------------------------------------- master profile */
.profile-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr) 380px; gap: 1.25rem; align-items: start; }
.entry-list { position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow: auto; display: flex; flex-direction: column; gap: 1rem; padding-right: .25rem; }
.entry-group h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .3rem; }
.entry-link { display: flex; flex-direction: column; padding: .45rem .6rem; border-radius: 8px; color: var(--text); }
.entry-link:hover { background: var(--surface-2); text-decoration: none; }
.entry-link.active { background: var(--accent-soft); }
.entry-link.dim { opacity: .65; }
.entry-link-title { font-weight: 500; line-height: 1.3; }
.conflict-banner { display: flex; align-items: center; gap: .4rem; padding: .6rem .7rem; border-radius: 8px; background: var(--warn-soft); color: var(--text); font-size: .88rem; }
.entry-detail { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.entry-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.fact { padding: .6rem 0; border-top: 1px solid var(--border); }
.fact:first-of-type { border-top: none; }
.fact-text { margin: 0; }
.assistant-pane { position: sticky; top: 72px; }
.assistant { display: flex; flex-direction: column; height: calc(100vh - 100px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.assistant-head { display: flex; align-items: center; gap: .5rem; padding: .7rem .9rem; border-bottom: 1px solid var(--border); }
.assistant-head > div { flex: 1; min-width: 0; }
.assistant-head h3 { margin: 0; }
.assistant-close, .assistant-toggle { display: none; }
.chat-log { flex: 1; overflow: auto; padding: .9rem; display: flex; flex-direction: column; gap: .7rem; }
.chat-empty p { margin-bottom: .5rem; }
.msg { max-width: 92%; padding: .55rem .8rem; border-radius: 12px; font-size: .92rem; }
.msg p:last-child { margin-bottom: 0; }
.msg-user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg-assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.proposal { margin-top: .6rem; padding: .6rem .7rem; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
.proposal-head { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.proposal-applied { border-color: var(--ok); }
.proposal-dismissed { opacity: .6; }
.chat-input { border-top: 1px solid var(--border); padding: .7rem; }
.chat-input .row-end { justify-content: space-between; }
.conflict-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .6rem; }
.conflict .chips { margin-top: .3rem; }

/* ----------------------------------------------------------------------------------------- sources */
.sources-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
.dropzone { display: block; text-align: center; padding: .9rem; border: 1.5px dashed var(--border); border-radius: 8px; cursor: pointer; color: var(--accent); font-weight: 500; margin: .5rem 0; }
.dropzone:hover { background: var(--accent-soft); }
.file-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow: auto; }
.file-list li { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--border); }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.build { box-shadow: none; }
.build-head { display: flex; gap: .5rem; align-items: center; }

/* ----------------------------------------------------------------------------------------- overlays */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(10, 12, 18, .45); padding: 1rem; }
.modal { width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 14px; padding: 1.3rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal-body { margin: .75rem 0 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; }
#toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 60; display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 2rem)); }
.toast { padding: .7rem 1rem; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: 0 8px 24px rgba(0, 0, 0, .2); transition: opacity .5s, transform .5s; font-size: .92rem; }
.toast-ok { background: var(--ok); color: #fff; }
.toast-error { background: var(--bad); color: #fff; }
.toast-hide { opacity: 0; transform: translateY(8px); }

/* ----------------------------------------------------------------------------------------- tracker */
button.stat { font: inherit; color: inherit; text-align: left; cursor: pointer; }
button.stat:hover { border-color: var(--accent); }
.stat-warn { border-color: var(--warn); background: var(--warn-soft); }
.stat-bad { border-color: var(--bad); }
.stat-bad .stat-value { color: var(--bad); }
.funnel { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: 1rem; }
.funnel button { border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 999px; padding: .25rem .75rem; font: inherit; font-size: .85rem; cursor: pointer; }
.funnel button.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.tracker td { font-size: .92rem; }
.stage-select { padding: .3rem .5rem; font-size: .85rem; font-weight: 600; max-width: 9rem; }
.stars { color: var(--warn); font-size: .85rem; letter-spacing: -1px; }
.score-chips { display: inline-flex; flex-wrap: wrap; gap: .25rem; max-width: 15rem; }
.decide { margin-top: .35rem; }
.row-open td { border-bottom-color: transparent; background: var(--surface-2); }
.drawer-row > td { background: var(--surface-2); padding-top: 0; }
.drawer { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.25rem; padding: .75rem 0 .5rem; }
.drawer h3 { margin-bottom: .6rem; }
.drawer-form { display: flex; flex-direction: column; gap: .7rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem .75rem; }
.event-add { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .6rem; }
.event-add .input:not(.input-inline) { flex: 1; min-width: 12rem; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; max-height: 320px; overflow: auto; font-size: .88rem; }
.timeline li { display: flex; gap: .45rem; align-items: baseline; flex-wrap: wrap; }
.timeline-date { color: var(--muted); font-size: .8rem; min-width: 4.5rem; }

/* ----------------------------------------------------------------------------------------- evaluation */
.head-scores { display: inline-flex; border: 0; background: none; padding: 0; margin-top: .3rem; cursor: pointer; }
.head-scores .score-chips { max-width: none; }
.eval-bar { display: flex; gap: 1rem; align-items: center; justify-content: space-between; }
.eval-bar p { margin: 0; }
.report h4 { font-size: .9rem; margin: .4rem 0 .3rem; }
.report-head { display: flex; gap: 1rem; align-items: center; }
.report-summary p { margin: 0 0 .2rem; }
.score-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .6rem; }
.score-tile { border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .8rem; background: var(--surface); min-width: 120px; }
.score-tile.tone-ok { border-color: var(--ok); }
.score-tile.tone-info { border-color: var(--info); }
.score-tile.tone-warn { border-color: var(--warn); }
.score-tile.tone-bad { border-color: var(--bad); }
.score-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.score-value small { font-size: .8rem; font-weight: 500; opacity: .75; margin-left: .1rem; }
.score-label { font-weight: 600; font-size: .9rem; color: var(--text); }
.score-sub { font-size: .78rem; opacity: .85; }
.meters { display: flex; flex-direction: column; gap: .35rem; margin: .4rem 0; }
.meter { display: grid; grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr) 2.5rem 3rem; gap: .6rem; align-items: center; font-size: .85rem; }
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.bar > i { display: block; height: 100%; background: var(--muted); border-radius: 999px; }
.bar > i.tone-ok { background: var(--ok); }
.bar > i.tone-info { background: var(--info); }
.bar > i.tone-warn { background: var(--warn); }
.bar > i.tone-bad { background: var(--bad); }
.meter-value { font-weight: 600; text-align: right; }
.meter-weight { font-size: .78rem; }
.callout-bad { background: var(--bad-soft); }
.grade-head { display: flex; align-items: center; gap: .6rem; }
.grade-head h3 { margin: 0; flex: 1; }
.grade { font-size: 1.3rem; font-weight: 800; padding: .1rem .6rem; border-radius: 8px; }
.criteria { display: flex; flex-direction: column; gap: .5rem; }
.criterion-head { display: flex; justify-content: space-between; gap: .5rem; font-weight: 500; font-size: .9rem; }
.chip-off { background: var(--bad-soft); color: var(--bad); }
.checks { margin: .5rem 0; }
.table-compact td, .table-compact th { padding: .45rem .7rem; font-size: .86rem; }
.modal:has(.report) { max-width: 880px; }

/* ----------------------------------------------------------------------------------------- improve */
.btn-improve { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.btn-improve:hover { background: var(--accent-soft); filter: brightness(1.05); }
.conflict h3 { margin: 0 0 .2rem; }
.conflict-actions .field { min-width: 11rem; }

/* ----------------------------------------------------------------------------------------- responsive */
@media (max-width: 1200px) {
  .profile-layout { grid-template-columns: 230px minmax(0, 1fr); }
  .assistant-pane { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); z-index: 40; padding: .5rem; transform: translateX(105%); transition: transform .2s; }
  .show-assistant .assistant-pane { transform: none; }
  .assistant { height: 100%; }
  .assistant-close, .assistant-toggle { display: inline-flex; }
}
@media (max-width: 900px) {
  .editor, .editor[data-layout] { grid-template-columns: 1fr; }
  .editor[data-layout="preview"] .editor-pane { display: block; }
  .editor[data-layout="preview"] .editor-rail, .layout-seg, .collapse-editor { display: none; }
  .preview-pane { position: static; }
  .pdf-frame { height: 75vh; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .sources-grid { grid-template-columns: 1fr; }
  .profile-layout { grid-template-columns: 1fr; }
  .drawer { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .entry-list { position: static; max-height: 40vh; border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem; background: var(--surface); }
}
@media (max-width: 640px) {
  .view { padding: 1rem; }
  .topbar { padding: .5rem 1rem; gap: .75rem; flex-wrap: wrap; }
  .topbar .nav { order: 3; flex-basis: 100%; }
  h1 { font-size: 1.35rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-skill { grid-template-columns: 1fr auto; }
  .grid-skill > textarea { grid-column: 1 / -1; grid-row: 2; }
  .table thead { display: none; }
  .table tr { display: block; padding: .6rem .8rem; border-bottom: 1px solid var(--border); }
  .table td { display: block; border: 0; padding: .2rem 0; }
  .table td.right { text-align: left; padding-top: .5rem; }
  .actions .btn { margin: 0 .3rem .3rem 0; }
  .source-note { max-width: 100%; flex-basis: 100%; }
  .input-search { max-width: none; }
  .grid-3 { grid-template-columns: 1fr; }
  .meter { grid-template-columns: minmax(0, 1fr) 2.2rem 2.6rem; }
  .meter .bar { grid-column: 1 / -1; grid-row: 2; }
  .report-head, .eval-bar { flex-direction: column; align-items: stretch; }
  .table tr.drawer-row { padding: 0 .8rem; }
}

/* ---- v2: accounts, settings, admin, onboarding ---------------------------------------------------------- */
.center { text-align: center; }
.narrow { max-width: 560px; }
.spacer-y { height: 1rem; }
.page-head.compact { margin-bottom: .25rem; align-items: center; }
.user-menu > summary { cursor: pointer; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .85rem; user-select: none; }
.menu-head { padding: .5rem .7rem .6rem; border-bottom: 1px solid var(--border); margin-bottom: .25rem; }
button.menu-item { background: none; border: 0; text-align: left; font: inherit; cursor: pointer; }
.usage { display: flex; flex-direction: column; gap: .7rem; }
.usage-row { display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr) minmax(7rem, auto); gap: .8rem; align-items: center; }
.usage-value { font-variant-numeric: tabular-nums; text-align: right; font-size: .9rem; }
.usage-row .bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.usage-row .bar > span { display: block; height: 100%; border-radius: 99px; background: var(--ok); }
.usage-row .bar.tone-warn > span { background: var(--warn); }
.usage-row .bar.tone-bad > span { background: var(--bad); }
.danger-zone { border-color: var(--bad); }
.wizard { max-width: 760px; margin: 0 auto; }
.steps { list-style: none; display: flex; gap: .5rem; padding: 0; margin: 0 0 1rem; flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: .4rem; color: var(--muted); font-weight: 500; padding: .3rem .7rem .3rem .3rem; border-radius: 99px; background: var(--surface-2); }
.steps li.active { color: var(--accent); background: var(--accent-soft); }
.steps li.done { color: var(--ok); }
.step-num { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; background: var(--surface); }
.wizard-actions { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; flex-wrap: wrap; }
.build-log { font-family: var(--mono); min-height: 1.5rem; }
@media (max-width: 720px) {
  .usage-row { grid-template-columns: 1fr; gap: .3rem; }
  .usage-value { text-align: left; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
.topbar .user-menu { margin-left: auto; }
.stack-sm { display: flex; flex-direction: column; gap: .5rem; }
.btn-sso { background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600; text-align: center; }
.btn-sso:hover { background: var(--surface-2); text-decoration: none; }
.divider { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .8rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ------------------------------------------------------------------------------------ v3: generation */
.genbar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .5rem; margin-top: 1rem; padding: .6rem .8rem;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.genbar strong { margin-right: .25rem; }
.bulkbar { position: sticky; top: .5rem; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  margin: .75rem 0; padding: .6rem .8rem; border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent-soft); box-shadow: var(--shadow); }
.bulkbar .spacer { flex: 1 1 auto; }
.col-check { width: 2.2rem; text-align: center; }
.col-check input { width: 1.05rem; height: 1.05rem; cursor: pointer; }
tr.row-selected td { background: var(--accent-soft); }
.warn-text { color: var(--warn); }
.ok-text { color: var(--ok); }
.row-wrap { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; }
.tabs-wrap { flex-wrap: wrap; }
.provider-list { display: grid; gap: .6rem; }
.provider .muted { margin-top: .15rem; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem; }
.preset { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; display: flex; flex-direction: column; gap: .4rem; }
.preset p { flex: 1 1 auto; margin: 0; }
.preset-active { border-color: var(--accent); background: var(--accent-soft); }
.usage-group { display: grid; gap: .25rem; }
.usage-group .usage-row { padding-left: .75rem; }
@media (max-width: 720px) {
  .bulkbar { top: 0; }
  .col-check { width: auto; text-align: left; }
}
.callout-ok { background: var(--ok-soft); }
.callout-warn { background: var(--warn-soft); }

/* Settings → Writing preferences, Add from text */
.pref-list { padding-left: 0; list-style: none; display: grid; gap: .35rem; }
.pref-item { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 8px; }
.pref-text { flex: 1 1 18rem; }
.import-list { list-style: none; padding-left: 0; display: grid; gap: .6rem; }
.import-item { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .75rem; }
.import-item .facts { list-style: none; padding-left: 1.4rem; margin: .35rem 0 0; display: grid; gap: .2rem; }
.import-item .why { margin: .15rem 0 0 1.6rem; }
.career-chip { display: inline-flex; gap: .35rem; align-items: center; }

/* v5: sign-in notices, Google button, approval queue */
.callout.info { background: var(--surface-2); }
.callout.success { background: var(--ok-soft); }
.btn-google { display: flex; align-items: center; justify-content: center; gap: .5rem; }
.g-mark { display: inline-flex; width: 1.25rem; height: 1.25rem; border-radius: 50%; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem; color: #fff; background: conic-gradient(#4285f4 0 25%, #34a853 0 50%, #fbbc05 0 75%, #ea4335 0); }
.pending-card { border: 1px solid var(--border); border-left: 4px solid var(--warn); border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: .6rem; background: var(--surface); display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; }
.pending-card .who { flex: 1 1 16rem; }
.pending-card .note { width: 100%; font-size: .9rem; color: var(--muted); white-space: pre-wrap; }
.badge-pending { background: var(--warn-soft); color: var(--text); }
.badge-rejected { background: var(--bad-soft); }

/* v5: charts (Analytics / Insights). Series colours validated for CVD on both surfaces (dataviz palette). */
:root { --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --viz-grid: #eceef2; --viz-base: #c9ced6; }
@media (prefers-color-scheme: dark) {
  :root { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --viz-grid: #232832; --viz-base: #3a404c; }
}
.viz { margin: 0; display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
.viz-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.viz-title { font-weight: 600; }
.viz-svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-base { stroke: var(--viz-base); stroke-width: 1; }
.viz-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-bar.s1, .viz-barlist-fill.s1 { fill: var(--series-1); background: var(--series-1); }
.viz-bar.s2 { fill: var(--series-2); }
.viz-bar.s3 { fill: var(--series-3); }
.viz-col:hover .viz-bar, .viz-col:focus .viz-bar { filter: brightness(1.12); }
.viz-col:focus { outline: none; }
.viz-col:focus-visible .viz-hit { stroke: var(--accent); stroke-width: 1.5; }
.viz-hit { fill: transparent; }
.viz-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-line.s1, .viz-dot.s1 { stroke: var(--series-1); }
.viz-line.s2, .viz-dot.s2 { stroke: var(--series-2); }
.viz-line.s3, .viz-dot.s3 { stroke: var(--series-3); }
.viz-area.s1 { fill: var(--series-1); opacity: .12; }
.viz-dot { fill: var(--surface); stroke-width: 2; }
.viz-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
.viz-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .82rem; color: var(--muted); }
.viz-legend-item { display: inline-flex; align-items: center; gap: .35rem; }
.viz-key { display: inline-block; flex: none; }
.viz-key-rect { width: 10px; height: 10px; border-radius: 3px; }
.viz-key-line { width: 14px; height: 2px; border-radius: 2px; }
.viz-key.s1 { background: var(--series-1); } .viz-key.s2 { background: var(--series-2); } .viz-key.s3 { background: var(--series-3); }
.viz-tip { position: fixed; z-index: 1000; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 8px; padding: .45rem .6rem; font-size: .82rem; min-width: 8rem; }
.viz-tip-head { color: var(--muted); font-size: .75rem; margin-bottom: .2rem; }
.viz-tip-row { display: flex; align-items: center; gap: .35rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.viz-barlist { display: flex; flex-direction: column; gap: .45rem; }
.viz-barlist-row { display: grid; grid-template-columns: minmax(7rem, 34%) 1fr auto; align-items: center; gap: .6rem; font-size: .88rem; }
.viz-barlist-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viz-barlist-track { height: 10px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.viz-barlist-fill { height: 100%; border-radius: 0 4px 4px 0; }
.viz-barlist-value { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.viz-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.viz-filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .9rem; }
.viz-loading { opacity: .55; transition: opacity .15s; }
@media (max-width: 760px) { .viz-grid-2 { grid-template-columns: 1fr; } .stats { grid-template-columns: repeat(2, 1fr); } }
.stats-compact { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
.stats-compact .stat { box-shadow: none; padding: .6rem .75rem; }
.stats-compact .stat-value { font-size: 1.35rem; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .8rem; }
.plan-card { border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; gap: .4rem; background: var(--surface); }
.plan-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.plan-card h3 { margin: 0; }
.plan-price { font-size: 1.25rem; font-weight: 700; }
.diff-card summary { font-weight: 600; }
.diff-list { margin: .5rem 0 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .6rem; }
.diff-old, .diff-new { padding: .3rem .55rem; border-radius: 6px; font-size: .9rem; margin-top: .15rem; }
.diff-old { background: var(--bad-soft); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--bad) 60%, transparent); }
.diff-old::before { content: "− "; font-weight: 700; text-decoration: none; display: inline-block; }
.diff-new { background: var(--ok-soft); }
.diff-new::before { content: "+ "; font-weight: 700; }
.rating-card { display: flex; flex-direction: column; gap: .5rem; }
.rating-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; }
.stars { display: inline-flex; gap: .1rem; }
.star { border: 0; background: none; font-size: 1.45rem; line-height: 1; cursor: pointer; color: var(--muted); padding: .1rem; }
.star.on { color: #d4a000; }
.star:focus-visible { outline: 2px solid var(--accent); border-radius: 4px; }
@media (max-width: 640px) {
  .viz-barlist-row { grid-template-columns: 1fr auto; row-gap: .2rem; }
  .viz-barlist-label { grid-column: 1 / -1; white-space: normal; }
  .viz-barlist-track { grid-column: 1; }
}
