:root {
  --bg: #fbfaf7;
  --panel: #ffffff;
  --ink: #16221c;
  --muted: #5f6f67;
  --line: #dfe5e1;
  --brand: #1f4d3d;
  --brand-soft: #e7f1ec;
  --warn: #8a4b12;
  --bad: #b3261e;
  --ok: #1c6b4a;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", system-ui, sans-serif;
  line-height: 1.6;
  font-size: 16px;
  word-break: keep-all;
}

body.big-text { font-size: 19px; }

html[data-theme="dark"] {
  --bg: #121815;
  --panel: #1a231e;
  --ink: #e8efea;
  --muted: #a3b3aa;
  --line: #2d3a33;
  --brand: #7fd7b6;
  --brand-soft: #1e2f28;
}
html[data-theme="dark"] textarea, html[data-theme="dark"] input[type="text"], html[data-theme="dark"] select { background: #16201b; }
html[data-theme="dark"] button.primary, html[data-theme="dark"] .button.primary { color: #0d1512; }
html[data-theme="dark"] details.faq, html[data-theme="dark"] .card, html[data-theme="dark"] .links li a { background: var(--panel); }

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

code { background: var(--brand-soft); padding: 0 0.25em; border-radius: 4px; font-size: 0.92em; }

.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.chrome { background: var(--panel); border-bottom: 1px solid var(--line); }
.chrome .in {
  max-width: 960px; margin: 0 auto; padding: 0.6rem 1rem;
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
}
.chrome .brand { font-weight: 700; color: var(--brand); text-decoration: none; }
.chrome nav a { color: var(--muted); text-decoration: none; font-size: 0.92rem; padding: 0.2rem 0.35rem; border-radius: 6px; }
.chrome nav a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); font-weight: 600; }

main { max-width: 960px; margin: 0 auto; padding: 1rem 1rem 3rem; }

h1 { font-size: 1.5rem; line-height: 1.35; margin: 0.6rem 0 0.8rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.6rem; }
h3 { font-size: 1rem; margin: 0 0 0.3rem; }

.lede { color: var(--muted); margin-top: 0; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin: 0 0 1rem;
}

.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.warn { color: var(--warn); font-size: 0.9rem; }
.banner {
  background: #fff5e6; border: 1px solid #f0d3a8; color: var(--warn);
  border-radius: 10px; padding: 0.7rem 0.8rem; font-size: 0.92rem;
}

.field { display: block; margin: 0 0 0.9rem; }
.field > span { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 0.3rem; }
.field.inline { display: inline-flex; flex-direction: column; margin-right: 0.75rem; }
.field.checkbox { flex-direction: row; align-items: center; gap: 0.4rem; }

textarea, input[type="text"], select {
  width: 100%; font: inherit; color: inherit; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.7rem;
}
textarea:focus, input[type="text"]:focus, select:focus, button:focus-visible {
  outline: 3px solid #a9cfbd; outline-offset: 1px;
}

.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.6rem 0; }

button, .button {
  font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); padding: 0.55rem 0.95rem;
  text-decoration: none; display: inline-block; line-height: 1.3;
}
button.primary, .button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
button.ghost, .button.ghost { background: transparent; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.preview-list { margin: 0.4rem 0 0.8rem; padding-left: 1.4rem; }
.preview-list li { margin: 0.15rem 0; }

.progress { font-weight: 600; color: var(--muted); margin: 0.2rem 0 0.6rem; }
.sentence {
  font-size: 1.35rem; font-weight: 700; letter-spacing: 0.01em;
  background: var(--brand-soft); border-radius: 12px; padding: 1rem; margin: 0.4rem 0 0.8rem;
  min-height: 3.4rem;
}
.score { font-size: 1.5rem; font-weight: 700; margin: 0.2rem 0; }

.card {
  border: 1px solid var(--line); border-left-width: 5px; border-radius: 12px;
  padding: 0.75rem 0.9rem; margin: 0.6rem 0; background: #fff;
}
.card.v-exact { border-left-color: var(--ok); }
.card.v-accepted { border-left-color: #b07d18; }
.card.v-wrong { border-left-color: var(--bad); }
.card header { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.3rem; }
.card .badge { font-size: 0.8rem; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.card.v-wrong .badge { background: #fdeceb; color: var(--bad); }
.card.v-accepted .badge { background: #fdf4e3; color: #8a5a00; }
.card p { margin: 0.2rem 0; }
.card-expected { font-weight: 600; }
.card-answer { color: var(--muted); }

.tag {
  display: inline-block; font-size: 0.8rem; padding: 0.1rem 0.45rem;
  border-radius: 999px; background: #f1f5f3; color: var(--muted); margin: 0 0.25rem 0.25rem 0;
}

.diff { margin-top: 0.5rem; border-top: 1px dashed var(--line); padding-top: 0.4rem; }
.diff-row { display: flex; gap: 0.5rem; margin: 0.15rem 0; font-size: 0.95rem; }
.diff-label { color: var(--muted); min-width: 2.2rem; font-size: 0.82rem; }
.diff mark { background: #ffe9e6; color: var(--bad); border-radius: 4px; padding: 0 0.1em; }
.diff mark.ins { background: #e7f1ec; color: var(--brand); }
.diff .gap { color: var(--muted); }

.queue { margin: 0.2rem 0 0.4rem; font-weight: 600; }
.tag-stats { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.session { border-top: 1px solid var(--line); padding: 0.6rem 0; }
.session:first-child { border-top: 0; }

.rate-chart .bar-row { display: flex; align-items: center; gap: 0.5rem; margin: 0.25rem 0; font-size: 0.9rem; }
.rate-chart .bar { display: inline-block; height: 0.8rem; background: var(--brand); border-radius: 4px; min-width: 2px; }

.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { border: 1px solid var(--line); padding: 0.45rem 0.5rem; text-align: left; vertical-align: top; }
.table th { background: var(--brand-soft); }

.glossary { margin: 0; }
.glossary dt { font-weight: 700; margin-top: 0.7rem; }
.glossary dd { margin: 0.1rem 0 0 0; color: var(--muted); }

details.faq { border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.8rem; margin: 0.5rem 0; background: #fff; }
details.faq summary { cursor: pointer; font-weight: 600; }
details.faq p { color: var(--muted); margin: 0.5rem 0 0; }

.links { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; padding: 0; margin: 0; }
.links li a {
  display: inline-block; padding: 0.35rem 0.7rem; border: 1px solid var(--line);
  border-radius: 999px; text-decoration: none; font-size: 0.9rem; background: #fff;
}

.ad-slot { margin: 1rem 0; min-height: 0; }
.ad-slot:empty { display: none; }
.contact { font-weight: 600; }

footer.chrome { border-top: 1px solid var(--line); border-bottom: 0; margin-top: 2rem; }
footer.chrome .in { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
footer.chrome h2 { font-size: 0.9rem; color: var(--muted); }
footer.chrome ul { list-style: none; padding: 0; margin: 0; }
footer.chrome li { margin: 0.2rem 0; font-size: 0.88rem; }
footer.chrome a { text-decoration: none; color: var(--muted); }
.disc { font-size: 0.82rem; color: var(--muted); }

/* A4 sheet */
.sheet { background: #fff; color: #111; padding: 8mm; }
.sheet.a4 { width: 194mm; max-width: 100%; margin: 0 auto; box-shadow: 0 1px 8px rgba(0,0,0,0.08); }
.sheet-head h1 { font-size: 16pt; margin: 0 0 2mm; }
.sheet-meta { font-size: 9pt; color: #555; margin: 0 0 3mm; }
.sheet-guide { font-size: 9pt; color: #555; margin: 0 0 4mm; }
.sheet-list { list-style: none; padding: 0; margin: 0; }
.sheet-item { margin-bottom: 5mm; page-break-inside: avoid; }
.sheet-prompt { font-size: 11pt; margin: 0 0 2mm; }
.sheet-no { color: #666; }
.write-line { border-bottom: 1px solid #bbb; height: 9mm; }
.sheet-answer { font-size: 8.5pt; color: #666; margin: 1mm 0 0; }
.sheet-tags { font-size: 8pt; color: #777; }
.sheet-score { font-size: 10pt; font-weight: 700; margin: 0 0 3mm; }
.sheet-table { width: 100%; border-collapse: collapse; font-size: 9pt; }
.sheet-table th, .sheet-table td { border: 1px solid #ccc; padding: 1.5mm; text-align: left; }
.sheet-foot { margin-top: 4mm; font-size: 8pt; color: #777; border-top: 1px solid #ddd; padding-top: 2mm; }

@media print {
  .chrome, main > h1, .breadcrumb, .related, .panel > h2, footer.chrome, .ad-slot { display: none !important; }
  body { background: #fff; }
  .sheet.a4 { box-shadow: none; width: auto; padding: 0; }
  @page { size: A4; margin: 10mm; }
}

@media (max-width: 520px) {
  main { padding: 0.75rem 0.75rem 2rem; }
  h1 { font-size: 1.28rem; }
  .sentence { font-size: 1.18rem; }
  .sheet.a4 { width: 100%; padding: 4mm; }
  .chrome .in nav { display: flex; flex-wrap: wrap; gap: 0.1rem; }
}
