:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #edf6f6;
  --ink: #16222d;
  --muted: #687789;
  --line: #d8e1e8;
  --teal: #0f7c83;
  --teal-dark: #075a61;
  --coral: #d94f3d;
  --gold: #be7c12;
  --green: #2f8a5f;
  --shadow: 0 18px 50px rgba(21, 35, 47, 0.11);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family:
    "Inter",
    "Segoe UI",
    "Yu Gothic UI",
    "Hiragino Sans",
    Meiryo,
    sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(18px, 4vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius);
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.eyebrow,
.panel-label,
.module-kicker,
.field-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 2vw, 1.75rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.25rem, 2vw, 1.7rem);
  line-height: 1.15;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.sound-button,
.nav-button,
.mode-tab,
.answer-button,
.mark-button,
.module-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
}

.icon-button svg,
.search-box svg,
.sound-button svg,
.mic-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.main-layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 0;
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 22px;
  background: #fbfcfd;
  min-height: calc(100vh - 80px);
}

.progress-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 16px;
}

.progress-number {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 10px 0 12px;
  font-size: 2.1rem;
  font-weight: 800;
}

.progress-number span:not(:first-child) {
  color: var(--muted);
  font-size: 1.05rem;
}

.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: #e4ecf2;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--green);
  border-radius: inherit;
  transition: width 180ms ease;
}

.search-box {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  margin-bottom: 16px;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.module-list {
  display: grid;
  gap: 8px;
}

.module-button {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px 12px;
  text-align: left;
}

.module-button:hover,
.module-button.is-active {
  border-color: rgba(15, 124, 131, 0.55);
  background: var(--surface-soft);
}

.module-button-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.module-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.module-goal {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.83rem;
}

.module-count {
  min-width: 34px;
  text-align: center;
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--teal-dark);
  background: #dff1f1;
  font-size: 0.82rem;
  font-weight: 800;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 18px;
  padding: clamp(20px, 4vw, 42px);
}

.workspace-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
}

.mode-tabs {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(64px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.mode-tab {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  color: var(--muted);
}

.mode-tab.is-active {
  background: var(--teal);
  color: #fff;
}

.lesson-card {
  min-height: 430px;
  display: grid;
  align-content: start;
  gap: 20px;
  padding: clamp(18px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.lesson-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.lesson-index {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.source-line {
  margin: 8px 0 0;
  font-size: clamp(2rem, 5vw, 4.8rem);
  line-height: 1.05;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.intent-line {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

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

.sound-button,
.answer-button,
.mark-button,
.nav-button,
.mic-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 800;
  white-space: nowrap;
}

.sound-button:hover,
.answer-button:hover,
.mark-button:hover,
.nav-button:hover,
.mic-button:hover,
.icon-button:hover {
  border-color: var(--teal);
}

.english-block {
  display: grid;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.primary-en {
  margin: 0;
  color: var(--teal-dark);
  font-size: clamp(1.6rem, 3vw, 2.65rem);
  line-height: 1.12;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.sample-en {
  margin: 0;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.7;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.detail-block {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.detail-block ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
}

.detail-block li,
.detail-block p {
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
}

.detail-block.warning {
  border-color: rgba(217, 79, 61, 0.35);
  background: #fff7f5;
}

.detail-block.warning .field-label {
  color: var(--coral);
}

.quiz-cover {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  border: 1px solid rgba(15, 124, 131, 0.2);
}

.quiz-cover p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.answer-button {
  width: fit-content;
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.lesson-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.lesson-actions-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mark-button.is-mastered {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.practice-panel {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

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

.practice-prompt {
  margin: 0;
  color: var(--ink);
  line-height: 1.6;
}

.mic-button {
  border: 1px solid var(--teal);
  border-radius: var(--radius);
  background: var(--teal);
  color: #fff;
}

.mic-button.is-recording {
  background: var(--coral);
  border-color: var(--coral);
}

.transcript-box {
  display: grid;
  gap: 10px;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.transcript-text {
  margin: 0;
  color: var(--ink);
  line-height: 1.55;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.score-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: #e9f6ef;
  color: var(--green);
  font-size: 0.85rem;
  font-weight: 900;
}

.score-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.fallback-input {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
}

.empty-state {
  min-height: 340px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.loading-state {
  display: grid;
  gap: 14px;
}

.loading-line {
  height: 26px;
  width: 70%;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #edf2f6, #f7f9fb, #edf2f6);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}

.loading-line.short {
  width: 42%;
}

.loading-line.wide {
  width: 90%;
  height: 120px;
}

.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;
}

@keyframes shimmer {
  from {
    background-position: 0% 0;
  }

  to {
    background-position: -200% 0;
  }
}

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

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

@media (max-width: 720px) {
  .topbar,
  .workspace-head,
  .lesson-top,
  .practice-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: static;
  }

  .workspace-head,
  .lesson-top {
    display: grid;
  }

  .mode-tabs,
  .module-list,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .sound-actions,
  .lesson-actions,
  .lesson-actions-group {
    justify-content: stretch;
  }

  .sound-button,
  .answer-button,
  .mark-button,
  .nav-button,
  .mic-button {
    width: 100%;
  }

  .lesson-card {
    min-height: auto;
  }
}
