:root {
  color-scheme: light;
  --ink: #111827;
  --ink-soft: #243244;
  --muted: #637183;
  --subtle: #8a97a6;
  --paper: #f5f8fb;
  --paper-strong: #edf3f7;
  --panel: #ffffff;
  --panel-tint: #f9fdfe;
  --line: #dce6ed;
  --line-strong: #c7d5df;
  --teal: #149982;
  --teal-deep: #0a776d;
  --mint: #64d6bd;
  --gold: #e3aa20;
  --coral: #d94650;
  --blue: #2f68d8;
  --radius-lg: 24px;
  --radius-md: 18px;
  --shadow-page: 0 28px 70px rgba(29, 49, 68, 0.1);
  --shadow-panel: 0 20px 54px rgba(31, 49, 66, 0.1);
  --shadow-control: 0 14px 28px rgba(17, 24, 39, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(245, 248, 251, 0.96) 42%, rgba(238, 244, 248, 0.96) 100%),
    linear-gradient(90deg, rgba(20, 153, 130, 0.04), rgba(227, 170, 32, 0.03));
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: min(1320px, calc(100% - 48px));
  min-height: 100svh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto 1fr;
  padding: 24px 0 30px;
}

.topbar,
.lesson-setup,
.control-strip,
.coach-panel,
.history-panel,
.archive-panel,
.listen-panel,
.language-panel,
.correction,
.login-panel {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(18px);
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-radius: 22px;
  padding: 14px 18px;
}

.brand {
  min-width: 0;
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 13px;
  font-weight: 900;
  font-size: 1.28rem;
}

.brand img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex: 0 0 auto;
  box-shadow: 0 10px 22px rgba(17, 24, 39, 0.12);
}

.top-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.status-pill,
.ui-language-control,
.top-model-control,
.logout-button {
  height: 46px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  white-space: nowrap;
}

.ui-language-control {
  gap: 9px;
  padding: 0 10px 0 14px;
}

.status-pill {
  gap: 9px;
  padding: 0 17px;
  color: var(--ink-soft);
  font-weight: 850;
}

.top-model-control {
  gap: 10px;
  padding: 0 8px 0 14px;
}

.top-control-label {
  color: var(--teal-deep);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.logout-button {
  gap: 9px;
  padding: 0 16px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
}

.dot,
.listen-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--teal);
  box-shadow: 0 0 0 5px rgba(20, 153, 130, 0.12);
}

.lesson-setup {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  align-items: end;
  border-radius: 22px;
  padding: 16px 18px;
}

.setup-field {
  min-width: 0;
  display: grid;
  gap: 9px;
}

.difficulty-field,
.language-pair-field,
.situation-field {
  grid-column: span 2;
}

.difficulty-options,
.turn-mode-options,
.model-tier-options {
  min-width: 0;
  display: grid;
  gap: 8px;
}

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

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

.model-tier-options {
  grid-template-columns: repeat(2, minmax(80px, 1fr));
}

.difficulty-button,
.turn-mode-button,
.model-tier-button {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink-soft);
  font-weight: 900;
}

.top-model-control .model-tier-options {
  min-width: 188px;
}

.top-model-control .model-tier-button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.difficulty-button.is-active,
.turn-mode-button.is-active,
.model-tier-button.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
  box-shadow: 0 12px 24px rgba(17, 24, 39, 0.14);
}

.difficulty-button:disabled,
.turn-mode-button:disabled,
.model-tier-button:disabled,
.situation-field input:disabled,
.voice-field select:disabled,
.language-select-wrap select:disabled,
.ui-language-control select:disabled,
.voice-sample-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.voice-control-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.language-pair-control {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.language-select-wrap {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.language-select-wrap span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
}

.situation-field input,
.voice-field select,
.language-select-wrap select,
.ui-language-control select {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 0 12px;
  font-weight: 760;
  outline: none;
}

.ui-language-control select {
  width: 168px;
  height: 34px;
  border-radius: 999px;
  padding: 0 30px 0 12px;
  font-size: 0.84rem;
}

.voice-field select,
.language-select-wrap select,
.ui-language-control select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.voice-sample-button {
  min-width: 86px;
  height: 44px;
  border: 1px solid rgba(20, 153, 130, 0.34);
  border-radius: 14px;
  background: rgba(242, 253, 250, 0.94);
  color: var(--teal-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  font-weight: 900;
}

.voice-sample-button .button-svg {
  width: 18px;
  height: 18px;
}

.situation-field input:focus,
.voice-field select:focus,
.language-select-wrap select:focus,
.ui-language-control select:focus,
.voice-sample-button:focus-visible,
.translation-toggle:focus-visible,
.turn-mode-button:focus-visible,
.model-tier-button:focus-visible,
.recommendation-list:focus-visible,
.recommendation-chip:focus-visible {
  outline: 2px solid rgba(47, 104, 216, 0.92);
  outline-offset: 2px;
  border-color: rgba(47, 104, 216, 0.62);
  box-shadow: 0 0 0 4px rgba(47, 104, 216, 0.11);
}

.session-shell {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 30px 0 0;
}

.study-options {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  margin: -6px 0 -8px;
}

.translation-toggle {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
}

.translation-toggle[aria-pressed="false"] {
  border-color: rgba(20, 153, 130, 0.34);
  background: rgba(242, 253, 250, 0.94);
  color: var(--teal-deep);
}

.translation-toggle .button-svg {
  width: 18px;
  height: 18px;
}

.voice-stage {
  min-height: 0;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.listen-panel {
  min-height: 322px;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  border-radius: var(--radius-lg);
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 253, 253, 0.94)),
    var(--panel);
}

.listen-status {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--teal-deep);
  font-weight: 900;
  line-height: 1;
}

.pulse {
  width: 170px;
  aspect-ratio: 1;
  position: relative;
  border-radius: 50%;
  display: grid;
  grid-auto-flow: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f4fbfa 100%);
  border: 1px solid var(--line-strong);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 18px 36px rgba(20, 153, 130, 0.1);
}

.pulse::before,
.pulse::after {
  content: "";
  position: absolute;
  inset: -14px;
  border: 1px solid rgba(20, 153, 130, 0.12);
  border-radius: inherit;
}

.pulse::after {
  inset: -27px;
  opacity: 0.55;
}

.pulse span {
  width: 9px;
  height: 34px;
  border-radius: 999px;
  background: var(--ink-soft);
  transform-origin: center;
}

.pulse span:nth-child(2),
.pulse span:nth-child(4) {
  height: 58px;
  background: var(--teal);
}

.pulse span:nth-child(3) {
  width: 10px;
  height: 88px;
  background: var(--gold);
}

.pulse.is-listening span,
.pulse.is-loading span {
  animation: voice 820ms ease-in-out infinite;
}

.pulse.is-listening span:nth-child(2),
.pulse.is-loading span:nth-child(2) {
  animation-delay: 90ms;
}

.pulse.is-listening span:nth-child(3),
.pulse.is-loading span:nth-child(3) {
  animation-delay: 170ms;
}

.pulse.is-listening span:nth-child(4),
.pulse.is-loading span:nth-child(4) {
  animation-delay: 250ms;
}

.pulse.is-listening span:nth-child(5),
.pulse.is-loading span:nth-child(5) {
  animation-delay: 330ms;
}

@keyframes voice {
  0%,
  100% {
    transform: scaleY(0.52);
  }

  50% {
    transform: scaleY(1.08);
  }
}

.language-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.language-grid.is-japanese-hidden {
  grid-template-rows: minmax(0, 1fr);
}

.language-panel {
  min-height: 152px;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 24px 30px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98) 0%, rgba(249, 253, 254, 0.98) 100%),
    var(--panel);
}

.language-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.94);
}

.language-panel p {
  margin: 24px 0 0;
  color: var(--ink);
  font-weight: 900;
  line-height: 1.13;
  font-size: 2.35rem;
  overflow-wrap: normal;
  text-wrap: pretty;
  word-break: normal;
}

.japanese-panel {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98) 0%, rgba(246, 253, 251, 0.98) 100%),
    var(--panel);
}

.japanese-panel[hidden] {
  display: none;
}

.japanese-panel p {
  line-height: 1.22;
  font-size: 2.08rem;
  line-break: strict;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.japanese-panel p.is-pending {
  color: var(--muted);
  font-size: 1.55rem;
}

.phrase-token {
  display: inline-block;
  white-space: pre-wrap;
}

.panel-label {
  color: var(--teal-deep);
  font-size: 0.76rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.correction {
  grid-column: 2;
  min-height: 92px;
  border-color: rgba(217, 70, 80, 0.3);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: 0 18px 38px rgba(217, 70, 80, 0.09);
}

.correction p,
.heard p {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 1.08rem;
  line-height: 1.48;
  font-weight: 760;
  overflow-wrap: anywhere;
}

.voice-heard {
  width: 100%;
  align-self: end;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.74);
  padding: 11px 14px;
  box-shadow: none;
}

.voice-heard .panel-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.68rem;
}

.voice-heard p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 780;
  text-align: left;
}

.control-strip {
  width: 100%;
  justify-self: center;
  min-height: 86px;
  display: grid;
  grid-template-columns: minmax(112px, 0.46fr) minmax(260px, 1fr) minmax(220px, 0.72fr) minmax(188px, 0.64fr);
  align-items: center;
  justify-content: center;
  gap: 14px;
  border-radius: 22px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.9);
}

.coach-panel {
  width: 100%;
  justify-self: center;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.82fr);
  gap: 16px;
  border-radius: 22px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.88);
}

.recommendation-area,
.coach-area {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 12px;
}

.recommendation-list {
  display: grid;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 16px;
  outline: none;
}

.recommendation-chip {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(248, 251, 254, 0.94);
  color: var(--ink);
  padding: 9px 12px;
  text-align: left;
  font-weight: 820;
  line-height: 1.36;
  cursor: pointer;
  display: grid;
  gap: 3px;
}

.recommendation-chip:hover {
  border-color: rgba(47, 104, 216, 0.34);
  box-shadow: 0 10px 22px rgba(17, 24, 39, 0.08);
}

.recommendation-status {
  min-height: 44px;
  display: flex;
  gap: 9px;
  align-items: center;
  color: var(--muted);
  cursor: default;
}

.recommendation-status::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid rgba(21, 143, 133, 0.24);
  border-top-color: var(--teal);
  border-radius: 999px;
  animation: spin 0.85s linear infinite;
}

.recommendation-status:hover {
  border-color: var(--line);
  box-shadow: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.recommendation-english {
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 900;
}

.recommendation-japanese {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 780;
}

.coach-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.coach-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: var(--paper-strong);
  color: var(--muted);
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 900;
}

.coach-output {
  display: grid;
  gap: 9px;
}

.coach-output[hidden],
.recommendation-list[hidden] {
  display: none;
}

.coach-heard,
.coach-suggestion {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(249, 253, 254, 0.92);
  padding: 11px 12px;
  overflow-wrap: anywhere;
}

.coach-heard {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 760;
}

.coach-suggestion {
  display: grid;
  gap: 8px;
  color: var(--ink);
}

.coach-suggestion p {
  margin: 0;
}

.coach-support-english {
  color: var(--ink);
  font-size: clamp(1.12rem, 1.5vw, 1.34rem);
  font-weight: 950;
  line-height: 1.28;
}

.coach-support-note {
  border-top: 1px solid rgba(18, 128, 116, 0.14);
  padding-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 760;
  line-height: 1.45;
}

.coach-button {
  min-height: 48px;
  border: 1px solid rgba(20, 153, 130, 0.36);
  border-radius: 999px;
  background: rgba(242, 253, 250, 0.94);
  color: var(--teal-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
}

.coach-button.is-active {
  border-color: rgba(217, 70, 80, 0.48);
  background: rgba(255, 244, 245, 0.96);
  color: var(--coral);
}

.coach-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.icon-button,
.realtime-button,
.replay-button,
.coach-button,
.difficulty-button,
.turn-mode-button,
.model-tier-button,
.voice-sample-button,
.translation-toggle,
.confirm-button,
.logout-button,
.login-submit {
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.icon-button:hover,
.realtime-button:hover,
.replay-button:hover,
.coach-button:hover,
.difficulty-button:hover,
.turn-mode-button:hover,
.model-tier-button:hover,
.voice-sample-button:hover,
.translation-toggle:hover,
.confirm-button:hover,
.logout-button:hover,
.login-submit:hover {
  box-shadow: 0 16px 34px rgba(17, 24, 39, 0.13);
}

.icon-button:active,
.realtime-button:active,
.replay-button:active,
.coach-button:active,
.difficulty-button:active,
.turn-mode-button:active,
.model-tier-button:active,
.voice-sample-button:active,
.translation-toggle:active,
.confirm-button:active,
.logout-button:active,
.login-submit:active {
  transform: translateY(1px);
}

.icon-button,
.realtime-button,
.replay-button {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-weight: 850;
  white-space: nowrap;
}

.icon-button {
  padding: 0 16px;
}

.realtime-button {
  padding: 0 18px;
  border-color: rgba(47, 104, 216, 0.28);
  background: rgba(245, 249, 255, 0.94);
  color: #184ea7;
  min-height: 58px;
  font-size: 1.06rem;
}

.realtime-button.is-connecting,
.realtime-button.is-connected {
  border-color: rgba(47, 104, 216, 0.5);
  background: linear-gradient(180deg, #3a78e9 0%, #235fc9 100%);
  color: white;
  box-shadow: 0 14px 28px rgba(47, 104, 216, 0.18);
}

.replay-button {
  padding: 0 18px;
}

.replay-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  box-shadow: none;
}

.realtime-button .button-svg,
.replay-button .button-svg {
  width: 19px;
  height: 19px;
}

.button-svg {
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
}

.button-svg * {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logout-svg {
  width: 18px;
  height: 18px;
}

.confirm-overlay[hidden] {
  display: none;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 24, 39, 0.34);
  backdrop-filter: blur(10px);
}

.confirm-dialog {
  width: min(380px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow-control);
}

.confirm-dialog h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1.5;
}

.confirm-dialog p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
  font-weight: 720;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

.confirm-button {
  min-height: 46px;
  border-radius: 999px;
  border: 0;
  font-weight: 880;
}

.confirm-button.secondary {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.confirm-button.primary {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
}

.history-panel {
  border-radius: 22px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.88);
}

.archive-panel {
  border-radius: 22px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.88);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-count {
  min-width: 28px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--paper-strong);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 950;
}

.history-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(250, 253, 254, 0.96));
  padding: 14px 16px;
  display: grid;
  gap: 10px;
}

.history-bubble {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
}

.history-user {
  width: min(78%, 720px);
  justify-self: start;
  background: rgba(245, 249, 255, 0.9);
  border-color: rgba(47, 104, 216, 0.18);
}

.history-ai {
  width: min(86%, 820px);
  justify-self: end;
  background: rgba(242, 253, 250, 0.92);
  border-color: rgba(20, 153, 130, 0.2);
}

.history-role {
  color: var(--teal-deep);
  font-size: 0.76rem;
  font-weight: 950;
  line-height: 1.45;
}

.history-bubble p {
  margin: 0;
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.45;
  font-weight: 740;
  overflow-wrap: anywhere;
}

.history-japanese {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 760;
}

.archive-summary {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  font-weight: 740;
}

.archive-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.archive-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(249, 253, 254, 0.94);
  padding: 12px 14px;
}

.archive-title {
  color: var(--teal-deep);
  font-size: 0.8rem;
  font-weight: 950;
}

.archive-item p {
  margin: 6px 0 0;
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.45;
  font-weight: 740;
  overflow-wrap: anywhere;
}

.login-view {
  min-height: 100svh;
  width: min(100% - 30px, 520px);
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 28px 0;
}

.login-panel {
  width: 100%;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(249, 253, 254, 0.96)),
    var(--panel);
  box-shadow: var(--shadow-page);
  padding: 32px;
}

.login-brand {
  margin-bottom: 28px;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 26px;
}

.login-form label {
  display: grid;
  gap: 9px;
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 900;
}

.login-form input {
  width: 100%;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 15px;
  background: white;
  color: var(--ink);
  font-weight: 760;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.login-form input:focus {
  border-color: rgba(20, 153, 130, 0.72);
  box-shadow: 0 0 0 4px rgba(20, 153, 130, 0.12);
}

.login-submit {
  height: 54px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #18a98f 0%, #0b8277 100%);
  color: white;
  font-weight: 950;
}

.login-submit:disabled {
  cursor: wait;
  opacity: 0.72;
}

.login-error {
  margin: 0;
  color: var(--coral);
  font-weight: 820;
}

.login-status {
  margin: 20px 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.login-status div {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px;
  background: var(--panel-tint);
}

.login-status dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.login-status dd {
  margin: 4px 0 0;
  font-size: 0.9rem;
  font-weight: 800;
}

@media (max-width: 1100px) {
  .app {
    width: min(100% - 36px, 940px);
  }

  .topbar,
  .lesson-setup,
  .session-shell {
    min-width: 0;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .top-actions {
    min-width: 0;
    flex: 1 1 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .lesson-setup {
    grid-template-columns: 1fr;
  }

  .language-pair-field {
    grid-column: 1;
  }

  .difficulty-field,
  .situation-field {
    grid-column: 1;
  }

  .voice-stage {
    grid-template-columns: 1fr;
  }

  .listen-panel {
    min-height: 190px;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 28px;
    justify-items: start;
  }

  .listen-status {
    grid-column: 2;
    grid-row: 1;
  }

  .pulse {
    grid-column: 1;
    grid-row: 1 / 3;
    width: 126px;
  }

  .voice-heard {
    grid-column: 2;
    grid-row: 2;
  }

  .correction {
    grid-column: auto;
  }

  .coach-panel {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 821px) and (max-width: 1100px) {
  .control-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .realtime-button,
  .coach-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .app {
    width: min(100% - 22px, 600px);
    padding: 12px 0 16px;
  }

  .topbar {
    min-height: 64px;
    flex-wrap: wrap;
    border-radius: 18px;
    padding: 10px 11px;
  }

  .brand {
    gap: 10px;
    font-size: 1.04rem;
  }

  .brand img {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .top-actions {
    width: 100%;
    flex: 1 1 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 7px;
  }

  .status-pill,
  .ui-language-control,
  .top-model-control {
    height: 40px;
    padding: 0 12px;
    font-size: 0.9rem;
  }

  .top-model-control {
    gap: 8px;
  }

  .ui-language-control {
    gap: 8px;
  }

  .top-control-label {
    display: none;
  }

  .ui-language-control select {
    width: 142px;
  }

  .top-model-control .model-tier-options {
    min-width: 184px;
  }

  .logout-button {
    width: 42px;
    height: 40px;
    padding: 0;
    justify-content: center;
  }

  .logout-text {
    display: none;
  }

  .logout-svg {
    width: 20px;
    height: 20px;
  }

  .lesson-setup {
    margin-top: 14px;
    border-radius: 20px;
    padding: 13px;
  }

  body.is-setup-collapsed .lesson-setup {
    max-height: 0;
    margin-top: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    box-shadow: none;
  }

  .language-pair-control {
    grid-template-columns: 1fr;
  }

  .voice-control-row {
    grid-template-columns: 1fr;
  }

  .voice-sample-button {
    width: 100%;
  }

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

  .difficulty-button,
  .turn-mode-button,
  .model-tier-button,
  .situation-field input,
  .voice-field select,
  .language-select-wrap select,
  .ui-language-control select,
  .voice-sample-button {
    min-height: 42px;
  }

  .session-shell {
    gap: 10px;
    padding: 10px 0 0;
  }

  .study-options {
    order: 1;
    justify-content: stretch;
    margin: -2px 0 -4px;
  }

  .translation-toggle {
    width: 100%;
    min-height: 40px;
    font-size: 0.9rem;
  }

  .voice-stage,
  .language-grid {
    gap: 10px;
  }

  .voice-stage {
    order: 2;
  }

  body.is-setup-collapsed .voice-stage {
    display: contents;
  }

  .language-grid {
    grid-template-columns: 1fr;
    order: 1;
  }

  body.is-setup-collapsed .language-grid {
    order: 2;
  }

  .listen-panel {
    order: 2;
    min-height: 128px;
    border-radius: 20px;
    padding: 16px;
  }

  .pulse {
    width: 92px;
  }

  .pulse span {
    width: 6px;
    height: 21px;
  }

  .pulse span:nth-child(2),
  .pulse span:nth-child(4) {
    height: 36px;
  }

  .pulse span:nth-child(3) {
    height: 50px;
  }

  body.is-setup-collapsed .listen-panel {
    order: 4;
    min-height: 74px;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 12px;
    align-items: center;
    justify-items: start;
    padding: 10px 12px;
    text-align: left;
  }

  body.is-setup-collapsed .pulse {
    width: 58px;
  }

  body.is-setup-collapsed .pulse span {
    width: 5px;
    height: 16px;
  }

  body.is-setup-collapsed .pulse span:nth-child(2),
  body.is-setup-collapsed .pulse span:nth-child(4) {
    height: 27px;
  }

  body.is-setup-collapsed .pulse span:nth-child(3) {
    height: 36px;
  }

  body.is-setup-collapsed .voice-heard {
    padding: 8px 10px;
  }

  body.is-setup-collapsed .voice-heard p {
    max-height: 2.6em;
    overflow: hidden;
    font-size: 0.82rem;
  }

  .language-panel {
    min-height: 126px;
    border-radius: 20px;
    padding: 16px 18px;
  }

  .language-panel p {
    margin-top: 15px;
    font-size: 1.5rem;
    line-height: 1.14;
  }

  .japanese-panel {
    min-height: 92px;
  }

  .japanese-panel p {
    margin-top: 12px;
    font-size: 1.18rem;
    line-height: 1.24;
  }

  .control-strip {
    order: 4;
    min-height: auto;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 9px;
    border-radius: 20px;
    padding: 10px;
  }

  .coach-panel {
    order: 3;
    border-radius: 20px;
    padding: 12px;
    gap: 10px;
    align-content: start;
  }

  body.is-setup-collapsed .control-strip {
    order: 5;
  }

  body.is-setup-collapsed .correction {
    order: 4;
  }

  .recommendation-list:not([hidden]) {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 84%);
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-padding-inline: 2px;
    scroll-snap-type: x proximity;
    scrollbar-color: rgba(47, 104, 216, 0.34) transparent;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    padding: 0 2px 2px 0;
  }

  .recommendation-list[data-scrollable="true"]:not([hidden]) {
    padding: 0 18px 2px 0;
    background:
      linear-gradient(90deg, transparent calc(100% - 22px), rgba(248, 251, 254, 0.98) 100%),
      linear-gradient(90deg, rgba(47, 104, 216, 0), rgba(47, 104, 216, 0.12));
    background-size: 100% 100%, 22px 100%;
    background-position: 0 0, right center;
    background-repeat: no-repeat;
  }

  .recommendation-chip {
    min-height: 58px;
    scroll-snap-align: start;
  }

  .recommendation-english {
    font-size: 0.96rem;
  }

  .recommendation-japanese {
    font-size: 0.8rem;
  }

  .icon-button,
  .realtime-button,
  .replay-button,
  .coach-button {
    min-height: 46px;
    padding: 0 12px;
    font-size: 0.9rem;
  }

  .icon-button {
    grid-column: 1;
    grid-row: 2;
  }

  .realtime-button {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .replay-button {
    grid-column: 2;
    grid-row: 2;
  }

  .coach-button {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .history-panel,
  .archive-panel {
    border-radius: 20px;
    padding: 14px;
  }

  .history-user,
  .history-ai {
    width: 100%;
  }

  .login-panel {
    padding: 24px;
  }
}

@media (max-width: 430px) {
  .brand span {
    max-width: 104px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .status-pill {
    max-width: 92px;
  }

  .listen-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    justify-items: center;
    text-align: center;
  }

  .listen-status,
  .pulse,
  .voice-heard {
    grid-column: auto;
    grid-row: auto;
  }

  .voice-heard {
    margin-top: 2px;
  }

  body.is-setup-collapsed .listen-panel {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    justify-items: start;
    text-align: left;
    min-height: 72px;
  }

  body.is-setup-collapsed .listen-status,
  body.is-setup-collapsed .pulse,
  body.is-setup-collapsed .voice-heard {
    grid-column: auto;
    grid-row: auto;
  }

  .language-panel p {
    font-size: 1.42rem;
  }

  .japanese-panel p {
    font-size: 1.08rem;
  }

  .recommendation-list:not([hidden]) {
    grid-auto-columns: minmax(210px, 88%);
  }

  .difficulty-options,
  .model-tier-options {
    gap: 7px;
  }

  .difficulty-button,
  .model-tier-button {
    font-size: 0.88rem;
  }

  .replay-button,
  .realtime-button,
  .coach-button,
  .icon-button {
    font-size: 0.84rem;
  }
}

@media (max-width: 380px) {
  body.is-setup-collapsed .session-shell {
    gap: 8px;
    padding-top: 8px;
  }

  body.is-setup-collapsed .language-grid {
    gap: 8px;
  }

  body.is-setup-collapsed .language-panel {
    min-height: 116px;
    padding: 14px 16px;
  }

  body.is-setup-collapsed .language-panel p {
    margin-top: 12px;
    font-size: 1.36rem;
  }

  body.is-setup-collapsed .japanese-panel {
    min-height: 82px;
  }

  body.is-setup-collapsed .japanese-panel p {
    font-size: 1.02rem;
  }

  body.is-setup-collapsed .coach-panel {
    padding: 10px;
    gap: 8px;
  }

  body.is-setup-collapsed .recommendation-list:not([hidden]) {
    grid-auto-columns: minmax(204px, 88%);
  }

  body.is-setup-collapsed .recommendation-chip {
    min-height: 54px;
    padding: 8px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
