:root {
  color-scheme: light;
  --ink: #14162a;
  --muted: #546074;
  --surface: #f8f8fc;
  --line: #e2e8f0;
  --accent: #6347eb;
  --accent-dark: #5e35b1;
  --accent-light: #f4f1ff;
  --danger: #b71b43;
  --gutter: clamp(16px, 5vw, 24px);
  color: var(--ink);
  background: var(--surface);
  font: 16px/1.45 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, p { margin: 0; }
button { font: inherit; }
button, summary { -webkit-tap-highlight-color: transparent; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  border-radius: 16px;
  padding: 8px 14px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-weight: 650;
  text-align: center;
  touch-action: manipulation;
}

button:disabled { opacity: .55; cursor: default; }
button:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent-dark);
  outline-offset: 3px;
}

svg {
  display: block;
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

h1, h2 { overflow-wrap: anywhere; }
h1 { font-size: 27px; font-weight: 790; letter-spacing: -.035em; line-height: 1.17; }
h2 { font-size: 21px; line-height: 1.31; }

#app {
  width: min(100%, 460px);
  min-height: 100vh;
  min-height: 100dvh;
  margin-inline: auto;
  padding-top: env(safe-area-inset-top);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

@media (min-width: 600px) {
  body { background: #edeef5; }
  #app { box-shadow: 0 0 56px #1e1b4b18; }
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px var(--gutter);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.16;
}

.brand strong { letter-spacing: -.025em; }

.brand-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 15px;
  background: var(--accent);
  box-shadow: 0 4px 10px #6347eb3d;
  color: white;
}

.brand-caption {
  display: block;
  margin-top: 3px;
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.brand-mark {
  width: 34px;
  height: 38px;
  stroke: none;
}

.brand-name-accessible {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.app-content {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.screen {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  padding: 4px var(--gutter) 16px;
}

.intro, #history-info {
  color: var(--muted);
  font-size: 14px;
}

.intro { margin-top: 6px; }

.question-card {
  display: block;
  text-align: start;
  text-decoration: none;
  touch-action: manipulation;
  overflow: hidden;
  border-radius: 28px;
  padding: 24px;
  background:
    radial-gradient(circle at 95% 0, #ffffff29, transparent 38%),
    linear-gradient(132deg, #6347eb, #5e35b1 58%, #43238a);
  box-shadow: 0 12px 24px #5e35b12b;
  color: white;
}

.question-card:focus-visible {
  outline: 3px solid var(--accent-dark);
  outline-offset: 3px;
}

.question-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  border-radius: 999px;
  padding: 5px 11px;
  background: #1d094c30;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.question-badge::before, .draft-banner > span::before {
  content: '';
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a7f3d0;
}

.question-title {
  display: block;
  margin-top: 14px;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.31;
  overflow-wrap: anywhere;
}

.question-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
  border-top: 1px solid #ffffff40;
  padding-top: 11px;
  color: #faf8ff;
  font-size: 13px;
  font-weight: 550;
}

.question-arrow {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  flex: none;
  border-radius: 50%;
  background: #ffffff33;
}

.topic-actions {
  position: sticky;
  z-index: 1;
  bottom: calc(66px + env(safe-area-inset-bottom));
  margin-top: auto;
  border-radius: 17px 17px 0 0;
  padding-top: 6px;
  background: var(--surface);
}

.primary, .secondary { width: 100%; min-height: 48px; }
.primary { color: white; background: var(--accent); box-shadow: 0 5px 14px #6347eb35; }

.secondary {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.quiet {
  border: 1px solid var(--line);
  background: white;
  color: #374151;
  font-size: 14px;
}

.draft-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 8px 10px 8px 14px;
  background: white;
  font-size: 14px;
  font-weight: 650;
}

.draft-banner > span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.draft-banner > span::before { background: #c47416; }

.draft-banner .quiet, .capture-actions .quiet {
  border: 0;
  background: #edf0f6;
}

#app[data-screen="record"] {
  background: white;
  padding-bottom: env(safe-area-inset-bottom);
}

#app[data-screen="record"] .app-header,
#app[data-screen="history"] .app-header { display: none; }

.record { gap: 12px; background: white; }

.record-header {
  display: grid;
  grid-template-columns: minmax(44px, 1fr) auto minmax(44px, 1fr);
  align-items: center;
  gap: 8px;
  margin-inline: calc(0px - var(--gutter));
  border-bottom: 1px solid #eef0f5;
  padding: 7px var(--gutter);
}

.record-header .back { width: 44px; padding: 0; border: 0; background: #f3f4f9; }
.record-header h1 { font-size: 16px; text-align: center; letter-spacing: -.01em; }

.record-header:has(.record-share:not([hidden])) {
  grid-template-columns: 44px minmax(0, 1fr) auto;
}

.record-header-actions {
  position: relative;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}

.record-share {
  flex: none;
  width: 44px;
  padding: 0;
  background: var(--accent-light);
  color: var(--accent-dark);
}

.record-share-status {
  position: absolute;
  z-index: 2;
  inset-block-start: calc(100% + 8px);
  inset-inline-end: 0;
  width: max-content;
  max-width: calc(100vw - 2 * var(--gutter));
  pointer-events: none;
}

.record-share-status:not(:empty) {
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--ink);
  color: white;
  font-size: 14px;
  box-shadow: 0 4px 12px #14162a30;
}

.record-draft-open {
  justify-self: end;
  padding-inline: 8px;
  background: var(--accent-light);
  color: var(--accent-dark);
  font-size: 12px;
}

.record-topic {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 13px;
  background: #f7f8fb;
}

.record-topic summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
}

summary::-webkit-details-marker { display: none; }

.topic-caption {
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.topic-hint {
  width: 8px;
  height: 8px;
  margin: 0 4px 3px 5px;
  border: solid var(--muted);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.record-topic[open] .topic-hint { transform: rotate(225deg); }

.record-question {
  grid-column: 1 / -1;
  font-size: 14px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.record-topic:not([open]) .record-question {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.capture, .review { display: flex; flex: 1; flex-direction: column; gap: 13px; }

.capture-center {
  display: grid;
  flex: 1;
  min-height: 160px;
  justify-items: center;
  align-content: center;
  gap: 7px;
  padding: clamp(10px, 4vh, 40px) 0;
}

.record-mic, .capture-wave {
  display: grid;
  place-items: center;
  position: relative;
  width: clamp(98px, 18vh, 144px);
  min-height: 0;
  aspect-ratio: 1;
  border-radius: 50%;
  padding: 0;
  background: #fff1f4;
}

.mic-core {
  display: flex;
  width: clamp(56px, 10.26vh, 82px);
  height: clamp(56px, 10.26vh, 82px);
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 50%;
  background: #df254f;
  box-shadow: 0 0 0 15px #ffe0e8, 0 0 0 1px #b71b43 inset;
  color: white;
}

.mic-core svg { width: 31px; height: 31px; }
.capture-wave { display: none; }
[data-state="recording"] .capture-wave { display: grid; }
[data-state="interrupted"] .capture-center { display: none; }

.capture-wave i {
  width: 4px;
  height: 9px;
  border-radius: 999px;
  background: white;
  animation: wave .9s ease-in-out infinite alternate;
}

.capture-wave i:nth-child(2), .capture-wave i:nth-child(4) { height: 17px; animation-delay: -.2s; }
.capture-wave i:nth-child(3) { height: 24px; animation-delay: -.5s; }

@keyframes wave { to { transform: scaleY(.4); } }
@media (prefers-reduced-motion: reduce) { .capture-wave i { animation: none; } }

.timer {
  font-size: clamp(28px, 4.8vh, 35px);
  font-weight: 780;
  font-variant-numeric: tabular-nums;
  line-height: 1.12;
  letter-spacing: -.035em;
}

.timer-limit { color: var(--muted); font-weight: 600; }
.capture-state {
  margin-bottom: 9px;
  border-radius: 999px;
  padding: 6px 12px;
  background: #edf0f6;
  color: #39455a;
  font-size: 12px;
  font-weight: 650;
  text-align: center;
}

[data-state="recording"] .capture-state {
  background: #fff1f4;
  color: var(--danger);
}

.capture-hint, .capture-note, .draft-expiry { color: var(--muted); font-size: 13px; }
.capture-note { border-radius: 15px; padding: 12px; background: #f7f8fb; text-align: center; }
[data-state="recording"] .capture-note, [data-state="interrupted"] .capture-note { display: none; }

.capture-actions, .review-actions { display: grid; gap: 8px; }
.capture-actions { margin-top: auto; }

.review-player {
  border: 1px solid #e4e7f2;
  border-radius: 22px;
  padding: 15px;
  background: #f3f4f9;
}

.review-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--accent-dark);
}

.review-heading h2 {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.review-heading time { font-size: 13px; font-variant-numeric: tabular-nums; }

.preview-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.play {
  width: 48px;
  min-height: 48px;
  flex: none;
  padding: 0;
  border-radius: 50%;
  background: #14151a;
  color: white;
}

.pause-icon, .play[aria-pressed="true"] .play-icon { display: none; }
.play[aria-pressed="true"] .pause-icon { display: block; }

.seek {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.seek input {
  display: block;
  width: 100%;
  min-height: 36px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.seek-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  border-top: 1px solid #e4e7f2;
  padding-top: 8px;
}

.seek-actions button { border-radius: 12px; font-size: 13px; }
#player { display: none; }
.draft-expiry { margin-top: 8px; overflow-wrap: anywhere; }
.review-actions { margin-top: auto; }

.destructive {
  justify-self: center;
  color: var(--danger);
  font-size: 14px;
}

.history {
  gap: 0;
  padding: 0;
}

.history-header {
  position: sticky;
  top: env(safe-area-inset-top);
  z-index: 2;
  border-bottom: 1px solid var(--line);
  padding: 14px var(--gutter);
  background: var(--surface);
}

.history-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  column-gap: 12px;
  row-gap: 3px;
}

.history-heading h1 { font-size: 25px; }
.history-heading > span { color: var(--muted); font-size: 12px; }
#history-info { margin-top: 6px; }

.history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.history-filters button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding-inline: 12px;
  background: white;
  color: #374151;
  font-size: 13px;
}

.history-filters button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.history-list {
  display: grid;
  gap: 12px;
  padding: 14px var(--gutter) 0;
}

#history {
  display: grid;
  gap: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.history-empty, .history-entry {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: white;
}

.history-empty, .history-meta { color: var(--muted); font-size: 14px; }
.history-title { font-size: 16px; font-weight: 680; }
.history-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 9px; margin-bottom: 6px; }
.history-state {
  border-radius: 999px;
  padding: 3px 8px;
  background: #e5f7ed;
  color: #155e45;
  font-size: 12px;
  font-weight: 650;
}
.draft-state { background: #fff3dc; color: #72470e; }
#history-draft-open { margin-top: 8px; }

#history details { margin-top: 8px; }

#history summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  border-radius: 12px;
  padding: 7px 10px;
  background: var(--accent-light);
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
  list-style: none;
}

#history summary::after {
  content: '';
  width: 8px;
  height: 8px;
  margin: 0 4px 3px 0;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

#history details[open] summary::after { transform: rotate(225deg); }

.history-transcript {
  margin-top: 9px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.messages { padding-inline: var(--gutter); }
.messages p {
  margin-bottom: 12px;
  border-radius: 13px;
  padding: 9px 12px;
  background: #edf0f6;
  color: #39455a;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.messages p:empty { display: none; }
.messages #notice { background: #fff3dc; color: #72470e; }

.navigation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  place-items: center;
  position: sticky;
  bottom: 0;
  z-index: 3;
  padding: 7px var(--gutter) calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: white;
}

.navigation button {
  width: min(120px, 100%);
  min-height: 51px;
  flex-direction: column;
  gap: 3px;
  padding: 5px 9px;
  color: var(--muted);
  font-size: 12px;
}

.navigation button[aria-current="page"] { background: var(--accent-light); color: var(--accent-dark); }

@media (max-height: 670px) {
  .capture-center { padding-block: 10px; }
  .record { gap: 8px; }
  .record-header { padding-block: 4px; }
}

@media (max-width: 350px) {
  .app-header { padding-block: 8px; }
  .topics { gap: 10px; }
  .topics h1 { font-size: 24px; }
  .question-card { padding: 17px; }
  .question-title { margin-top: 10px; font-size: 19px; }
  .question-footer { margin-top: 12px; padding-top: 7px; }
}
