/* 매일수학 (Daily Math) — mobile-first, light/dark via prefers-color-scheme */

:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1e2530;
  --muted: #566070;
  --line: #dfe4ec;
  --chip: #edf1f9;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --ok: #167c3a;
  --bad: #b3231f;
  --shadow: 0 1px 3px rgba(20, 30, 50, 0.07);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1320;
    --card: #161d2c;
    --ink: #e8edf5;
    --muted: #9aa6ba;
    --line: #2b3446;
    --chip: #1d2740;
    --accent: #8fb3ff;
    --accent-ink: #0b1220;
    --ok: #55d68a;
    --bad: #ff8a85;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  line-height: 1.5;
}

[hidden] { display: none !important; }

button { font: inherit; cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

a { color: var(--accent); }

/* ---------- header / footer ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 16px 6px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 0.85rem; font-weight: 800; letter-spacing: -1px;
}
.app-footer {
  max-width: 520px;
  margin: 0 auto;
  padding: 10px 16px 26px;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

/* ---------- layout ---------- */
main { max-width: 520px; margin: 0 auto; padding: 10px 14px 30px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin-bottom: 14px;
}

.chip {
  display: inline-block;
  background: var(--chip);
  color: var(--ink);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.chip-fire b { font-size: 0.9rem; }

/* ---------- home ---------- */
.today { margin: 0; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.hero-title { margin: 6px 0 8px; font-size: 1.5rem; }
.hero-sub { margin: 0 0 14px; color: var(--muted); font-size: 0.85rem; word-break: keep-all; }

.dots { display: flex; justify-content: space-between; gap: 4px; }
.dot-cell {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 0.68rem; color: var(--muted); min-width: 12px;
}
.dot-cell.today { color: var(--ink); font-weight: 800; }
.dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--line); border: 2px solid transparent;
}
.dot.on { background: var(--ok); }
.dot-cell.today .dot { border-color: var(--accent); }

.grades-title { margin: 0 0 12px; font-size: 1.05rem; }
.grade-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grade-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 12px 10px; min-height: 84px;
  background: var(--card); color: var(--ink);
  border: 2px solid var(--line); border-radius: 12px;
  text-align: left;
}
.grade-btn:hover { border-color: var(--accent); }
.grade-btn.done { border-color: var(--ok); }
.g-name { font-weight: 800; font-size: 1.02rem; }
.g-desc { font-size: 0.68rem; color: var(--muted); word-break: keep-all; overflow-wrap: anywhere; }
.g-done { font-size: 0.68rem; color: var(--ok); font-weight: 800; margin-top: auto; }

/* ---------- quiz ---------- */
.quiz-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.btn-back {
  background: none; border: none; color: var(--accent);
  font-weight: 800; font-size: 0.9rem; padding: 6px 4px;
}
.quiz-title { margin: 0; font-size: 1.12rem; flex: 1; min-width: 0; }
.quiz-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 2px; }
.quiz-date { margin: 4px 0 12px; color: var(--muted); font-size: 0.82rem; }

.probs { list-style: none; margin: 0; padding: 0; }
.prob {
  position: relative;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  margin-bottom: 10px;
}
.prob.solved { border-color: var(--ok); }
.prob.failed { border-color: var(--bad); }

.q { display: flex; gap: 8px; align-items: flex-start; font-weight: 700; font-size: 1.02rem; word-break: keep-all; padding-right: 26px; }
.q-no { color: var(--accent); font-weight: 800; }

.ans { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.ans input {
  width: 108px; min-width: 0;
  padding: 9px 10px;
  font-size: 1.08rem; text-align: center;
  color: var(--ink); background: var(--bg);
  border: 2px solid var(--line); border-radius: 10px;
}
.ans input:focus { border-color: var(--accent); }
.ans input:disabled { opacity: 0.55; }
.unit { color: var(--muted); font-weight: 700; white-space: nowrap; font-size: 0.92rem; }

.pair-item { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.pair-item input { width: 76px; padding: 7px 8px; font-size: 1rem; }
.pair-label { font-size: 0.68rem; color: var(--muted); font-weight: 700; }
.pair-sep { color: var(--muted); font-weight: 800; align-self: center; padding-bottom: 4px; }

.btn-check {
  padding: 9px 14px;
  background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 10px;
  font-weight: 800; font-size: 0.92rem;
}
.btn-check:disabled { opacity: 0.5; cursor: default; }

.fb { margin: 8px 0 0; font-size: 0.85rem; min-height: 1.3em; }
.fb.ok { color: var(--ok); font-weight: 700; }
.fb.bad { color: var(--bad); font-weight: 700; }
.fb.warn { color: var(--muted); }

.hint {
  margin: 8px 0 0;
  font-size: 0.82rem; color: var(--ink);
  background: var(--chip);
  border-radius: 8px;
  padding: 8px 10px;
  word-break: keep-all;
}

.mark { position: absolute; top: 10px; right: 12px; font-size: 1.25rem; font-weight: 800; }
.mark.good { color: var(--ok); }
.mark.bad { color: var(--bad); }

.quiz-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

.btn {
  padding: 9px 13px;
  border: 2px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink);
  font-weight: 700; font-size: 0.88rem;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }

/* ---------- summary ---------- */
.summary { border: 2px solid var(--ok); }
.sum-title { margin: 0 0 10px; font-size: 1.2rem; }
.sum-score { margin: 0 0 4px; font-size: 1.05rem; font-weight: 800; }
.sum-time, .sum-streak { margin: 0 0 4px; color: var(--muted); font-size: 0.9rem; }
.sum-streak { font-weight: 700; color: var(--ink); }
.sum-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.sum-actions .btn { width: 100%; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 9px 16px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 700;
  max-width: calc(100vw - 32px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  z-index: 50;
}

/* ---------- animation ---------- */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.shake { animation: shake 0.3s ease; }
@media (prefers-reduced-motion: reduce) {
  .shake { animation: none; }
  * { scroll-behavior: auto; }
}

/* ---------- print (worksheet, no answers) ---------- */
#printSheet { display: none; }

@media print {
  body { background: #fff; color: #000; }
  body > *:not(#printSheet) { display: none !important; }
  #printSheet { display: block !important; }

  .ps-head { border-bottom: 3px double #000; padding-bottom: 10px; margin-bottom: 14px; }
  .ps-title { font-size: 20pt; margin: 0 0 4pt; }
  .ps-meta { font-size: 11pt; margin: 0; }
  .ps-list { margin: 0; padding-left: 0; list-style: none; }
  .ps-item { margin: 0 0 16pt; page-break-inside: avoid; }
  .ps-q { font-size: 13pt; font-weight: 700; margin: 0 0 8pt; }
  .ps-blank { font-size: 12pt; color: #444; margin: 0; }
  .ps-foot { margin-top: 24pt; padding-top: 8pt; border-top: 1px solid #999; font-size: 8pt; color: #555; }
}
