:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #16202c;
  --muted: #5d6b7a;
  --border: #e1e5ea;
  --brand: #1f3a5f;
  --brand-contrast: #ffffff;
  --focus: #2f6fd6;
  --ai: #d6333b;
  --ai-bg: rgba(214, 51, 59, 0.16);
  --ai-bg-hover: rgba(214, 51, 59, 0.28);
  --assisted: #c77800;
  --assisted-bg: rgba(232, 150, 20, 0.2);
  --assisted-bg-hover: rgba(232, 150, 20, 0.34);
  --human: #2f8a57;
  --track: #e9edf1;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a;
    --surface: #171e26;
    --text: #e6ebf0;
    --muted: #93a1b0;
    --border: #28323d;
    --brand: #8fb4e6;
    --brand-contrast: #0f141a;
    --focus: #7aa7ea;
    --ai: #ff6b72;
    --ai-bg: rgba(255, 107, 114, 0.2);
    --ai-bg-hover: rgba(255, 107, 114, 0.32);
    --assisted: #f0a93a;
    --assisted-bg: rgba(240, 169, 58, 0.2);
    --assisted-bg-hover: rgba(240, 169, 58, 0.32);
    --human: #5cc48a;
    --track: #25303b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  background: var(--brand); color: var(--brand-contrast); font-weight: 700; font-size: 14px; letter-spacing: -0.02em;
}
.brand-name { font-weight: 700; font-size: 17px; }
.brand-product { color: var(--muted); font-size: 15px; padding-left: 10px; border-left: 1px solid var(--border); }
.pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }

.intro { padding: 36px 0 20px; }
.intro h1 { margin: 0 0 6px; font-size: 28px; line-height: 1.2; letter-spacing: -0.01em; }
.intro p { margin: 0; color: var(--muted); max-width: 640px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

.input-card { padding: 16px; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: 0; padding: 8px 12px; margin-bottom: -1px; cursor: pointer;
  color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent;
}
.tab.is-active { color: var(--text); border-bottom-color: var(--brand); }

textarea {
  width: 100%; min-height: 220px; resize: vertical; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
  line-height: 1.6;
}
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 220px; padding: 24px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--border); border-radius: 8px; background: var(--bg); color: var(--muted);
}
.dropzone strong { color: var(--text); }
.dropzone.is-over { border-color: var(--focus); background: color-mix(in srgb, var(--focus) 8%, var(--bg)); }

.input-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.model-picker { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; margin-right: 4px; }
.model-picker select {
  font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 8px; max-width: 100%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn { border-radius: 8px; padding: 9px 18px; font-weight: 600; cursor: pointer; border: 1px solid transparent; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--brand-contrast); }
.btn-ghost { background: transparent; border-color: var(--border); }

.model-note { margin: 10px 0 0; font-size: 13px; text-align: right; }
.notice { margin-top: 12px; padding: 10px 12px; border-radius: 8px; font-size: 14px; background: var(--track); }
.notice.is-error { background: var(--ai-bg); color: var(--text); }
.progress { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.progress-bar { flex: 1; height: 6px; background: var(--track); border-radius: 99px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--brand); transition: width 0.3s ease; }

#results { margin-top: 20px; }
.summary { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.verdict-card { padding: 18px 20px; }
.eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.verdict-card h2 { margin: 4px 0 12px; font-size: 24px; line-height: 1.25; }
.share-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--track); }
.seg { display: block; height: 100%; width: 0; transition: width 0.4s ease; }
.seg-ai { background: var(--ai); }
.seg-assisted { background: var(--assisted); }
.share p { margin: 8px 0 0; font-size: 14px; }
.model-line { margin: 10px 0 0; font-size: 13px; }

.stats-card { display: grid; grid-template-columns: repeat(2, 1fr); padding: 6px; }
.stat { display: flex; flex-direction: column; justify-content: center; padding: 12px 14px; }
.stat-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-ai { color: var(--ai); }
.stat-assisted { color: var(--assisted); }
.stat-label { font-size: 13px; color: var(--muted); }

.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; margin-top: 16px; align-items: start; }
.doc-card { padding: 0; overflow: hidden; }
.doc-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.legend-item input { margin: 0; }
.swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.swatch-ai { background: var(--ai-bg); border-bottom: 2px solid var(--ai); }
.swatch-assisted { background: var(--assisted-bg); border-bottom: 2px solid var(--assisted); }
.swatch-low { border: 1.5px dashed var(--muted); }

.document {
  padding: 20px 24px; white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: 16px; line-height: 1.8; max-height: 70vh; overflow-y: auto;
}
.sent { border-radius: 3px; cursor: pointer; padding: 1px 0; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.sent:hover { background: var(--track); }
.show-ai .sent.ai { background: var(--ai-bg); border-bottom: 2px solid var(--ai); }
.show-ai .sent.ai:hover { background: var(--ai-bg-hover); }
.show-assisted .sent.assisted { background: var(--assisted-bg); border-bottom: 2px solid var(--assisted); }
.show-assisted .sent.assisted:hover { background: var(--assisted-bg-hover); }
.show-ai .sent.ai.low, .show-assisted .sent.assisted.low { border-bottom-style: dashed; }
.sent.is-selected { outline: 2px solid var(--focus); outline-offset: 1px; }

.detail-card { padding: 16px; position: sticky; top: 16px; }
.detail-empty { margin: 0; font-size: 14px; }
.detail-card h3 { margin: 0 0 4px; font-size: 16px; }
.detail-quote {
  margin: 8px 0 14px; padding: 8px 10px; border-left: 3px solid var(--border);
  font-size: 14px; max-height: 160px; overflow-y: auto;
}
.detail-section { margin-top: 14px; }
.detail-section h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.bar-row { display: grid; grid-template-columns: 96px 1fr 44px; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.bar-track { height: 6px; background: var(--track); border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--muted); }
.bar-fill.ai { background: var(--ai); }
.bar-fill.assisted { background: var(--assisted); }
.bar-fill.human { background: var(--human); }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.tag.ai { background: var(--ai-bg); color: var(--ai); }
.tag.assisted { background: var(--assisted-bg); color: var(--assisted); }
.tag.human { background: var(--track); color: var(--human); }

.footer { padding: 28px 16px 40px; font-size: 13px; }

@media (max-width: 860px) {
  .summary, .doc-layout { grid-template-columns: 1fr; }
  .detail-card { position: static; }
  .document { padding: 16px; font-size: 15px; max-height: none; }
  .intro h1 { font-size: 24px; }
  .brand-product { display: none; }
  .model-note { text-align: left; }
}
