:root {
  color-scheme: light;
  --ink: #1f2328;
  --muted: #667085;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --line: #d8dee8;
  --blue: #2866c7;
  --green: #217a58;
  --red: #b5413c;
  --gold: #d89b21;
  --shadow: 0 20px 55px rgba(32, 38, 46, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Yu Gothic UI", "Hiragino Sans", "Meiryo", system-ui, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(40, 102, 199, 0.10), transparent 32%),
    linear-gradient(315deg, rgba(33, 122, 88, 0.10), transparent 30%),
    var(--paper);
}

button,
select,
textarea {
  font: inherit;
}

button,
select {
  min-height: 42px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.practice-panel,
.side-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.practice-panel {
  border-radius: 8px;
  padding: 26px;
}

.side-panel {
  border-radius: 8px;
  padding: 18px;
  align-self: start;
}

.topbar,
.question-meta,
.action-row,
.session-row,
.speech-row,
.history-head {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow,
.jp-label,
.feedback-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.7rem, 4vw, 2.55rem);
  line-height: 1.12;
}

h2 {
  font-size: 1rem;
}

.streak {
  display: grid;
  place-items: center;
  min-width: 88px;
  aspect-ratio: 1;
  border: 1px solid #f0cf84;
  border-radius: 8px;
  background: #fff7e3;
}

.streak span {
  font-size: 2rem;
  font-weight: 800;
  color: #8c5e00;
}

.streak small {
  color: #8c5e00;
  font-weight: 700;
}

.controls {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.9fr;
  gap: 12px;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

select {
  padding: 0 12px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

button {
  border: 1px solid var(--blue);
  border-radius: 8px;
  padding: 0 15px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.96);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.tab-button {
  background: #eef4ff;
  color: #24466f;
  border-color: #bfd2ef;
}

.tab-button.active {
  background: #24466f;
  color: #fff;
}

.question-card {
  border: 1px solid #cbd9ec;
  border-radius: 8px;
  background: #f7fbff;
  padding: 20px;
  margin-bottom: 16px;
}

.question-meta {
  justify-content: space-between;
  gap: 12px;
  color: #36516c;
  font-size: 0.86rem;
  font-weight: 800;
}

.japanese {
  min-height: 88px;
  margin: 8px 0 18px;
  font-size: clamp(1.55rem, 3.6vw, 2.65rem);
  line-height: 1.32;
  font-weight: 800;
}

.timer-line {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #dde9f7;
}

#timerBar {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold), var(--red));
  transform-origin: left center;
}

.answer-area {
  margin-bottom: 14px;
}

.answer-label {
  margin-bottom: 7px;
}

textarea {
  min-height: 116px;
  resize: vertical;
  padding: 14px;
  font-size: 1.02rem;
  line-height: 1.55;
}

.speech-row {
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.secondary {
  background: #eef4ff;
  color: #24466f;
  border-color: #bfd2ef;
}

.action-row {
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.session-row {
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 12px;
  padding: 10px;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #fbfcfe;
}

.session-row span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.success {
  border-color: var(--green);
  background: var(--green);
}

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

.ghost {
  min-height: 34px;
  padding: 0 10px;
  border-color: #c8ced8;
  background: #fff;
  color: #4b5563;
}

.feedback {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.feedback > div,
.coach-box,
.history-box,
.stats-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.feedback > div {
  min-height: 104px;
  padding: 14px;
}

#modelAnswer,
#hintText {
  margin: 0;
  line-height: 1.5;
}

#modelAnswer {
  font-size: 1.14rem;
  font-weight: 800;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stats-grid > div {
  display: grid;
  gap: 3px;
  min-height: 78px;
  place-items: center;
  padding: 10px 6px;
}

.stats-grid strong {
  font-size: 1.45rem;
}

.stats-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.coach-box,
.history-box {
  padding: 14px;
  margin-top: 12px;
}

ol {
  margin: 10px 0 0;
  padding-left: 20px;
  color: #344054;
  line-height: 1.65;
}

.history-head {
  justify-content: space-between;
  gap: 10px;
}

#historyList {
  display: grid;
  gap: 8px;
  min-height: 132px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

#historyList li {
  border-left: 4px solid var(--line);
  padding: 8px 9px;
  background: #f8fafc;
  color: #344054;
  font-size: 0.88rem;
  line-height: 1.35;
}

#historyList li.good {
  border-color: var(--green);
}

#historyList li.miss {
  border-color: var(--red);
}

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

  .side-panel {
    order: -1;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding: 9px 0;
  }

  .practice-panel,
  .side-panel {
    padding: 14px;
  }

  .topbar {
    align-items: start;
  }

  .streak {
    min-width: 66px;
  }

  .streak span {
    font-size: 1.45rem;
  }

  .controls,
  .feedback,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .japanese {
    min-height: 96px;
  }
}
