:root {
  color-scheme: dark;
  --bg: #08111f;
  --bg-elevated: #0e172a;
  --surface: #101b31;
  --surface-soft: #13203a;
  --surface-muted: rgba(148, 163, 184, 0.08);
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(110, 168, 254, 0.34);
  --text: #ebf2ff;
  --text-muted: #9fb0ce;
  --text-dim: #70819f;
  --accent: #6ea8fe;
  --accent-strong: #4f8df0;
  --success: #31c48d;
  --danger: #ff6b81;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
  --space-6: 32px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(180deg, #08111f 0%, #0b1630 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  padding: 0;
}

button,
audio,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

h1,
h2,
h3,
p,
ul {
  margin: 0;
}

h1 {
  font-size: clamp(1.3rem, 6vw, 2rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

h2 {
  font-size: 1.08rem;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

h3 {
  font-size: 0.96rem;
  line-height: 1.2;
}

.app-shell {
  min-height: 100vh;
  max-width: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: rgba(8, 17, 31, 0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand-block {
  display: grid;
  gap: 4px;
}

.eyebrow,
.panel-label,
.mini-stat-label {
  font-size: 0.72rem;
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--accent);
}

.status-panel {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.status-dot {
  width: 10px;
  height: 10px;
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(49, 196, 141, 0.14);
}

.status-dot.recording {
  background: var(--danger);
  box-shadow: 0 0 0 6px rgba(255, 107, 129, 0.14);
}

.top-nav,
.bottom-nav {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 1px;
  background: var(--line);
}

.top-nav {
  position: sticky;
  top: 72px;
  z-index: 25;
  border-bottom: 1px solid var(--line);
}

.nav-link,
.bottom-link {
  min-height: 46px;
  padding: 0 10px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.nav-link.is-active,
.bottom-link.is-active {
  color: var(--text);
  background: var(--surface);
}

.screen-stack {
  position: relative;
  min-height: 0;
}

.screen {
  display: none;
  min-height: calc(100vh - 172px);
  padding: var(--space-4);
  align-content: start;
  gap: var(--space-4);
}

.screen.is-active {
  display: grid;
}

.screen-head,
.section-head,
.action-row,
.screen-head-actions,
.process-type-actions,
.progress-copy,
.structure-guide-head,
.structure-run-toolbar,
.utility-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.screen-head,
.section-head,
.structure-guide-head,
.progress-copy {
  justify-content: space-between;
}

.meta-line,
.helper-text,
.install-hint,
.recording-details,
.structure-empty-state,
.structure-run-empty {
  color: var(--text-muted);
  line-height: 1.5;
}

.headset-hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid rgba(110, 168, 254, 0.24);
  background: rgba(110, 168, 254, 0.12);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.4;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.headset-hint::before {
  content: "ᛒ";
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(110, 168, 254, 0.18);
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 800;
  flex: 0 0 auto;
}

.headset-hint.is-detected {
  border-color: rgba(49, 196, 141, 0.34);
  background: rgba(49, 196, 141, 0.16);
  color: #dffbf1;
  box-shadow: 0 0 0 1px rgba(49, 196, 141, 0.08);
}

.headset-hint.is-detected::before {
  background: rgba(49, 196, 141, 0.22);
  color: var(--success);
}

.hero-panel,
.screen-card,
.progress-card,
.content-output,
.selected-dump-banner,
.structure-guide-card,
.structure-guide-instructions,
.structure-run,
.recording-item {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero-panel,
.screen-card,
.progress-card,
.content-output,
.selected-dump-banner,
.structure-guide-card,
.recording-item {
  padding: var(--space-4);
}

.action-grid,
.dump-tabs,
.recordings-list,
.structure-guides-list,
.structure-runs-list,
.process-type-picker,
.selected-dump-copy,
.structure-guide-instructions,
.recording-meta,
.brand-block,
.hero-panel,
.screen-card,
.content-output {
  display: grid;
  gap: var(--space-3);
}

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

.ghost-button,
.recording-play,
.recording-delete,
.structure-guide-run-button {
  min-height: 42px;
  padding: 0 14px;
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 600;
}

.ghost-button:hover,
.ghost-button:focus-visible,
.recording-play:hover,
.recording-delete:hover,
.structure-guide-run-button:hover {
  background: rgba(110, 168, 254, 0.14);
  border-color: var(--line-strong);
}

.ghost-button.is-active {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: white;
  border-color: transparent;
}

.primary-button {
  min-height: 42px;
  padding: 0 16px;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: white;
  border: 1px solid transparent;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(79, 141, 240, 0.24);
}

.primary-button:hover,
.primary-button:focus-visible {
  filter: brightness(1.05);
}

.primary-button:disabled {
  opacity: 0.6;
  box-shadow: none;
  cursor: not-allowed;
}

.danger-button {
  color: #ffb8c2;
  border-color: rgba(255, 107, 129, 0.22);
  background: rgba(255, 107, 129, 0.08);
}

.record-button {
  width: 100%;
  min-height: 180px;
  padding: var(--space-4);
  background: linear-gradient(180deg, #6ea8fe, #4f8df0);
  color: white;
  display: grid;
  justify-items: start;
  align-content: space-between;
  gap: 12px;
  box-shadow: 0 16px 36px rgba(79, 141, 240, 0.3);
}

.record-button.is-recording {
  background: linear-gradient(180deg, #ff889b, #f45f79);
  box-shadow: 0 16px 36px rgba(244, 95, 121, 0.3);
}

.record-label {
  font-size: clamp(1.35rem, 6vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.record-timer {
  font-size: clamp(2rem, 10vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.06em;
}

.meta-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 0.84rem;
}

.selected-dump-banner {
  display: grid;
  margin: var(--space-4) var(--space-4) 0;
  gap: 8px;
  background: linear-gradient(180deg, rgba(110, 168, 254, 0.14), rgba(110, 168, 254, 0.08));
  border-color: rgba(110, 168, 254, 0.26);
}

.screen-head-actions {
  justify-content: flex-end;
}

.selected-dump-copy {
  min-width: 0;
}

.selected-dump-name,
#selected-dump-name {
  font-size: 1rem;
  font-weight: 800;
}

.dump-tab-card {
  display: grid;
  gap: 10px;
}

.dump-tab {
  width: 100%;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  text-align: left;
}

.dump-tab-trailing {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.dump-tab-state {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(110, 168, 254, 0.18);
  color: #dce9ff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dump-tab-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.dump-tab-action {
  width: 100%;
}

.dump-tab.is-active {
  border-color: rgba(110, 168, 254, 0.42);
  background: rgba(110, 168, 254, 0.14);
  box-shadow: inset 0 0 0 1px rgba(110, 168, 254, 0.24);
}

.dump-tab-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.dump-tab-title {
  font-weight: 700;
  color: var(--text);
}

.dump-tab-meta {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.dump-tab-badge {
  min-width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.8rem;
  font-weight: 700;
}

.recordings-list {
  list-style: none;
  padding: 0;
}

.recording-item {
  gap: 12px;
}

.recording-item.empty-state {
  min-height: 94px;
  align-content: center;
}

.recording-title {
  font-weight: 700;
}

.recording-audio {
  width: 100%;
  min-width: 0;
}

.progress-card {
  gap: 10px;
  background: rgba(110, 168, 254, 0.08);
  border-color: rgba(110, 168, 254, 0.22);
}

.progress-bar {
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-fill {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
}

.content-output {
  min-height: 200px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.structure-guide-instructions {
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.structure-guide-instructions-input {
  min-height: 110px;
}

.structure-guide-state {
  min-height: 20px;
}

.toggle-group-label {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.process-type-actions,
.structure-run-toolbar {
  width: fit-content;
  max-width: 100%;
  padding: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.toggle-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
}

.toggle-button:hover,
.toggle-button:focus-visible {
  background: rgba(110, 168, 254, 0.1);
  color: var(--text);
}

.toggle-button.is-active {
  background: rgba(110, 168, 254, 0.18);
  border-color: rgba(110, 168, 254, 0.26);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(110, 168, 254, 0.16);
}

.structure-run summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  font-weight: 600;
}

.structure-run summary::-webkit-details-marker {
  display: none;
}

.structure-run-toolbar,
.structure-output {
  padding: 0 14px 14px;
}

.markdown-output {
  display: grid;
  gap: 10px;
}

.markdown-output h1,
.markdown-output h2,
.markdown-output h3,
.markdown-output h4 {
  margin-top: 4px;
}

.markdown-output p,
.markdown-output li,
.markdown-output blockquote {
  line-height: 1.65;
}

.markdown-output ul,
.markdown-output ol {
  margin: 0;
  padding-left: 1.2rem;
}

.markdown-output blockquote {
  margin: 0;
  padding-left: 14px;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
}

.markdown-output code {
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.08);
}

.markdown-output pre,
.code-output {
  margin: 0;
  padding: 14px;
  overflow: auto;
  background: rgba(2, 8, 23, 0.82);
  border: 1px solid var(--line);
  color: var(--text);
}

.graphic-output {
  padding: 0 14px 14px;
}

.image-output {
  padding: 0 14px 14px;
}

.generated-image-shell {
  border: 1px solid var(--line);
  background: rgba(6, 10, 20, 0.42);
  overflow: hidden;
}

.generated-image {
  display: block;
  width: 100%;
  height: auto;
}

.graphic-render {
  min-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    rgba(6, 10, 20, 0.42);
  background-size: 24px 24px;
}

.graphic-render svg {
  display: block;
  width: 100%;
  height: auto;
}

.structure-empty-state,
.structure-run-empty {
  padding: 16px;
  border: 1px dashed rgba(148, 163, 184, 0.28);
  background: rgba(255, 255, 255, 0.03);
}

.install-hint a,
.markdown-output a {
  color: #9fc0ff;
}

.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-top: 1px solid var(--line);
  background: rgba(8, 17, 31, 0.95);
  backdrop-filter: blur(18px);
}

[hidden] {
  display: none !important;
}

@media (min-width: 960px) {
  .app-shell {
    max-width: 1280px;
    margin: 0 auto;
    grid-template-columns: 220px minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
  }

  .app-header {
    grid-column: 1 / -1;
  }

  .top-nav {
    top: 81px;
    display: grid;
    grid-auto-flow: row;
    grid-auto-rows: 52px;
    align-content: start;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    min-height: calc(100vh - 81px);
  }

  .screen-stack {
    min-height: calc(100vh - 81px);
  }

  .screen {
    min-height: calc(100vh - 81px);
    padding: 24px;
  }

  .selected-dump-banner {
    margin: 24px 24px 0;
  }

  .bottom-nav {
    display: none;
  }

  .recording-item {
    grid-template-columns: auto minmax(0, 1fr) minmax(240px, 0.9fr) auto;
    align-items: center;
  }
}

@media (max-width: 640px) {
  .app-header,
  .screen {
    padding: 14px;
  }

  .status-panel {
    max-width: 42vw;
  }

  .action-grid {
    grid-template-columns: 1fr;
  }

  .screen-head,
  .screen-head-actions,
  .progress-copy,
  .structure-guide-head,
  .structure-run summary {
    flex-direction: column;
    align-items: flex-start;
  }
}

.collapsible-panel {
  padding: 0;
}

.collapsible-panel summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
}

.collapsible-panel summary::-webkit-details-marker {
  display: none;
}

.collapse-indicator {
  color: var(--text-dim);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.collapsible-panel[open] .collapse-indicator {
  color: var(--text);
}

.segment-transcripts-list {
  display: grid;
  gap: 12px;
  padding: 0 18px 18px;
}

.segment-transcript-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

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

.segment-transcript-input {
  width: 100%;
  min-height: 140px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: rgba(8, 17, 31, 0.42);
  color: var(--text);
  line-height: 1.6;
  resize: vertical;
}

.segment-transcript-input:focus {
  outline: 2px solid rgba(110, 168, 254, 0.3);
  border-color: var(--line-strong);
}

.segment-transcript-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.segment-transcript-state {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.auth-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4);
  border-bottom: 1px solid var(--line);
  background: rgba(10, 20, 38, 0.88);
}

.auth-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-card {
  gap: var(--space-3);
}

.settings-grid {
  display: grid;
  gap: var(--space-3);
}

.settings-field {
  display: grid;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.settings-field input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
}

.settings-field input::placeholder {
  color: var(--text-dim);
}

.settings-field input:focus {
  outline: none;
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(110, 168, 254, 0.14);
}

@media (min-width: 720px) {
  .settings-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
