:root {
  color-scheme: light;
  --ink: #17312e;
  --muted: #667a77;
  --line: #ccd9d6;
  --paper: #ffffff;
  --ground: #eef3f2;
  --teal: #149b8d;
  --teal-dark: #0c685f;
  --yellow: #f3b51b;
  --coral: #ef6659;
  --blue: #3177c8;
  --shadow: 0 20px 50px rgba(20, 57, 53, 0.12);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--ground); }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--ground);
}

button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.app-header {
  position: relative;
  min-height: 112px;
  padding: 16px clamp(18px, 4vw, 54px);
  display: grid;
  grid-template-columns: 90px minmax(230px, 1fr) 300px;
  align-items: center;
  gap: 24px;
  color: #fff;
  background: var(--ink);
  overflow: hidden;
}

.account-link {
  position: absolute;
  top: 12px;
  right: clamp(18px, 4vw, 54px);
  padding: 5px 8px;
  color: #d8e4e2;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  text-decoration: none;
}
.account-link:hover { color: var(--ink); background: var(--yellow); border-color: var(--yellow); }

.itland-link {
  width: fit-content;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  border-bottom: 2px solid var(--yellow);
  padding-bottom: 4px;
}

.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-mark, .worksheet-brand span {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  font: 800 21px/1 "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--yellow);
  border-radius: 50%;
}
.brand-lockup h1 { margin: 0; font-size: 28px; line-height: 1; }
.brand-lockup p { margin: 7px 0 0; color: #bfd0cd; font-size: 13px; }
.app-header > img {
  width: 300px;
  height: 80px;
  object-fit: cover;
  object-position: center;
  border-radius: 6px;
}

.workspace {
  width: min(1440px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: calc(100vh - 112px);
}

.control-panel {
  padding: 30px 28px;
  background: #fff;
  border-right: 1px solid var(--line);
}

.panel-heading { display: flex; flex-direction: column; margin-bottom: 26px; }
.panel-heading span, .usage-band > div > span, .gate-copy > span {
  color: var(--teal-dark);
  font-size: 10px;
  font-weight: 800;
}
.panel-heading strong { margin-top: 5px; font-size: 22px; }

.practice-status {
  margin: -4px 0 24px;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  border: 1px solid var(--line);
  background: #f7faf9;
}
.practice-status span { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 9px; }
.practice-status span:last-of-type { align-items: end; }
.practice-status span b { color: var(--ink); font-size: 13px; }
.practice-status .status-title { grid-column: 1 / -1; align-items: start; padding-bottom: 8px; border-bottom: 1px solid #dbe5e3; }
.practice-status .status-title b { color: var(--teal-dark); font-size: 15px; }
.practice-status i { grid-column: 1 / -1; height: 4px; overflow: hidden; background: #dbe5e3; }
.practice-status i b { display: block; width: 33.333%; height: 100%; background: var(--yellow); transition: width .3s ease; }
.practice-status > small { grid-column: 1 / -1; color: var(--muted); font-size: 9px; line-height: 1.45; }
.records-button {
  width: 100%;
  min-height: 38px;
  margin: -15px 0 24px;
  color: var(--teal-dark);
  border: 1px solid #aec4c0;
  border-radius: 6px;
  background: #fff;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.records-button:hover { background: #eff6f4; }
.today-button {
  width: 100%;
  min-height: 54px;
  margin: -15px 0 24px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
  border: 0;
  border-radius: 6px;
  background: var(--teal-dark);
  cursor: pointer;
}
.today-button:hover { background: #084f49; }
.today-button span { font-size: 13px; font-weight: 800; }
.today-button small { color: #bfe0db; font-size: 9px; }

fieldset { padding: 0; margin: 0 0 24px; border: 0; }
legend, .text-field > span {
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 800;
}

.operation-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.operation-grid label, .difficulty-control label, .layout-control label { cursor: pointer; }
.operation-grid input, .difficulty-control input, .layout-control input { position: absolute; opacity: 0; pointer-events: none; }
.operation-grid span {
  min-height: 48px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  background: #fff;
}
.operation-grid span b { font-size: 22px; line-height: 1; color: var(--teal-dark); }
.operation-grid input:checked + span {
  color: #fff;
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}
.operation-grid input:checked + span b { color: var(--yellow); }
.operation-grid input:focus-visible + span, .difficulty-control input:focus-visible + span, .layout-control input:focus-visible + span { outline: 3px solid rgba(49,119,200,.28); outline-offset: 2px; }

.layout-control { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.layout-control span {
  min-height: 57px;
  padding: 7px 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 11px;
  font-weight: 800;
}
.layout-control span b { color: var(--ink); font: 700 13px/1.15 "Segoe UI", sans-serif; text-align: center; }
.layout-control input:checked + span { color: #fff; border-color: var(--blue); background: var(--blue); }
.layout-control input:checked + span b { color: #fff; }

.difficulty-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 3px;
  background: var(--ground);
  border-radius: 6px;
}
.difficulty-control span {
  min-height: 36px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 800;
}
.difficulty-control input:checked + span { color: #fff; background: var(--ink); }
.field-note, .output-note, .field-error { margin: 8px 0 0; font-size: 11px; line-height: 1.55; color: var(--muted); }
.field-error { color: #b93a30; font-weight: 700; }

.select-field { margin: -5px 0 22px; display: flex; flex-direction: column; gap: 8px; }
.select-field > span { font-size: 13px; font-weight: 800; }
.select-field select {
  width: 100%;
  height: 42px;
  padding: 0 36px 0 11px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.select-field select:focus { outline: 3px solid rgba(20,155,141,.13); border-color: var(--teal); }
.select-field small { color: var(--muted); font-size: 9px; line-height: 1.5; }

.text-field { display: flex; flex-direction: column; margin-bottom: 22px; }
.text-field input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: 0;
}
.text-field input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(20,155,141,.13); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; cursor: pointer; }
.compact-switch { margin-top: -12px; }
.switch-row span { display: flex; flex-direction: column; }
.switch-row b { font-size: 13px; }
.switch-row small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.switch-row input {
  appearance: none;
  width: 42px;
  height: 24px;
  margin: 0;
  flex: 0 0 auto;
  border: 1px solid #a9bab7;
  border-radius: 20px;
  background: #dbe5e3;
  transition: .2s ease;
}
.switch-row input::before {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  margin: 2px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s ease;
}
.switch-row input:checked { background: var(--teal); border-color: var(--teal); }
.switch-row input:checked::before { transform: translateX(18px); }

.primary-button, .secondary-button, .output-actions button, .gate-action {
  border: 0;
  border-radius: 6px;
  font-weight: 800;
  cursor: pointer;
}
.primary-button {
  width: 100%;
  min-height: 48px;
  color: #fff;
  background: var(--teal-dark);
}
.primary-button:hover { background: #084f49; }
.primary-button:disabled { color: #82918f; background: #dce4e2; cursor: not-allowed; }
.grade-button { background: #245f9f; }
.grade-button:hover { background: #194c82; }
.secondary-button {
  width: 100%;
  min-height: 42px;
  margin-top: 8px;
  color: var(--teal-dark);
  border: 1px solid #a8bfbb;
  background: #fff;
}
.secondary-button:hover { background: #eff6f4; }
.result-panel { margin-top: 10px; padding: 14px; border-left: 4px solid var(--yellow); background: #f4f7f6; }
.result-panel[hidden] { display: none; }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.result-head strong { font-size: 20px; color: var(--blue); }
.result-head > b { color: var(--ink); font: 800 17px/1 "Segoe UI", sans-serif; }
.result-panel p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.result-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 11px; }
.result-facts span { padding: 8px; display: flex; flex-direction: column; gap: 3px; border: 1px solid var(--line); background: #fff; }
.result-facts small { color: var(--muted); font-size: 8px; }
.result-facts b { font-size: 11px; }
.result-login { display: block; margin-top: 10px; color: var(--blue); font-size: 10px; font-weight: 800; }
.retry-button {
  width: 100%;
  min-height: 36px;
  margin-top: 10px;
  color: var(--blue);
  border: 1px solid #9dbdde;
  border-radius: 5px;
  background: #fff;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}
.retry-button:hover { background: #edf5fd; }
.retry-button[hidden] { display: none; }
.output-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.output-actions button { min-height: 44px; background: #e1eae8; }
.output-actions button:hover { background: #d4e1df; }
.output-actions button span { color: var(--teal-dark); }
.inline-ad-home { min-height: 118px; margin-top: 10px; }
.gate-ad-host { min-height: 132px; margin: 22px 0 18px; }
.output-settings { margin-top: 10px; border: 1px solid var(--line); border-radius: 6px; background: #f8faf9; }
.output-settings summary { padding: 11px 12px; font-size: 11px; font-weight: 800; cursor: pointer; }
.output-settings[open] summary { border-bottom: 1px solid var(--line); }
.output-settings > fieldset { margin: 13px 12px; }
.output-settings legend { margin-bottom: 7px; font-size: 10px; }
.sheet-count-control { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.sheet-count-control input { position: absolute; opacity: 0; pointer-events: none; }
.sheet-count-control span { min-height: 32px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 4px; background: #fff; font-size: 10px; font-weight: 800; cursor: pointer; }
.sheet-count-control input:checked + span { color: #fff; border-color: var(--ink); background: var(--ink); }
.student-output-fields { margin: 0 12px 12px; display: grid; grid-template-columns: 1fr 1.2fr; gap: 7px; }
.student-output-fields label { display: grid; gap: 5px; color: var(--muted); font-size: 9px; font-weight: 700; }
.student-output-fields input { width: 100%; min-width: 0; height: 34px; padding: 0 7px; color: var(--ink); border: 1px solid var(--line); border-radius: 4px; background: #fff; font-size: 10px; }
.check-row { margin: 0 12px 13px; display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.check-row input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--teal-dark); }
.check-row span { display: grid; gap: 2px; }
.check-row b { font-size: 10px; }
.check-row small { color: var(--muted); font-size: 8px; line-height: 1.45; }

.sheet-stage { min-width: 0; padding: 26px clamp(18px, 4vw, 54px) 54px; background: #dfe9e7; }
.practice-toolbar {
  position: sticky;
  top: 8px;
  z-index: 3;
  width: min(100%, 794px);
  min-height: 48px;
  margin: 0 auto 10px;
  padding: 7px 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  color: #fff;
  background: rgba(23,49,46,.96);
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 8px 22px rgba(20,57,53,.16);
  backdrop-filter: blur(8px);
}
.practice-toolbar span { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-right: 1px solid rgba(255,255,255,.18); }
.practice-toolbar span:last-child { border-right: 0; }
.practice-toolbar small { color: #bcd0cd; font-size: 8px; font-weight: 700; }
.practice-toolbar b { font-size: 13px; }
.practice-toolbar .timer-stat b { color: var(--yellow); font: 800 16px/1 "Segoe UI", sans-serif; }
.timer-running .timer-stat b::before { content: ""; width: 5px; height: 5px; margin: 0 6px 2px 0; display: inline-block; border-radius: 50%; background: var(--coral); }
.preview-label { display: flex; justify-content: space-between; width: min(100%, 794px); margin: 0 auto 10px; font-size: 11px; color: #49645f; }
.preview-label span { font-weight: 800; }

.worksheet {
  width: min(100%, 794px);
  aspect-ratio: 210 / 297;
  min-height: 900px;
  margin: 0 auto;
  padding: clamp(34px, 5vw, 64px);
  display: flex;
  flex-direction: column;
  color: #1c2a28;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.worksheet-header { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 24px; padding-bottom: 22px; border-bottom: 4px solid var(--ink); }
.worksheet-brand { display: flex; align-items: center; gap: 8px; }
.worksheet-brand span { width: 36px; height: 36px; font-size: 15px; }
.worksheet-brand b { font-size: 13px; }
.worksheet-header p { margin: 0 0 7px; color: var(--teal-dark); font-size: 9px; font-weight: 800; }
.worksheet-header h2 { margin: 0; font-size: 25px; line-height: 1.2; overflow-wrap: anywhere; }
.student-fields { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 28px; margin: 24px 0 8px; }
.student-fields span { display: flex; align-items: end; gap: 8px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.student-fields i { display: block; height: 19px; flex: 1; border-bottom: 1px solid #78908c; }
.student-fields b { font-size: 10px; }

.problem-list {
  list-style: none;
  padding: 0;
  margin: 22px 0 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(5, 1fr);
  grid-auto-flow: column;
  column-gap: 46px;
  flex: 1;
}
.problem {
  min-height: 104px;
  display: grid;
  grid-template-columns: 28px 1fr 52px;
  align-items: center;
  gap: 8px;
  border-bottom: 1px dashed #bdcbc8;
}
.problem:nth-child(5), .problem:nth-child(10) { border-bottom: 0; }
.problem-number {
  width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--teal);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
}
.equation { display: grid; grid-template-columns: 1fr 22px 1fr 20px; align-items: center; text-align: center; }
.equation b { font: 700 25px/1.2 "Segoe UI", sans-serif; }
.equation i { font: normal 18px/1 "Segoe UI", sans-serif; }
.answer-cell { display: grid; justify-items: center; gap: 3px; }
.answer-input {
  width: 48px;
  height: 42px;
  padding: 0 3px;
  text-align: center;
  color: var(--ink);
  background: #fff;
  border: 2px solid #344a46;
  border-radius: 0;
  outline: 0;
  font: 700 20px/1 "Segoe UI", sans-serif;
}
.answer-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(49,119,200,.16); }
.answer-input::-webkit-outer-spin-button, .answer-input::-webkit-inner-spin-button { appearance: none; margin: 0; }
.answer-cell small { color: #ba3e34; font-size: 8px; font-weight: 800; white-space: nowrap; }
.answers-visible .answer-input { color: var(--blue); border-color: var(--blue); background: #eff7ff; }
.problem.is-correct .problem-number { background: #16825c; }
.problem.is-correct .answer-input { color: #116646; border-color: #16825c; background: #effaf4; }
.problem.is-wrong .problem-number { background: #d14d42; }
.problem.is-wrong .answer-input { color: #a8362e; border-color: #d14d42; background: #fff2f0; }
.problem.is-column {
  grid-template-columns: 28px 1fr;
  align-items: center;
}
.column-equation {
  width: 82px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  justify-items: stretch;
}
.column-row { min-height: 24px; display: grid; grid-template-columns: 20px 1fr; align-items: center; }
.column-row i { text-align: center; font: normal 16px/1 "Segoe UI", sans-serif; }
.column-row b { text-align: right; padding-right: 10px; font: 700 20px/1 "Segoe UI", sans-serif; }
.column-rule { height: 2px; margin: 3px 0 4px; background: #344a46; }
.column-equation .answer-cell { min-height: 34px; justify-items: end; padding-right: 5px; }
.column-equation .answer-input { width: 52px; height: 31px; font-size: 17px; border-width: 0 0 1px; }
.long-division { width: 104px; margin: 0 auto; display: grid; justify-items: end; }
.long-division > .answer-cell { min-height: 33px; margin-right: 5px; }
.long-division .answer-input { width: 54px; height: 29px; font-size: 16px; border-width: 0 0 1px; }
.long-expression { width: 100%; min-height: 34px; display: grid; grid-template-columns: 34px 1fr; align-items: start; }
.long-expression b { padding: 8px 5px 0 0; text-align: right; font: 700 17px/1 "Segoe UI", sans-serif; }
.long-expression i { min-height: 34px; padding: 7px 7px 0 10px; border-top: 2px solid #344a46; border-left: 2px solid #344a46; border-radius: 13px 0 0; font: normal 700 18px/1 "Segoe UI", sans-serif; text-align: center; }
.output-note.is-error { color: #ba3e34; font-weight: 700; }
.answer-key { padding: 11px 14px; display: flex; align-items: center; gap: 13px; border: 1px solid #b8cbc7; background: #f1f7f6; font-size: 10px; }
.answer-key[hidden] { display: none; }
.answer-key strong { margin-right: 2px; color: var(--teal-dark); }
.worksheet-footer { padding-top: 16px; display: flex; justify-content: space-between; gap: 16px; border-top: 1px solid #c8d5d2; color: #687c78; font-size: 9px; }
.worksheet-footer b { color: var(--ink); }
.student-fields i { overflow: hidden; color: var(--ink); font-style: normal; text-align: center; white-space: nowrap; }
.print-packet { display: none; }

.usage-band { padding: 44px max(24px, calc((100% - 1160px) / 2)); display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: center; background: var(--yellow); }
.usage-band h2 { margin: 6px 0 0; font-size: 24px; }
.usage-band p { margin: 0; font-size: 13px; line-height: 1.75; }
.site-footer { padding: 22px max(24px, calc((100% - 1160px) / 2)); display: flex; justify-content: space-between; gap: 20px; color: #c6d4d2; background: #102724; font-size: 10px; }
.site-footer nav { display: flex; gap: 18px; }

.records-dialog {
  width: min(94vw, 660px);
  max-height: min(88vh, 820px);
  padding: 28px;
  color: var(--ink);
  border: 0;
  border-radius: 8px;
  box-shadow: 0 30px 90px rgba(0,0,0,.3);
}
.records-dialog::backdrop { background: rgba(10,29,27,.72); }
.dialog-close { position: absolute; top: 12px; right: 14px; width: 36px; height: 36px; border: 0; background: transparent; font-size: 25px; cursor: pointer; }
.records-heading > span { color: var(--teal-dark); font-size: 9px; font-weight: 800; }
.records-heading h2 { margin: 5px 36px 5px 0; font-size: 23px; }
.records-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.records-summary { margin: 20px 0; display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); border: 1px solid var(--line); }
.records-summary > div { min-width: 0; padding: 12px; display: flex; flex-direction: column; gap: 5px; border-right: 1px solid var(--line); }
.records-summary > div:last-child { border-right: 0; }
.records-summary small { color: var(--muted); font-size: 8px; }
.records-summary strong { overflow-wrap: anywhere; font-size: 13px; }
.records-section { margin-top: 20px; }
.records-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.records-section-head h3 { margin: 0; font-size: 13px; }
.records-section-head span { color: var(--muted); font-size: 9px; }
.week-chart { height: 114px; padding: 10px 10px 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; border: 1px solid var(--line); background: #f7faf9; }
.week-chart > div { height: 100%; display: grid; grid-template-rows: 1fr 20px; align-items: end; justify-items: center; }
.week-chart > div > b { position: relative; width: min(26px, 70%); min-height: 2px; display: block; background: var(--teal); }
.week-chart i { position: absolute; top: -15px; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 8px; font-style: normal; }
.week-chart span { font-size: 8px; }
.operation-records { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; }
.operation-records > div { display: grid; grid-template-columns: 68px 1fr 32px; align-items: center; gap: 8px; }
.operation-records span { font-size: 10px; font-weight: 800; }
.operation-records span small { margin-left: 4px; color: var(--muted); font-size: 7px; font-weight: 500; }
.operation-records i, .achievement i { height: 5px; overflow: hidden; background: #dce6e4; }
.operation-records i b, .achievement i b { height: 100%; display: block; background: var(--teal); }
.operation-records strong { text-align: right; font-size: 9px; }
.achievement-list { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.achievement { min-width: 0; padding: 9px; display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; color: #83918f; border: 1px solid #d9e2e0; background: #f7f9f8; }
.achievement > span { width: 20px; height: 20px; display: grid; place-items: center; border: 1px solid #bdc9c7; border-radius: 50%; font-size: 10px; font-weight: 800; }
.achievement > div { min-width: 0; display: grid; gap: 3px; }
.achievement b { font-size: 10px; }
.achievement small { font-size: 8px; }
.achievement > strong { font-size: 8px; white-space: nowrap; }
.achievement.is-unlocked { color: var(--ink); border-color: #a9c8c2; background: #eef8f5; }
.achievement.is-unlocked > span { color: #fff; border-color: var(--teal); background: var(--teal); }
.achievement.is-unlocked i b { background: var(--yellow); }
.records-account-link { margin-top: 20px; padding: 11px; display: block; text-align: center; color: #fff; background: var(--blue); border-radius: 5px; font-size: 10px; font-weight: 800; text-decoration: none; }

.output-gate {
  width: min(94vw, 480px);
  padding: 30px;
  color: var(--ink);
  border: 0;
  border-radius: 8px;
  box-shadow: 0 30px 90px rgba(0,0,0,.28);
}
.output-gate::backdrop { background: rgba(10, 29, 27, .72); }
.gate-close { position: absolute; top: 12px; right: 14px; width: 36px; height: 36px; border: 0; background: transparent; font-size: 25px; cursor: pointer; }
.gate-copy h2 { margin: 7px 30px 7px 0; font-size: 22px; }
.gate-copy p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.ad-wrap { width: 100%; min-height: 118px; padding: 8px; display: grid; place-items: center; align-content: center; overflow: hidden; border: 1px solid #d6e1df; background: #f4f7f6; }
.ad-wrap small { margin-bottom: 7px; color: #8a9b98; font-size: 8px; }
.ad-wrap.is-no-fill::after { content: "현재 표시할 광고가 없습니다."; color: var(--muted); font-size: 10px; }
.gate-status { display: grid; grid-template-columns: 54px 1fr; align-items: center; gap: 13px; }
.count-ring { width: 52px; height: 52px; display: flex; align-items: baseline; justify-content: center; padding-top: 11px; border: 2px solid var(--teal); border-radius: 50%; }
.count-ring b { font-size: 21px; }
.count-ring span { font-size: 9px; }
.gate-status strong { font-size: 12px; }
.gate-status p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.gate-progress { height: 4px; margin: 18px 0 14px; overflow: hidden; background: #dce6e4; }
.gate-progress::before { content: ""; display: block; width: var(--progress); height: 100%; background: var(--teal); transition: width .25s linear; }
.gate-action { width: 100%; min-height: 46px; color: #fff; background: var(--ink); }
.gate-action:disabled { color: #82918f; background: #dce4e2; cursor: wait; }

@media (max-width: 900px) {
  .app-header { grid-template-columns: 70px 1fr; }
  .app-header > img { display: none; }
  .workspace { grid-template-columns: 300px minmax(0, 1fr); }
  .control-panel { padding: 24px 20px; }
  .sheet-stage { padding: 22px 16px 38px; }
  .worksheet { min-height: 760px; padding: 36px; }
  .problem { min-height: 84px; grid-template-columns: 24px 1fr 40px; }
  .equation b { font-size: 20px; }
  .answer-input { width: 38px; height: 36px; font-size: 17px; }
  .problem-list { column-gap: 24px; }
  .problem.is-column { grid-template-columns: 24px 1fr; }
}

@media (max-width: 680px) {
  .app-header { min-height: 88px; padding: 13px 16px; grid-template-columns: 54px 1fr; gap: 10px; }
  .brand-mark { width: 42px; height: 42px; font-size: 17px; }
  .brand-lockup { gap: 10px; }
  .brand-lockup h1 { font-size: 22px; }
  .brand-lockup p { margin-top: 4px; font-size: 11px; }
  .account-link { top: 7px; right: 9px; }
  .workspace { width: 100%; display: block; overflow: hidden; }
  .control-panel { width: 100%; min-width: 0; padding: 22px 16px 18px; border: 0; border-bottom: 1px solid var(--line); }
  .control-panel fieldset, .control-panel label, .control-panel select, .today-button span, .today-button small { min-width: 0; }
  .today-button small { max-width: 48%; text-align: right; overflow-wrap: anywhere; }
  .panel-heading { margin-bottom: 18px; }
  .panel-heading strong { font-size: 19px; }
  fieldset { margin-bottom: 18px; }
  .text-field, .switch-row { margin-bottom: 18px; }
  .sheet-stage { padding: 18px 10px 30px; overflow-x: hidden; }
  .practice-toolbar { top: 4px; min-height: 44px; margin-bottom: 8px; padding: 6px 8px; }
  .preview-label { padding: 0 4px; }
  .worksheet { min-height: 0; padding: 24px 18px; }
  .worksheet-header { grid-template-columns: 86px 1fr; gap: 12px; padding-bottom: 14px; }
  .worksheet-brand span { width: 29px; height: 29px; font-size: 12px; }
  .worksheet-brand b { font-size: 10px; }
  .worksheet-header p { margin-bottom: 4px; font-size: 7px; }
  .worksheet-header h2 { font-size: 17px; }
  .student-fields { gap: 12px; margin-top: 16px; }
  .student-fields span { gap: 4px; font-size: 8px; }
  .student-fields b { font-size: 7px; }
  .problem-list { margin-top: 13px; column-gap: 10px; }
  .problem { min-height: 59px; grid-template-columns: 18px 1fr 29px; gap: 3px; }
  .problem-number { width: 17px; height: 17px; font-size: 8px; }
  .equation { grid-template-columns: 1fr 14px 1fr 12px; }
  .equation b { font-size: 14px; }
  .equation i { font-size: 11px; }
  .answer-input { width: 28px; height: 26px; border-width: 1px; font-size: 12px; }
  .answer-cell small { font-size: 6px; }
  .problem.is-column { grid-template-columns: 18px 1fr; }
  .column-equation { width: 58px; }
  .column-row { min-height: 17px; grid-template-columns: 15px 1fr; }
  .column-row i { font-size: 11px; }
  .column-row b { padding-right: 6px; font-size: 13px; }
  .column-rule { height: 1px; margin: 1px 0 2px; }
  .column-equation .answer-cell { min-height: 23px; padding-right: 3px; }
  .column-equation .answer-input { width: 38px; height: 21px; font-size: 11px; }
  .long-division { width: 67px; }
  .long-division > .answer-cell { min-height: 22px; margin-right: 3px; }
  .long-division .answer-input { width: 37px; height: 20px; font-size: 11px; }
  .long-expression { min-height: 23px; grid-template-columns: 24px 1fr; }
  .long-expression b { padding: 5px 3px 0 0; font-size: 11px; }
  .long-expression i { min-height: 23px; padding: 4px 4px 0 5px; border-width: 1px; border-radius: 9px 0 0; font-size: 12px; }
  .answer-key { padding: 7px; gap: 6px; flex-wrap: wrap; font-size: 7px; }
  .worksheet-footer { padding-top: 9px; font-size: 6px; }
  .usage-band { padding: 32px 20px; display: block; }
  .usage-band h2 { font-size: 20px; }
  .usage-band p { margin-top: 14px; }
  .site-footer { padding: 20px; flex-direction: column; }
  .records-dialog { width: 100vw; max-width: none; max-height: 92vh; margin: auto 0 0; padding: 24px 16px 18px; border-radius: 8px 8px 0 0; }
  .records-summary { grid-template-columns: 1fr 1fr; }
  .records-summary > div { border-bottom: 1px solid var(--line); }
  .records-summary > div:nth-child(2) { border-right: 0; }
  .records-summary > div:nth-last-child(-n+2) { border-bottom: 0; }
  .operation-records, .achievement-list { grid-template-columns: 1fr; }
  .output-gate { width: 100vw; max-width: none; margin: auto 0 0; padding: 26px 18px 20px; border-radius: 8px 8px 0 0; }
  .gate-ad-host { width: calc(100% + 36px); margin-inline: -18px; }
  .gate-ad-host .ad-wrap { border-inline: 0; }
}

@media print {
  @page { size: A4 portrait; margin: 10mm; }
  html, body { width: 210mm; min-width: 0; background: #fff; }
  .app-header, .control-panel, .practice-toolbar, .preview-label, .usage-band, .site-footer, .output-gate, .records-dialog { display: none !important; }
  .workspace, .sheet-stage { display: block; width: auto; min-height: 0; margin: 0; padding: 0; background: #fff; }
  .printing-packet .sheet-stage { display: none !important; }
  .printing-packet .print-packet { display: block; }
  .print-packet .worksheet { break-after: page; page-break-after: always; }
  .print-packet .worksheet:last-child { break-after: auto; page-break-after: auto; }
  .worksheet {
    width: 190mm;
    height: 277mm;
    min-height: 0;
    margin: 0;
    padding: 11mm 12mm 8mm;
    box-shadow: none;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .worksheet-header { grid-template-columns: 32mm 1fr; }
  .problem-list { column-gap: 11mm; }
  .problem { min-height: 25mm; }
  .answer-input { color: transparent; box-shadow: none !important; border-color: #344a46 !important; background: #fff !important; }
  .answers-visible .answer-input { color: var(--blue); border-color: var(--blue) !important; background: #eff7ff !important; }
  .is-answer-sheet .answer-input { color: var(--blue) !important; border-color: var(--blue) !important; background: #eff7ff !important; }
  .answer-cell small { display: none; }
  .problem.is-correct .problem-number, .problem.is-wrong .problem-number { background: var(--teal); }
}
