:root {
  --bg: #f3f7f5;
  --surface: #ffffff;
  --text: #17322e;
  --muted: #62736f;
  --primary: #0b6b5d;
  --primary-soft: #dff1ec;
  --accent: #e89842;
  --danger: #b43e45;
  --line: #d9e4e0;
  --shadow: 0 8px 28px rgba(23, 50, 46, .08);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 18px 12px;
  color: white; background: linear-gradient(135deg, #07594f, #0c7b6a);
}
.eyebrow { font-size: 11px; opacity: .78; letter-spacing: .06em; }
h1 { margin: 3px 0 0; font-size: 23px; line-height: 1.1; }
.icon-button { width: 42px; height: 42px; border: 0; border-radius: 50%; color: var(--primary); background: white; font-size: 28px; line-height: 1; }
.header-actions { display: flex; gap: 8px; }
.lock-button { font-size: 21px; }

.lock-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #e4f4ef, var(--bg) 50%); }
.lock-card { width: min(100%, 420px); padding: 26px 22px; border: 1px solid var(--line); border-radius: 22px; background: white; box-shadow: var(--shadow); }
.lock-card h1 { color: var(--text); margin: 0 0 8px; font-size: 26px; }
.lock-card p { color: var(--muted); line-height: 1.6; }
.lock-logo { width: 66px; height: 66px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 20px; color: white; background: var(--primary); font-weight: 800; font-size: 23px; }
.lock-error { min-height: 20px; margin: -4px 0 10px; color: var(--danger); font-size: 13px; }
.lock-actions { display: grid; gap: 10px; margin-top: 16px; }
.locked .app-header, .locked .record-strip, .locked .app-main, .locked .bottom-nav, .locked dialog { display: none !important; }
body:not(.locked) .lock-screen { display: none; }

.record-strip { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: #e9f4f1; border-bottom: 1px solid var(--line); }
.record-picker { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); text-align: left; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.record-picker::after { content: " ▾"; color: var(--muted); }
.save-state { color: var(--muted); font-size: 12px; white-space: nowrap; }

.app-main { max-width: 760px; margin: 0 auto; padding: 18px 14px calc(92px + env(safe-area-inset-bottom)); }
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 12; display: grid; grid-template-columns: repeat(5, 1fr); padding: 7px 6px calc(7px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); box-shadow: 0 -5px 20px rgba(23,50,46,.06); backdrop-filter: blur(12px); }
.bottom-nav button { border: 0; color: var(--muted); background: transparent; font-size: 11px; }
.bottom-nav button span { display: block; margin-bottom: 2px; font-size: 21px; line-height: 1.1; }
.bottom-nav button.active { color: var(--primary); font-weight: 700; }

.welcome { min-height: 65vh; display: grid; place-items: center; text-align: center; }
.welcome-card, .card, .score-card, .module-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.welcome-card { padding: 30px 22px; }
.welcome-mark { width: 72px; height: 72px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 22px; background: var(--primary-soft); color: var(--primary); font-size: 34px; font-weight: 800; }
.welcome h2 { margin: 0 0 8px; }
.welcome p { color: var(--muted); line-height: 1.65; }

.primary-button, .secondary-button, .danger-button { width: 100%; min-height: 48px; border-radius: 13px; font-weight: 700; }
.primary-button { border: 0; color: white; background: var(--primary); }
.secondary-button { border: 1px solid var(--primary); color: var(--primary); background: white; }
.danger-button { border: 1px solid #efc6c8; color: var(--danger); background: #fff6f6; }
.button-stack { display: grid; gap: 10px; }

.view-title { margin: 0 0 14px; font-size: 21px; }
.section-intro { margin: -6px 0 16px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.hero-card { padding: 18px; border-radius: 18px; color: white; background: linear-gradient(135deg, #0b6b5d, #119681); box-shadow: var(--shadow); }
.hero-card .small { opacity: .8; }
.hero-card h2 { margin: 5px 0; font-size: 25px; }
.progress-track { height: 9px; margin-top: 15px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.25); }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: white; }

.module-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.module-card { padding: 15px; text-align: left; }
.module-card button { width: 100%; padding: 0; border: 0; text-align: left; background: transparent; color: inherit; }
.module-card h3 { margin: 7px 0 5px; font-size: 16px; }
.module-card p { margin: 0; color: var(--muted); font-size: 12px; }
.status-dot { display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 50%; background: #bcc8c5; }
.status-dot.done { background: #21a273; }

.card { margin-bottom: 14px; padding: 17px; }
.card h2, .card h3 { margin: 0 0 14px; }
.card-header { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.badge { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 9px; border-radius: 99px; color: var(--primary); background: var(--primary-soft); font-size: 12px; font-weight: 700; white-space: nowrap; }
.warning { padding: 12px; border-left: 4px solid var(--accent); border-radius: 8px; color: #6d4b25; background: #fff7ec; font-size: 13px; line-height: 1.5; }

.field { display: grid; gap: 7px; margin-bottom: 15px; }
.field > span { font-size: 14px; font-weight: 700; }
.field small { color: var(--muted); }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #cbd8d4; border-radius: 12px; color: var(--text); background: #fbfdfc; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(11,107,93,.12); }
textarea { min-height: 90px; resize: vertical; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.segment { display: grid; grid-template-columns: repeat(var(--count, 2), 1fr); gap: 6px; }
.segment label { min-height: 43px; display: grid; place-items: center; padding: 6px; border: 1px solid #cbd8d4; border-radius: 10px; color: var(--muted); background: white; text-align: center; font-size: 13px; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment label:has(input:checked) { color: white; border-color: var(--primary); background: var(--primary); font-weight: 700; }

.question { padding: 14px 0; border-bottom: 1px solid #edf2f0; }
.question:last-child { border-bottom: 0; }
.question-title { margin-bottom: 9px; font-weight: 700; line-height: 1.45; }
.question-help { margin: -3px 0 9px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.scale-row { display: grid; grid-template-columns: minmax(0, 1fr) 118px; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #edf2f0; }
.scale-row:last-child { border-bottom: 0; }
.scale-row label { line-height: 1.35; }
.scale-row select { min-height: 42px; }

.score-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.score-card { padding: 13px; box-shadow: none; }
.score-card span { display: block; color: var(--muted); font-size: 12px; }
.score-card strong { display: block; margin-top: 4px; color: var(--primary); font-size: 23px; }

.accordion { margin-bottom: 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: var(--shadow); }
.accordion summary { display: flex; align-items: center; justify-content: space-between; padding: 16px; list-style: none; font-weight: 800; }
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::after { content: "+"; color: var(--primary); font-size: 22px; }
.accordion[open] summary::after { content: "−"; }
.accordion-body { padding: 0 16px 18px; }

.record-list { display: grid; gap: 9px; max-height: 55vh; overflow: auto; }
.record-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.record-item button { border: 0; text-align: left; background: transparent; color: inherit; }
.record-item small { display: block; margin-top: 3px; color: var(--muted); }
.mini-delete { padding: 7px 9px; color: var(--danger)!important; }

dialog { width: min(92vw, 520px); padding: 0; border: 0; border-radius: 20px; box-shadow: 0 25px 80px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(6,31,27,.5); backdrop-filter: blur(3px); }
.dialog-card { padding: 20px; }
.dialog-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.dialog-title-row h2 { margin: 0; font-size: 20px; }
.close-button { width: 38px; height: 38px; border: 0; border-radius: 50%; color: var(--muted); background: #edf3f1; font-size: 25px; }
.privacy-note { color: var(--muted); font-size: 12px; line-height: 1.5; }
.toast { position: fixed; left: 50%; bottom: 86px; z-index: 30; max-width: 84vw; padding: 10px 16px; border-radius: 99px; color: white; background: #17322e; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: .2s; font-size: 13px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.small { color: var(--muted); font-size: 12px; }
.empty-inline { padding: 20px; color: var(--muted); text-align: center; }

@media (max-width: 420px) {
  .module-grid, .field-grid { grid-template-columns: 1fr; }
  .module-grid { gap: 10px; }
  .scale-row { grid-template-columns: minmax(0, 1fr) 105px; }
  .segment { gap: 4px; }
  .segment label { padding: 5px 2px; font-size: 12px; }
}

@media (display-mode: standalone) {
  .app-header { padding-top: calc(18px + env(safe-area-inset-top)); }
}
