* {
  box-sizing: border-box;
}

:root {
  --ink: #17202f;
  --muted: #667085;
  --line: #d8dde6;
  --paper: #ffffff;
  --soft: #f4f7fb;
  --red: #c0392b;
  --red-soft: #fff0ee;
  --blue: #1f4d78;
  --blue-soft: #e8eef5;
  --teal: #177c70;
  --teal-soft: #e5f3ef;
  --amber: #9a6500;
  --amber-soft: #fff4dc;
  --shadow: 0 12px 30px rgba(23, 32, 47, 0.08);
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eef2f6;
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.72;
}

.app {
  min-height: 100vh;
}

.login-shell {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 24px 14px;
}

.login-shell.wide-login {
  width: min(100%, 860px);
}

.login-card,
.top-card,
.panel,
.day-card,
.word-card,
.list-card,
.task-button {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-card {
  padding: 22px;
  display: grid;
  gap: 14px;
}

.brand {
  display: grid;
  gap: 6px;
}

.eyebrow {
  margin: 0;
  color: var(--red);
  font-size: 12px;
  font-weight: 850;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 28px;
  line-height: 1.12;
}

.muted {
  color: var(--muted);
  line-height: 1.55;
}

.field {
  display: grid;
  gap: 7px;
  font-weight: 780;
}

.field input {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: 0;
  background: #fff;
}

.field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 77, 120, 0.12);
}

.primary,
.secondary,
.mode-button,
.day-card,
.choice-button,
.link-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 850;
}

.primary {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.secondary.is-active,
.mode-button.is-active,
.day-card.is-active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.secondary {
  padding: 9px 12px;
}

.logout-button {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.link-button {
  min-height: 36px;
  padding: 7px 10px;
  color: var(--blue);
  background: var(--blue-soft);
}

.error {
  color: var(--red);
  font-weight: 800;
}

.notice {
  border: 1px solid #b9e1da;
  background: var(--teal-soft);
  color: var(--teal);
  border-radius: 8px;
  padding: 10px;
  font-weight: 800;
}

.auth-tabs,
.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.check-field {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 760;
}

.check-field input {
  width: 18px;
  height: 18px;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.plan-card,
.checkout-box,
.legal-doc,
.mini-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 14px;
}

.plan-card h2 {
  margin-bottom: 8px;
  color: var(--blue);
}

.plan-card small {
  font-size: 14px;
  color: var(--muted);
}

.plan-card ul {
  margin: 0 0 14px;
  padding-left: 20px;
  color: var(--ink);
  line-height: 1.6;
}

.checkout-box {
  background: var(--amber-soft);
}

.divider {
  height: 1px;
  background: var(--line);
}

.shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  border-right: 1px solid var(--line);
  background: #fbfcfe;
  padding: 16px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
}

.top-card {
  padding: 14px;
}

.top-card h1 {
  font-size: 22px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.metric-grid.wide {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: var(--soft);
}

.metric strong {
  display: block;
  color: var(--blue);
  font-size: 20px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.day-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.day-card {
  padding: 10px;
  text-align: left;
}

.day-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.stage {
  min-width: 0;
  padding: 16px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mode-button {
  padding: 8px 12px;
}

.panel {
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.word-card {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.account-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 12px;
}

.word-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.word-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.word {
  margin: 0;
  font-size: 42px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.sound-button {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 0;
}

.sound-button:active {
  transform: translateY(1px);
}

.sound-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.meaning {
  color: var(--blue);
  font-weight: 850;
  font-size: 20px;
}

.chip-row,
.button-row,
.reason-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-actions {
  gap: 6px;
}

.tiny-button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 850;
}

.tiny-button.danger {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.chip {
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 8px;
  padding: 5px 8px;
  color: var(--muted);
  font-size: 12px;
}

.block {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  line-height: 1.55;
}

.block h3 {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.mission-band,
.level-band {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(135deg, #ffffff 0%, var(--blue-soft) 100%);
}

.mission-band {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.mission-band h3,
.level-band h3 {
  margin-bottom: 6px;
}

.mission-band .primary {
  min-width: 92px;
}

.level-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.level-head strong {
  color: var(--teal);
  font-size: 13px;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 8px;
  background: #dfe7f0;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--teal));
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.badge-card {
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  align-content: center;
  gap: 4px;
  background: var(--soft);
}

.badge-card.is-active {
  border-color: #b9e1da;
  background: var(--teal-soft);
}

.badge-card strong {
  color: var(--ink);
  font-size: 13px;
}

.badge-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.task-button {
  min-height: 96px;
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 5px;
  text-align: left;
}

.task-button strong {
  color: var(--ink);
}

.task-button span {
  color: var(--muted);
  font-size: 12px;
}

.reason-row {
  margin-top: 8px;
}

.reason-chip {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 850;
}

.reason-chip.is-active {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.choice-grid {
  display: grid;
  gap: 10px;
}

.choice-button {
  padding: 11px 12px;
  text-align: left;
}

.choice-button.correct {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
}

.choice-button.wrong {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.result {
  min-height: 28px;
  font-weight: 850;
}

.result .sound-button {
  width: 32px;
  height: 32px;
  min-height: 32px;
  margin-right: 4px;
  vertical-align: middle;
}

.result .sound-icon {
  width: 18px;
  height: 18px;
}

.result.good {
  color: var(--teal);
}

.result.bad {
  color: var(--red);
}

.list-grid {
  display: grid;
  gap: 10px;
}

.list-card {
  padding: 14px;
}

.list-card h3 {
  margin-bottom: 5px;
}

.list-card .word-line {
  margin-bottom: 5px;
}

.list-card .word {
  font-size: 22px;
}

.list-card .sound-button {
  width: 34px;
  height: 34px;
  min-height: 34px;
}

.list-card .sound-icon {
  width: 18px;
  height: 18px;
}

.list-card strong {
  color: var(--blue);
}

.mini-list {
  display: grid;
  gap: 3px;
}

.mini-list span {
  color: var(--muted);
  font-size: 13px;
}

.admin-shell {
  width: min(100%, 1240px);
  margin: 0 auto;
  padding: 18px;
  display: grid;
  gap: 12px;
}

.admin-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-panel {
  display: grid;
  gap: 12px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.admin-metric {
  background: var(--paper);
  box-shadow: var(--shadow);
}

.admin-two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
  gap: 12px;
}

.admin-code-layout {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(760px, 1fr);
  gap: 12px;
  align-items: start;
}

.admin-section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-size: 12px;
}

.admin-table small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 850;
  color: var(--muted);
  background: var(--soft);
}

.status-pill.good {
  border-color: #b9e1da;
  color: var(--teal);
  background: var(--teal-soft);
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.code-output {
  width: 100%;
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--soft);
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .side {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    grid-template-rows: auto auto auto;
  }

  .day-list {
    grid-auto-flow: column;
    grid-auto-columns: 150px;
    overflow-x: auto;
  }

  .stage {
    padding: 10px;
  }

  .mode-row {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 8px 0;
    background: #eef2f6;
  }

  .mode-button {
    flex: 1 1 42%;
  }

  .metric-grid.wide,
  .task-grid,
  .badge-grid,
  .plan-grid,
  .account-grid,
  .admin-grid,
  .admin-two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-code-layout {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 12px;
    box-shadow: none;
  }

  .word {
    font-size: 34px;
  }

  .primary,
  .secondary {
    flex: 1 1 44%;
  }

  .mission-band {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .metric-grid.wide,
  .task-grid,
  .badge-grid,
  .plan-grid,
  .account-grid,
  .admin-grid,
  .admin-two-col,
  .admin-code-layout,
  .admin-form {
    grid-template-columns: 1fr;
  }

  .admin-shell {
    padding: 10px;
  }

  .admin-top {
    display: grid;
  }
}
