:root {
  color-scheme: light;
  --ink: #0b1320;
  --muted: #607083;
  --line: #dfe5ec;
  --line-strong: #cbd5df;
  --surface: #ffffff;
  --surface-soft: #f5f7fa;
  --surface-deep: #edf2f7;
  --accent: #0d6b66;
  --accent-strong: #084f4b;
  --accent-soft: #e7f4f2;
  --danger: #a83a3a;
  --shadow: 0 16px 45px rgba(17, 31, 48, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 10% -10%, rgba(13,107,102,.10), transparent 34rem),
    linear-gradient(180deg, #f7f9fb 0, #f1f4f7 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 42px 0 30px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 26px; }
.eyebrow { margin: 0 0 7px; color: var(--accent); font-weight: 760; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(30px, 4vw, 48px); line-height: 1.1; letter-spacing: -.035em; }
.subhead { max-width: 660px; margin: 10px 0 0; color: var(--muted); font-size: 16px; }
.version-pill { flex: none; margin-top: 4px; border: 1px solid #b8d7d4; background: var(--accent-soft); color: var(--accent-strong); border-radius: 999px; padding: 8px 12px; font-size: 12px; font-weight: 750; }

.work-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, .8fr); gap: 18px; align-items: start; }
.panel { background: rgba(255,255,255,.94); border: 1px solid rgba(207,217,227,.9); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.input-panel, .result-panel, .audit-panel, .list-panel { padding: 24px; }
.result-panel { position: sticky; top: 18px; overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.panel-heading > div:first-child { display: flex; align-items: center; gap: 10px; }
.panel-heading h2 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.panel-heading.compact { margin-bottom: 12px; }
.step { display: inline-grid; place-items: center; min-width: 34px; height: 28px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .05em; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 7px; }
.field > span { font-size: 14px; font-weight: 730; }
.field em { color: var(--muted); font-size: 12px; font-style: normal; font-weight: 500; }
.field input { width: 100%; height: 48px; border: 1px solid var(--line-strong); border-radius: 13px; padding: 0 14px; background: #fff; color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(13,107,102,.10); }
.field small { color: var(--muted); font-size: 12px; }

.counter-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.section-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section-intro h3 { margin: 0; font-size: 15px; }
.section-intro p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.true-total { white-space: nowrap; color: var(--muted); font-size: 12px; }
.true-total strong { color: var(--ink); font-size: 15px; }
.counter-list { display: grid; gap: 8px; }
.counter-row { display: grid; grid-template-columns: minmax(120px, 1fr) auto; align-items: center; gap: 12px; min-height: 54px; padding: 7px 8px 7px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.counter-year { display: flex; align-items: baseline; gap: 8px; font-weight: 720; }
.counter-year small { color: var(--muted); font-weight: 550; }
.counter-control { display: grid; grid-template-columns: 44px 52px 44px; align-items: center; gap: 4px; }
.counter-btn { display: grid; place-items: center; width: 44px; height: 40px; border: 0; border-radius: 11px; background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); font-size: 22px; line-height: 1; cursor: pointer; }
.counter-btn:active { transform: translateY(1px); }
.counter-input { width: 52px; height: 40px; border: 0; background: transparent; color: var(--ink); text-align: center; font-weight: 800; outline: none; -moz-appearance: textfield; }
.counter-input::-webkit-inner-spin-button, .counter-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.validation-box { margin-top: 14px; border-radius: 13px; padding: 11px 13px; background: #fff0f0; color: #8a2929; border: 1px solid #f0caca; font-size: 13px; }
.primary-button, .secondary-button { width: 100%; min-height: 50px; border: 0; border-radius: 14px; font-weight: 780; cursor: pointer; }
.primary-button { margin-top: 18px; background: var(--ink); color: #fff; box-shadow: 0 8px 18px rgba(11,19,32,.16); }
.primary-button:hover { background: #172232; }
.secondary-button { margin-top: 18px; background: var(--accent); color: #fff; }
.secondary-button:hover { background: var(--accent-strong); }
.text-button, .danger-text-button { border: 0; background: transparent; padding: 8px; cursor: pointer; font-size: 13px; font-weight: 700; }
.text-button { color: var(--muted); }
.danger-text-button { color: var(--danger); }

.result-empty { min-height: 310px; display: grid; place-content: center; text-align: center; color: var(--muted); }
.result-empty p { margin: 16px 0 4px; font-weight: 700; color: var(--ink); }
.result-empty small { max-width: 240px; }
.result-orbit { width: 88px; height: 88px; margin: auto; border-radius: 50%; border: 1px solid #c8d5df; display: grid; place-items: center; background: radial-gradient(circle, #fff 45%, var(--surface-deep)); }
.result-orbit span { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 11px var(--accent-soft); }
.result-content { padding: 22px 0 8px; }
.result-label { margin: 0; color: var(--muted); font-size: 14px; font-weight: 700; }
.result-number { display: flex; align-items: baseline; gap: 8px; margin: 5px 0 12px; }
.result-number strong { font-size: clamp(72px, 11vw, 112px); line-height: .95; letter-spacing: -.08em; }
.result-number span { color: var(--muted); font-size: 22px; font-weight: 750; }
.result-tip { margin: 9px 0 0; border-radius: 12px; padding: 10px 12px; background: var(--accent-soft); color: var(--accent-strong); font-size: 13px; font-weight: 650; }
.result-tip.secondary { background: var(--surface-soft); color: var(--muted); font-weight: 550; }
.result-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.result-meta span { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); font-size: 12px; }
.result-meta b { display: block; margin-top: 2px; color: var(--ink); font-size: 16px; }
.debug-box { margin-top: 12px; padding: 10px; border-radius: 10px; background: #111923; color: #d6e2ed; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }

.audit-panel, .list-panel { margin-top: 18px; }
.audit-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.metric { min-height: 92px; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-soft); }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 5px; font-size: 26px; letter-spacing: -.04em; }
.metric.accent { background: var(--accent-soft); border-color: #c7e2df; }
.metric.accent strong { color: var(--accent-strong); }
.audit-note { margin: 12px 0 0; color: var(--muted); font-size: 12px; }
.list-heading { align-items: flex-end; }
.list-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.list-empty { padding: 34px 18px; text-align: center; color: var(--muted); background: var(--surface-soft); border-radius: 14px; border: 1px dashed var(--line-strong); }
.topic-list { display: grid; gap: 9px; }
.topic-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 15px; }
.topic-rank { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 800; }
.topic-main { min-width: 0; }
.topic-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.topic-main p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.topic-k { min-width: 74px; text-align: right; }
.topic-k strong { display: block; font-size: 24px; line-height: 1; }
.topic-k span { color: var(--muted); font-size: 11px; }
.topic-delete { width: 38px; height: 38px; border: 0; border-radius: 10px; background: var(--surface-soft); color: var(--muted); cursor: pointer; font-size: 17px; }
.topic-delete:hover { background: #fff0f0; color: var(--danger); }

footer { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 18px 2px 0; color: #7b8999; font-size: 11px; }
.toast { position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translate(-50%, 12px); min-width: 220px; max-width: min(420px, calc(100% - 32px)); padding: 11px 15px; border-radius: 12px; background: #0f1722; color: #fff; text-align: center; font-size: 13px; box-shadow: 0 12px 36px rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 20; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .app-shell { width: min(760px, calc(100% - 24px)); padding-top: 28px; }
  .work-grid { grid-template-columns: 1fr; }
  .result-panel { position: static; }
  .result-empty { min-height: 190px; }
  .audit-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 560px) {
  .app-shell { width: calc(100% - 20px); padding-top: 20px; }
  .topbar { display: block; }
  .version-pill { display: inline-block; margin-top: 14px; }
  .input-panel, .result-panel, .audit-panel, .list-panel { padding: 17px; border-radius: 20px; }
  .field-grid { grid-template-columns: 1fr; }
  .section-intro { align-items: flex-start; }
  .true-total { padding-top: 3px; }
  .counter-row { grid-template-columns: minmax(0, 1fr) auto; padding-left: 11px; }
  .counter-year { display: block; }
  .counter-year small { display: block; margin-top: 1px; }
  .counter-control { grid-template-columns: 42px 46px 42px; }
  .counter-btn { width: 42px; min-height: 42px; }
  .counter-input { width: 46px; }
  .result-number strong { font-size: 86px; }
  .audit-grid { grid-template-columns: 1fr 1fr; }
  .metric.accent { grid-column: 1 / -1; }
  .list-heading { align-items: flex-start; }
  .list-heading p { display: none; }
  .topic-card { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; }
  .topic-delete { grid-column: 3; grid-row: 2; width: 34px; height: 32px; }
  .topic-k { grid-column: 3; grid-row: 1; }
  .topic-rank { align-self: start; }
}

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