/* ─── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Tokens ────────────────────────────────────────────────────────────── */
:root {
  --bg:           #080b14;
  --surface:      #0e1120;
  --surface2:     #151929;
  --surface3:     #1c2035;
  --border:       rgba(255,255,255,0.07);
  --border-light: rgba(255,255,255,0.04);

  --accent:       #6366f1;
  --accent2:      #818cf8;
  --accent-glow:  rgba(99,102,241,0.25);
  --accent-dim:   rgba(99,102,241,0.12);

  --green:        #22c55e;
  --green-dim:    rgba(34,197,94,0.12);
  --yellow:       #f59e0b;
  --yellow-dim:   rgba(245,158,11,0.12);
  --red:          #f43f5e;
  --red-dim:      rgba(244,63,94,0.12);

  --text:         #f1f5f9;
  --text-2:       #94a3b8;
  --text-3:       #475569;

  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    14px;
  --radius-xl:    20px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --shadow: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Layout ────────────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-rows: 56px 56px 1fr;
  height: 100vh;
  overflow: hidden;
}

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

.header-left, .header-right { flex: 1; }
.header-right { display: flex; justify-content: flex-end; }

.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 32px; height: 32px;
  background: var(--accent-dim);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent2);
}
.logo-text { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; }

/* Mode switcher */
.mode-switcher {
  display: flex;
  gap: 2px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 3px;
}
.mode-btn {
  border: none;
  background: transparent;
  color: var(--text-2);
  padding: 5px 14px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
  font-family: var(--font);
}
.mode-btn:hover:not(.active) { color: var(--text); background: var(--surface2); }
.mode-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* Connection pill */
.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  transition: all 0.3s;
}
.conn-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); transition: all 0.3s; }
.connection-pill.connected { border-color: rgba(34,197,94,0.3); color: var(--green); }
.connection-pill.connected .conn-dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.connection-pill.error { border-color: rgba(244,63,94,0.3); color: var(--red); }
.connection-pill.error .conn-dot { background: var(--red); }

/* ─── Controls ──────────────────────────────────────────────────────────── */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.mic-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 320px;
}
.mic-icon { color: var(--text-3); flex-shrink: 0; }
.mic-select {
  flex: 1;
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}
.mic-select:focus { border-color: rgba(99,102,241,0.5); }
.mic-select:disabled { opacity: 0.4; cursor: not-allowed; }

/* Buttons */
.btn-group { display: flex; gap: 6px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.btn:disabled { opacity: 0.3; cursor: not-allowed; pointer-events: none; }

.btn-start  { background: var(--green-dim); color: var(--green); border-color: rgba(34,197,94,0.25); }
.btn-start:not(:disabled):hover  { background: var(--green); color: #fff; box-shadow: 0 0 16px rgba(34,197,94,0.3); }

.btn-pause  { background: var(--yellow-dim); color: var(--yellow); border-color: rgba(245,158,11,0.25); }
.btn-pause:not(:disabled):hover  { background: var(--yellow); color: #000; }

.btn-resume { background: var(--accent-dim); color: var(--accent2); border-color: rgba(99,102,241,0.25); display: none; }
.btn-resume:not(:disabled):hover { background: var(--accent); color: #fff; }

.btn-stop   { background: var(--red-dim); color: var(--red); border-color: rgba(244,63,94,0.25); }
.btn-stop:not(:disabled):hover   { background: var(--red); color: #fff; box-shadow: 0 0 16px rgba(244,63,94,0.25); }

/* Recording badge */
.rec-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--red-dim);
  border: 1px solid rgba(244,63,94,0.2);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--red);
  opacity: 0;
  transition: opacity 0.3s;
  font-variant-numeric: tabular-nums;
}
.rec-badge.active { opacity: 1; }
.rec-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ─── Workspace ─────────────────────────────────────────────────────────── */
.workspace {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 0;
  overflow: hidden;
  min-height: 0;
}

/* ─── Panel ─────────────────────────────────────────────────────────────── */
.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.transcript-panel {
  border-right: 1px solid var(--border);
  position: relative;
}

.summary-panel {
  background: var(--surface);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}

.panel-title-group {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.panel-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

.entry-count {
  font-size: 11px;
  color: var(--text-3);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: all 0.18s;
}
.icon-btn:hover { color: var(--text); background: var(--surface3); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scroll-behavior: smooth;
}
.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }
.panel-body::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 2px; }

/* ─── Empty states ──────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  min-height: 200px;
  text-align: center;
}
.empty-icon { margin-bottom: 4px; }
.empty-title { font-size: 13px; font-weight: 600; color: var(--text-2); }
.empty-sub   { font-size: 12px; color: var(--text-3); max-width: 200px; }

/* ─── Transcript entries ────────────────────────────────────────────────── */
.transcript-entry {
  margin-bottom: 14px;
  animation: fadeUp 0.2s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.entry-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.entry-time  { font-size: 10px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.entry-original {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}

.entry-translation {
  margin-top: 4px;
  padding: 6px 10px;
  background: var(--accent-dim);
  border-left: 2px solid rgba(99,102,241,0.4);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--accent2);
  font-style: italic;
}

.partial-line {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-3);
  font-style: italic;
  min-height: 20px;
}

/* Scroll to latest */
.scroll-btn {
  position: absolute;
  bottom: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  box-shadow: 0 4px 16px var(--accent-glow);
  transition: all 0.18s;
  z-index: 10;
}
.scroll-btn:hover { background: var(--accent2); transform: translateY(-1px); }

/* ─── Summary ───────────────────────────────────────────────────────────── */
.export-btns { display: flex; gap: 6px; }

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.18s;
}
.export-btn:hover { border-color: rgba(99,102,241,0.4); color: var(--accent2); background: var(--accent-dim); }

/* Summary loading */
.summary-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: 200px;
  color: var(--text-2);
  font-size: 13px;
}
.loading-ring {
  width: 28px; height: 28px;
  border: 2px solid var(--surface3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Summary content */
.summary-content { display: flex; flex-direction: column; gap: 20px; }

.summary-section {}
.section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent2);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.summary-para {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-2);
}

.summary-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.summary-list li {
  display: flex;
  gap: 8px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-2);
}
.summary-list li::before {
  content: '·';
  color: var(--accent2);
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}
.action-list li::before { content: '→'; }
.action-list li { color: var(--text); }

/* ─── Toasts ────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 999;
  pointer-events: none;
}
.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  color: var(--text);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastIn 0.25s ease;
  pointer-events: auto;
  white-space: nowrap;
}
.toast.error   { border-color: rgba(244,63,94,0.4);  color: var(--red); }
.toast.success { border-color: rgba(34,197,94,0.4);  color: var(--green); }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .transcript-panel { border-right: none; border-bottom: 1px solid var(--border); }
  .mode-btn { padding: 5px 8px; font-size: 11px; }
}
