:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-soft: #f7f9fa;
  --ink: #17252e;
  --muted: #64737c;
  --line: #dce3e7;
  --accent: #176b5b;
  --accent-dark: #105348;
  --accent-soft: #e6f2ef;
  --warning: #9a5a12;
  --warning-soft: #fff5e6;
  --danger: #a13d3d;
  --shadow: 0 8px 30px rgba(27, 45, 54, 0.07);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55; }
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid rgba(23, 107, 91, 0.25); outline-offset: 2px; }
button:disabled { cursor: wait; opacity: .6; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 20px; line-height: 1.35; letter-spacing: .02em; }
h2 { margin-bottom: 0; font-size: 20px; line-height: 1.35; }
h3 { margin-bottom: 4px; font-size: 16px; }
[hidden] { display: none !important; }

.app-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { max-width: 1160px; margin: auto; padding: 20px 18px 17px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.eyebrow, .section-kicker { margin-bottom: 4px; color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.save-status { flex: none; padding: 4px 9px; border-radius: 20px; background: var(--accent-soft); color: var(--accent-dark); font-size: 11px; }

.step-nav { display: flex; gap: 4px; overflow-x: auto; padding: 10px 12px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.step-nav::-webkit-scrollbar { display: none; }
.step-button { flex: 1 0 auto; min-width: 82px; min-height: 46px; padding: 6px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.step-button span { display: block; color: #91a0a8; font-size: 10px; letter-spacing: .1em; }
.step-button.active { background: var(--accent-soft); color: var(--accent-dark); }
.step-button.active span { color: var(--accent); }

.app-layout { max-width: 1160px; margin: 0 auto; padding: 16px 12px 40px; }
.workspace { min-width: 0; }
.form-panel, .preview-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.form-panel { padding: 18px 16px; }
.section-heading, .preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-badge { flex: none; padding: 4px 9px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 20px; color: var(--muted); font-size: 11px; }
.section-description { margin-bottom: 16px; color: var(--muted); font-size: 13px; }
.full-width { width: 100%; }
.primary-button { min-height: 48px; margin-top: 18px; padding: 12px 18px; border: 0; border-radius: 11px; background: var(--accent); color: #fff; font-weight: 700; box-shadow: 0 4px 12px rgba(23,107,91,.15); }
.primary-button:active { background: var(--accent-dark); transform: translateY(1px); }

.fixed-info { margin: 0 0 20px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.fixed-info div { display: grid; grid-template-columns: 70px 1fr; gap: 10px; padding: 11px 13px; background: var(--surface-soft); border-bottom: 1px solid var(--line); }
.fixed-info div:last-child { border-bottom: 0; }
.fixed-info dt { color: var(--muted); }
.fixed-info dd { margin: 0; font-weight: 600; }
.field-group { margin: 16px 0; }
.field-group label { display: block; margin-bottom: 7px; font-weight: 650; }
.optional, .required { margin-left: 5px; font-size: 11px; font-weight: 500; }
.optional { color: var(--muted); }
.required { color: var(--danger); }
.field-group input, .field-group select { width: 100%; min-height: 48px; padding: 11px 13px; border: 1px solid #cbd6db; border-radius: 10px; background: #fff; color: var(--ink); }
.field-group select:invalid { color: var(--muted); }
.field-hint { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.field-hint.error { color: var(--danger); }

.progress-track { height: 6px; margin: -4px 0 16px; overflow: hidden; background: #e9edef; border-radius: 6px; }
.progress-track div { width: 0; height: 100%; background: var(--accent); border-radius: inherit; transition: width .2s ease; }
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 18px; }
.quick-actions button { min-height: 44px; padding: 8px 5px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); color: var(--accent-dark); font-size: 12px; }
.rating-group { margin: 0 0 16px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; }
.rating-group-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 13px; background: var(--surface-soft); border-bottom: 1px solid var(--line); }
.rating-group-header h3 { font-size: 15px; }
.rating-group-header p { margin: 0; color: var(--muted); font-size: 11px; }
.group-score { flex: none; text-align: right; color: var(--muted); font-size: 11px; }
.group-score strong { display: block; color: var(--accent-dark); font-size: 20px; line-height: 1.2; }
.rating-item { padding: 14px 12px; border-bottom: 1px solid var(--line); }
.rating-item:last-child { border-bottom: 0; }
.rating-item > p { margin-bottom: 11px; color: #34434b; font-size: 13px; line-height: 1.65; }
.rating-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.rating-option { position: relative; min-width: 0; }
.rating-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.rating-option span { display: flex; min-height: 48px; padding: 5px 2px; align-items: center; justify-content: center; flex-direction: column; border: 1px solid #d5dfe3; border-radius: 8px; background: #fff; color: var(--muted); font-size: 11px; line-height: 1.25; cursor: pointer; }
.rating-option small { margin-top: 3px; font-size: 10px; }
.rating-option input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; box-shadow: inset 0 0 0 1px var(--accent); }
.rating-option input:focus-visible + span { outline: 3px solid rgba(23,107,91,.25); }
.total-card { display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 16px; border-radius: 12px; background: var(--accent-soft); }
.total-card span { font-weight: 700; }
.total-card strong { grid-row: span 2; color: var(--accent-dark); font-size: 32px; }
.total-card small { color: var(--muted); }

.metric-list { display: grid; gap: 12px; }
.metric-card { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.metric-card h3 { margin-bottom: 12px; font-size: 14px; line-height: 1.5; }
.metric-values { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric-picker { min-height: 70px; padding: 8px; border: 1px solid #d4dee2; border-radius: 10px; background: #fff; color: var(--ink); }
.metric-picker small { display: block; color: var(--muted); font-size: 10px; }
.metric-picker strong { color: var(--accent-dark); font-size: 22px; }
.metric-picker em { margin-left: 3px; color: var(--muted); font-size: 11px; font-style: normal; }

.dice-button { min-height: 44px; padding: 8px 11px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; white-space: nowrap; }
.dice-button span { font-size: 19px; vertical-align: -1px; }
.problem-list { display: grid; gap: 12px; }
.problem-card { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; }
.problem-card-header { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; background: var(--surface-soft); border-bottom: 1px solid var(--line); }
.problem-card-header strong { font-size: 13px; }
.problem-random { min-width: 44px; min-height: 38px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--accent-dark); }
.problem-content { padding: 12px; }
.problem-content dl { margin: 0; }
.problem-content dl div { display: grid; grid-template-columns: 62px 1fr; gap: 7px; margin-bottom: 7px; font-size: 12px; }
.problem-content dt { color: var(--muted); }
.problem-content dd { margin: 0; }
.date-field { display: block; margin-top: 10px; color: var(--muted); font-size: 12px; }
.date-field input { display: block; width: 100%; min-height: 44px; margin-top: 5px; padding: 8px 10px; border: 1px solid #cbd6db; border-radius: 8px; background: #fff; color: var(--ink); }
.teacher-note { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; padding: 13px; border-radius: 10px; background: var(--surface-soft); color: var(--muted); font-size: 12px; }
.teacher-note strong { color: var(--ink); }

.validation-message { margin-bottom: 14px; padding: 12px 13px; border: 1px solid #ecd7b5; border-radius: 10px; background: var(--warning-soft); color: var(--warning); font-size: 12px; }
.validation-message.valid { border-color: #c7e0d9; background: var(--accent-soft); color: var(--accent-dark); }
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.export-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.export-thumb { display: block; width: 100%; height: auto; background: #fff; border-bottom: 1px solid var(--line); }
.export-card > div { padding: 10px; }
.export-card strong { display: block; min-height: 34px; font-size: 11px; }
.export-card button { width: 100%; min-height: 42px; margin-top: 7px; padding: 8px 4px; border: 1px solid var(--accent); border-radius: 8px; background: #fff; color: var(--accent-dark); font-size: 11px; font-weight: 700; }
.export-note { margin: 12px 0; color: var(--muted); font-size: 11px; }
.local-help { color: var(--muted); font-size: 12px; }
.local-help summary { min-height: 40px; cursor: pointer; }
.local-help p { margin-bottom: 0; }
code { padding: 2px 4px; border-radius: 4px; background: #edf1f3; color: #34434b; overflow-wrap: anywhere; }

.preview-panel { margin-top: 16px; padding: 16px 12px; }
.preview-heading { margin: 0 4px 12px; }
.preview-size { color: var(--muted); font-size: 10px; }
.page-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 12px; padding: 4px; border-radius: 10px; background: var(--surface-soft); }
.page-tabs button { min-height: 40px; padding: 6px 3px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 11px; }
.page-tabs button[aria-selected="true"] { background: #fff; color: var(--accent-dark); font-weight: 700; box-shadow: 0 1px 5px rgba(20,40,50,.1); }
.canvas-frame { overflow: hidden; border: 1px solid #d7dee1; border-radius: 8px; background: #e7ebed; }
#previewCanvas { display: block; width: 100%; height: auto; background: #fff; }
.preview-caption { margin: 9px 3px 0; color: var(--muted); font-size: 10px; text-align: center; }

.toast { position: fixed; z-index: 30; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); width: max-content; max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 10px; background: rgba(23,37,46,.94); color: #fff; font-size: 13px; text-align: center; box-shadow: 0 8px 25px rgba(0,0,0,.2); opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.wheel-modal { position: fixed; z-index: 50; inset: 0; display: flex; align-items: flex-end; justify-content: center; }
.wheel-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(15,28,35,.42); }
.wheel-sheet { position: relative; width: 100%; max-width: 480px; padding: 9px 20px calc(18px + env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; background: #fff; box-shadow: 0 -12px 40px rgba(0,0,0,.15); }
.sheet-handle { width: 38px; height: 4px; margin: 0 auto 12px; border-radius: 4px; background: #d7dfe2; }
.wheel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wheel-header small { color: var(--muted); }
.wheel-header h2 { font-size: 17px; }
.wheel-header button { min-width: 58px; min-height: 44px; border: 0; background: transparent; color: var(--accent); font-weight: 700; }
.wheel-window { position: relative; height: 220px; margin-top: 10px; overflow: hidden; }
.wheel-window::before, .wheel-window::after { content: ""; position: absolute; z-index: 2; left: 0; right: 0; height: 65px; pointer-events: none; }
.wheel-window::before { top: 0; background: linear-gradient(#fff, rgba(255,255,255,0)); }
.wheel-window::after { bottom: 0; background: linear-gradient(rgba(255,255,255,0), #fff); }
.wheel-highlight { position: absolute; top: 88px; left: 0; right: 0; height: 44px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--accent-soft); pointer-events: none; }
.wheel-options { position: relative; z-index: 1; height: 220px; overflow-y: auto; padding: 88px 0; scroll-snap-type: y mandatory; overscroll-behavior: contain; scrollbar-width: none; }
.wheel-options::-webkit-scrollbar { display: none; }
.wheel-option { display: flex; align-items: center; justify-content: center; height: 44px; scroll-snap-align: center; color: var(--muted); font-size: 21px; font-variant-numeric: tabular-nums; }
.wheel-option.selected { color: var(--accent-dark); font-weight: 700; }
.wheel-current { margin: 8px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
body.modal-open { overflow: hidden; }

@media (min-width: 700px) {
  .step-nav { justify-content: center; }
  .step-button { flex: 0 1 130px; }
  .app-layout { padding: 22px 18px 50px; }
  .form-panel { padding: 24px; }
  .export-grid { grid-template-columns: repeat(4, 1fr); }
  .metric-list { grid-template-columns: 1fr 1fr; }
  .metric-card:last-child { grid-column: span 2; }
}

@media (min-width: 960px) {
  .app-layout { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(350px, .88fr); gap: 20px; align-items: start; }
  .preview-panel { position: sticky; top: 16px; margin-top: 0; }
  .step-nav { position: sticky; top: 0; z-index: 10; }
}

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