:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #182033;
  --muted: #647087;
  --line: #dfe5ef;
  --primary: #2857e8;
  --primary-soft: #e8edff;
  --danger: #c62828;
  --ok: #18794e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at top left, rgba(40, 87, 232, 0.18), transparent 34%),
    linear-gradient(135deg, #eef3ff 0%, #f7f9fc 48%, #e8eefb 100%);
}

.phone-shell {
  width: min(430px, 100%);
  height: min(860px, calc(100vh - 56px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 10px solid #101828;
  border-radius: 38px;
  background: var(--bg);
  box-shadow: 0 28px 80px rgba(16, 24, 40, 0.24);
}

.phone-device-bar {
  display: grid;
  place-items: center;
  height: 22px;
  background: #101828;
}

.phone-device-bar span {
  width: 72px;
  height: 5px;
  border-radius: 999px;
  background: #344054;
}

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

button {
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  padding: 10px 14px;
}

button.secondary {
  background: var(--primary-soft);
  color: var(--primary);
}

button.danger {
  background: #ffe8e8;
  color: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.hero {
  display: grid;
  gap: 12px;
  padding: 18px 18px 16px;
  background: linear-gradient(135deg, #17203a, #294de0);
  color: #fff;
}

.eyebrow {
  margin: 0 0 8px;
  opacity: 0.76;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
h3 {
  margin: 0;
}

.subtitle {
  margin: 8px 0 0;
  opacity: 0.86;
}

.runtime {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  padding: 10px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.1);
}

.app-screen {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 14px 20px;
  scroll-behavior: smooth;
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: grid;
  gap: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 10px 28px rgba(20, 35, 70, 0.05);
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--danger);
}

.section-heading {
  display: grid;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.full-width {
  width: 100%;
  justify-content: center;
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  padding: 8px 12px;
}

.badge.completed {
  background: #e5f8ef;
  color: var(--ok);
}

.badge.failed {
  background: #ffe8e8;
  color: var(--danger);
}

.progress {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf6;
  margin: 14px 0 8px;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2857e8, #42b5ff);
  transition: width 180ms ease;
}

.steps {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
  padding-left: 22px;
  color: var(--muted);
}

.steps li.current {
  color: var(--primary);
  font-weight: 700;
}

.steps li.done {
  color: var(--ok);
}

.steps li .step-info {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85em;
}

.session-list,
.speaker-list,
.card-list,
.morning-swipe-list,
.transcript-list,
.citation-list,
.related-card-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.transcript-asr-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.06);
  border: 1px solid rgba(37, 99, 235, 0.14);
  font-size: 12px;
  line-height: 1.4;
}

.transcript-asr-meta-label {
  color: var(--muted);
  font-weight: 600;
}

.transcript-asr-meta-value {
  color: var(--text);
}

.session-item,
.speaker-item,
.memory-card,
.morning-card,
.segment,
.citation-card,
.related-card,
.answer-box {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}

.session-item {
  display: grid;
  gap: 12px;
}

.speaker-item {
  display: grid;
  gap: 12px;
}

.speaker-controls {
  display: grid;
  gap: 8px;
  align-items: center;
}

.speaker-profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.speaker-bind-profile {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.speaker-bind-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.speaker-bind-row .profile-picker {
  width: 100%;
  min-width: 0;
}

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

.morning-card {
  display: grid;
  gap: 12px;
  border-left: 5px solid var(--primary);
  background: linear-gradient(180deg, #ffffff, #fbfcff);
}

.morning-card.reason-possible_resolved {
  border-left-color: var(--ok);
}

.morning-card.reason-about_to_decay {
  border-left-color: #d68a00;
}

.review-reason {
  border-radius: 12px;
  background: #f1f5ff;
  color: #2c3852;
  padding: 10px 12px;
}

.possible-resolution {
  border: 1px solid #bfe8d3;
  border-radius: 12px;
  background: #f4fff9;
  padding: 10px 12px;
}

.possible-resolution p {
  margin: 6px 0;
}

.review-sources {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.compact-source {
  cursor: pointer;
}

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

.swipe-actions button[data-action="resolve"] {
  grid-column: 1 / -1;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 18px;
  color: var(--muted);
  background: #fbfcff;
}

.card-title-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 8px;
  background: #edf1f8;
  color: #3f4b63;
  font-size: 12px;
}

.source {
  border-left: 3px solid var(--primary);
  background: #f8faff;
  padding: 8px 10px;
  color: #2c3852;
}

.entity-correction-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.entity-correction-note {
  border: 1px solid #c9d6ff;
  border-radius: 10px;
  background: #f1f5ff;
  color: #2c3852;
  padding: 7px 9px;
  font-size: 13px;
}

.search-row {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.answer-box {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.answer-box.direct {
  border-color: #bfe8d3;
  background: #f4fff9;
}

.answer-box.weak {
  border-color: #f2d389;
  background: #fffaf0;
}

.answer-box.refusal {
  border-color: #f2b8b5;
  background: #fff7f7;
}

.citation-card {
  border-left: 4px solid var(--primary);
  display: grid;
  gap: 10px;
}

.related-card {
  background: #fbfcff;
  display: grid;
  gap: 6px;
}

.segment.highlight {
  border-color: var(--primary);
  background: #f8faff;
}

.segment-meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.edit-grid {
  display: grid;
  gap: 8px;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
}

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.bottom-nav button {
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  padding: 10px 6px;
  font-size: 13px;
  font-weight: 700;
}

.bottom-nav button.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.segmented-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 12px;
  border-radius: 16px;
  background: #e8edf6;
  padding: 5px;
}

.segmented-tabs button {
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segmented-tabs button.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 4px 14px rgba(20, 35, 70, 0.08);
}

.advanced-panel {
  margin-top: 12px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: #fbfcff;
}

.advanced-panel summary {
  cursor: pointer;
  font-weight: 700;
}

.advanced-panel textarea,
.advanced-panel .button-row {
  margin-top: 10px;
}

@media (max-width: 620px) {
  .app-stage {
    display: block;
    padding: 0;
    background: var(--bg);
  }

  .phone-shell {
    width: 100%;
    height: 100vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .phone-device-bar {
    display: none;
  }
}


.debug-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.debug-toggle input {
  width: auto;
}

.debug-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  border: 1px dashed #b9c5dc;
  border-radius: 14px;
  padding: 14px;
  background: #fbfcff;
}

.debug-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
}

.debug-section summary,
.debug-item summary {
  cursor: pointer;
  font-weight: 700;
}

.debug-kv {
  display: grid;
  gap: 8px 12px;
  margin-top: 10px;
}

.debug-key {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.debug-value {
  min-width: 0;
}

.debug-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.debug-item {
  border-left: 3px solid var(--primary-soft);
  padding-left: 8px;
}

.debug-panel pre {
  overflow: auto;
  max-height: 360px;
  border-radius: 10px;
  background: #111827;
  color: #e5e7eb;
  padding: 10px;
  font-size: 12px;
}

.debug-panel code {
  display: inline-block;
  border-radius: 6px;
  background: #eef2ff;
  padding: 2px 6px;
  color: #2c3852;
}

.debug-token-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.debug-token-list span {
  border-radius: 999px;
  background: #eef2ff;
  color: #2c3852;
  padding: 3px 8px;
  font-size: 12px;
}

.import-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.demo-meta {
  margin: 10px 0;
}

#asrImportText {
  min-height: 160px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.failure-panel {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #ffd5d5;
  background: #fff7f7;
}
.chapter-item.failed {
  border-color: #ffd5d5;
  background: #fff9f9;
}
.chapter-item.selected {
  border-color: var(--primary);
  background: #eef5ff;
  box-shadow: inset 3px 0 0 var(--primary);
}
.chapter-item {
  cursor: pointer;
}
.chapter-item .chapter-steps {
  margin: 8px 0 0;
  padding-left: 18px;
}
.chapter-item .chapter-actions {
  margin-top: 8px;
  flex-wrap: wrap;
}
.chapter-item .chapter-error {
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.45;
}
