:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-strong: #fdfefe;
  --ink: #172033;
  --muted: #687386;
  --line: #dfe5ee;
  --line-strong: #c8d1df;
  --blue: #2865d8;
  --blue-ink: #16408b;
  --green: #2f8b6b;
  --amber: #b76d16;
  --red: #c4494d;
  --violet: #7457c8;
  --shadow: 0 18px 55px rgba(36, 48, 74, 0.13);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(246, 248, 251, 0.92), rgba(246, 248, 251, 0.98)),
    url("./assets/kana-field.svg") center 0 / cover fixed;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue-ink);
  font-size: 0.76rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.45rem;
  line-height: 1.15;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.top-actions,
.mode-tabs,
.answer-row,
.rating-row,
.chart-toolbar,
.legend,
.focus-numbers,
.api-status,
.chat-actions {
  display: flex;
  align-items: center;
}

.top-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip,
.icon-button,
.mode-tab,
.ghost,
.primary,
.rating,
.speak,
.quick-prompt {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease, color 160ms ease;
}

.chip,
.mode-tab,
.ghost,
.primary,
.rating,
.quick-prompt {
  padding: 0 13px;
  font-weight: 720;
}

.chip.is-active,
.mode-tab.is-active {
  border-color: rgba(40, 101, 216, 0.35);
  background: #eaf1ff;
  color: var(--blue-ink);
}

.icon-button,
.speak {
  width: 42px;
  padding: 0;
  font-weight: 800;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.trainer,
.side-panel {
  border: 1px solid rgba(205, 213, 226, 0.86);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.trainer {
  padding: 18px;
}

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

.mode-tabs {
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f3f6fa;
}

.mode-tab {
  min-height: 34px;
  border-color: transparent;
  background: transparent;
}

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

.stat {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.stat-value {
  display: block;
  font-size: 1.55rem;
  font-weight: 820;
  line-height: 1;
}

.stat-label {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.practice-pane {
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(280px, 1fr);
  gap: 14px;
}

.kana-card {
  position: relative;
  min-height: 430px;
  padding: 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(160deg, rgba(234, 241, 255, 0.78), rgba(255, 255, 255, 0.94) 54%),
    radial-gradient(circle at 24% 18%, rgba(47, 139, 107, 0.16), transparent 35%);
  overflow: hidden;
}

.queue-label {
  display: inline-flex;
  max-width: calc(100% - 54px);
  min-height: 30px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 740;
}

.speak {
  position: absolute;
  top: 14px;
  right: 14px;
}

.kana-glyph {
  display: grid;
  min-height: 210px;
  place-items: center;
  padding: 20px 0 8px;
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  font-size: clamp(7rem, 18vw, 12rem);
  font-weight: 760;
  line-height: 1;
}

.kana-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.kana-meta span {
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid rgba(104, 115, 134, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-weight: 720;
}

.memory-hook {
  margin: 0;
  color: #38445a;
  font-size: 1rem;
  line-height: 1.65;
}

.answer-form,
.feedback,
.rating-row,
.tutor-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.answer-form {
  padding: 16px;
  align-self: start;
}

.answer-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 740;
}

.answer-row {
  gap: 8px;
}

.answer-row input {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  outline: none;
}

.answer-row input:focus,
.chat-input textarea:focus {
  border-color: rgba(40, 101, 216, 0.65);
  box-shadow: 0 0 0 3px rgba(40, 101, 216, 0.12);
}

.primary {
  min-width: 86px;
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.feedback {
  min-height: 70px;
  padding: 14px 16px;
  color: var(--muted);
  line-height: 1.5;
  align-self: start;
}

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

.feedback.is-right {
  border-color: rgba(47, 139, 107, 0.35);
  color: var(--green);
}

.feedback.is-wrong {
  border-color: rgba(196, 73, 77, 0.35);
  color: var(--red);
}

.rating-row {
  align-self: start;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
}

.rating {
  flex: 1 1 88px;
}

.rating.again {
  color: var(--red);
}

.rating.hard {
  color: var(--amber);
}

.rating.good {
  color: var(--green);
}

.rating.easy {
  color: var(--blue);
}

.chart-pane {
  min-height: 420px;
}

.chart-toolbar {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.ghost {
  background: #f7f9fc;
}

.legend {
  gap: 12px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 720;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 5px;
  border-radius: 50%;
  vertical-align: middle;
}

.dot.new {
  background: var(--muted);
}

.dot.due {
  background: var(--amber);
}

.dot.learned {
  background: var(--green);
}

.kana-chart {
  display: grid;
  grid-template-columns: repeat(5, minmax(64px, 1fr));
  gap: 8px;
}

.chart-cell {
  min-height: 76px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.chart-cell .jp {
  display: block;
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  font-size: 1.8rem;
  font-weight: 760;
  line-height: 1;
}

.chart-cell .ro {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 740;
}

.chart-cell.is-due {
  border-color: rgba(183, 109, 22, 0.4);
  background: #fff7eb;
}

.chart-cell.is-learned {
  border-color: rgba(47, 139, 107, 0.35);
  background: #eef9f4;
}

.side-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.panel-art {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #edf3fb;
}

.focus-block,
.settings,
.review-list,
.tutor-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.84);
}

.focus-block h2 {
  margin-bottom: 12px;
}

.focus-meter {
  width: 100%;
  height: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f1;
}

.focus-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width 220ms ease;
}

.focus-numbers {
  justify-content: flex-end;
  gap: 4px;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 740;
}

#sprintDone {
  color: var(--ink);
}

.settings {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
}

.settings label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 740;
}

.settings input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--blue);
}

.settings output {
  color: var(--blue-ink);
  font-weight: 820;
}

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

.review-list ol {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-list li {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-weight: 740;
}

.review-list small {
  color: var(--muted);
  font-weight: 680;
}

.tutor-panel {
  display: grid;
  gap: 10px;
}

.api-status {
  justify-content: space-between;
  gap: 8px;
}

.status-pill {
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid rgba(104, 115, 134, 0.18);
  border-radius: 999px;
  background: #f7f9fc;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 740;
}

.status-pill.is-ok {
  color: var(--green);
}

.status-pill.is-bad {
  color: var(--red);
}

.chat-log {
  display: grid;
  max-height: 280px;
  overflow: auto;
  gap: 8px;
  padding-right: 2px;
}

.message {
  padding: 9px 10px;
  border-radius: var(--radius);
  line-height: 1.5;
  white-space: pre-wrap;
}

.message.user {
  margin-left: 24px;
  background: #eaf1ff;
  color: var(--blue-ink);
}

.message.assistant {
  margin-right: 18px;
  background: #f3f6fa;
}

.chat-input {
  display: grid;
  gap: 8px;
}

.chat-input textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  padding: 10px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
}

.chat-actions {
  justify-content: space-between;
  gap: 8px;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-prompt {
  min-height: 32px;
  padding: 0 9px;
  color: var(--muted);
  font-size: 0.8rem;
}

.hide {
  display: none !important;
}

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

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

  .panel-art {
    height: 100%;
    min-height: 160px;
  }
}

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

  .topbar,
  .trainer-head {
    display: grid;
  }

  .top-actions {
    justify-content: start;
  }

  .stats-grid,
  .practice-pane,
  .side-panel {
    grid-template-columns: 1fr;
  }

  .kana-card {
    min-height: 360px;
  }

  .answer-row {
    align-items: stretch;
    flex-direction: column;
  }

  .primary {
    width: 100%;
  }

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