:root {
  --bg: #f6f3ed;
  --surface: #ffffff;
  --surface-soft: #faf8f4;
  --border: #e5dfd5;
  --border-strong: #d5cdc0;
  --ink: #1d242b;
  --ink-muted: #5d6773;
  --ink-faint: #8a939e;

  --indigo: #294b7a;
  --indigo-hover: #1e395f;
  --indigo-soft: #edf2fa;

  --vermilion: #d64933;
  --vermilion-hover: #b83a26;
  --vermilion-soft: #fdf0ed;

  --matcha: #2a7b57;
  --matcha-soft: #eaf6f0;

  --amber: #b86e00;
  --amber-soft: #fef6e4;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(29, 36, 43, 0.05);
  --shadow-md: 0 8px 24px rgba(29, 36, 43, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* App Shell */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.studio-header {
  height: 60px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--indigo), #3d6aa6);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 10px rgba(41, 75, 122, 0.25);
}

.brand-text h1 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.brand-text span {
  font-size: 12px;
  color: var(--ink-muted);
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-pill {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.stat-label {
  color: var(--ink-muted);
}

.stat-pill strong {
  color: var(--indigo);
  font-size: 13px;
}

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

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

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

.status-dot.live {
  background: var(--matcha);
}

/* Main 3-Column Grid */
.studio-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 285px minmax(420px, 1fr) 415px;
  gap: 14px;
  padding: 14px;
  overflow: hidden;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Buttons */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-indigo {
  background: var(--indigo);
  color: #fff;
}

.btn-indigo:hover:not(:disabled) {
  background: var(--indigo-hover);
}

.btn-vermilion {
  background: var(--vermilion);
  color: #fff;
}

.btn-vermilion:hover:not(:disabled) {
  background: var(--vermilion-hover);
}

.btn-vermilion.recording {
  animation: pulseRing 1.4s infinite;
}

.btn-vermilion-soft {
  background: var(--vermilion-soft);
  color: var(--vermilion);
  border: 1px solid #f5cdc5;
}

.btn-vermilion-soft:hover:not(:disabled) {
  background: #fbe3de;
}

.btn-soft-green {
  background: var(--matcha-soft);
  color: var(--matcha);
  border: 1px solid #c5e6d5;
}

.btn-soft-green.is-done {
  background: var(--matcha);
  color: #fff;
  border-color: var(--matcha);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-soft);
  color: var(--ink);
}

.btn-outline {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface-soft);
}

.btn-link {
  background: none;
  border: none;
  color: var(--indigo);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}

.btn-link:hover {
  background: var(--indigo-soft);
}

/* Badges */
.badge-indigo, .badge-muted, .badge-amber {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
}

.badge-indigo {
  background: var(--indigo-soft);
  color: var(--indigo);
}

.badge-muted {
  background: var(--surface-soft);
  color: var(--ink-muted);
  border: 1px solid var(--border);
}

.badge-amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.muted-note {
  font-size: 12px;
  color: var(--ink-muted);
}

/* LEFT PANEL: Library */
.panel-head {
  padding: 14px 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
}

.collection-tabs {
  display: flex;
  gap: 6px;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.col-tab {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--ink-muted);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.col-tab.active {
  background: var(--indigo);
  color: #fff;
  border-color: var(--indigo);
}

.search-wrap {
  padding: 10px 12px 8px;
}

.search-wrap input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface-soft);
  color: var(--ink);
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--indigo);
  background: #fff;
}

.library-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 14px;
}

.unit-group {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-soft);
}

.unit-group summary {
  padding: 9px 11px;
  cursor: pointer;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  user-select: none;
}

.unit-group summary::-webkit-details-marker {
  display: none;
}

.unit-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
}

.unit-scene-sub {
  font-size: 11px;
  color: var(--ink-muted);
}

.unit-tracks {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.track-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 7px 9px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink);
  font-family: inherit;
}

.track-item:hover {
  background: var(--surface-soft);
}

.track-item.active {
  background: var(--indigo-soft);
  color: var(--indigo);
  font-weight: 700;
}

.track-item-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.track-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.done-check {
  color: var(--matcha);
  font-weight: 700;
  font-size: 12px;
}

.track-size {
  font-size: 11px;
  color: var(--ink-faint);
  flex-shrink: 0;
}

/* CENTER PANEL: Shadowing Player */
.player-panel {
  padding: 16px 18px 10px;
  gap: 12px;
  overflow-y: auto;
}

.track-hero {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.track-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.track-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.track-title {
  margin: 0;
  font-size: 19px;
  line-height: 1.3;
}

.scene-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  flex-wrap: wrap;
}

.scene-label {
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 600;
}

.scene-label code {
  background: #ede9e0;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--indigo);
}

.scene-controls select {
  border: 1px solid var(--border-strong);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 12.5px;
  color: var(--ink);
  font-weight: 600;
  font-family: inherit;
}

/* Player Card */
.player-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
}

.mono-time {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: var(--ink-muted);
  font-weight: 600;
}

.echo-banner {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--vermilion-soft);
  color: var(--vermilion);
  border: 1px solid #f5c9c0;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 700;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--vermilion);
  animation: pulseDot 1s infinite;
}

.scrubber {
  position: relative;
  height: 22px;
  background: #e9e4da;
  border-radius: 999px;
  cursor: pointer;
  overflow: visible;
  display: flex;
  align-items: center;
}

.scrubber-segments {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 999px;
  overflow: hidden;
}

.seg-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1.5px;
  background: rgba(255, 255, 255, 0.7);
}

.scrubber-ab {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(184, 110, 0, 0.28);
  border-left: 2px solid var(--amber);
  border-right: 2px solid var(--amber);
  pointer-events: none;
}

.scrubber-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--indigo), #4c75ad);
  border-radius: 999px;
  pointer-events: none;
}

.scrubber-thumb {
  position: absolute;
  left: 0%;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--indigo);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.transport-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.transport-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-play {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--indigo);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(41, 75, 122, 0.28);
}

.btn-play:hover {
  background: var(--indigo-hover);
}

.btn-icon, .btn-pill {
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  height: 34px;
  padding: 0 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-icon:hover, .btn-pill:hover {
  background: var(--indigo-soft);
  border-color: var(--indigo);
  color: var(--indigo);
}

.speed-group {
  display: inline-flex;
  background: #ece7de;
  padding: 3px;
  border-radius: 9px;
  gap: 2px;
}

.speed-btn {
  border: none;
  background: transparent;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
}

.speed-btn.active {
  background: #fff;
  color: var(--indigo);
  box-shadow: var(--shadow-sm);
}

.drill-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.ab-group, .loop-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.control-label {
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 600;
}

.btn-chip {
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.btn-chip.active {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
  font-weight: 700;
}

.ab-label {
  font-size: 11.5px;
  color: var(--ink-muted);
  font-family: ui-monospace, monospace;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.shadow-rec-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.shadow-rec-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.shadow-rec-playback audio,
.coach-rec-wrap audio {
  width: 100%;
  height: 34px;
}

/* Segments Grid */
.segments-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 140px;
}

.segments-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.segments-head h3 {
  margin: 0;
  font-size: 14.5px;
}

.segments-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.segments-actions select {
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 12px;
  background: #fff;
  font-family: inherit;
}

.segments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
}

.seg-card {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  font-family: inherit;
}

.seg-card:hover {
  border-color: var(--indigo);
  background: var(--indigo-soft);
}

.seg-card.active {
  border-color: var(--indigo);
  background: var(--indigo);
  color: #fff;
  box-shadow: 0 4px 12px rgba(41, 75, 122, 0.22);
}

.seg-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 700;
}

.seg-card-time {
  font-size: 11px;
  font-family: ui-monospace, monospace;
  opacity: 0.8;
}

.shortcut-footer {
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

kbd {
  background: var(--surface-soft);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  color: var(--ink);
}

/* RIGHT PANEL: Coach */
.right-tabs {
  display: grid;
  grid-template-columns: 1.3fr 1fr 0.7fr;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.right-tab {
  border: none;
  background: transparent;
  padding: 12px 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-family: inherit;
}

.right-tab.active {
  color: var(--indigo);
  background: #fff;
  border-bottom-color: var(--indigo);
}

.mini-count {
  background: var(--indigo-soft);
  color: var(--indigo);
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 11px;
  margin-left: 3px;
}

.right-tab-pane {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  flex-direction: column;
  gap: 12px;
}

.right-tab-pane.active {
  display: flex;
}

.micro-q-card {
  background: var(--amber-soft);
  border: 1px solid #f2dfb8;
  border-radius: var(--radius-md);
  padding: 11px 13px;
}

.micro-q-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.micro-q-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: #4a3308;
  font-weight: 600;
}

.speak-box {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.speak-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.stt-lang-switch {
  display: inline-flex;
  background: #ece7de;
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.lang-pill {
  border: none;
  background: transparent;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink-muted);
}

.lang-pill.active {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.stt-status {
  font-size: 11.5px;
  color: var(--ink-muted);
}

.stt-status.active {
  color: var(--vermilion);
  font-weight: 600;
}

.speak-box textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 13.5px;
  line-height: 1.55;
  resize: vertical;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.speak-box textarea:focus {
  border-color: var(--indigo);
}

.coach-rec-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.demo-presets {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.presets-label {
  font-size: 11px;
  color: var(--ink-muted);
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.preset-chip {
  border: 1px dashed var(--border-strong);
  background: #fff;
  color: var(--ink-muted);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11.5px;
  cursor: pointer;
  font-family: inherit;
}

.preset-chip:hover {
  border-color: var(--indigo);
  color: var(--indigo);
  background: var(--indigo-soft);
}

.speak-submit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Coach Results */
.coach-result {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.micro-tip-banner {
  background: var(--matcha-soft);
  border: 1px solid #bfe3d1;
  color: #185138;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.mode-mini-tag {
  margin-left: auto;
  font-size: 10.5px;
  background: rgba(255, 255, 255, 0.8);
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--matcha);
}

.fix-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  background: #fff;
}

.fix-faithful {
  border-left: 4px solid var(--indigo);
}

.fix-native {
  border-left: 4px solid var(--matcha);
}

.fix-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 7px;
  flex-wrap: wrap;
}

.fix-tag {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
}

.fix-tag.indigo {
  background: var(--indigo-soft);
  color: var(--indigo);
}

.fix-tag.green {
  background: var(--matcha-soft);
  color: var(--matcha);
}

.fix-sub {
  font-size: 11px;
  color: var(--ink-muted);
  margin-left: 5px;
}

.fix-actions {
  display: flex;
  gap: 4px;
}

.btn-mini-tts, .btn-mini-copy {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--ink);
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
}

.btn-mini-tts:hover, .btn-mini-copy:hover {
  background: var(--indigo-soft);
  border-color: var(--indigo);
  color: var(--indigo);
}

.jp-sentence {
  margin: 0;
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  font-weight: 600;
}

.vocab-block {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

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

.vocab-block-head h4 {
  margin: 0;
  font-size: 13px;
}

.rescued-list, .saved-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vocab-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vocab-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.vocab-pair {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.vocab-zh {
  font-size: 12px;
  background: var(--amber-soft);
  color: var(--amber);
  padding: 2px 6px;
  border-radius: 5px;
  font-weight: 600;
}

.vocab-jp {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--indigo);
}

.vocab-note {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.45;
}

.raw-json-details {
  font-size: 12px;
  color: var(--ink-muted);
}

.raw-json-details summary {
  cursor: pointer;
  padding: 4px 0;
}

.raw-json-details pre {
  margin: 6px 0 0;
  background: #1c2229;
  color: #e6edf3;
  padding: 10px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 11.5px;
  line-height: 1.5;
}

.pane-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
}

.history-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-muted);
}

.empty-hint {
  padding: 24px 12px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
}

/* PDF Drawer */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  justify-content: flex-end;
}

.drawer-backdrop, .modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 26, 33, 0.42);
  backdrop-filter: blur(2px);
}

.drawer-sheet {
  position: relative;
  width: min(860px, 92vw);
  height: 100%;
  background: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.18);
}

.drawer-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drawer-head h3 {
  margin: 0;
  font-size: 15px;
}

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

.pdf-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #525659;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-card {
  position: relative;
  width: min(620px, 95vw);
  max-height: 88vh;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h3 {
  margin: 0;
  font-size: 16px;
}

.modal-desc {
  margin: 12px 18px 0;
}

.prompt-preview {
  margin: 12px 18px;
  padding: 14px;
  background: #1c2229;
  color: #e6edf3;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.6;
  overflow: auto;
  white-space: pre-wrap;
  max-height: 54vh;
}

.modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.settings-form {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.radio-card p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.45;
}

.api-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
}

.field input {
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 13px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1d242b;
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  z-index: 80;
}

@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(214, 73, 51, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(214, 73, 51, 0); }
  100% { box-shadow: 0 0 0 0 rgba(214, 73, 51, 0); }
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Profile pill & Auth Overlay */
.profile-pill {
  font-size: 12px;
  font-weight: 600;
  color: var(--indigo);
  background: var(--indigo-soft);
  border-radius: 999px;
  padding: 5px 10px;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(246, 243, 237, 0.94);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(400px, 94vw);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand h2 {
  margin: 0;
  font-size: 19px;
}

.auth-brand p {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--ink-muted);
}

.auth-error {
  font-size: 12.5px;
  color: var(--vermilion);
  background: var(--vermilion-soft);
  border: 1px solid #f4c6bd;
  border-radius: 8px;
  padding: 8px 10px;
}

.btn-block {
  width: 100%;
  padding: 11px 16px;
  font-size: 14px;
}

/* Mobile Bottom Nav (hidden on desktop) */
.mobile-nav {
  display: none;
}

/* Responsive */
@media (max-width: 1180px) and (min-width: 821px) {
  .app-shell {
    height: auto;
    overflow: auto;
  }
  .studio-grid {
    grid-template-columns: 260px 1fr;
    overflow: visible;
  }
  .coach-panel {
    grid-column: 1 / -1;
    min-height: 520px;
  }
}

@media (max-width: 820px) {
  .app-shell {
    height: 100dvh;
    overflow: hidden;
  }
  .studio-header {
    height: auto;
    padding: 8px 12px;
    gap: 8px;
  }
  .brand-text span,
  .header-stats,
  .profile-pill,
  .shortcut-footer {
    display: none;
  }
  .header-actions .btn {
    padding: 6px 9px;
    font-size: 12px;
  }
  .studio-grid {
    grid-template-columns: 1fr;
    padding: 8px;
    gap: 0;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  .panel[data-mobile-pane] {
    display: none;
    height: 100%;
  }
  .panel[data-mobile-pane].active-mobile {
    display: flex;
  }
  .track-title {
    font-size: 16px;
  }
  .segments-grid {
    grid-template-columns: repeat(auto-fill, minmax(102px, 1fr));
  }
  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    flex-shrink: 0;
  }
  .mobile-nav-btn {
    border: none;
    background: transparent;
    color: var(--ink-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 5px 4px;
    border-radius: 10px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
  }
  .mobile-nav-btn span:first-child {
    font-size: 18px;
    line-height: 1;
  }
  .mobile-nav-btn.active {
    color: var(--indigo);
    background: var(--indigo-soft);
  }
}
