:root {
  --bg: #f4efe7;
  --paper: #fffdf8;
  --ink: #24201b;
  --muted: #756d63;
  --line: #d9d0c4;
  --accent: #b94f3a;
  --accent-soft: #ead2c7;
  --olive: #6b7158;
  --shadow: 0 14px 40px rgba(45, 36, 28, .08);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(185, 79, 58, .08), transparent 30%),
    radial-gradient(circle at 85% 10%, rgba(107, 113, 88, .08), transparent 28%),
    var(--bg);
  font-family: Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.site-header {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
}

.eyebrow, .kicker, .step-label {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.eyebrow { color: var(--accent); }
.kicker { color: var(--olive); }
.step-label { color: var(--muted); }

h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-size: clamp(30px, 4vw, 46px); font-weight: 800; letter-spacing: -.04em; }
h2 { font-size: clamp(28px, 4vw, 40px); letter-spacing: -.03em; }
h3 { font-size: 21px; letter-spacing: -.02em; }
.subhead, .muted, .micro { color: var(--muted); }
.subhead { margin: 8px 0 0; }
.micro { font-size: 12px; margin: 0; }

.header-actions { display: flex; gap: 8px; }
.shell { width: min(1040px, calc(100% - 32px)); margin: 20px auto 72px; }
.view { display: none; }
.view.active { display: block; }

.card, .hero-card {
  background: rgba(255, 253, 248, .9);
  border: 1px solid rgba(217, 208, 196, .9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card { padding: 24px; margin-top: 16px; }
.card.compact { padding: 20px 24px; }
.hero-card {
  padding: 28px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 32px;
}
.hero-card .muted { max-width: 640px; margin-bottom: 0; }
.hero-meta { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.hero-meta span {
  padding: 8px 11px;
  border-radius: 999px;
  background: #eee7dc;
  color: #574f46;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 20px;
}

.form-grid, .scale-row, .metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
label { display: grid; gap: 8px; font-weight: 700; font-size: 14px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(185,79,58,.08); }
textarea { resize: vertical; }

fieldset { border: 0; margin: 0; padding: 0; }
legend { margin-bottom: 9px; font-weight: 700; font-size: 14px; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.scale button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}
.scale button.selected { border-color: var(--accent); background: var(--accent-soft); color: #7f2c1c; }

.primary, .ghost {
  border-radius: 999px;
  padding: 11px 16px;
  font-weight: 800;
  border: 1px solid transparent;
}
.primary { background: var(--ink); color: #fff; }
.primary:hover { background: #3a342d; }
.ghost { background: rgba(255,255,255,.58); color: var(--ink); border-color: var(--line); }
.ghost:hover { background: #fff; }
.wide { width: 100%; margin-top: 20px; padding-block: 14px; }

.status-line {
  min-height: 20px;
  margin: 12px 0 20px;
  font-size: 13px;
  color: var(--muted);
}
.status-line.good { color: #4f6544; }
.status-line.warn { color: #925d31; }

.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.day-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 13px;
  padding: 11px 8px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.day-chip strong { display: block; color: var(--ink); font-size: 14px; }
.day-chip.done { background: #e7eadf; border-color: #c5ccb7; }
.day-chip.current { outline: 2px solid var(--accent-soft); }

.training-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 14px;
}
.timer {
  font-variant-numeric: tabular-nums;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.03em;
}
.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #ddd4c9;
}
#progressBar { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }
.training-card { min-height: 390px; display: flex; flex-direction: column; justify-content: space-between; }
.stage-body { display: grid; gap: 18px; }
.stage-intro { max-width: 720px; }
.stage-intro p { margin: 8px 0 0; color: var(--muted); }
.word-grid, .memory-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.word-card, .memory-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 14px;
}
.word-card strong, .memory-card strong { display: block; font-size: 18px; margin-bottom: 3px; }
.word-card span, .memory-card span { color: var(--muted); }
.rule-box {
  border-left: 4px solid var(--accent);
  border-radius: 0 14px 14px 0;
  background: #f8eee9;
  padding: 14px 16px;
}
.puzzle-box {
  border: 1px dashed #b7aa9c;
  background: #fbf8f2;
  border-radius: 15px;
  padding: 18px;
  font-size: 17px;
}
.answer-stack { display: grid; gap: 10px; }
.stage-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.stage-actions .primary { min-width: 140px; }

.review-list { display: grid; gap: 10px; }
.review-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}
.review-row .answer { color: var(--muted); font-size: 13px; margin-top: 5px; }
.review-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 10px; }
.review-controls button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 9px;
  font-weight: 700;
}
.review-controls button.selected[data-grade="exact"] { background: #e2eadc; border-color: #b8c7aa; }
.review-controls button.selected[data-grade="partial"] { background: #f2e7c8; border-color: #d7c58b; }
.review-controls button.selected[data-grade="miss"] { background: #f2d9d3; border-color: #d6aaa1; }
.familiar-check { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.familiar-check input { width: auto; }

.result-hero { align-items: center; }
.score-ring {
  width: 94px;
  height: 94px;
  flex: 0 0 94px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--accent) 0deg, #ddd5cb 0deg);
  position: relative;
}
.score-ring::after { content: ""; position: absolute; inset: 9px; background: var(--paper); border-radius: 50%; }
.score-ring span { position: relative; z-index: 1; font-weight: 900; font-size: 20px; }
.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 5px; font-size: 23px; }

.parking-panel { position: fixed; right: 20px; bottom: 20px; z-index: 20; }
.parking-trigger {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 24px rgba(103, 47, 34, .25);
  padding: 12px 15px;
  font-weight: 800;
}
.parking-trigger span { margin-left: 7px; background: rgba(255,255,255,.2); padding: 2px 7px; border-radius: 999px; }
.parking-popover {
  position: absolute;
  right: 0;
  bottom: 54px;
  width: min(360px, calc(100vw - 32px));
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 16px;
}
.parking-popover p { color: var(--muted); font-size: 12px; margin: 4px 0 12px; }
.parking-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.parking-form button { border: 0; border-radius: 12px; background: var(--ink); color: #fff; padding: 0 14px; font-weight: 800; }
#parkingList { margin: 12px 0 0; padding-left: 20px; max-height: 150px; overflow: auto; color: var(--muted); font-size: 12px; }

.history-overview { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.history-list { display: grid; gap: 10px; }
.history-item { border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 15px; }
.history-item-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.history-item p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.history-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.history-tags span { font-size: 11px; background: #eee8df; padding: 4px 7px; border-radius: 999px; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }

 dialog { border: 0; padding: 0; background: transparent; }
dialog::backdrop { background: rgba(24,20,16,.35); backdrop-filter: blur(3px); }
.dialog-card { min-width: min(420px, calc(100vw - 32px)); border-radius: 18px; padding: 24px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

@media (max-width: 760px) {
  .site-header { align-items: flex-start; flex-direction: column; padding-top: 22px; }
  .header-actions { width: 100%; }
  .header-actions button { flex: 1; }
  .hero-card, .section-head { align-items: flex-start; flex-direction: column; }
  .hero-meta { justify-content: flex-start; }
  .form-grid, .scale-row, .metrics-grid, .word-grid, .memory-grid, .history-overview { grid-template-columns: 1fr; }
  .week-strip { grid-template-columns: repeat(4, 1fr); }
  .training-card { min-height: 440px; }
  .parking-panel { right: 14px; bottom: 14px; }
}
