:root {
  color-scheme: light;
  /* Typeface decision: IBM Plex Sans (Latin) + IBM Plex Sans KR (Korean) — an
     engineered corporate family designed for IBM's own brand, chosen for a
     technical, commercial product voice. CJK falls back to native system faces. */
  --font-sans: "IBM Plex Sans", "IBM Plex Sans KR", "Helvetica Neue", Arial,
    "Apple SD Gothic Neo", "Malgum Gothic", "Noto Sans KR",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
    system-ui, sans-serif;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-subtle: #f5f6f8;
  --ink: #15171b;
  --muted: #686e78;
  --faint: #6f747e;
  --border: #e1e4e8;
  --border-strong: #cbd0d7;
  --accent: #3578c8;
  --accent-soft: #edf4fb;
  --success: #277a5b;
  --success-soft: #edf7f2;
  --warning: #a56a1d;
  --warning-soft: #fbf5e8;
  --danger: #b84945;
  --danger-soft: #fbefee;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(20 25 32 / 4%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgb(255 255 255 / 58%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 58%) 1px, transparent 1px),
    var(--bg);
  background-size: 36px 36px;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

button:focus-visible,
label:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.shell { width: min(1040px, calc(100% - 40px)); margin: 0 auto; padding: 32px 0 88px; }

.site-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 28px; padding: 12px 0 24px; }
.section-kicker { margin: 0 0 5px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; }
.eyebrow { margin: 0 0 5px; color: var(--ink); font-size: 18px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.brand-lockup { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.brand-lockup .eyebrow { margin: 0; }
.brand-mark { display: block; width: 34px; height: 34px; border-radius: 9px; }
.site-header h1 { margin: 0; font-size: clamp(25px, 3vw, 34px); font-weight: 600; line-height: 1.12; letter-spacing: -.03em; }
.subtitle { max-width: 620px; margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.header-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.quota-pill { min-height: 36px; display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 9px; color: var(--muted); background: rgb(255 255 255 / 78%); cursor: pointer; font-size: 12px; transition: border-color .18s, color .18s; }
.quota-pill:hover { border-color: var(--border-strong); color: var(--ink); }
.quota-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.quota-pill.ready .quota-dot { background: var(--success); }
.quota-pill.low .quota-dot { background: var(--warning); }
.quota-pill.empty .quota-dot { background: var(--danger); }
.quota-pill.admin { color: var(--accent); border-color: #b9d0ea; background: var(--accent-soft); font-weight: 600; }
.quota-pill.admin .quota-dot { background: var(--accent); }
.language-switch { display: flex; gap: 2px; padding: 3px; border-radius: 9px; background: #eceff2; }
.language-button { min-height: 30px; padding: 5px 11px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 600; transition: color .18s, background .18s, transform .18s; }
.language-button.active { color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.language-button:active, .primary-button:active, .icon-button:active { transform: scale(.98); }

.upload-card, .result-overview, .detail-card, .raw-details, .status-bar {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.upload-card { padding: 26px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.section-heading h2, .detail-heading h2, .history-header h2 { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.3; letter-spacing: -.02em; }
#fileInput { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.drop-zone { min-height: 224px; display: grid; place-items: center; align-content: center; padding: 28px; border: 1.5px dashed var(--border-strong); border-radius: 12px; background: var(--surface-subtle); cursor: pointer; text-align: center; transition: border-color .2s, background .2s, transform .2s; }
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.drop-zone.drag-over { transform: scale(.995); }
.upload-icon-wrap { width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 15px; border: 1px solid var(--border); border-radius: 12px; color: var(--accent); background: var(--surface); box-shadow: 0 4px 14px rgb(20 25 32 / 6%); }
.drop-title { color: var(--ink); font-size: 15px; font-weight: 600; }
.drop-copy { margin-top: 2px; color: var(--muted); font-size: 13px; }
.drop-copy strong { color: var(--accent); }
.drop-hint { margin-top: 12px; color: var(--faint); font-size: 11px; }
.paste-divider { display: flex; align-items: center; gap: 12px; margin-top: 16px; color: var(--faint); font-size: 11px; }
.paste-divider::before, .paste-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
#pasteInput { width: 100%; box-sizing: border-box; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fafbfc; color: var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.5; resize: vertical; }
#pasteInput:focus { outline: none; border-color: var(--accent); }
.selected-file { align-items: center; gap: 12px; margin-top: 12px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fafbfc; }
.selected-file:not([hidden]) { display: flex; }
.file-icon { width: 36px; height: 36px; display: grid; place-items: center; flex: none; border-radius: 9px; color: var(--accent); background: var(--accent-soft); }
.file-details { display: grid; min-width: 0; flex: 1; }
.file-details strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.file-details span { color: var(--muted); font-size: 11px; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; flex: none; padding: 0; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; }
.icon-button:hover { color: var(--ink); background: #eceff2; }
.icon-button .icon { width: 17px; height: 17px; }
.upload-actions { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 16px; }
.upload-actions p { max-width: 520px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.primary-button { min-height: 42px; display: inline-flex; align-items: center; gap: 20px; padding: 10px 16px 10px 18px; border: 0; border-radius: 10px; color: white; background: var(--accent); cursor: pointer; font-size: 13px; font-weight: 600; transition: background .18s, transform .18s, opacity .18s; }
.primary-button:hover:not(:disabled) { background: #2869b6; }
.primary-button:disabled { opacity: .42; cursor: not-allowed; }
.button-arrow { font-size: 17px; font-weight: 400; line-height: 1; }
.form-error { margin: 10px 0 0; color: var(--danger); font-size: 12px; }

.status-bar { display: flex; align-items: flex-start; gap: 18px; min-height: 112px; margin-top: 14px; padding: 22px 24px; }
.status-bar[hidden] { display: none; }
.status-bar.processing { border-left: 3px solid var(--accent); }
.status-bar.success { border-left: 3px solid var(--success); }
.status-bar.error { border-left: 3px solid var(--danger); }
.status-indicator { width: 12px; height: 12px; flex: none; margin-top: 5px; border-radius: 50%; background: var(--accent); animation: status-pulse 1.4s ease-in-out infinite; }
.status-bar.success .status-indicator { background: var(--success); animation: none; }
.status-bar.error .status-indicator { background: var(--danger); animation: none; }
.status-content { min-width: 0; flex: 1; }
.status-content > strong { display: block; font-size: 16px; font-weight: 600; line-height: 1.4; }
.status-content > span { display: block; overflow: hidden; margin-top: 4px; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.pipeline { display: flex; align-items: center; max-width: 520px; margin-top: 18px; }
.pipeline-step { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 12px; font-weight: 600; white-space: nowrap; transition: color .2s; }
.pipeline-step i { position: relative; width: 22px; height: 22px; display: grid; place-items: center; flex: none; border: 1.5px solid var(--border-strong); border-radius: 50%; color: var(--faint); background: var(--surface); font-size: 11px; font-style: normal; font-weight: 600; transition: border-color .2s, background .2s, color .2s; }
.pipeline-step.current { color: var(--accent); }
.pipeline-step.current i { border-color: var(--accent); color: var(--accent); }
.pipeline-step.current i::before { content: ""; position: absolute; inset: -5px; border: 1.5px solid transparent; border-top-color: var(--accent); border-radius: 50%; animation: step-spin .9s linear infinite; }
.pipeline-step.done { color: var(--muted); }
.pipeline-step.done i { border-color: var(--accent); color: transparent; background: var(--accent); }
.pipeline-step.done i::after { content: ""; position: absolute; top: 50%; left: 50%; width: 9px; height: 5px; border-bottom: 2px solid #fff; border-left: 2px solid #fff; transform: translate(-50%, -65%) rotate(-45deg); }
.pipeline-line { position: relative; width: 64px; height: 2px; flex: none; margin: 0 12px; border-radius: 1px; background: var(--border); }
.pipeline-line b { position: absolute; inset: 0; border-radius: inherit; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .35s ease; }
.pipeline-line.done b { transform: scaleX(1); }
.status-bar.error .pipeline-step.current { color: var(--danger); }
.status-bar.error .pipeline-step.current i { border-color: var(--danger); color: transparent; }
.status-bar.error .pipeline-step.current i::before { display: none; }
.status-bar.error .pipeline-step.current i::after { content: "\D7"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--danger); font-size: 14px; font-weight: 600; }

.empty-state { padding: 70px 20px 56px; text-align: center; }
.waveform { height: 56px; display: flex; align-items: center; justify-content: center; gap: 5px; margin-bottom: 22px; color: var(--accent); }
.waveform i { width: 3px; height: var(--bar-height, 20px); border-radius: 3px; background: currentColor; opacity: var(--bar-opacity, .32); }
.waveform i:nth-child(1), .waveform i:nth-child(11) { --bar-height: 12px; --bar-opacity: .2; }
.waveform i:nth-child(2), .waveform i:nth-child(10) { --bar-height: 22px; --bar-opacity: .3; }
.waveform i:nth-child(3), .waveform i:nth-child(9) { --bar-height: 34px; --bar-opacity: .45; }
.waveform i:nth-child(4), .waveform i:nth-child(8) { --bar-height: 48px; --bar-opacity: .7; }
.waveform i:nth-child(5), .waveform i:nth-child(7) { --bar-height: 30px; --bar-opacity: .52; }
.waveform i:nth-child(6) { --bar-height: 54px; --bar-opacity: 1; }
.empty-state h2 { margin: 0; font-size: 20px; letter-spacing: -.03em; }
.empty-state > p { max-width: 560px; margin: 9px auto 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.guide-steps { display: grid; grid-template-columns: repeat(3, 1fr); max-width: 640px; margin: 36px auto 0; border-top: 1px solid var(--border); }
.guide-steps > div { padding: 15px 12px 0; }
.guide-steps span { color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.guide-steps p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }

.result-section { margin-top: 14px; }
.result-overview { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); min-height: 330px; overflow: hidden; }
.result-primary { padding: 30px; border-right: 1px solid var(--border); }
.result-label-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.verdict-badge { padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); background: var(--surface-subtle); font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.verdict-badge.pure { border-color: #e4c1bf; color: var(--danger); background: var(--danger-soft); }
.verdict-badge.likely { border-color: #e5d2ad; color: var(--warning); background: var(--warning-soft); }
.verdict-badge.human { border-color: #c3dfd3; color: var(--success); background: var(--success-soft); }
.score-row { margin-top: 34px; line-height: .9; letter-spacing: -.06em; }
.score-number { font-size: clamp(72px, 11vw, 110px); font-weight: 700; }
.score-number.pure { color: var(--danger); }
.score-number.likely { color: var(--warning); }
.score-number.human { color: var(--success); }
.score-unit { margin-left: 7px; color: var(--muted); font-size: 27px; font-weight: 500; letter-spacing: -.03em; }
.score-label { margin: 14px 0 24px; color: var(--muted); font-size: 12px; }
/* Numeric UI uses tabular figures so digits align when scanned */
.score-row, .quota-pill, .fact strong, .source-topline, .stem-button strong,
.stem-meta strong, .history-score, .segment-ratios, .segment-probability {
  font-variant-numeric: tabular-nums;
}
.probability-track { height: 6px; overflow: hidden; border-radius: 4px; background: linear-gradient(90deg, #d9e5df 0 35%, #ece7d9 35% 70%, #ead9d7 70% 100%); }
.probability-track span { display: block; width: 0; height: 100%; border-radius: inherit; transform-origin: left; }
.probability-track span.pure { background: var(--danger); }
.probability-track span.likely { background: var(--warning); }
.probability-track span.human { background: var(--success); }
.thresholds { display: flex; justify-content: space-between; margin-top: 7px; color: var(--faint); font-size: 9px; }
.thresholds span:first-child { color: var(--success); }
.thresholds span:nth-child(2) { color: var(--warning); }
.thresholds span:last-child { color: var(--danger); }
.result-facts { display: grid; grid-template-columns: 1fr 1fr; }
.fact { min-width: 0; padding: 23px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
.fact:nth-child(2n) { border-right: 0; }
.fact:nth-last-child(-n + 2) { border-bottom: 0; }
.fact.featured { grid-column: 1 / -1; padding-top: 30px; background: var(--accent-soft); }
.fact.featured + .fact { grid-column: 1 / -1; }
.fact span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.fact strong { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.fact.featured strong { color: var(--accent); font-size: 28px; letter-spacing: -.03em; }

.detail-card { margin-top: 14px; padding: 25px 28px 28px; }
.detail-heading { display: flex; justify-content: space-between; gap: 28px; margin-bottom: 20px; }
.detail-heading > p { max-width: 390px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; text-align: right; }
.active-stem-label { color: var(--ink); }
.stem-selector { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.stem-button { min-width: 0; display: grid; gap: 5px; padding: 17px; border: 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: #fafbfc; cursor: pointer; text-align: left; transition: background .18s, transform .18s; }
.stem-button:hover { background: var(--surface-subtle); }
.stem-button:active { transform: scale(.99); }
.stem-button.active { background: var(--accent-soft); box-shadow: inset 0 3px 0 var(--accent); }
.stem-button-label { overflow: hidden; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .05em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.stem-button strong { font-size: 27px; line-height: 1; letter-spacing: -.04em; }
.stem-button small { color: var(--muted); font-size: 10px; }
.stem-button > i { height: 3px; overflow: hidden; margin-top: 4px; border-radius: 2px; background: #e1e5e9; }
.stem-button > i span { display: block; height: 100%; border-radius: inherit; }
.stem-button.pure strong, .stem-button.pure small { color: var(--danger); }
.stem-button.likely strong, .stem-button.likely small { color: var(--warning); }
.stem-button.human strong, .stem-button.human small { color: var(--success); }
.stem-button.pure > i span { background: var(--danger); }
.stem-button.likely > i span { background: var(--warning); }
.stem-button.human > i span { background: var(--success); }
.stem-meta { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 18px; border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.stem-meta > div { min-width: 0; padding: 13px 15px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.stem-meta span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 9px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; }
.stem-meta strong { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.stem-meta strong.pure { color: var(--danger); }
.stem-meta strong.likely { color: var(--warning); }
.stem-meta strong.human { color: var(--success); }
#activeStemModel { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; }
.source-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.source-item { padding: 15px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: #fafbfc; }
.source-item.active { background: var(--accent-soft); }
.source-topline { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; font-weight: 600; }
.source-topline strong { font-size: 13px; font-weight: 700; }
.source-bar { height: 3px; margin-top: 10px; overflow: hidden; border-radius: 2px; background: #e2e6ea; }
.source-bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.detail-empty { margin: 0; padding: 28px 18px; border: 1px dashed var(--border-strong); border-radius: 10px; color: var(--muted); background: var(--surface-subtle); font-size: 12px; text-align: center; }

.segment-ratios { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 20px; padding: 15px 17px; border: 1px solid var(--border); background: var(--surface-subtle); }
.segment-ratios > div { display: grid; grid-template-columns: 48px 1fr 40px; align-items: center; gap: 9px; }
.segment-ratios span, .segment-ratios strong { font-size: 10px; }
.segment-ratios strong { text-align: right; }
.segment-ratios > div:first-child > span, .segment-ratios > div:first-child > strong { color: var(--danger); }
.segment-ratios > div:last-child > span, .segment-ratios > div:last-child > strong { color: var(--success); }
.ratio-track { height: 6px; overflow: hidden; border-radius: 3px; background: #dde1e5; }
.ratio-fill { display: block; height: 100%; border-radius: inherit; }
.ratio-fill.ai { background: var(--danger); }
.ratio-fill.human { background: var(--success); }
.segment-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 9px; color: var(--muted); font-size: 10px; }
.segment-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.legend-swatch { width: 9px; height: 9px; border-radius: 2px; }
.legend-swatch.pure, .segment-block.pure { background: var(--danger); }
.legend-swatch.likely, .segment-block.likely { background: var(--warning); }
.legend-swatch.human, .segment-block.human { background: var(--success); }
.segment-timeline { position: relative; height: 36px; overflow: hidden; border-radius: 7px; background: #e8ebee; }
.segment-block { position: absolute; top: 0; height: 100%; min-width: 2px; border-right: 1px solid rgb(255 255 255 / 72%); opacity: .92; }
.timeline-labels { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: 9px; }
.segment-list { display: grid; margin-top: 17px; border-top: 1px solid var(--border); }
.segment-row { display: grid; grid-template-columns: 130px 1fr auto; align-items: center; gap: 14px; padding: 11px 3px; border-bottom: 1px solid var(--border); }
.segment-time { font: 10px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.segment-result { display: grid; gap: 1px; }
.segment-result strong { font-size: 11px; }
.segment-result strong.pure { color: var(--danger); }
.segment-result strong.likely { color: var(--warning); }
.segment-result strong.human { color: var(--success); }
.segment-result small { color: var(--muted); font-size: 10px; }
.segment-probability { min-width: 64px; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 600; text-align: center; }
.segment-probability.pure { color: var(--danger); background: var(--danger-soft); }
.segment-probability.likely { color: var(--warning); background: var(--warning-soft); }
.segment-probability.human { color: var(--success); background: var(--success-soft); }

.raw-details { margin-top: 14px; overflow: hidden; }
.raw-details summary { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; cursor: pointer; font-size: 12px; font-weight: 700; list-style: none; }
.raw-details summary::-webkit-details-marker { display: none; }
.raw-details summary .icon { width: 16px; height: 16px; transition: transform .2s; }
.raw-details[open] summary .icon { transform: rotate(180deg); }
.raw-body { position: relative; border-top: 1px solid var(--border); background: #f5f6f8; }
.raw-body pre { max-height: 300px; margin: 0; padding: 54px 18px 18px; overflow: auto; color: #4d535c; font: 11px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.copy-button { position: absolute; top: 12px; right: 14px; z-index: 1; display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 7px; color: var(--muted); background: var(--surface); cursor: pointer; font-size: 10px; font-weight: 700; }
.copy-button .icon { width: 14px; height: 14px; }

.history-handle { position: fixed; top: 50%; right: 0; z-index: 20; display: inline-flex; align-items: center; gap: 7px; padding: 11px 10px; border: 0; border-radius: 10px 0 0 10px; color: white; background: var(--ink); cursor: pointer; font-size: 11px; font-weight: 600; writing-mode: vertical-rl; }
.history-handle .icon { width: 16px; height: 16px; }
.history-count { min-width: 18px; height: 18px; display: grid; place-items: center; border-radius: 999px; color: white; background: var(--accent); font-size: 9px; writing-mode: horizontal-tb; }
.drawer-scrim { position: fixed; inset: 0; z-index: 29; background: rgb(21 23 27 / 24%); opacity: 0; transition: opacity .25s; }
.drawer-scrim.open { opacity: 1; }
.history-panel { position: fixed; inset: 0 0 0 auto; z-index: 30; width: min(360px, 92vw); padding: 23px; overflow-y: auto; border-left: 1px solid var(--border); background: var(--surface); box-shadow: -12px 0 40px rgb(20 25 32 / 12%); transform: translateX(101%); transition: transform .3s cubic-bezier(.16, 1, .3, 1); }
.history-panel.open { transform: translateX(0); }
.history-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.history-list { padding: 14px 0; }
.history-empty { padding: 44px 12px; color: var(--muted); font-size: 12px; line-height: 1.6; text-align: center; }
.history-item { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; width: 100%; padding: 12px 3px; border: 0; border-bottom: 1px solid var(--border); background: transparent; cursor: pointer; text-align: left; }
.history-item:hover strong { color: var(--accent); }
.history-item strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.history-item .history-score { grid-row: 1 / 3; grid-column: 2; align-self: center; font-size: 18px; font-weight: 700; }
.history-score.pure { color: var(--danger); }
.history-score.likely { color: var(--warning); }
.history-score.human { color: var(--success); }
.history-item small { color: var(--muted); font-size: 10px; }
.clear-history { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; }
.clear-history:hover { color: var(--danger); border-color: #e4c1bf; background: var(--danger-soft); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; max-width: min(440px, calc(100% - 32px)); padding: 10px 15px; border-radius: 9px; color: white; background: var(--ink); box-shadow: 0 8px 28px rgb(20 25 32 / 18%); font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.admin-scrim { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgb(21 23 27 / 32%); opacity: 0; transition: opacity .2s; }
.admin-scrim.open { opacity: 1; }
.admin-dialog { width: min(360px, 100%); padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 16px 48px rgb(20 25 32 / 18%); }
.admin-dialog h2 { margin: 0 0 6px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.admin-dialog > p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.admin-dialog input { width: 100%; height: 38px; margin-top: 14px; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 8px; color: var(--ink); background: var(--surface); font-size: 13px; }
.admin-dialog input:focus { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
.admin-error { margin: 8px 0 0; color: var(--danger); font-size: 12px; }
.admin-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.ghost-button { min-height: 36px; padding: 7px 13px; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); background: var(--surface); cursor: pointer; font-size: 12px; font-weight: 600; transition: color .18s, background .18s; }
.ghost-button:hover { color: var(--ink); background: var(--surface-subtle); }
.admin-submit { min-height: 36px; gap: 0; padding: 7px 14px; }

.site-footer { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; text-align: center; }

@keyframes status-pulse { 50% { opacity: .28; transform: scale(.76); } }
@keyframes step-spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .shell { width: min(100% - 28px, 1040px); padding-top: 18px; }
  .site-header { flex-direction: column; gap: 15px; }
  .header-actions { width: 100%; justify-content: space-between; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 14px; }
  .upload-card { padding: 18px; }
  .drop-zone { min-height: 200px; padding: 22px 15px; }
  .upload-actions { align-items: stretch; flex-direction: column; gap: 12px; }
  .primary-button { justify-content: space-between; width: 100%; }
  .status-bar { gap: 14px; min-height: 104px; padding: 18px; }
  .status-indicator { width: 11px; height: 11px; }
  .pipeline { max-width: 100%; margin-top: 14px; }
  .pipeline-step { gap: 6px; font-size: 11px; }
  .pipeline-step i { width: 20px; height: 20px; font-size: 10px; }
  .pipeline-line { width: auto; min-width: 16px; flex: 1; margin: 0 7px; }
  .result-overview { grid-template-columns: 1fr; }
  .result-primary { padding: 23px; border-right: 0; border-bottom: 1px solid var(--border); }
  .score-number { font-size: 78px; }
  .detail-heading { flex-direction: column; gap: 8px; }
  .detail-heading > p { text-align: left; }
  .stem-meta { grid-template-columns: 1fr 1fr; }
  .source-list { grid-template-columns: 1fr 1fr; }
  .segment-ratios { grid-template-columns: 1fr; gap: 10px; }
  .history-handle { top: auto; right: 14px; bottom: 15px; border-radius: 10px; writing-mode: horizontal-tb; }
}

@media (max-width: 480px) {
  .quota-pill { max-width: 180px; }
  .quota-pill span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .guide-steps { grid-template-columns: 1fr; gap: 0; max-width: 240px; }
  .guide-steps > div { display: grid; grid-template-columns: 28px 1fr; align-items: center; padding-top: 10px; text-align: left; }
  .guide-steps p { margin: 0; }
  .stem-selector { grid-template-columns: 1fr; }
  .stem-button { grid-template-columns: 1fr auto; align-items: center; }
  .stem-button small, .stem-button > i { grid-column: 1 / -1; }
  .source-list { grid-template-columns: 1fr; }
  .segment-row { grid-template-columns: 105px 1fr auto; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  body { background: white; }
  .shell { width: 100%; padding: 0; }
  .site-header { padding-top: 0; }
  .header-actions, .upload-card, .status-bar, .empty-state, .history-handle, .history-panel, .drawer-scrim, .admin-scrim, .raw-details { display: none !important; }
  .result-overview, .detail-card { break-inside: avoid; box-shadow: none; }
}
