:root {
  --bg: #09090b;
  --bg-soft: #101014;
  --panel: rgba(18, 18, 24, 0.68);
  --panel-strong: rgba(20, 20, 27, 0.88);
  --panel-line: rgba(232, 228, 223, 0.08);
  --panel-line-strong: rgba(232, 228, 223, 0.14);
  --text: #ece7e1;
  --text-dim: rgba(236, 231, 225, 0.72);
  --text-muted: rgba(236, 231, 225, 0.42);
  --text-faint: rgba(236, 231, 225, 0.22);
  --warm: rgba(240, 202, 156, 0.85);
  --cool: rgba(186, 195, 245, 0.82);
  --ok: rgba(160, 210, 170, 0.88);
  --danger: rgba(211, 144, 144, 0.9);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.32);
  --blur: 24px;
  --radius: 22px;
  --radius-sm: 14px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html, body {
  height: 100%;
  background:
    radial-gradient(circle at 20% 20%, rgba(245, 214, 173, 0.05), transparent 28%),
    radial-gradient(circle at 80% 18%, rgba(170, 186, 245, 0.05), transparent 28%),
    linear-gradient(180deg, #0a0a0d 0%, #09090b 100%);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  overflow: hidden;
}

button, input {
  font: inherit;
}

::selection {
  background: rgba(236, 231, 225, 0.12);
  color: var(--text);
}

#auth-overlay,
#boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: #09090b;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.9s ease, visibility 0.9s ease;
}

#auth-overlay.hidden,
#boot-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-content {
  position: relative;
  text-align: center;
  min-width: 240px;
}

.boot-glow {
  width: 70px;
  height: 70px;
  margin: 0 auto 28px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(236, 231, 225, 0.34) 0%, rgba(236, 231, 225, 0.09) 35%, transparent 72%);
  animation: breathe 3.2s ease-in-out infinite;
}

.boot-text,
.auth-label {
  color: var(--text-dim);
  letter-spacing: 0.03em;
}

.auth-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.auth-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}

.auth-input {
  width: 220px;
  border: none;
  border-bottom: 1px solid var(--panel-line-strong);
  background: transparent;
  color: var(--text);
  text-align: center;
  padding: 12px 0;
  outline: none;
  letter-spacing: 0.12em;
}

.auth-input::placeholder {
  color: var(--text-faint);
}

.auth-error {
  min-height: 18px;
  font-size: 12px;
  color: var(--danger);
}

.room {
  position: relative;
  min-height: 100%;
  padding: 26px 28px 28px;
}

.room-noise {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,0.028) 0.5px, transparent 0.5px);
  background-size: 4px 4px;
  opacity: 0.08;
  mix-blend-mode: soft-light;
}

.topbar {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar-right {
  justify-self: end;
  text-align: right;
}

.topbar-center {
  justify-self: center;
}

.eyebrow,
.panel-title,
.transcript-role,
.clock-label,
.mode-pill,
.input-mode,
.setting-label,
.status-key {
  letter-spacing: 0.08em;
}

.eyebrow,
.panel-title,
.status-key,
.transcript-role {
  text-transform: uppercase;
}

.eyebrow,
.panel-title {
  font-size: 11px;
  color: var(--text-muted);
}

.presence-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  color: var(--text-dim);
}

.presence-dot,
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(236, 231, 225, 0.24);
  box-shadow: 0 0 0 0 rgba(236, 231, 225, 0.1);
  transition: background 0.4s ease, box-shadow 0.4s ease;
}

.presence-dot.listening { background: var(--warm); box-shadow: 0 0 16px rgba(240, 202, 156, 0.25); }
.presence-dot.processing { background: var(--cool); box-shadow: 0 0 16px rgba(186, 195, 245, 0.22); }
.presence-dot.speaking { background: rgba(242, 224, 200, 0.92); box-shadow: 0 0 18px rgba(242, 224, 200, 0.26); }
.presence-dot.idle { background: rgba(236, 231, 225, 0.24); }
.status-dot.online { background: var(--ok); box-shadow: 0 0 12px rgba(160, 210, 170, 0.18); }
.status-dot.offline { background: var(--danger); }
.status-dot.degraded { background: var(--warm); }

.mode-pill-wrap {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.mode-pill {
  min-width: 140px;
  text-align: center;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--panel-line);
  background: rgba(236, 231, 225, 0.03);
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
}

.mode-subpill {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.clock-label {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.main-panel {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(280px, 1fr) minmax(340px, 520px) minmax(220px, 280px);
  gap: 22px;
  height: calc(100vh - 98px);
  align-items: stretch;
}

.sidepanel,
.conversation-panel {
  min-height: 0;
}

.sidepanel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-card,
.settings-panel,
.composer-card,
.transcript-wrap,
.presence-shell,
.mode-pill {
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
}

.panel-card,
.settings-panel,
.composer-card,
.transcript-wrap,
.presence-shell {
  border: 1px solid var(--panel-line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-card,
.settings-panel,
.transcript-wrap,
.composer-card {
  border-radius: var(--radius);
}

.panel-card {
  padding: 18px;
}

.panel-copy,
.settings-copy,
.panel-subtitle,
.setting-note,
.status-meta,
.mode-summary,
.empty-copy {
  color: var(--text-muted);
}

.status-card .status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  color: var(--text-dim);
}

.status-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.status-item {
  display: grid;
  gap: 4px;
}

.status-key {
  font-size: 10px;
  color: var(--text-faint);
}

.status-value {
  color: var(--text-dim);
}

.quiet-card {
  margin-top: auto;
}

.flow-card {
  gap: 8px;
}

.flow-copy {
  color: var(--text-dim);
  margin-top: 12px;
}

.flow-meta,
.settings-status {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 8px;
  line-height: 1.5;
}

.presence-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.presence-shell {
  position: relative;
  width: min(100%, 520px);
  aspect-ratio: 1 / 1;
  border-radius: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 50%, rgba(236,231,225,0.03) 0%, transparent 55%),
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0));
  transition: border-color 0.35s ease, transform 0.35s ease, box-shadow 0.35s ease;
}

.presence-shell.listening {
  border-color: rgba(240, 202, 156, 0.22);
}

.presence-shell.processing {
  border-color: rgba(186, 195, 245, 0.22);
}

.presence-shell.speaking {
  border-color: rgba(242, 224, 200, 0.26);
}

#orb-canvas {
  width: min(78vw, 420px);
  height: min(78vw, 420px);
  max-width: 100%;
  max-height: 100%;
  cursor: pointer;
}

.presence-status {
  position: absolute;
  bottom: 30px;
  left: 30px;
  right: 30px;
  text-align: center;
  min-height: 20px;
  color: var(--text-dim);
}

.realtime-indicator {
  position: absolute;
  top: 22px;
  right: 22px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(240, 202, 156, 0.18);
  background: rgba(240, 202, 156, 0.08);
  color: rgba(255, 219, 167, 0.82);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.realtime-indicator.hidden {
  opacity: 0;
  visibility: hidden;
}

.conversation-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
  min-height: 0;
}

.transcript-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.clear-btn,
.settings-trigger,
.confirm-btn,
.ghost-btn {
  border: 1px solid var(--panel-line);
  background: rgba(236, 231, 225, 0.03);
  color: var(--text-dim);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.clear-btn,
.settings-trigger,
.ghost-btn {
  padding: 10px 14px;
}

.ghost-btn {
  white-space: nowrap;
}

.clear-btn:hover,
.settings-trigger:hover,
.confirm-btn:hover,
.ghost-btn:hover {
  background: rgba(236, 231, 225, 0.06);
  border-color: var(--panel-line-strong);
  color: var(--text);
}

.transcript-wrap {
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
  gap: 8px;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.empty-state.hidden {
  opacity: 0;
}

.empty-title {
  max-width: 260px;
  color: var(--text-dim);
}

.transcript {
  position: relative;
  height: 100%;
  overflow-y: auto;
  padding: 18px 20px;
  scroll-behavior: smooth;
  mask-image: linear-gradient(to bottom, transparent 0%, black 7%, black 93%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 7%, black 93%, transparent 100%);
}

.transcript::-webkit-scrollbar { width: 4px; }
.transcript::-webkit-scrollbar-track { background: transparent; }
.transcript::-webkit-scrollbar-thumb { background: rgba(236, 231, 225, 0.12); border-radius: 999px; }

.transcript-entry {
  position: relative;
  padding: 14px 0;
  animation: fadeUp 0.32s ease;
}

.transcript-entry + .transcript-entry {
  border-top: 1px solid rgba(236, 231, 225, 0.05);
}

.transcript-entry.history-entry {
  opacity: 0.45;
}

.transcript-role {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--text-faint);
  margin-bottom: 5px;
}

.transcript-timestamp {
  text-transform: none;
  letter-spacing: 0.04em;
}

.transcript-text {
  color: var(--text);
  line-height: 1.7;
}

.transcript-entry.user .transcript-text {
  color: var(--text-dim);
}

.transcript-entry.assistant::before {
  content: '';
  position: absolute;
  inset: 4px -12px;
  border-radius: 16px;
  background: radial-gradient(circle at 0% 50%, rgba(245, 214, 173, 0.045), transparent 66%);
  z-index: -1;
}

.copy-btn {
  position: absolute;
  top: 12px;
  right: 0;
  padding: 4px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.transcript-entry:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  color: var(--text-dim);
}

.copy-feedback {
  font-size: 10px;
  color: var(--text-dim);
}

.transcript-text.streaming::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 14px;
  margin-left: 3px;
  background: var(--text-dim);
  vertical-align: text-bottom;
  animation: blink 0.85s ease infinite;
}

.md-codeblock {
  margin: 9px 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(236, 231, 225, 0.08);
  background: rgba(12, 12, 17, 0.72);
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 12px;
}

.md-inline-code {
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(236, 231, 225, 0.06);
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 12px;
}

.md-link {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: rgba(236, 231, 225, 0.24);
  text-underline-offset: 2px;
}

.md-list {
  padding-left: 18px;
  margin: 6px 0;
}

.md-list li { margin: 4px 0; }

.composer-card {
  padding: 16px;
}

.composer-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.input-mode {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
}

.input-hint {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}

.input-area {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mic-btn {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  border: 1px solid var(--panel-line);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  color: var(--text-dim);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.mic-btn:hover {
  transform: translateY(-1px);
  border-color: var(--panel-line-strong);
  color: var(--text);
}

.mic-btn.recording {
  border-color: rgba(240, 202, 156, 0.42);
  color: var(--warm);
  box-shadow: 0 0 0 6px rgba(240, 202, 156, 0.04), 0 0 28px rgba(240, 202, 156, 0.08);
}

.mic-btn.processing {
  border-color: rgba(186, 195, 245, 0.34);
  color: var(--cool);
  box-shadow: 0 0 0 6px rgba(186, 195, 245, 0.03), 0 0 24px rgba(186, 195, 245, 0.08);
}

.mic-icon {
  width: 18px;
  height: 18px;
}

.text-input {
  flex: 1;
  min-width: 0;
  border: 1px solid transparent;
  background: rgba(236, 231, 225, 0.03);
  color: var(--text);
  border-radius: 16px;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.25s ease, background 0.25s ease;
}

.text-input::placeholder {
  color: var(--text-faint);
}

.text-input:focus {
  border-color: rgba(236, 231, 225, 0.1);
  background: rgba(236, 231, 225, 0.04);
}

.settings-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border-radius: 16px;
}

.settings-panel {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-copy {
  margin-top: -8px;
  margin-bottom: 4px;
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid rgba(236, 231, 225, 0.05);
  cursor: pointer;
}

.setting:first-of-type {
  border-top: none;
}

.setting > div {
  display: grid;
  gap: 4px;
}

.setting-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.setting-note {
  font-size: 12px;
}

.setting input[type='checkbox'] {
  display: none;
}

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: rgba(236, 231, 225, 0.09);
  transition: background 0.24s ease;
  flex-shrink: 0;
}

.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(236, 231, 225, 0.42);
  transition: transform 0.24s ease, background 0.24s ease;
}

.setting input[type='checkbox']:checked + .toggle {
  background: rgba(236, 231, 225, 0.18);
}

.setting input[type='checkbox']:checked + .toggle::after {
  transform: translateX(18px);
  background: var(--text);
}

.setting.volume {
  align-items: flex-start;
  flex-direction: column;
}

.setting input[type='range'] {
  width: 100%;
  appearance: none;
  height: 3px;
  border-radius: 999px;
  background: rgba(236, 231, 225, 0.1);
  outline: none;
}

.setting input[type='range']::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-dim);
  border: none;
  cursor: pointer;
}

.mode-summary {
  padding-top: 12px;
  border-top: 1px solid rgba(236, 231, 225, 0.05);
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 8, 0.72);
  backdrop-filter: blur(6px);
}

.confirm-dialog {
  width: min(92vw, 360px);
  border-radius: 22px;
  padding: 24px;
  border: 1px solid var(--panel-line);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.confirm-dialog p {
  margin-top: 10px;
  color: var(--text-dim);
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.confirm-btn {
  padding: 10px 14px;
}

.confirm-btn.danger:hover {
  color: var(--danger);
  border-color: rgba(211, 144, 144, 0.34);
}

.shortcut-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3200;
  width: min(92vw, 320px);
  padding: 22px;
  border-radius: 22px;
  border: 1px solid var(--panel-line);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.shortcut-overlay.hidden {
  display: none;
}

.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  color: var(--text-dim);
}

.shortcut-row kbd {
  border: 1px solid var(--panel-line);
  border-radius: 9px;
  padding: 4px 8px;
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
}

.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.55; }
  50% { transform: scale(1.14); opacity: 0.82; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@media (max-width: 1240px) {
  .main-panel {
    grid-template-columns: minmax(180px, 220px) minmax(260px, 1fr) minmax(320px, 1.1fr);
  }

  .sidepanel-left {
    display: none;
  }
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .room {
    padding: 18px 16px 22px;
  }

  .topbar {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .topbar-center,
  .topbar-right {
    justify-self: start;
    text-align: left;
  }

  .main-panel {
    height: auto;
    grid-template-columns: 1fr;
  }

  .sidepanel-right,
  .sidepanel-left {
    order: 3;
  }

  .presence-stage {
    order: 1;
  }

  .conversation-panel {
    order: 2;
    min-height: 60vh;
  }

  .presence-shell {
    min-height: 280px;
  }

  #orb-canvas {
    width: min(70vw, 320px);
    height: min(70vw, 320px);
  }
}

@media (max-width: 640px) {
  .composer-topline,
  .transcript-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .input-hint {
    text-align: left;
  }

  .presence-status {
    bottom: 18px;
    left: 16px;
    right: 16px;
  }

  .settings-trigger,
  .clear-btn {
    width: 100%;
    justify-content: center;
  }
}
