/* Kaynakça Masası — ink-on-paper review desk.
   Color only signals action (ink blue) or record status; the UI speaks in a grotesk,
   scholarly content (paragraphs, references, evidence) is set in Literata. */
:root {
  --paper: #f6f7f9;
  --surface: #ffffff;
  --sunken: #eef1f5;
  --ink: #14213d;
  --muted: #586379;
  --line: #dde2ea;
  --line-strong: #c4ccd8;
  --accent: #2347b8;
  --accent-hover: #1b3893;
  --accent-soft: #e8edfb;
  --on-accent: #ffffff;
  --ok: #17784c;
  --ok-soft: #e3f3ea;
  --ok-hover: #12613d;
  --on-ok: #ffffff;
  --warn: #a85a08;
  --warn-soft: #fcf0de;
  --bad: #be3a31;
  --bad-soft: #fbe7e5;
  --wait: #6a52c7;
  --wait-soft: #efebfb;
  --mark: #fff3c4;
  --shadow-float: 0 12px 40px rgba(20, 33, 61, .14);
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 14px;
  --ui: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --text: "Literata", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1420;
    --surface: #161d2b;
    --sunken: #1c2433;
    --ink: #e6eaf2;
    --muted: #9aa5b8;
    --line: #273145;
    --line-strong: #364259;
    --accent: #7ea2ff;
    --accent-hover: #a3bdff;
    --accent-soft: #1d2a4d;
    --on-accent: #0c1220;
    --ok: #5fcf97;
    --ok-soft: #15301f;
    --ok-hover: #7fdcac;
    --on-ok: #0c1a12;
    --warn: #f0b05a;
    --warn-soft: #3a2a12;
    --bad: #ff8f86;
    --bad-soft: #3c1b19;
    --wait: #b4a4ff;
    --wait-soft: #272046;
    --mark: #4a3f12;
    --shadow-float: 0 12px 40px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); font: 15px/1.6 var(--ui); font-feature-settings: "ss01"; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4, h5 { font-family: var(--ui); color: var(--ink); text-wrap: balance; }
h2 { margin: 0; font-size: 22px; line-height: 1.25; font-weight: 650; letter-spacing: -.015em; }
h3 { font-size: 18px; line-height: 1.3; font-weight: 650; letter-spacing: -.01em; }
p { text-wrap: pretty; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.hidden { display: none !important; }
[hidden], .app-page[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 30; padding: 8px 14px; border-radius: var(--radius-s); background: var(--accent); color: var(--on-accent); text-decoration: none; }
.skip-link:focus { top: 12px; }

/* Top bar with page switcher */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 28px; min-height: 64px; padding: 0 max(var(--gutter), calc((100% - 1160px) / 2 + var(--gutter))); background: color-mix(in srgb, var(--paper) 88%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: saturate(1.4) blur(10px); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; }
.brand:hover { color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--ink); color: var(--paper); font: 600 17px/1 var(--text); }
.page-navigation { display: flex; gap: 4px; height: 64px; align-items: stretch; }
.page-navigation a { display: flex; align-items: center; padding: 0 12px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.page-navigation a.is-locked::after { content: "\1F512"; margin-left: 6px; font-size: 11px; opacity: .75; }
/* Areas the plan does not include: their controls disappear (auth-app.js lists the missing areas in data-no). */
html[data-no~="export"] [data-feature="export"], html[data-no~="scholar"] [data-feature="scholar"], html[data-no~="web"] [data-feature="web"], html[data-no~="styles"] [data-feature="styles"] { display: none !important; }
.page-navigation a:hover { color: var(--ink); }
.page-navigation a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.topbar-note { margin: 0 0 0 auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.signal-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

/* Page frame */
.shell { width: min(1160px, 100%); margin: 0 auto; padding: 0 var(--gutter); }
.hero { padding: 40px 0 28px; }
.hero h1 { margin: 0; font-size: clamp(28px, 3.6vw, 40px); line-height: 1.12; font-weight: 700; letter-spacing: -.03em; }
.hero-lede { margin: 10px 0 0; max-width: 64ch; color: var(--muted); font-size: 16px; }
.workbench, .results-section, .output-section { padding: 0 0 32px; }
.footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; margin-top: 24px; padding: 24px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

/* Shared controls */
.primary-button, .copy-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 9px 16px; border: 1px solid transparent; border-radius: var(--radius-s); background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 14px; line-height: 1.2; cursor: pointer; white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s; }
.primary-button:hover, .copy-button:hover { background: var(--accent-hover); }
.copy-button.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.copy-button.btn-secondary:hover { border-color: var(--accent); color: var(--accent); background: var(--surface); }
.text-button { display: inline-flex; align-items: center; min-height: 32px; padding: 4px 6px; border: 0; border-radius: var(--radius-s); background: none; color: var(--muted); font-weight: 500; font-size: 14px; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 4px; }
.text-button:hover { color: var(--ink); text-decoration-color: currentColor; }
.text-button.btn-danger { color: var(--bad); text-decoration-color: color-mix(in srgb, var(--bad) 40%, transparent); }
button:disabled, .primary-button:disabled, .copy-button:disabled { opacity: .45; cursor: not-allowed; }
.copy-button:disabled:hover, .primary-button:disabled:hover { background: var(--accent); }
.copy-button.btn-secondary:disabled:hover { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.copy-button.btn-success, .copy-button.btn-success:disabled:hover { background: var(--ok); color: var(--on-ok); }
.copy-button.btn-success:hover { background: var(--ok-hover); }
.reference-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 20px; margin: 8px 0; }
.reference-meta .provider-note { margin: 0; }
.reference-meta .reference-score { flex: none; }
.reference-meta .reference-reason { flex: 1 1 280px; }
select { appearance: none; width: 100%; min-height: 40px; padding: 8px 36px 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23586379' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center; color: var(--ink); font-size: 14px; }
input[type="search"], input[type="text"] { min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font-size: 14px; }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
details > summary { cursor: pointer; }

/* Bibliography page: input surface */
.input-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.input-panel, .control-panel, .output-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); }
.input-panel { padding: 20px 22px 14px; }
.panel-heading, .input-footer, .results-heading, .output-heading, .progress-topline { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.panel-heading p, .results-heading p, .output-heading p { margin: 4px 0 0; color: var(--muted); font-size: 14px; max-width: 70ch; }
.count-badge { padding: 4px 10px; border-radius: 999px; background: var(--sunken); color: var(--muted); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
textarea { width: 100%; }
#reference-input { display: block; min-height: 300px; resize: vertical; margin: 16px 0 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--paper); color: var(--ink); font: 13.5px/1.75 var(--mono); }
#reference-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-footer { color: var(--muted); font-size: 13px; }
.control-panel { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.control-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.select-wrap { display: block; }
.primary-button { width: 100%; min-height: 46px; font-size: 15px; }
.control-note { margin: 4px 0 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1.55; }
.examples-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 4px; color: var(--muted); font-size: 13px; }
.examples-row > span { flex-basis: 100%; }
.example-button { padding: 5px 11px; border: 1px solid var(--line-strong); border-radius: 999px; background: transparent; color: var(--ink); font-size: 13px; cursor: pointer; }
.example-button:hover { border-color: var(--accent); color: var(--accent); }
.provider-details { margin-top: 20px; padding: 14px 0; border-top: 1px solid var(--line); }
.provider-details summary { font-weight: 600; font-size: 14px; }
.provider-note { color: var(--muted); font-size: 13px; line-height: 1.6; max-width: 75ch; }
.provider-catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 24px; padding-top: 8px; }
.provider-entry { padding-bottom: 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
.provider-entry strong { display: block; }
.provider-entry span { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.provider-entry a, .manual-links a { font-size: 13px; }
.manual-links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }

/* Progress */
.progress-section { margin: 0 0 28px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
.progress-topline { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
#progress-label { color: var(--ink); font-weight: 600; }
.progress-track { height: 6px; margin-top: 12px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .35s ease; }
#stop-button { margin-top: 10px; }
#progress-value { white-space: nowrap; }

/* Results */
.results-heading { align-items: flex-end; margin-bottom: 18px; flex-wrap: wrap; }
.summary-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.summary-stat { min-width: 84px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); color: inherit; text-align: left; cursor: pointer; font: inherit; }
.summary-stat:hover { border-color: var(--line-strong); }
.summary-stat[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.summary-stat strong { display: block; font-size: 22px; line-height: 1.2; font-weight: 700; font-variant-numeric: tabular-nums; }
.summary-stat span { color: var(--muted); font-size: 13px; }
.empty-results { color: var(--muted); padding: 20px 0; }
.result-list { display: grid; gap: 12px; }
.result-card { position: relative; padding: 18px 20px 18px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow-wrap: anywhere; }
.result-card::before { content: ""; position: absolute; left: -1px; top: -1px; bottom: -1px; width: 4px; border-radius: var(--radius-m) 0 0 var(--radius-m); background: var(--line-strong); }
.result-card.verified::before { background: var(--ok); }
.result-card.review::before { background: var(--warn); }
.result-card.failed::before, .result-card.error::before { background: var(--bad); }
.result-card.pending::before { background: var(--wait); }
.result-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.result-number { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill.verified { color: var(--ok); background: var(--ok-soft); }
.status-pill.review { color: var(--warn); background: var(--warn-soft); }
.status-pill.failed, .status-pill.error { color: var(--bad); background: var(--bad-soft); }
.status-pill.pending { color: var(--wait); background: var(--wait-soft); }
.raw-reference { margin: 12px 0 8px; color: var(--muted); font: 13px/1.65 var(--mono); }
.matched-reference { margin: 0; font: 16px/1.65 var(--text); }
.result-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.changes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.change-tag { padding: 2px 8px; border-radius: 999px; background: var(--sunken); color: var(--muted); font-size: 12.5px; }
.reason { margin: 12px 0 0; color: var(--warn); font-size: 14px; line-height: 1.55; }
.retry-detail { color: var(--muted); font-size: 13px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.result-actions:empty { display: none; }
.result-action { display: inline-flex; align-items: center; min-height: 34px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); text-decoration: none; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.result-action:hover { border-color: var(--accent); color: var(--accent); }
.result-action.apply-suggestion { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.result-action.apply-suggestion:hover { background: var(--accent-hover); color: var(--on-accent); }
.result-action:disabled { opacity: .45; cursor: not-allowed; }
.scholar-search { font-size: 13.5px; }

/* Output */
.output-section { padding-bottom: 48px; }
.output-card { padding: 22px; }
.output-text { max-height: 440px; overflow: auto; margin-top: 18px; padding: 18px 20px; border-radius: var(--radius-m); background: var(--paper); border: 1px solid var(--line); white-space: pre-wrap; font: 15px/1.8 var(--text); }
.copy-status { min-height: 20px; margin-top: 8px; color: var(--ok); font-size: 13px; }

/* Web reference editor and evidence */
.web-editor { margin: 14px 0; }
.web-editor label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.web-editor textarea { display: block; min-height: 110px; resize: vertical; padding: 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface); font: 15px/1.6 var(--text); }
.web-editor textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.web-evidence { margin-top: 12px; overflow-x: auto; }
.web-evidence table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.web-evidence th, .web-evidence td { padding: 8px; text-align: left; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; vertical-align: top; }
.web-evidence th { color: var(--muted); font-weight: 600; }
.web-evidence p { font-size: 13.5px; overflow-wrap: anywhere; }
.debug-panel { margin: 14px 0; padding: 12px 14px; border: 1px dashed var(--warn); border-radius: var(--radius-s); background: var(--warn-soft); font-size: 13px; }
.debug-panel summary { font-weight: 600; }
.debug-panel p { overflow-wrap: anywhere; line-height: 1.5; }
.debug-panel code { white-space: pre-wrap; overflow-wrap: anywhere; }
.word-debug-entry { margin-top: 12px; padding-top: 12px; border-top: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.word-debug-entry:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.crossref-citation-modal { width: min(680px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-float); }
.crossref-citation-modal::backdrop { background: rgba(10, 16, 30, .5); }
.crossref-citation-dialog { position: relative; padding: 24px; }
.crossref-citation-dialog textarea { min-height: 130px; padding: 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--paper); line-height: 1.5; }
.modal-close { position: absolute; right: 14px; top: 10px; border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }

/* Word pages: upload */
.upload-zone { position: relative; display: flex; align-items: center; gap: 16px; padding: 22px 24px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius-l); background: var(--surface); transition: border-color .15s, background-color .15s; }
.upload-zone input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload-zone:hover, .upload-zone.is-dragging { border-color: var(--accent); background: var(--accent-soft); }
.upload-zone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.upload-zone:has(input:disabled) { opacity: .55; }
.upload-zone:has(input:disabled) input { cursor: not-allowed; }
.upload-icon { flex: none; width: 44px; height: 52px; border-radius: 6px 14px 6px 6px; border: 1.5px solid var(--accent); background: linear-gradient(var(--accent), var(--accent)) 10px 18px / 22px 1.5px no-repeat, linear-gradient(var(--accent), var(--accent)) 10px 25px / 22px 1.5px no-repeat, linear-gradient(var(--accent), var(--accent)) 10px 32px / 14px 1.5px no-repeat, var(--surface); }
.upload-copy { display: grid; gap: 2px; min-width: 0; }
.upload-copy strong { font-size: 16px; }
.upload-copy span { color: var(--muted); font-size: 14px; }
.upload-button { flex: none; margin-left: auto; padding: 9px 16px; border-radius: var(--radius-s); background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 14px; pointer-events: none; }
.status-message { margin: 12px 0 0; font-size: 14px; }
.status-message:empty { display: none; }
.check-options { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0 0 14px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
.check-options legend { float: left; width: 100%; margin-bottom: 6px; padding: 0; font-weight: 600; font-size: 14px; }
.check-options label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.document-library { margin: 16px 0 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
.document-library > summary { padding: 12px 16px; font-weight: 600; font-size: 15px; }
.document-library > p { margin: 0; padding: 0 16px 8px; color: var(--muted); font-size: 13px; }
.document-library > div { max-height: 300px; overflow: auto; padding: 0 16px 6px; }
.document-library > div > p { color: var(--muted); font-size: 14px; }
.library-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px; align-items: baseline; padding: 12px 0; border-top: 1px solid var(--line); }
.library-row .word-inline-button { margin: 0; justify-self: start; font-size: 15px; text-align: left; }
.library-row small { grid-column: 1; color: var(--muted); font-size: 12.5px; }
.library-row p { grid-column: 1; margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.library-row a { grid-column: 2; grid-row: 1 / span 2; font-size: 13px; white-space: nowrap; }
.library-row a + a { grid-row: auto; }

/* Word pages: review */
.word-workbench > p:not(.status-message):not(.provider-note) { max-width: 72ch; }
.word-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 20px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); position: sticky; top: 72px; z-index: 6; }
.action-spacer { flex: 1 1 0; }
.word-range { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 14px 0; }
.word-range label { display: grid; gap: 6px; flex: 1 1 220px; color: var(--muted); font-size: 13px; }
.word-range select { max-width: 460px; }
.panel-details { margin: 14px 0 0; }
.panel-details > summary { font-weight: 600; font-size: 14px; color: var(--muted); }
.panel-details > p { color: var(--muted); font-size: 14px; }
.word-preview { max-height: 360px; overflow: auto; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); font: 15px/1.7 var(--text); }
.word-preview p:target { background: var(--mark); }
.content-disclosure { margin: 12px 0 0; }
.page-next { display: inline-block; margin: 14px 0 0; font-size: 14px; font-weight: 600; }
.word-workbench blockquote { margin: 12px 0; padding-left: 14px; border-left: 3px solid var(--accent); }
.word-navigation { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin: 28px 0 0; }
.word-navigation button { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); color: var(--muted); font-size: 14px; font-weight: 600; line-height: 1.3; text-align: left; cursor: pointer; }
.word-navigation button:hover { border-color: var(--line-strong); color: var(--ink); }
.word-navigation button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.word-navigation button strong { flex: none; min-width: 28px; padding: 2px 8px; border-radius: 999px; background: var(--sunken); color: var(--ink); font-variant-numeric: tabular-nums; text-align: center; }
.word-navigation button[aria-pressed="true"] strong { background: var(--accent); color: var(--on-accent); }
.word-list-tools { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; margin: 20px 0; }
.word-search { display: grid; gap: 6px; width: min(400px, 100%); color: var(--muted); font-size: 13px; }
.word-search input { width: 100%; }
.word-list-heading { margin: 8px 0 16px; }
.word-list-heading h3 { margin: 0; font-size: 20px; }
.word-list-heading p { margin: 4px 0 0; max-width: 72ch; color: var(--muted); font-size: 14px; }
.word-reference-summary { margin: 0 0 18px; }
.word-card-heading { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 16px; }
.word-card-heading h4 { margin: 0; font-size: 16px; line-height: 1.45; }
.word-card-heading > span:not(.status-pill) { color: var(--muted); font-size: 13px; }
.word-finding-original { margin: 12px 0; font: 16px/1.7 var(--text); }
.word-guidance { max-width: 75ch; color: var(--warn); font-size: 14px; line-height: 1.6; }
.word-location { color: var(--accent); }
.word-drawer { margin: 14px 0 0; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.word-drawer > summary { position: relative; padding: 10px 40px 10px 14px; background: var(--sunken); color: var(--ink); font-size: 14px; font-weight: 600; list-style: none; }
.word-drawer > summary::-webkit-details-marker { display: none; }
.word-drawer > summary::after { content: ""; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px; border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted); transform: translateY(-70%) rotate(45deg); transition: transform .15s; }
.word-drawer[open] > summary::after { transform: translateY(-30%) rotate(225deg); }
.word-drawer-body { padding: 16px; background: var(--surface); }
.word-drawer-body > p { margin: 0 0 12px; font-size: 14px; }
.word-drawer-body > p:last-child { margin-bottom: 0; }
.word-paragraph > p:not(.word-paragraph-label) { max-width: 78ch; margin: 8px 0; font: 16.5px/1.8 var(--text); white-space: pre-wrap; }
.word-paragraph-label { margin: 0; color: var(--muted); font-size: 13px; }
.word-paragraph mark { padding: 1px 2px; border-radius: 3px; background: var(--mark); color: inherit; }
.word-cited-sentence { padding-left: 12px; border-left: 3px solid var(--accent); }
.word-inline-button { display: inline-flex; margin: 12px 14px 0 0; padding: 0; border: 0; background: transparent; color: var(--accent); font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); cursor: pointer; }
.word-inline-button:hover { color: var(--accent-hover); text-decoration-color: currentColor; }
.word-correction { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius-s); background: var(--accent-soft); }
.word-correction > p { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 10px; font-size: 15px; }
.word-card-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.word-patch-select { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.word-field { display: grid; gap: 6px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.word-field textarea { min-height: 160px; padding: 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font: 15px/1.7 var(--text); resize: vertical; }
.word-field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.word-pdf { display: grid; gap: 6px; margin: 14px 0; font-size: 14px; }
.word-pdf input { max-width: 100%; font-size: 13px; }
.word-evidence-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; }
.word-evidence-filters button { display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.word-evidence-filters button span { min-width: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.word-evidence-filters button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.word-evidence-result { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.word-evidence-result h5 { margin: 0; font-size: 15px; }
.word-evidence-result p { font-size: 14px; }
.word-claim { margin: 14px 0; padding: 12px 14px; border-radius: var(--radius-s); background: var(--sunken); }
.word-claim p { margin: 0; }
.word-claim blockquote { font: 16px/1.7 var(--text); }
.word-empty { padding: 28px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius-m); color: var(--muted); font-size: 14px; text-align: center; }
.word-empty p { margin: 0; }
[id^="word-citation-"], [id^="word-reference-"] { scroll-margin-top: 140px; }
.word-inspection { width: min(900px, calc(100vw - 32px)); max-height: 85vh; padding: 0 24px 24px; border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--paper); color: var(--ink); box-shadow: var(--shadow-float); overflow: auto; }
.word-inspection::backdrop { background: rgba(10, 16, 30, .5); }
.word-inspection > header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 0; background: var(--paper); }
.word-inspection > header h3 { margin: 0; }
body[data-page="word"] #word-content, body[data-page="word"] .content-disclosure { display: none; }
body[data-page="word"] .word-navigation { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.content-review-results .word-navigation { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* Content page: progress, editor, live query feed */
.content-progress { margin: 16px 0 0; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
.content-progress:empty { display: none; }
.content-progress h3 { margin: 0 0 12px; font-size: 16px; }
.progress-stage { margin: 14px 0; }
.progress-stage-heading { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 14px; }
.progress-stage-heading strong { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); }
.progress-stage progress { display: block; width: 100%; height: 6px; margin: 8px 0; border: 0; border-radius: 999px; overflow: hidden; background: var(--sunken); accent-color: var(--accent); }
.progress-stage progress::-webkit-progress-bar { background: var(--sunken); border-radius: 999px; }
.progress-stage progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; transition: width .35s ease; }
.progress-stage progress::-moz-progress-bar { background: var(--accent); }
.progress-stage p { margin: 0; color: var(--muted); font-size: 13px; }
.progress-stage.is-active label { font-weight: 600; }
.progress-stage.is-active label::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--accent); vertical-align: 1px; }
.content-review-layout { display: block; }
.content-review-results, .paragraph-editor { min-width: 0; }
.paragraph-editor { position: sticky; top: 90px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
.paragraph-editor > p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.paragraph-editor h3 { margin: 0; }
.editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 14px 0; }
#content-save-status { color: var(--muted); font-size: 13px; }
#content-editor { max-height: 65vh; overflow: auto; }
.editor-paragraph { padding: 12px 0; border-top: 1px solid var(--line); scroll-margin-top: 100px; }
.editor-paragraph label > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.editor-paragraph textarea { display: block; min-height: 120px; padding: 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface); font: 16px/1.7 var(--text); resize: vertical; }
.editor-paragraph textarea[readonly] { background: var(--sunken); color: var(--muted); }
.query-monitor { margin: 16px 0 0; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); overflow: hidden; }
.query-monitor > summary { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-weight: 600; font-size: 14px; }
.query-monitor-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--sunken); }
.query-monitor-header p { margin: 0; color: var(--muted); font-size: 13px; }
.query-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.query-monitor.is-live .query-live-dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); animation: query-pulse 1.6s ease-out infinite; }
@keyframes query-pulse { 50% { box-shadow: 0 0 0 6px transparent; } }
.query-monitor-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.query-monitor-summary:empty { display: none; }
.query-monitor-summary article { min-width: 0; padding: 12px 16px; }
.query-monitor-summary article + article { border-left: 1px solid var(--line); }
.query-monitor-summary span, .query-monitor-summary small { display: block; color: var(--muted); font-size: 12.5px; }
.query-monitor-summary strong { display: block; margin: 4px 0; font-size: 15px; }
.query-monitor-log { max-height: 420px; overflow: auto; padding: 0 16px; border-top: 1px solid var(--line); }
.query-event { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; padding: 10px 0 10px 10px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; }
.query-event time { color: var(--muted); font: 12px/1.5 var(--mono); }
.query-event p { margin: 0; line-height: 1.45; font-size: 14px; }
.query-event p strong { margin-right: 8px; }
.query-event p span, .query-event small { color: var(--muted); font-size: 12.5px; }
.query-event code { display: block; margin: 4px 0; padding: 6px 8px; border-radius: 4px; background: var(--sunken); font: 12px/1.5 var(--mono); overflow-wrap: anywhere; }
.query-event .query-record { margin-top: 4px; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.query-event.wait { border-left-color: var(--warn); }
.query-event.error { border-left-color: var(--bad); }
.query-event.response, .query-event.success, .query-event.result { border-left-color: var(--ok); }
.query-monitor-empty { padding: 16px 0; color: var(--muted); font-size: 13px; }

/* Accounts and admin panel */
.account-menu { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; white-space: nowrap; }
.acct-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.acct-link:hover { color: var(--accent); }
.acct-plan { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
.acct-quota { padding: 1px 7px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--muted); font-size: 12px; }
.acct-wrap { max-width: 480px; margin: 8px auto 48px; display: grid; gap: 20px; }
.acct-wrap.acct-wide { max-width: 1100px; }
.acct-card { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
.acct-card h2, .acct-wrap > h2 { margin: 0 0 8px; font-size: 22px; }
.acct-card h3 { margin: 20px 0 8px; font-size: 16px; }
.acct-lead, .acct-muted { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }
.acct-form { display: grid; gap: 14px; margin-top: 12px; }
.acct-field { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
.acct-field small { color: var(--muted); font-weight: 400; }
.acct-field input, .acct-field select, .acct-field textarea, .adm-toolbar input, .adm-toolbar select { min-height: 40px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--paper); color: var(--ink); font: inherit; font-weight: 400; }
.acct-field input:focus, .acct-field select:focus, .acct-field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.acct-features { display: grid; gap: 6px; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 12px; }
.acct-features legend { font-weight: 600; font-size: 14px; padding: 0 6px; }
.acct-check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.acct-message { margin: 0; font-size: 14px; }
.acct-message:empty { display: none; }
.acct-message.is-error { padding: 8px 12px; border-radius: var(--radius-s); background: var(--bad-soft); color: var(--bad); }
.acct-message.is-ok { padding: 8px 12px; border-radius: var(--radius-s); background: var(--ok-soft); color: var(--ok); }
.acct-links { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 16px 0 0; font-size: 14px; }
.acct-links a { color: var(--accent); }
.acct-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.acct-table th, .acct-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.acct-table th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.acct-meter { height: 10px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.acct-meter span { display: block; height: 100%; background: var(--accent); }
.acct-meter span.is-hot { background: var(--bad); }
.acct-upgrade { margin: 14px 0 0; padding: 10px 12px; border-radius: var(--radius-s); background: var(--accent-soft); font-size: 14px; }
.copy-button.btn-danger { background: var(--bad); color: #fff; }
.adm-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.adm-tab { padding: 10px 14px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.adm-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.adm-panel { display: grid; gap: 14px; }
.adm-panel h3 { margin: 16px 0 4px; font-size: 16px; }
.adm-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.adm-card { display: grid; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
.adm-card span { color: var(--muted); font-size: 13px; }
.adm-card strong { font-size: 24px; }
.adm-card small { color: var(--muted); font-size: 12px; }
.adm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; }
.adm-bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding: 8px 0 0; border-bottom: 1px solid var(--line); }
.adm-bar { flex: 1; min-width: 6px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.adm-bar span { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; }
.adm-bar small { margin-top: 4px; color: var(--muted); font-size: 9px; writing-mode: vertical-rl; }
.adm-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.adm-scroll { overflow-x: auto; }
.adm-table td small.adm-sub { display: block; color: var(--muted); font-size: 12px; }
.adm-table tr.is-off td { opacity: .55; }
.adm-pager { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.adm-section > summary { cursor: pointer; list-style: none; }
.adm-section > summary h3 { display: inline; margin: 0; }
.adm-dialog { width: min(760px, 94vw); max-height: 90vh; padding: 20px; border: 1px solid var(--line-strong); border-radius: var(--radius-m); background: var(--surface); color: var(--ink); }
.adm-dialog::backdrop { background: rgba(10, 16, 30, .55); }
.adm-dialog header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.adm-secret { display: inline-block; padding: 6px 10px; border-radius: var(--radius-s); background: var(--sunken); font-family: var(--mono); font-size: 16px; user-select: all; }
@media (max-width: 1000px) { .account-menu { order: 2; } }

/* Responsive */
@media (max-width: 1000px) {
  .topbar { flex-wrap: wrap; gap: 0 20px; padding-top: 8px; }
  .topbar-note { display: none; }
  .page-navigation { order: 3; width: 100%; height: 44px; margin: 0 calc(var(--gutter) * -1); padding: 0 calc(var(--gutter) - 12px); overflow-x: auto; scrollbar-width: none; }
  .input-grid { grid-template-columns: 1fr; }
  .control-panel { position: static; }
  .word-navigation { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body[data-page="word"] .word-navigation { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .paragraph-editor { position: static; }
  #content-editor { max-height: 450px; }
  .word-actions { top: 104px; }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .hero { padding: 24px 0 18px; }
  .page-navigation a { padding: 0 10px; font-size: 13.5px; }
  .input-panel, .output-card, .control-panel { padding: 16px; }
  #reference-input { min-height: 240px; }
  .upload-zone { flex-wrap: wrap; padding: 18px; }
  .upload-icon { width: 36px; height: 44px; background-size: 16px 1.5px, 16px 1.5px, 10px 1.5px, auto; background-position: 8px 14px, 8px 20px, 8px 26px, 0 0; }
  .upload-copy { flex: 1 1 200px; }
  .upload-button { margin-left: 0; width: 100%; text-align: center; }
  .word-actions { position: static; }
  .word-actions > .copy-button { flex: 1 1 100%; }
  .action-spacer { display: none; }
  .word-navigation, body[data-page="word"] .word-navigation { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .word-list-tools { flex-direction: column; align-items: stretch; }
  .word-search { width: 100%; }
  .result-card { padding: 16px 14px 16px 18px; }
  .word-paragraph > p:not(.word-paragraph-label) { font-size: 16px; }
  .results-heading, .output-heading { flex-direction: column; align-items: stretch; }
  .copy-button { width: 100%; }
  .query-monitor-summary { grid-template-columns: 1fr; }
  .query-monitor-summary article + article { border-left: 0; border-top: 1px solid var(--line); }
  .query-event { grid-template-columns: 1fr; gap: 2px; }
  .library-row { grid-template-columns: 1fr; }
  .library-row a { grid-column: 1; grid-row: auto; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* With a document open, the upload area shrinks to a single row so the review comes first. */
.word-workbench:has(> div[id$="-panel"]:not(.hidden)) .upload-zone { padding: 10px 14px; gap: 12px; border-style: solid; border-width: 1px; }
.word-workbench:has(> div[id$="-panel"]:not(.hidden)) .upload-icon,
.word-workbench:has(> div[id$="-panel"]:not(.hidden)) .upload-copy > span { display: none; }
.word-workbench:has(> div[id$="-panel"]:not(.hidden)) .upload-copy strong { font-size: 14px; font-weight: 600; color: var(--muted); }
.word-workbench:has(> div[id$="-panel"]:not(.hidden)) .upload-button { padding: 6px 12px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); }

/* Orphan-reference page progress: one prominent bar; a moving sheen until the first record returns. */
.word-progress { padding: 14px 18px; }
.word-progress .progress-stage { margin: 0; }
.word-progress .progress-stage progress { height: 8px; }
.word-progress .progress-stage p + p { margin-top: 4px; }
.progress-stage progress.is-starting { background: linear-gradient(90deg, var(--sunken) 0%, var(--accent-soft) 50%, var(--sunken) 100%) 0 0 / 200% 100%; animation: progress-sheen 1.4s linear infinite; }
.progress-stage progress.is-starting::-webkit-progress-bar { background: transparent; }
@keyframes progress-sheen { to { background-position: -200% 0; } }

/* Read-only notice for PDF manuscripts. */
.format-note { margin: 10px 0 0; padding: 10px 14px; border-radius: var(--radius-s); background: var(--accent-soft); color: var(--ink); font-size: 14px; line-height: 1.55; }

/* Editable bibliography suggestion inside reference cards. */
.reference-suggestion .word-field { margin-bottom: 6px; }
.reference-suggestion-label { margin: 0 0 4px; color: var(--ink); font-size: 13.5px; font-weight: 600; }
.reference-suggestion textarea { min-height: 96px; }
.reference-suggestion .provider-note { margin: 0 0 10px; }
.reference-suggestion .word-card-actions .copy-button { margin: 0; }

/* ---- Yazım yardımcısı (#/yazim): projeler ve kaynaklar | soru-cevap | makale editörü ---- */
.wr { display: grid; gap: 14px; }
.wr-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.wr-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font: 600 .78rem var(--ui); background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.wr-badge.wr-ok { background: var(--ok-soft); color: var(--ok); }
.wr-badge.wr-warn { background: var(--warn-soft); color: var(--warn); }
.wr-muted { color: var(--muted); font-size: .88rem; margin: 0; }
.wr-warn-text { color: var(--warn); font-size: .9rem; margin: 6px 0 0; }
.wr-error-text { color: var(--bad); margin: 0; }
.status-message.wr-error { color: var(--bad); }
.status-message.wr-warn { color: var(--warn); }
.status-message.wr-ok { color: var(--ok); }
.status-message.wr-upgrade { color: var(--ink); background: var(--warn-soft); border-left: 3px solid var(--warn); padding: 8px 12px; border-radius: var(--radius-s); }
.wr-view { display: grid; gap: 16px; }
.wr-view[hidden] { display: none; }
/* Writing view: project, chosen collections, then questions and the wide article, one under the other. */
.wr-grid { display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr); }
.wr-chat, .wr-doc { width: 100%; max-width: 1100px; margin-inline: auto; box-sizing: border-box; }
.wr-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 2px 0 4px; }
.wr-tab { padding: 10px 18px; font: 600 .95rem var(--ui); color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; border-radius: var(--radius-s) var(--radius-s) 0 0; }
.wr-tab { white-space: nowrap; }
@media (max-width: 520px) { .wr-tab { padding: 10px 12px; font-size: .9rem; } }
.wr-tab:hover { color: var(--ink); background: var(--accent-soft); }
.wr-tab[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.wr-count:not(:empty) { display: inline-block; min-width: 20px; margin-left: 6px; padding: 0 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font: 700 .78rem/20px var(--ui); text-align: center; }
.wr-project-row { align-items: flex-end; }
.wr-project-select { flex: 1 1 260px; max-width: 420px; }
.wr-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.wr-head h3 { margin: 0; }
.wr-link { font: 600 .9rem var(--ui); color: var(--accent); text-decoration: none; }
.wr-link:hover { text-decoration: underline; }
.wr-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.wr-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); cursor: pointer; font: 600 .9rem var(--ui); transition: background .12s, border-color .12s; }
.wr-chip:hover { border-color: var(--accent); }
.wr-chip input { accent-color: var(--accent); margin: 0; }
.wr-chip-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.wr-chip-meta { font-weight: 400; color: var(--muted); font-size: .8rem; }
.wr-cta { display: inline-block; text-decoration: none; width: fit-content; }
/* Collections view: the list on the left, the selected collection's sources on the right. */
.wr-collections { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .wr-collections { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); align-items: start; } }
.wr-collection-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.wr-collection-item { width: 100%; text-align: left; display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.wr-collection-item:hover { background: var(--accent-soft); }
.wr-collection-item.wr-active { border-color: var(--accent); background: var(--accent-soft); }
.wr-collection-detail { min-height: 220px; }
#wr-collection-name, #wr-collection-rename-input, #wr-title-input { flex: 1 1 160px; min-width: 0; }
.wr-collection-list form { flex-wrap: nowrap; }
.wr-side, .wr-chat, .wr-doc { display: grid; gap: 14px; min-width: 0; align-content: start; }
.wr-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px; display: grid; gap: 10px; }
.wr-block h3 { margin: 0; font-size: .95rem; }
.wr-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wr-row > .wr-field { flex: 1 1 90px; }
.wr-field { display: grid; gap: 4px; font-size: .84rem; color: var(--muted); }
.wr-check { display: flex; gap: 8px; align-items: flex-start; font-size: .88rem; color: var(--muted); }
.wr-block select, .wr-form select, .wr-field input, .wr-field textarea, #wr-title-input, #wr-question {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 8px 10px; }
.wr-field textarea, #wr-question { resize: vertical; }
.wr-new-collection { display: grid; gap: 8px; }
.wr-search { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 12px 0; display: grid; gap: 10px; }
.wr-search > summary { cursor: pointer; font-weight: 600; }
.wr-search input[type=text] { flex: 1 1 260px; min-width: 0; }
.wr-papers { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.wr-paper { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.wr-paper-pick { display: flex; gap: 10px; align-items: flex-start; flex: 1 1 auto; min-width: 0; cursor: pointer; }
.wr-paper-main { display: grid; gap: 2px; min-width: 0; }
.wr-pager { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; justify-content: center; margin-top: 10px; }
.wr-pager button { min-width: 36px; }
.wr-pager button[aria-current="page"] { font-weight: 700; text-decoration: underline; }
.wr-paper-side { display: flex; gap: 8px; align-items: center; flex: none; }
.wr-upload { padding: 14px 16px; }
.wr-upload input:disabled { cursor: not-allowed; }
.wr-sources { display: grid; gap: 10px; }
.wr-source { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; display: grid; gap: 6px; background: var(--sunken); }
.wr-source.wr-source-error { border-color: color-mix(in srgb, var(--bad) 55%, var(--line)); border-left: 4px solid var(--bad); background: var(--bad-soft); }
.wr-source-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.wr-source-head strong { font-size: .92rem; overflow-wrap: anywhere; }
.wr-source-flags { display: inline-flex; gap: 6px; align-items: center; flex-shrink: 0; }
.wr-embed { display: inline-flex; line-height: 0; }
.wr-embed.wr-ok { color: var(--ok); }
.wr-embed.wr-warn { color: var(--warn); }
.wr-ref { margin: 0; font: .86rem/1.45 var(--text); color: var(--ink); overflow-wrap: anywhere; }
.wr-meta { display: grid; gap: 8px; margin-top: 8px; }
.wr-messages { display: grid; gap: 12px; max-height: 56vh; min-height: 120px; overflow-y: auto; padding: 2px; }
.wr-empty { padding: 28px 8px; text-align: center; }
.wr-msg { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px; background: var(--surface); display: grid; gap: 8px; }
.wr-msg.wr-user { background: var(--accent-soft); border-color: transparent; }
.wr-msg-meta { font: 600 .76rem var(--ui); color: var(--muted); letter-spacing: .02em; }
.wr-msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.wr-answer { display: grid; gap: 10px; font: 1rem/1.65 var(--text); }
.wr-form { display: grid; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px; }
.wr-toolbar { display: flex; gap: 4px; flex-wrap: wrap; }
.wr-toolbar button { font: 600 .84rem var(--ui); min-width: 34px; padding: 6px 9px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); cursor: pointer; }
.wr-toolbar button:hover { background: var(--accent-soft); }
.wr-doc { padding-top: 6px; border-top: 2px solid var(--line); }
.wr-doc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.wr-doc-head h3 { margin: 0; font-size: 1.15rem; }
.wr-doc .wr-toolbar { position: sticky; top: 0; z-index: 2; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: 0 2px 8px rgba(20, 33, 61, .06); }
.wr-editor { width: 100%; max-width: 1100px; margin-inline: auto; box-sizing: border-box; min-height: max(640px, 80vh); padding: clamp(24px, 4vw, 56px) clamp(22px, 5vw, 72px); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-m);
  box-shadow: 0 6px 24px rgba(20, 33, 61, .08); font: 1.08rem/1.85 var(--text); color: var(--ink); outline: none; overflow-wrap: anywhere; }
.wr-doc > .wr-toolbar, .wr-doc > .wr-doc-head, .wr-doc > .wr-row, .wr-doc > .wr-block { width: 100%; max-width: 1100px; margin-inline: auto; box-sizing: border-box; }
.wr-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.wr-editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.wr-editor h1 { font-size: 1.5rem; margin: 1.1em 0 .4em; } .wr-editor h2 { font-size: 1.28rem; margin: 1em 0 .4em; } .wr-editor h3 { font-size: 1.1rem; margin: 1em 0 .4em; }
.wr-editor p { margin: 0 0 .8em; } .wr-editor p.ref { padding-left: 2em; text-indent: -2em; }
.wr-editor .cite { color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 3px; cursor: default; }
.wr-bib { margin: 0; padding-left: 1.3em; display: grid; gap: 8px; font: .92rem/1.5 var(--text); }
.wr-bib li { overflow-wrap: anywhere; }

/* Spinner for background work on a source: reading text, embedding, künye lookup. */
.wr-spinner { display: inline-block; flex: none; width: 14px; height: 14px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; vertical-align: -2px; animation: wr-spin .8s linear infinite; }
.wr-progress { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
.wr-progress-top { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font: 600 .86rem var(--ui); font-variant-numeric: tabular-nums; }
.wr-progress-track { height: 6px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.wr-progress-fill { width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .35s ease; }
.wr-work { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--accent); font: 600 .86rem var(--ui); }
[data-action="verify"]:disabled { opacity: .7; cursor: progress; }
#wr-picker-hint[data-busy="1"]::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; vertical-align: -2px; animation: wr-spin .8s linear infinite; }
@keyframes wr-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .wr-spinner, #wr-picker-hint[data-busy="1"]::before { animation-duration: 2.4s; } }
.status-message.wr-busy { color: var(--accent); }
.wr-language { flex: 0 1 150px; }
.wr-language select { min-width: 0; }

/* Admin → API keys */
.adm-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line); color: var(--ink); }
.adm-badge.is-ok { background: var(--ok-soft); color: var(--ok); }
.adm-badge.is-warn { background: var(--warn-soft); color: var(--warn); }
.adm-badge.is-error { background: var(--bad-soft); color: var(--bad); }
.adm-badge.is-off { background: var(--line); color: var(--muted); }
.adm-keys { display: grid; gap: 8px; }
.adm-actions { white-space: nowrap; }
.adm-actions .text-button + .text-button { margin-left: 6px; }
.adm-prompt { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; line-height: 1.45; resize: vertical; }
.adm-actions { white-space: normal; }

/* admin reports */
.adm-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 22px; }
.adm-heading h3 { margin: 0; }
.adm-subtabs { display: flex; flex-wrap: wrap; gap: 4px; }
.adm-report { display: grid; gap: 14px; margin-top: 12px; }
.adm-chart h4 { margin: 8px 0 0; font-size: 14px; }
.adm-legend { margin-left: 8px; padding-left: 14px; font-size: 12px; font-weight: 400; color: var(--muted); position: relative; }
.adm-legend::before { content: ""; position: absolute; left: 0; top: 3px; width: 10px; height: 10px; border-radius: 2px; background: var(--accent); }
.adm-bar span.is-bad, .adm-legend.is-bad::before { background: #c0392b; }
.adm-bar span.is-warn, .adm-legend.is-warn::before { background: #d68910; }
.adm-bar span.is-gray, .adm-legend.is-gray::before { background: #8a8f98; }
.adm-insights { display: grid; gap: 8px; }
.adm-insight { padding: 10px 14px; border: 1px solid var(--line); border-left-width: 5px; border-radius: var(--radius-m); background: var(--surface); }
.adm-insight p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.adm-insight .adm-action { color: inherit; }
.adm-insight.is-critical { border-left-color: #c0392b; }
.adm-insight.is-warning { border-left-color: #d68910; }
.adm-insight.is-info { border-left-color: #2e86c1; }
.adm-insight.is-good { border-left-color: #1e8449; }
.adm-score { display: inline-block; min-width: 2.5em; padding: 1px 8px; border-radius: 999px; text-align: center; font-weight: 600; background: var(--line); }
.adm-score.is-good { background: #d5f0dc; color: #14532d; }
.adm-score.is-fair { background: #fdebc8; color: #7a4a00; }
.adm-score.is-poor { background: #f7d4d0; color: #8a1f13; }

.to-top { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 50; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface); color: var(--accent); box-shadow: 0 2px 10px rgba(20, 33, 61, .18); cursor: pointer; }
.to-top[hidden] { display: none; }
.to-top:hover { background: var(--accent-soft); color: var(--accent-hover); }
.to-top:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media print { .to-top { display: none; } }
.query-event.output { border-left-color: var(--accent, var(--muted)); }
.query-event.skip { border-left-color: var(--warn); }
.query-event.verdict, .query-event.summary { border-left-color: var(--ok); }
.query-event details { margin-top: 4px; font-size: 12.5px; }
.query-event .query-preview { margin: 4px 0 0; padding: 8px; max-height: 220px; overflow: auto; border-radius: 4px; background: var(--sunken); font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
