:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d7dee8;
  --panel: #ffffff;
  --mist: #eef6f3;
  --accent: #0f8b8d;
  --accent-dark: #0a5f61;
  --coral: #df6b57;
  --gold: #e2a84b;
  --blue: #4169a8;
  --ok: #21835b;
  --bad: #bf3b3b;
  --shadow: 0 18px 50px rgba(31, 41, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 139, 141, 0.14), transparent 34%),
    linear-gradient(315deg, rgba(223, 107, 87, 0.13), transparent 32%),
    #f7faf9;
}

button,
select,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.hero {
  position: relative;
  min-height: 300px;
  display: grid;
  grid-template-columns: minmax(210px, 0.8fr) minmax(280px, 1.2fr) minmax(210px, 0.7fr);
  align-items: center;
  gap: 24px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(215, 222, 232, 0.9);
  box-shadow: var(--shadow);
}

.portal-hero {
  position: relative;
  min-height: 520px;
  display: grid;
  grid-template-columns: minmax(300px, 1.15fr) minmax(260px, 0.85fr);
  align-items: center;
  gap: 28px;
  padding: 72px 34px 34px;
  background:
    linear-gradient(135deg, rgba(16, 169, 214, 0.16), rgba(255, 255, 255, 0) 40%),
    #fff;
  border: 1px solid rgba(215, 222, 232, 0.9);
  box-shadow: var(--shadow);
}

.brand-mark {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 7px 10px 7px 12px;
  color: var(--accent-dark);
  background: #fff;
  border: 1px solid rgba(15, 139, 141, 0.22);
  text-decoration: none;
  box-shadow: 0 8px 22px rgba(31, 41, 51, 0.1);
}

.brand-mark span {
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-mark img {
  display: block;
  width: 72px;
  height: 24px;
  object-fit: cover;
  object-position: center;
}

.portal-brand {
  right: auto;
  left: 24px;
}

.portal-copy h1 {
  margin: 10px 0 16px;
  font-size: clamp(3rem, 7vw, 6.4rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.portal-copy p {
  max-width: 680px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.8;
}

.portal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.primary-link,
.secondary-link {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  font-weight: 850;
  line-height: 1.2;
  text-decoration: none;
}

.primary-link {
  color: #fff;
  background: var(--accent-dark);
}

.secondary-link {
  color: var(--accent-dark);
  background: #fff;
  border: 1px solid rgba(15, 139, 141, 0.34);
}

.portal-kana {
  min-height: 320px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.portal-kana span {
  display: grid;
  place-items: center;
  min-height: 136px;
  padding: 18px;
  color: #fff;
  background: var(--accent);
  font-weight: 900;
  box-shadow: 0 16px 34px rgba(31, 41, 51, 0.12);
}

.portal-kana span:nth-child(1) {
  background: var(--accent);
  font-size: 5rem;
}

.portal-kana span:nth-child(2) {
  background: var(--blue);
  font-size: 5rem;
}

.portal-kana span:nth-child(3) {
  background: var(--coral);
  font-size: 2rem;
}

.portal-kana span:nth-child(4) {
  background: var(--gold);
  color: var(--ink);
  font-size: 1.7rem;
}

.site-fit,
.placement-guide {
  margin-top: 18px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(31, 41, 51, 0.08);
}

.site-fit {
  display: grid;
  grid-template-columns: minmax(260px, 0.78fr) minmax(320px, 1.22fr);
  gap: 24px;
  align-items: center;
}

.site-fit h2,
.placement-guide h2 {
  margin: 6px 0 12px;
  font-size: 1.8rem;
}

.site-fit p,
.placement-guide p {
  color: var(--muted);
  line-height: 1.7;
}

.path-grid,
.guide-grid {
  display: grid;
  gap: 12px;
}

.path-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.guide-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.path-card {
  min-height: 190px;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 20px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  text-decoration: none;
}

.path-card strong,
.guide-grid strong {
  font-size: 1.08rem;
}

.path-card small {
  color: var(--muted);
  line-height: 1.6;
}

.path-step {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent-dark);
  font-weight: 900;
}

.guide-grid div {
  min-height: 150px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
}

.hero-art {
  min-height: 220px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.92) 0 31%, transparent 32%),
    conic-gradient(from 20deg, #0f8b8d, #e2a84b, #df6b57, #4169a8, #0f8b8d);
  clip-path: polygon(50% 0, 94% 25%, 94% 75%, 50% 100%, 6% 75%, 6% 25%);
}

.kana-orbit {
  position: relative;
  width: 176px;
  height: 176px;
  border: 2px solid rgba(31, 41, 51, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.74);
}

.kana-orbit span {
  position: absolute;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(31, 41, 51, 0.18);
}

.kana-orbit span:nth-child(1) { inset: -12px auto auto 63px; background: var(--accent); }
.kana-orbit span:nth-child(2) { inset: 28px -4px auto auto; background: var(--gold); }
.kana-orbit span:nth-child(3) { inset: auto -4px 28px auto; background: var(--coral); }
.kana-orbit span:nth-child(4) { inset: auto auto -12px 63px; background: var(--blue); }
.kana-orbit span:nth-child(5) { inset: auto auto 28px -4px; background: var(--accent-dark); }
.kana-orbit span:nth-child(6) { inset: 28px auto auto -4px; background: #6a7f3f; }

.hero-copy h1 {
  margin: 8px 0 12px;
  font-size: clamp(2.7rem, 6vw, 5.6rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.hero-copy p:last-child {
  margin: 0;
  max-width: 620px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.eyebrow {
  margin: 0;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.stats-panel div {
  padding: 16px;
  background: var(--ink);
  color: #fff;
}

.stats-panel span {
  display: block;
  font-size: 2rem;
  font-weight: 800;
}

.stats-panel small {
  color: rgba(255, 255, 255, 0.72);
}

.mode-tabs {
  display: flex;
  gap: 8px;
  margin: 18px 0;
  overflow-x: auto;
}

.tab-button {
  min-width: 92px;
  min-height: 44px;
  padding: 0 18px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
}

.tab-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 18px;
  color: var(--accent-dark);
  background: #fff;
  border: 1px solid rgba(15, 139, 141, 0.28);
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.tab-button.active {
  color: #fff;
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.workspace {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  align-items: start;
}

.control-panel,
.tab-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(31, 41, 51, 0.08);
}

.control-panel {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 16px;
  padding: 18px;
}

.field-label,
.toggle-group legend {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

select,
input[type="text"] {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.toggle-group {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
}

.toggle-group label,
.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.switch-row {
  justify-content: space-between;
  font-weight: 750;
}

.tab-panel {
  display: none;
  min-height: 520px;
  padding: 22px;
}

.tab-panel.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head h2 {
  margin: 4px 0 0;
  font-size: 1.6rem;
}

.icon-button,
.secondary-button,
.input-row button {
  min-height: 44px;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  line-height: 1.2;
}

.icon-button {
  width: 46px;
  padding: 0;
  border-radius: 50%;
}

.secondary-button {
  background: var(--ink);
}

.kana-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(94px, 1fr));
  gap: 10px;
}

.kana-tile {
  min-height: 104px;
  display: grid;
  gap: 4px;
  place-items: center;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
}

.kana-tile.mastered {
  border-color: rgba(33, 131, 91, 0.48);
  background: #f0faf5;
}

.kana-char {
  font-size: 2.4rem;
  font-weight: 850;
}

.kana-romaji {
  color: var(--muted);
  font-weight: 750;
}

.tile-score {
  width: 100%;
  height: 4px;
  background: #e8edf2;
}

.tile-score span {
  display: block;
  height: 100%;
  background: var(--ok);
}

.quiz-card,
.typing-card,
.word-card,
.vocab-card {
  min-height: 390px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  padding: 30px;
  background: linear-gradient(180deg, #fff, var(--mist));
  border: 1px solid var(--line);
}

.prompt-audio {
  justify-self: center;
}

.quiz-prompt,
.typing-prompt,
.word-kana,
.vocab-prompt {
  font-size: clamp(4rem, 12vw, 8rem);
  line-height: 1;
  font-weight: 900;
}

.quiz-hint,
.word-romaji,
.word-meaning,
.vocab-label {
  color: var(--muted);
  font-weight: 750;
  line-height: 1.5;
  text-align: center;
}

.answer-grid {
  width: min(560px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.answer-grid button {
  min-height: 58px;
  padding: 0 14px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 850;
}

.answer-grid button.correct {
  background: #e8f7ef;
  border-color: var(--ok);
}

.answer-grid button.wrong {
  background: #fff0ef;
  border-color: var(--bad);
}

.feedback {
  min-height: 28px;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.feedback.good {
  color: var(--ok);
}

.feedback.bad {
  color: var(--bad);
}

.typing-card {
  justify-items: stretch;
}

.vocab-card {
  justify-items: center;
}

.typing-prompt {
  text-align: center;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  width: min(520px, 100%);
  justify-self: center;
}

.word-card {
  text-align: center;
}

.word-kana {
  font-size: clamp(3.3rem, 10vw, 6.5rem);
}

.word-romaji {
  font-size: 1.4rem;
}

.word-meaning {
  font-size: 1.05rem;
}

.vocab-prompt {
  font-size: clamp(2.6rem, 8vw, 5.8rem);
  text-align: center;
}

.breakdown {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.breakdown span {
  min-width: 58px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  font-weight: 800;
}

@media (max-width: 860px) {
  .hero,
  .workspace,
  .portal-hero,
  .site-fit,
  .path-grid,
  .guide-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 20px;
    padding-top: 76px;
  }

  .hero-art {
    min-height: 190px;
  }

  .brand-mark {
    top: 16px;
    left: 20px;
    right: auto;
  }

  .portal-hero {
    padding: 76px 20px 20px;
  }

  .portal-kana {
    min-height: auto;
  }

  .stats-panel {
    grid-template-columns: repeat(3, 1fr);
  }

  .control-panel {
    position: static;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .hero-copy h1 {
    font-size: 3rem;
  }

  .stats-panel,
  .answer-grid,
  .input-row {
    grid-template-columns: 1fr;
  }

  .tab-panel,
  .quiz-card,
  .typing-card,
  .word-card,
  .vocab-card {
    padding: 16px;
  }

  .kana-grid {
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  }
}
