:root {
  color-scheme: light dark;
  --bg: #f2f5f2;
  --surface: #ffffff;
  --surface-soft: #e8efeb;
  --text: #16201d;
  --muted: #65716d;
  --line: #d8e0dc;
  --brand: #0b6b56;
  --brand-deep: #064d3e;
  --brand-soft: #dceee7;
  --rise: #c94039;
  --fall: #16835e;
  --warn: #9a6612;
  --danger: #b4322e;
  --shadow: 0 18px 45px rgba(21, 43, 35, 0.10);
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-width: 320px; }
button, input { font: inherit; }
button { color: inherit; }
.app-shell { min-height: 100dvh; }
.hidden { display: none !important; }

.product-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  min-height: 62px; padding: max(10px, env(safe-area-inset-top)) 18px 10px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 9px; border: 0; padding: 0; background: transparent; font-weight: 760; }
.brand-mark, .hero-mark {
  display: grid; place-items: center; color: white; background: var(--brand);
  font-family: "Songti SC", serif; font-weight: 800;
}
.brand-mark { width: 34px; height: 34px; border-radius: 9px; }
.step-chip { padding: 6px 9px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: 12px; }

.home-view { width: min(100%, 580px); margin: 0 auto; padding: max(52px, env(safe-area-inset-top)) 22px 28px; }
.home-hero { text-align: center; padding: 28px 0 30px; }
.hero-kicker, .eyebrow, .card-kicker { color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.hero-mark { width: 72px; height: 72px; margin: 20px auto 18px; border-radius: 18px; box-shadow: var(--shadow); font-size: 30px; }
.home-hero h1 { margin: 0; font-size: clamp(30px, 9vw, 42px); letter-spacing: -.04em; }
.home-hero p { max-width: 360px; margin: 12px auto 0; color: var(--muted); line-height: 1.7; }
.home-actions { display: grid; gap: 12px; }
.status-badge { display: inline-flex; align-items: center; margin-left: .35rem; padding: .12rem .42rem; border-radius: 999px; font-size: .68rem; font-style: normal; font-weight: 800; vertical-align: .12rem; }
.status-badge.beta { color: #8a4b00; background: #fff0c7; }
.status-badge.stable { color: #087748; background: #dff8ec; }
.ocr-beta-note { margin: -.35rem 0 1rem; color: var(--muted); font-size: .82rem; line-height: 1.55; text-align: center; }
.primary-action, .secondary-action {
  width: 100%; min-height: 82px; display: flex; align-items: center; gap: 16px; text-align: left;
  padding: 18px; border-radius: 16px; cursor: pointer;
}
.primary-action { color: white; background: var(--brand); border: 1px solid var(--brand); box-shadow: var(--shadow); }
.secondary-action { color: var(--text); background: var(--surface); border: 1px solid var(--line); }
.primary-action input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.action-icon { display: grid; place-items: center; flex: 0 0 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,.14); font-size: 24px; }
.secondary-action .action-icon { color: var(--brand); background: var(--brand-soft); }
.home-actions strong { display: block; font-size: 17px; }
.home-actions small { display: block; margin-top: 5px; opacity: .72; }
.privacy-card { display: flex; gap: 12px; margin-top: 22px; padding: 15px; border: 1px solid color-mix(in srgb, var(--brand) 25%, var(--line)); background: var(--brand-soft); border-radius: 14px; }
.privacy-icon { display: grid; place-items: center; flex: 0 0 28px; height: 28px; border-radius: 50%; color: white; background: var(--brand); }
.privacy-card strong { font-size: 14px; }
.privacy-card p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.home-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 18px; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: 13px; }
.home-meta div { display: grid; gap: 5px; padding: 14px; background: var(--surface); }
.home-meta span { color: var(--muted); font-size: 11px; }
.home-meta strong { font-size: 14px; }
.text-button { width: 100%; margin-top: 16px; padding: 13px; border: 0; background: transparent; color: var(--brand); cursor: pointer; }
.text-button.muted { color: var(--muted); cursor: default; }

.content-view { width: min(100%, 720px); margin: 0 auto; padding: 28px 18px 42px; }
.compact-view { width: min(100%, 520px); }
.screen-heading { margin-bottom: 24px; }
.screen-heading h1, .result-intro h1 { margin: 7px 0 8px; font-size: clamp(28px, 8vw, 38px); letter-spacing: -.04em; }
.screen-heading p, .section-title p { margin: 0; color: var(--muted); line-height: 1.65; }
.ocr-preview { display: block; max-width: 260px; max-height: 420px; margin: 0 auto 20px; border-radius: 12px; box-shadow: var(--shadow); }
.progress-card { padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; }
.progress-track { height: 8px; overflow: hidden; margin-bottom: 16px; background: var(--surface-soft); border-radius: 999px; }
.progress-track span { display: block; height: 100%; background: var(--brand); transition: width .22s ease; }
.progress-card p { margin: 8px 0 0; color: var(--muted); }
.notice { margin-bottom: 16px; padding: 16px; border: 1px solid var(--line); border-radius: 13px; line-height: 1.6; }
.notice.error { color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.notice.warning { color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }

.source-preview { margin-bottom: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
summary { cursor: pointer; color: var(--brand); font-weight: 750; }
.source-preview img { display: block; max-width: 220px; max-height: 380px; margin: 15px auto; }
.ocr-evidence { display: grid; gap: 6px; }
.ocr-evidence span { padding: 7px 9px; border-radius: 7px; background: var(--surface-soft); color: var(--muted); font-size: 12px; }
.ocr-evidence span.bad { color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.confirm-form { display: grid; gap: 14px; }
.form-section { padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.form-section h2 { margin: 0 0 16px; font-size: 17px; }
.form-section > p { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.form-section > .distribution-note { margin: -7px 0 14px; padding: 9px 11px; border-left: 3px solid var(--brand); background: var(--surface-soft); line-height: 1.55; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.input-field { display: grid; gap: 7px; min-width: 0; }
.field-diagnostic, .inference-candidate { grid-column: 1 / -1; display: block; margin-top: .35rem; color: #8a5a00; font-size: .75rem; line-height: 1.45; }
.field-diagnostic.conflict { color: var(--danger); font-weight: 700; }
.inference-candidate button { margin-left: .3rem; padding: .22rem .48rem; border: 1px solid currentColor; border-radius: .45rem; color: inherit; background: transparent; font: inherit; font-weight: 800; }
.input-field > span { display: flex; align-items: center; justify-content: space-between; min-height: 20px; color: var(--muted); font-size: 12px; }
.input-shell { display: flex; align-items: center; min-height: 48px; padding: 0 12px; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; }
.input-shell:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent); }
.input-shell input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 17px; font-weight: 720; }
.input-shell b { color: var(--muted); }
.confidence { margin-left: 6px; padding: 3px 6px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 10px; }
.confidence.medium { color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); }
.confidence.low { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.field-alert .input-shell, .validation-error .input-shell { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 5%, var(--surface)); }
.subset-field { grid-column: 1 / -1; margin: 2px 0 0 18px; padding: 10px 0 0 14px; border-left: 2px solid color-mix(in srgb, var(--brand) 40%, var(--line)); }
.subset-field .input-shell { max-width: calc(50% - 15px); }
.subset-field > span { justify-content: flex-start; gap: 8px; color: var(--brand); font-weight: 720; }
.segment-status { display: grid; gap: 3px; margin-top: 14px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); }
.segment-status span { font-size: 13px; }
.segment-status small { color: var(--muted); line-height: 1.45; }
.segment-status.valid { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); background: var(--brand-soft); }
.segment-status.invalid { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }
.date-section .input-field { max-width: 280px; }
.validation-box { display: grid; gap: 6px; margin: 16px 0; padding: 15px 16px; border-radius: 13px; border: 1px solid var(--line); }
.validation-box.valid { color: var(--brand); background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.validation-box.invalid { color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.validation-box span, .validation-box li { font-size: 12px; line-height: 1.5; }
.validation-box ul { margin: 3px 0 0; padding-left: 18px; }
.button { width: 100%; min-height: 52px; margin-top: 10px; border-radius: 12px; border: 1px solid transparent; font-weight: 780; cursor: pointer; }
.button.primary { color: white; background: var(--brand); }
.button.ghost { color: var(--text); background: var(--surface); border-color: var(--line); }
.button:disabled { opacity: .42; cursor: not-allowed; }

.result-view { width: min(100%, 760px); }
.result-intro { padding: 8px 2px 20px; }
.market-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.market-summary div { display: grid; gap: 5px; padding: 13px 10px; background: var(--surface); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.market-summary span { color: var(--muted); font-size: 11px; }
.market-summary strong { font-size: 16px; }
.rise { color: var(--rise); }
.fall { color: var(--fall); }
.conclusion-card, .reliability-card, .metric-card { margin-top: 14px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 7px 24px rgba(21,43,35,.05); }
.conclusion-card { border-top: 5px solid var(--brand); }
.conclusion-main { display: flex; align-items: end; justify-content: space-between; margin-top: 8px; }
.conclusion-main h2 { margin: 0; font-size: 32px; letter-spacing: -.04em; }
.conclusion-main > strong { font-size: 42px; line-height: 1; color: var(--brand); }
.conclusion-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 20px; overflow: hidden; border: 1px solid var(--line); background: var(--line); border-radius: 10px; }
.conclusion-stats div, .split-concepts div { display: grid; gap: 5px; padding: 12px; background: var(--surface-soft); }
.conclusion-stats span, .split-concepts span { color: var(--muted); font-size: 11px; }
.split-concepts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.split-concepts div { border-radius: 10px; }
.conclusion-card > p, .reliability-card > p { margin: 16px 0 0; color: var(--muted); line-height: 1.7; }
.very-strong { --accent: #0b6b56; }
.strong { --accent: #31876c; }
.normal { --accent: #6c7b76; }
.weak { --accent: #b27425; }
.very-weak { --accent: #b8403b; }
.conclusion-card { border-top-color: var(--accent, var(--brand)); }
.conclusion-card .conclusion-main > strong { color: var(--accent, var(--brand)); }
.reliability-card > div:first-child { display: flex; align-items: end; justify-content: space-between; }
.reliability-card h2 { margin: 0; font-size: 28px; }
.model-strip { display: grid !important; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 14px; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: 10px; }
.model-strip span { display: grid; gap: 4px; padding: 11px 8px; background: var(--surface-soft); color: var(--muted); text-align: center; font-size: 11px; }
.model-strip strong { color: var(--text); font-size: 15px; }
.reliability-card details { margin-top: 14px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.detail-grid span { display: grid; gap: 4px; padding: 10px; border-radius: 8px; background: var(--surface-soft); color: var(--muted); font-size: 11px; }
.detail-grid strong { color: var(--text); }

.metrics-section, .commentary-section, .similar-section { margin-top: 36px; }
.section-title { margin: 0 3px 16px; }
.section-title > span { color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.section-title h2 { margin: 4px 0 6px; font-size: 24px; letter-spacing: -.03em; }
.metric-card { position: relative; overflow: hidden; }
.metric-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent, var(--brand)); }
.metric-title { display: flex; align-items: center; justify-content: space-between; }
.metric-title h3 { margin: 0; font-size: 17px; }
.metric-title > span { padding: 5px 8px; border-radius: 999px; color: var(--accent, var(--brand)); background: color-mix(in srgb, var(--accent, var(--brand)) 10%, var(--surface)); font-size: 11px; font-weight: 800; }
.metric-value { margin: 12px 0; font-size: 32px; font-weight: 820; letter-spacing: -.04em; }
.percentile-rail { position: relative; height: 7px; margin: 20px 0 12px; background: var(--surface-soft); border-radius: 999px; }
.percentile-rail span { display: block; height: 100%; background: var(--accent, var(--brand)); border-radius: 999px; }
.percentile-rail i { position: absolute; top: 50%; width: 14px; height: 14px; border: 3px solid var(--surface); border-radius: 50%; background: var(--accent, var(--brand)); transform: translate(-50%, -50%); box-shadow: 0 0 0 1px var(--accent, var(--brand)); }
.direction-note { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.metric-reference { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.metric-reference div { display: grid; gap: 4px; padding: 9px; border-radius: 8px; background: var(--surface-soft); }
.metric-reference span { color: var(--muted); font-size: 10px; }
.metric-reference strong { font-size: 13px; }
.metric-details { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.detail-stack { display: grid; gap: 8px; margin-top: 12px; }
.detail-row { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; padding: 10px; background: var(--surface-soft); border-radius: 8px; }
.detail-row strong { grid-column: 1 / -1; }
.detail-row span { color: var(--muted); font-size: 11px; }
.metric-card.unavailable { opacity: .72; }
.metric-card.unavailable p { color: var(--muted); }
.commentary-card { overflow: hidden; border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line)); background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); }
.commentary-structure { padding: 20px; color: white; background: linear-gradient(135deg, var(--brand-deep), var(--brand)); }
.commentary-structure span { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; opacity: .78; }
.commentary-structure h3 { margin: 7px 0 0; font-size: clamp(21px, 6vw, 29px); line-height: 1.25; letter-spacing: -.03em; }
.commentary-dimensions { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.commentary-dimensions div { display: grid; gap: 5px; padding: 13px 15px; background: var(--surface-soft); }
.commentary-dimensions span { color: var(--muted); font-size: 11px; }
.commentary-dimensions strong { font-size: 14px; }
.commentary-copy { padding: 18px 20px 6px; }
.commentary-copy p { margin: 0 0 13px; color: var(--text); font-size: 14px; line-height: 1.75; }
.commentary-copy p + p { padding-top: 2px; }
.commentary-evidence { margin: 0 20px 18px; padding-top: 13px; border-top: 1px solid var(--line); }
.commentary-evidence > div { display: grid; gap: 8px; margin-top: 13px; }
.commentary-evidence p { display: grid; gap: 4px; margin: 0; padding: 10px 11px; background: var(--surface-soft); border-radius: 9px; }
.commentary-evidence strong { color: var(--brand); font-size: 11px; letter-spacing: .05em; }
.commentary-evidence span { color: var(--muted); font-size: 12px; line-height: 1.5; }
.similar-list { display: grid; gap: 8px; }
.similar-list article { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 11px; }
.similar-list article > b { color: var(--muted); font-size: 12px; }
.similar-list article > div { display: grid; gap: 3px; min-width: 0; }
.similar-list article > div:last-child { text-align: right; }
.similar-list span { color: var(--muted); font-size: 10px; white-space: nowrap; }
.method-note { margin: 24px 0 16px; padding: 16px; border-left: 4px solid var(--brand); background: var(--surface-soft); }
.method-note p { margin: 7px 0; color: var(--muted); line-height: 1.6; }
.method-note span { color: var(--muted); font-size: 11px; }
.data-footer { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 18px; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; text-align: center; }
.about-tool { margin: 18px 0 4px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.about-tool summary { color: var(--brand); font-size: 14px; font-weight: 750; cursor: pointer; }
.about-content { margin-top: 14px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.about-content p { margin: 10px 0; }
.about-content dl { display: grid; gap: 8px; margin: 14px 0; }
.about-content dl > div { display: grid; grid-template-columns: minmax(95px, 1fr) minmax(0, 2fr); gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.about-content dt { color: var(--muted); }
.about-content dd { min-width: 0; margin: 0; color: var(--text); font-weight: 650; overflow-wrap: anywhere; }
.about-content .hash-value { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; }
.freshness-notice, .update-notice { margin-top: 14px; line-height: 1.6; }
.update-notice .text-button { display: inline; width: auto; min-height: 0; margin-left: 4px; padding: 0; }

@media (max-width: 400px) {
  .content-view { padding-inline: 13px; }
  .field-grid { gap: 9px; }
  .form-section { padding: 14px; }
  .input-shell { padding-inline: 9px; }
  .subset-field .input-shell { max-width: 100%; }
  .metric-reference { grid-template-columns: 1fr; }
  .similar-list article { grid-template-columns: 26px minmax(0, 1fr); }
  .similar-list article > div:last-child { grid-column: 2; grid-template-columns: 1fr 1fr; text-align: left; }
}

@media (min-width: 720px) {
  .metrics-section { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .metrics-section .section-title { grid-column: 1 / -1; }
  .metric-card { margin-top: 0; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1513;
    --surface: #18201d;
    --surface-soft: #222c28;
    --text: #edf3f0;
    --muted: #9eaba6;
    --line: #303b37;
    --brand: #46b08e;
    --brand-deep: #bde9da;
    --brand-soft: #17352d;
    --rise: #ef7c72;
    --fall: #52c896;
    --shadow: 0 18px 45px rgba(0, 0, 0, .30);
  }
  .primary-action, .button.primary { color: #061b15; }
  .brand-mark, .hero-mark, .privacy-icon { color: #061b15; }
  .commentary-structure { color: #061b15; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
