/* 글방, the study desk. White paper, a green manuscript-paper grid, one syllable per square.
   Gowun Dodum has a single weight, so emphasis comes from size and colour, never from bold. */

:root {
  --paper: #FAFBF9;
  --panel: #FFFFFF;
  --ink: #1B211E;
  --pencil: #5A645F;
  --grid: #7DB892;
  --green: #1F6B47;
  --green-soft: #A9D3B6;
  --green-on: #D7EBDD;
  --blue: #2A4FA3;
  --blue-soft: #B9C6E6;
  --blue-tint: #DCE4F7;
  --hair: #DCE5DF;
  --line: #C9D2CC;
  --dash: #9AA8A0;
  --dark: #16201B;
  --text: 'Gowun Dodum', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --cell: 80px;
  --cell-text: 50px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-weight: 400;
  font-synthesis: none;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, p { margin: 0; font-weight: 400; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: max(28px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 24px max(20px, env(safe-area-inset-left));
}
.screen.with-tabs { padding-bottom: 12px; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack.loose { gap: 16px; }
.line { display: flex; align-items: center; gap: 12px; }
.line.spread { justify-content: space-between; }
.wrap { display: flex; flex-wrap: wrap; gap: 8px; }

.mono { font-family: var(--mono); font-size: 12px; color: var(--pencil); }
.label { font-family: var(--mono); font-size: 12px; color: var(--pencil); letter-spacing: 0.02em; text-transform: uppercase; }
.pencil { color: var(--pencil); }
.small { font-size: 13px; line-height: 1.5; }
.green { color: var(--green); }
.blue { color: var(--blue); }
.korean { word-break: keep-all; }
.title { font-size: 30px; line-height: 1.25; letter-spacing: -0.01em; }
.big { font-size: 34px; line-height: 1.2; letter-spacing: -0.01em; }
.sentence { font-size: 25px; line-height: 1.6; word-break: keep-all; }
.center { text-align: center; }

/* Squares */
.cells { display: flex; flex-wrap: wrap; }
.cell {
  width: var(--cell); height: var(--cell);
  border: 1.5px solid var(--grid); background: var(--panel);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--cell-text); line-height: 1;
  margin-left: -1.5px;
}
.cells > .cell:first-child { margin-left: 0; }
.cell.on { background: var(--green); border-color: var(--green); color: #FFFFFF; }
.cell.result { border: 2.5px solid var(--green); }
button.cell { padding: 0; border-radius: 0; }
.cells.s150 { --cell: 150px; --cell-text: 104px; }
.cells.s112 { --cell: 112px; --cell-text: 66px; }
.cells.s64 { --cell: 64px; --cell-text: 36px; }
.cells.s56 { --cell: 56px; --cell-text: 32px; }
.cells.s44 { --cell: 44px; --cell-text: 24px; }
.cells.s36 { --cell: 36px; --cell-text: 20px; }
.cells.digits .cell { font-family: var(--mono); }

/* Controls */
.btn {
  min-height: 48px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink);
  font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  text-decoration: none;
}
.btn.primary { background: var(--green); border-color: var(--green); color: #FFFFFF; }
.btn.blue { border-color: var(--blue); color: var(--blue); }
.btn.blue-fill { background: var(--blue); border-color: var(--blue); color: #FFFFFF; }
.btn.tall { min-height: 56px; font-size: 17px; }
.btn.block { width: 100%; }
.btn.left { justify-content: flex-start; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible, .icon:focus-visible, .cell:focus-visible, .chip:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
}
.icon {
  width: 44px; height: 44px; padding: 0; flex: none;
  border: 0; background: none; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon.round { border: 1px solid var(--line); border-radius: 50%; background: var(--panel); color: var(--green); }
.icon.round.on { background: var(--green); border-color: var(--green); color: #FFFFFF; }
.chip {
  min-height: 44px; padding: 0 14px;
  border: 1px solid var(--blue-soft); border-radius: 999px;
  background: var(--panel); color: var(--blue); font-size: 14px;
}
.pill {
  font-size: 12px; color: var(--pencil); white-space: nowrap;
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px;
  display: inline-flex; align-items: center; gap: 6px;
}
.pill.green { color: var(--green); border-color: var(--grid); }

.bar { height: 4px; border-radius: 2px; background: var(--hair); overflow: hidden; }
.bar > i { display: block; height: 4px; border-radius: 2px; background: var(--green); }

.rule { border-top: 1px dashed var(--dash); padding-top: 16px; }
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 0; border-top: 1px solid var(--hair);
  color: var(--ink); text-decoration: none; background: none; border-left: 0; border-right: 0; border-bottom: 0;
  width: 100%; text-align: left;
}
.rows > .row:last-child { border-bottom: 1px solid var(--hair); }
.row .name { width: 78px; flex: none; display: flex; flex-direction: column; gap: 2px; }
.row .name b { font-weight: 400; font-size: 24px; line-height: 1.2; }
.row .body { flex: 1; min-width: 0; font-size: 14px; line-height: 1.45; }

.grades { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.grades.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grade {
  min-height: 60px; padding: 4px 0;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 17px;
}
.grade small { font-family: var(--mono); font-size: 12px; color: var(--pencil); }
.grade.good { background: var(--green); border-color: var(--green); color: #FFFFFF; }
.grade.good small { color: var(--green-on); }

.part {
  min-height: 60px; padding: 8px 12px;
  border: 1.5px solid var(--grid); border-radius: 0; background: var(--panel);
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
}
.part b { font-weight: 400; font-size: 20px; }
.part small { font-size: 12px; color: var(--pencil); }
.part.marked { border: 2.5px solid var(--blue); }
.part.marked small { color: var(--blue); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--pencil); }
.field input, .field select {
  height: 48px; padding: 0 14px; width: 100%;
  border: 1px solid var(--pencil); border-radius: 8px; background: var(--panel); font-size: 16px;
}
input[type="range"] { width: 100%; height: 28px; margin: 0; accent-color: var(--green); }

.notice { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 12px 14px; font-size: 14px; line-height: 1.5; }
.notice.warn { border-color: var(--blue-soft); }
.error { color: #9B2C1F; font-size: 14px; }

.tabs {
  position: sticky; bottom: 0;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 8px 8px max(16px, env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--hair);
}
.tab {
  min-height: 48px; border: 0; background: none; color: var(--pencil);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 12px; text-decoration: none;
}
.tab.on { color: var(--green); }

.sheet {
  position: fixed; inset: 0; z-index: 20;
  background: var(--paper);
  display: flex; justify-content: center;
}
.sheet > .screen { max-width: 480px; width: 100%; overflow-y: auto; }
.bubble {
  align-self: flex-end; max-width: 85%;
  padding: 10px 14px; border: 1.5px solid var(--blue); border-radius: 14px 14px 2px 14px;
  background: var(--panel); font-size: 16px;
}
.answer { font-size: 16px; line-height: 1.6; white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; }

.grid100 { display: grid; grid-template-columns: repeat(10, 1fr); border-right: 1.5px solid var(--grid); border-bottom: 1.5px solid var(--grid); }
.grid100 > i { aspect-ratio: 1; border-left: 1.5px solid var(--grid); border-top: 1.5px solid var(--grid); background: var(--panel); }
.grid100 > i.known { background: var(--green); }
.grid100 > i.learning { background: var(--green-soft); }

.swatch { width: 12px; height: 12px; display: inline-block; border: 1px solid var(--green); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); display: inline-block; }
.dot.green { background: var(--green); }
.switch { width: 52px; height: 44px; padding: 0; border: 0; background: none; display: flex; align-items: center; }
.switch > span { width: 52px; height: 30px; border-radius: 15px; border: 1.5px solid var(--pencil); background: var(--panel); display: flex; align-items: center; padding: 0 3px; }
.switch > span > i { width: 22px; height: 22px; border-radius: 50%; background: var(--pencil); }
.switch[aria-checked="true"] > span { border-color: var(--green); justify-content: flex-end; }
.switch[aria-checked="true"] > span > i { background: var(--green); }
.playing { display: inline-flex; align-items: flex-end; gap: 3px; height: 16px; }
.playing > i { width: 3px; background: var(--green); animation: bounce 0.9s ease-in-out infinite; }
.playing > i:nth-child(1) { height: 7px; }
.playing > i:nth-child(2) { height: 14px; animation-delay: 0.15s; }
.playing > i:nth-child(3) { height: 10px; animation-delay: 0.3s; }
.playing > i:nth-child(4) { height: 16px; animation-delay: 0.45s; }
@keyframes bounce { 50% { transform: scaleY(0.45); } }
.playing > i { transform-origin: bottom; }
@media (prefers-reduced-motion: reduce) { .playing > i { animation: none; } }

.hero-play { width: 80px; height: 80px; border-radius: 50%; border: 0; background: var(--green); color: #FFFFFF; display: flex; align-items: center; justify-content: center; }
