:root {
  --navy: #1b3f69;
  --navy-deep: #133354;
  --teal: #094e64;
  --teal-soft: #eaf3f5;
  --ink: #1f2933;
  --muted: #687481;
  --line: #dfe5eb;
  --line-strong: #cbd6df;
  --panel: #ffffff;
  --bg: #f5f7f9;
  --soft: #edf3f7;
  --warning: #98620a;
  --warning-bg: #fff5dd;
  --red: #9f2e2e;
  --red-bg: #fff0f0;
  --shadow: 0 16px 42px rgba(25, 49, 72, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.45;
}
button, select, input { font: inherit; }
button:focus-visible, select:focus-visible, [tabindex="0"]:focus-visible, a:focus-visible {
  outline: 3px solid rgba(9, 78, 100, .22);
  outline-offset: 2px;
}

.topbar {
  height: 68px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand-wrap { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -1px;
  color: #fff;
  background: var(--navy);
  padding: 7px 9px;
  border-radius: 7px;
}
.brand-name { font-weight: 800; color: var(--navy); letter-spacing: .08em; font-size: 13px; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.user-chip { background: var(--soft); border-radius: 999px; padding: 7px 10px; font-size: 12px; color: var(--teal); }
.link-button { border: 0; background: none; color: var(--muted); cursor: pointer; }

.page-shell { max-width: 1180px; margin: 0 auto; padding: 44px 24px 76px; }
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 30px; margin-bottom: 24px; }
.eyebrow { font-size: 11px; letter-spacing: .14em; font-weight: 800; color: var(--teal); margin-bottom: 8px; }
.hero h1, .login-card h1 {
  font-size: clamp(31px, 4vw, 40px);
  line-height: 1.06;
  letter-spacing: -.035em;
  color: var(--navy);
  margin: 0;
  max-width: 760px;
}
.lead { font-size: 16px; line-height: 1.58; color: var(--muted); max-width: 810px; margin: 13px 0 0; }
.privacy-pill {
  white-space: nowrap;
  background: #e9f5f2;
  color: #0b6656;
  border: 1px solid #cce7df;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
}
.privacy-pill span { display: inline-block; width: 7px; height: 7px; background: #1c8b76; border-radius: 50%; margin-right: 6px; }

.intake-setup, .progress-card, .results, .login-card, .guide-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.intake-setup { padding: 26px 28px 28px; }
.setup-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.setup-heading h2, .guide-intro h2 { color: var(--navy); font-size: 25px; line-height: 1.2; letter-spacing: -.02em; margin: 0; }
.setup-heading p { color: var(--muted); font-size: 12px; line-height: 1.5; max-width: 430px; margin: 0; }
.matter-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; gap: 18px; padding: 20px 0; }
.matter-row label { font-size: 13px; font-weight: 800; color: var(--navy); }
.matter-row select, .login-form input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 9px;
  padding: 11px 12px;
  font-size: 14px;
  color: var(--ink);
}
.matter-row select:focus, .login-form input:focus { border-color: var(--teal); }

.source-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.source-card {
  appearance: none;
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  padding: 17px;
  color: var(--ink);
  text-align: left;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 12px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.source-card:not(:disabled) { cursor: pointer; }
.source-card:not(:disabled):hover { border-color: #9fb3c1; box-shadow: 0 8px 20px rgba(25, 49, 72, .08); transform: translateY(-1px); }
.source-card:disabled { background: #f4f6f8; color: var(--muted); cursor: not-allowed; opacity: .68; }
.source-number {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--navy);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .04em;
}
.source-copy { align-self: start; }
.source-copy strong { display: block; color: var(--navy); font-size: 15px; line-height: 1.25; }
.source-copy small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.source-card.is-unavailable { background: #f8fafb; border-style: dashed; }
.source-card.is-unavailable .source-copy strong { color: #526577; }
.source-card.is-active { border: 2px solid var(--navy); padding: 16px; box-shadow: 0 8px 22px rgba(27, 63, 105, .11); }
.source-card.is-active .source-number { background: var(--navy); color: #fff; }

.transcript-panel, .record-panel, .audio-panel { margin-top: 16px; border: 1px solid #cddbe3; border-radius: 12px; background: #f9fbfc; padding: 20px; }
.transcript-panel-head { display: flex; justify-content: space-between; align-items: start; gap: 20px; margin-bottom: 14px; }
.transcript-panel-head h3 { color: var(--navy); font-size: 16px; margin: 0; }
.transcript-panel-head p { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.active-source-label { white-space: nowrap; color: var(--teal); background: var(--teal-soft); border-radius: 999px; padding: 5px 9px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.recorder-before { border-top: 1px solid var(--line); padding-top: 16px; }
.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #31475a;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.consent-row input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--navy); }
.recorder-start-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 16px; }
.recorder-start-row p, .recording-retry-row p { max-width: 720px; color: var(--muted); font-size: 11px; line-height: 1.5; margin: 0; }
.recorder-start-row .primary { min-width: 170px; }
.recorder-active { display: grid; grid-template-columns: auto minmax(190px, 290px) auto; align-items: center; justify-content: space-between; gap: 24px; border-top: 1px solid var(--line); padding-top: 18px; }
.recording-state { display: flex; align-items: center; gap: 9px; color: var(--navy); }
.recording-state strong { font-size: 14px; }
.recording-state #recording-timer { color: #40566a; font-variant-numeric: tabular-nums; font-size: 16px; font-weight: 750; letter-spacing: .03em; }
.recording-dot { width: 9px; height: 9px; border-radius: 50%; background: #b33d38; box-shadow: 0 0 0 4px rgba(179, 61, 56, .10); }
.recording-dot.is-paused { background: #8a96a1; box-shadow: 0 0 0 4px rgba(104, 116, 129, .10); }
.microphone-meter { min-width: 190px; }
.microphone-meter-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.microphone-meter-label { color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.microphone-meter-head strong { color: #53687a; font-size: 11px; }
.microphone-level-bars { display: grid; grid-template-columns: repeat(10, minmax(7px, 1fr)); gap: 3px; }
.microphone-level-bars span { height: 11px; border-radius: 3px; background: #dce5ea; transition: background-color 120ms ease, opacity 120ms ease; }
.microphone-meter.is-quiet .microphone-level-bars span.is-active { background: #728a98; }
.microphone-meter.is-good .microphone-level-bars span.is-active { background: #0b6a77; }
.microphone-meter.is-loud .microphone-level-bars span.is-active { background: #b33d38; }
.microphone-meter.is-paused .microphone-level-bars span { background: #e6ebee; opacity: .7; }
.microphone-level-warning { margin: 7px 0 0; color: var(--warning); font-size: 10px; line-height: 1.35; }
.recorder-actions { display: flex; align-items: center; gap: 9px; }
.recorder-actions .primary, .recorder-actions .ghost { min-width: 108px; }
.recorder-cancel { font-size: 12px; }
.link-button:disabled, .ghost:disabled { opacity: .45; cursor: not-allowed; }
.original-recording { margin-top: 17px; border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 14px; }
.original-recording-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.original-recording-head strong { color: var(--navy); font-size: 13px; }
.original-recording-head p, .original-recording-note { color: var(--muted); font-size: 11px; line-height: 1.45; margin: 4px 0 0; }
.original-recording-player-label { display: block; color: #40566a; font-size: 11px; font-weight: 750; margin-top: 12px; }
.original-recording audio { display: block; width: 100%; height: 40px; margin-top: 6px; }
.original-recording-note { margin-top: 8px; }
.recording-transcript { margin-top: 17px; border-top: 1px solid var(--line); padding-top: 15px; }
.recording-transcript details { border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 12px 14px; }
.recording-transcript summary { color: var(--navy); cursor: pointer; font-size: 13px; font-weight: 750; }
.recording-transcript pre {
  max-height: 320px;
  margin: 12px 0 0;
  overflow: auto;
  white-space: pre-wrap;
  color: #34495b;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.recording-retry-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 12px; }
.transcript-recovery-actions { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.dropzone {
  border: 2px dashed #b9c8d2;
  border-radius: 10px;
  background: #fff;
  min-height: 108px;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: left;
  gap: 13px;
  padding: 20px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--teal); background: #f4f9fa; }
.dropzone.loaded { border-style: solid; border-color: #9fc8b8; background: #f3faf7; }
.upload-icon { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--soft); color: var(--navy); font-weight: 900; }
.drop-title { font-weight: 800; color: var(--navy); font-size: 14px; }
.drop-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.generate-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 14px; }
.processing-note { max-width: 680px; font-size: 11px; line-height: 1.5; color: #74818d; }
.primary { border: 0; border-radius: 9px; background: var(--navy); color: #fff; padding: 12px 20px; font-size: 14px; font-weight: 800; cursor: pointer; transition: filter .15s, transform .15s, box-shadow .15s; }
.primary:not(:disabled):hover { filter: brightness(1.08); box-shadow: 0 7px 16px rgba(27, 63, 105, .16); transform: translateY(-1px); }
.primary:disabled { opacity: .42; cursor: not-allowed; }
.generate-row .primary { min-width: 190px; min-height: 46px; }

.progress-card { display: flex; gap: 16px; align-items: center; margin-top: 18px; padding: 20px 24px; }
.progress-card p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.spinner { width: 28px; height: 28px; border: 3px solid #dce5ec; border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { margin-top: 18px; border-radius: 10px; padding: 14px 16px; font-size: 13px; }
.error { background: var(--red-bg); border: 1px solid #f2caca; color: var(--red); }
.hidden { display: none !important; }

.results { margin-top: 20px; padding: 28px; }
.success-head { display: flex; align-items: center; gap: 14px; }
.success-icon { width: 42px; height: 42px; border-radius: 50%; background: #e5f5ef; color: #13775f; display: grid; place-items: center; font-size: 24px; font-weight: 900; }
.success-head h2 { margin: 0; color: var(--navy); font-size: 27px; }
.result-downloads { margin-top: 24px; }
.primary-downloads { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.download-card { min-height: 108px; text-align: left; border: 0; background: var(--navy); color: #fff; border-radius: 11px; padding: 18px; cursor: pointer; box-shadow: 0 8px 18px rgba(27, 63, 105, .13); transition: filter .15s, transform .15s, box-shadow .15s; }
.download-card.secondary { background: var(--teal); }
.download-card.transcript { background: #2d6574; }
.download-card strong, .download-card span { display: block; }
.download-card strong { font-size: 14px; line-height: 1.3; }
.download-card span { font-size: 11px; opacity: .8; margin-top: 4px; }
.download-card:not(:disabled):hover { filter: brightness(1.08); box-shadow: 0 12px 24px rgba(27, 63, 105, .19); transform: translateY(-2px); }
.download-card:disabled { opacity: .45; cursor: not-allowed; }
.download-utilities { display: grid; grid-template-columns: minmax(210px, .65fr) minmax(260px, 1fr); gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.download-text-option { text-align: left; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; color: var(--navy); padding: 10px 13px; cursor: pointer; transition: border-color .15s, background .15s, transform .15s; }
.download-text-option strong, .download-text-option span { display: block; }
.download-text-option strong { font-size: 12px; }
.download-text-option span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.download-text-option:hover { border-color: #9fb3c1; background: #f8fafb; transform: translateY(-1px); }
.download-everything { width: 100%; border: 1px solid var(--navy); border-radius: 9px; background: #f4f7fa; color: var(--navy); padding: 12px 16px; font-weight: 800; cursor: pointer; transition: background .15s, box-shadow .15s, transform .15s; }
.download-everything:hover { background: #eaf0f5; box-shadow: 0 6px 14px rgba(27, 63, 105, .10); transform: translateY(-1px); }
.result-transcript-preview { margin-top: 18px; border: 1px solid var(--line); border-radius: 9px; background: #fcfdfe; padding: 12px 14px; }
.result-transcript-preview summary { cursor: pointer; color: var(--navy); font-size: 13px; font-weight: 750; }
.result-transcript-preview pre { max-height: 360px; overflow: auto; margin: 12px 0 0; white-space: pre-wrap; color: #34495b; font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; }
.temporary-session-note { display: flex; gap: 12px; margin-top: 18px; padding: 13px 15px; border-radius: 9px; background: #f3f7fa; color: var(--muted); font-size: 12px; line-height: 1.5; }
.temporary-session-note strong { flex: 0 0 auto; color: var(--navy); }
.result-new-intake { margin-top: 18px; }
.ghost { border: 1px solid #cbd5de; background: #fff; color: var(--navy); border-radius: 9px; padding: 10px 14px; font-weight: 700; cursor: pointer; transition: border-color .15s, background .15s, transform .15s; }
.ghost:not(:disabled):hover { border-color: #9fb3c1; background: #f7f9fb; transform: translateY(-1px); }

.guide-shell { margin-top: 54px; }
.guide-intro { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 18px; }
.guide-intro p { color: var(--muted); font-size: 14px; line-height: 1.55; max-width: 730px; margin: 8px 0 0; }
.read-only-badge { white-space: nowrap; border: 1px solid var(--line-strong); color: var(--muted); background: #fff; border-radius: 999px; padding: 6px 10px; font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.guide-nav {
  position: sticky;
  top: 68px;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 55px;
  margin-bottom: 14px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, .97);
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: 0 8px 22px rgba(25, 49, 72, .07);
  backdrop-filter: blur(8px);
}
.guide-nav-label { flex: 0 0 auto; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.guide-nav-links { min-width: 0; display: flex; gap: 4px; overflow-x: auto; padding: 2px; scrollbar-width: thin; }
.guide-nav a { flex: 0 0 auto; color: #516475; text-decoration: none; border-radius: 7px; padding: 7px 9px; font-size: 11px; font-weight: 750; }
.guide-nav a:hover { background: var(--soft); color: var(--navy); }
.guide-nav a.is-current { background: var(--navy); color: #fff; }
.guide-sections { display: grid; gap: 13px; }
.guide-section { overflow: hidden; box-shadow: 0 8px 24px rgba(25, 49, 72, .055); scroll-margin-top: 142px; }
.guide-section.is-current { border-color: #a8bdcc; box-shadow: 0 8px 26px rgba(27, 63, 105, .10); }
.guide-section:focus { outline: none; }
.guide-section:focus-visible { outline: 3px solid rgba(9, 78, 100, .2); outline-offset: 2px; }
.guide-section-head { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line); background: #fbfcfd; }
.guide-section-number { flex: 0 0 28px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--navy); color: #fff; font-size: 11px; font-weight: 850; }
.guide-section-head h3 { color: var(--navy); font-size: 17px; letter-spacing: -.01em; margin: 0; }
.guide-section-head p { color: var(--muted); font-size: 11px; margin: 3px 0 0; }
.guide-section-body { padding: 16px 18px 18px; }
.guide-group + .guide-group { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.guide-group h4 { color: var(--teal); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 10px; }
.guide-field-grid { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 24px; row-gap: 0; margin: 0; padding: 0; }
.guide-field-grid li { position: relative; min-height: 41px; display: flex; align-items: center; padding: 8px 6px 8px 16px; border-bottom: 1px solid #e8edf1; color: #334657; font-size: 13px; line-height: 1.3; }
.guide-field-grid li::before { content: ""; position: absolute; left: 1px; width: 7px; height: 2px; border-radius: 2px; background: #5c8a98; }

.footer { text-align: center; color: #87919b; font-size: 11px; padding: 0 20px 28px; }
.login-card { max-width: 520px; margin: 70px auto; padding: 38px; }
.login-form { margin-top: 28px; }
.login-form label { display: block; font-size: 12px; font-weight: 800; color: var(--navy); margin-bottom: 8px; }
.login-form .primary { width: 100%; margin-top: 12px; min-height: 46px; }
.privacy-mini { font-size: 11px; line-height: 1.5; color: #7b8792; margin-top: 22px; }

@media (max-width: 900px) {
  .source-grid { grid-template-columns: 1fr; }
  .source-card { min-height: 104px; }
  .primary-downloads { grid-template-columns: 1fr; }
  .guide-field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recorder-active { grid-template-columns: auto minmax(180px, 1fr); }
  .recorder-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

@media (max-width: 700px) {
  .topbar { padding: 0 16px; }
  .brand-sub, .user-chip { display: none; }
  .page-shell { padding: 32px 14px 56px; }
  .hero, .setup-heading, .guide-intro, .transcript-panel-head, .generate-row, .recorder-start-row, .recorder-active, .recording-retry-row, .original-recording-head { display: block; }
  .privacy-pill { display: inline-block; margin-top: 16px; }
  .intake-setup { padding: 21px 17px; }
  .setup-heading p { margin-top: 8px; }
  .matter-row { grid-template-columns: 1fr; gap: 7px; }
  .source-card { min-height: 104px; }
  .transcript-panel, .record-panel, .audio-panel { padding: 16px; }
  .active-source-label { display: inline-block; margin-top: 10px; }
  .dropzone { justify-content: flex-start; }
  .generate-row .primary { width: 100%; margin-top: 12px; }
  .recorder-start-row .primary { width: 100%; margin-top: 12px; }
  .microphone-meter { margin-top: 15px; }
  .transcript-recovery-actions { margin-top: 12px; }
  .transcript-recovery-actions .primary, .transcript-recovery-actions .ghost { width: 100%; }
  .recorder-actions { display: grid; grid-template-columns: 1fr 1fr; margin-top: 16px; }
  .recorder-cancel { grid-column: 1 / -1; }
  .original-recording-head .ghost { width: 100%; margin-top: 12px; }
  .download-utilities { grid-template-columns: 1fr; }
  .temporary-session-note { align-items: stretch; flex-direction: column; }
  .read-only-badge { display: inline-block; margin-top: 10px; }
  .guide-nav { top: 68px; align-items: flex-start; }
  .guide-nav-label { padding-top: 8px; }
  .guide-field-grid { grid-template-columns: 1fr; }
  .guide-section-head, .guide-section-body { padding-left: 14px; padding-right: 14px; }
  .login-card { margin: 30px auto; padding: 28px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
