:root {
  --bg: #0b1020;
  --panel: rgba(13, 18, 37, 0.92);
  --text: #f8fafc;
  --muted: #b8c1d9;
  --border: rgba(255, 255, 255, 0.12);
  --english-a: #2563eb;
  --english-b: #1d4ed8;
  --japanese-a: #dc2626;
  --japanese-b: #b91c1c;
  --active: #22c55e;
  font-family: Inter, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button {
  font: inherit;
}

.hidden {
  display: none !important;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1rem 0.75rem;
  background: rgba(4, 7, 16, 0.72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.08em;
}

.muted {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.topbar-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.8rem 1rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.split-screen {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  min-height: 0;
}

.side-column {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
}

.talk-side {
  border: none;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 1.25rem;
  min-height: 44vh;
}

.english-side {
  background: linear-gradient(180deg, var(--english-a), var(--english-b));
}

.japanese-side {
  background: linear-gradient(180deg, var(--japanese-a), var(--japanese-b));
}

.talk-side.is-recording {
  outline: 6px solid rgba(255, 255, 255, 0.55);
  outline-offset: -6px;
  filter: brightness(1.08);
}

.talk-side.is-processing {
  box-shadow: inset 0 0 0 9999px rgba(0, 0, 0, 0.16);
}

.flag-emoji {
  font-size: 3rem;
  margin-bottom: 0.8rem;
}

.side-label {
  font-size: 0.95rem;
  opacity: 0.92;
  margin-bottom: 0.75rem;
}

.side-title {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 800;
  line-height: 1.05;
}

.side-subtitle {
  margin-top: 0.85rem;
  font-size: 1.1rem;
  opacity: 0.95;
}

.clone-button,
.side-controls {
  border: none;
  color: white;
  font-weight: 700;
  padding: 1rem;
  font-size: 1rem;
}

.canada-clone {
  background: rgba(37, 99, 235, 0.88);
}

.japan-clone {
  background: rgba(185, 28, 28, 0.9);
}

.voice-picker-label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.45rem;
}

.voice-picker {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: rgba(255,255,255,0.1);
  color: white;
}

.voice-picker option {
  color: black;
}

.clone-setup-card {
  margin-bottom: 0.85rem;
}

.script-block {
  margin: 0.35rem 0 0.85rem;
  padding: 0.75rem;
  border-radius: 0.75rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  line-height: 1.45;
}

.status-panel {
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 0.9rem 1rem calc(1rem + env(safe-area-inset-bottom));
}

#status {
  margin: 0 0 0.85rem;
  color: var(--muted);
}

.transcript-grid {
  display: grid;
  grid-template-columns: 1fr;
}

.transcript-card {
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.9rem;
}

.transcript-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.turn-log {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 24vh;
  overflow: auto;
}

.turn-entry {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.85rem;
  padding: 0.8rem;
  background: rgba(255, 255, 255, 0.03);
}

.turn-entry .dir {
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.45rem;
}

.turn-entry p {
  margin: 0.2rem 0;
  line-height: 1.35;
}

.turn-entry .translated {
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(4, 7, 16, 0.75);
  backdrop-filter: blur(8px);
}

.modal-card {
  width: min(720px, 100%);
  max-height: 85vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: rgba(13, 18, 37, 0.98);
  padding: 1rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.modal-card h2 {
  margin-top: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

@media (max-width: 700px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .split-screen {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  .side-column {
    grid-template-rows: 1fr auto;
  }

  .talk-side {
    min-height: 30vh;
  }
}
