:root {
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-muted: #f4f4f5;
  --text: #18181b;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --border: #ececed;
  --border-strong: #dddddf;
  --accent: #4157e0;
  --accent-bg: #eef1fd;
  --accent-border: #d3d9f8;
  --green: #22c55e;
  --green-bg: #e8f9ee;
  --red: #ef4444;
  --red-bg: #fdecec;
  --amber: #b5680a;
  --amber-bg: #fdf3e3;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --content-width: 760px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  background: var(--bg);
}

::selection {
  background: var(--accent-border);
}

a {
  color: inherit;
}

button {
  font-family: inherit;
  /* iOS Safari paints buttons with native chrome by default, which can
     mask author background-color/transform changes (e.g. the call
     button's active-state color and icon rotation never appearing). */
  -webkit-appearance: none;
  appearance: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Header */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.app-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.status-line {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.transcript-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.transcript-toggle:hover {
  background: var(--bg-subtle);
  border-color: var(--text-tertiary);
}

.transcript-toggle .chevron {
  transition: transform 0.15s var(--ease);
  color: var(--text-tertiary);
}

.transcript-toggle.collapsed .chevron {
  transform: rotate(-90deg);
}

/* Scroll area */

.scroll-area {
  flex: 1;
  overflow-y: auto;
}

/* Transcript */

.transcript-panel {
  max-height: 100000px;
  overflow: hidden;
  transition: max-height 0.25s var(--ease);
}

.transcript-panel.collapsed {
  max-height: 0;
}

.transcript-list {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 8px 24px 32px;
}

.transcript-entry {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.transcript-entry:last-child {
  border-bottom: none;
}

.entry-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.entry-speaker {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.entry-time {
  font-size: 12px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.entry-text {
  margin-top: 5px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
}

.transcript-system {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
}

.transcript-system .system-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 10px;
  flex-shrink: 0;
}

.transcript-system-start .system-icon {
  background: var(--green-bg);
  color: var(--green);
}

.transcript-system-end .system-icon {
  background: var(--red-bg);
  color: var(--red);
}

.transcript-system .system-label {
  flex: 1;
  font-weight: 500;
  color: var(--text);
}

/* Results page — empty/not-ready/not-found state */

.empty-state {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 96px 24px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state.hidden {
  display: none;
}

.empty-state p {
  font-size: 15px;
  margin: 0 0 20px;
}

.empty-state .download-button {
  display: inline-block;
  text-decoration: none;
  color: var(--text);
}

/* Results page — collapsible transcript */

.transcript-panel-details {
  margin-top: 28px;
}

.transcript-panel-details summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.transcript-panel-details summary:hover {
  color: var(--text);
}

.transcript-panel-details .transcript-list {
  margin: 10px 0 0;
  padding: 0;
  max-width: none;
}

/* Extraction section */

.extraction-section {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 28px 24px 48px;
}

.extraction-section.hidden {
  display: none;
}

.extraction-section.loading .cards-grid {
  opacity: 0.4;
}

.extraction-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.extraction-header h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.download-button {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.download-button:hover {
  background: var(--bg-subtle);
  border-color: var(--text-tertiary);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background: var(--bg-subtle);
  box-shadow: var(--shadow-xs);
}

.card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

.card-value {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text);
}

.card-intent {
  grid-column: 1 / -1;
  background: var(--accent-bg);
  border-color: var(--accent-border);
}

.card-intent .card-label {
  color: var(--accent);
}

.card-intent .card-value {
  color: #2c3a8f;
}

.raw-output-panel {
  margin-top: 20px;
}

.raw-output-panel summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.raw-output-panel summary:hover {
  color: var(--text);
}

.raw-output {
  margin-top: 10px;
  padding: 16px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Control bar */

.control-bar-wrap {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

.prompt-mode-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 12px 0 0 24px;
  padding: 4px 10px 4px 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.prompt-mode-label::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  flex-shrink: 0;
}

.prompt-mode-label.modified {
  color: var(--amber);
  background: var(--amber-bg);
  border-color: #f3ddad;
}

.prompt-mode-label.modified::before {
  background: var(--amber);
}

.control-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 12px 24px 18px;
}

.timer {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  width: 44px;
  flex-shrink: 0;
}

.waveform {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 32px;
}

.wave-bar {
  width: 3px;
  height: 8%;
  min-height: 3px;
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  transition: height 0.08s var(--ease);
}

.control-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease),
    color 0.15s var(--ease);
}

.icon-button:hover {
  border-color: var(--text-tertiary);
  color: var(--text);
}

.icon-button.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.call-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s var(--ease), transform 0.1s var(--ease);
}

.call-button:hover:not(:disabled) {
  transform: scale(1.04);
}

.call-button:active:not(:disabled) {
  transform: scale(0.97);
}

.call-button.active {
  background: var(--red);
}

.call-button:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.call-button .call-icon {
  transition: transform 0.15s var(--ease);
  transform-box: fill-box;
  transform-origin: center;
}

/* Active (in-call) state rotates the handset glyph into the conventional
   "hang up" orientation, so the state change reads as more than a color
   swap — same button, unmistakably different affordance. */
.call-button.active .call-icon {
  transform: rotate(135deg);
}

/* Small phones — tighten spacing so the header and control bar don't
   crowd the call button off the edge of the screen. */
@media (max-width: 430px) {
  .app-header {
    padding: 14px 16px;
  }

  .header-actions {
    gap: 6px;
  }

  .transcript-toggle {
    padding: 6px 10px;
    font-size: 12px;
  }

  .transcript-list,
  .extraction-section,
  .empty-state {
    padding-left: 16px;
    padding-right: 16px;
  }

  .prompt-mode-label {
    margin-left: 16px;
  }

  .control-bar {
    padding: 12px 16px 16px;
    gap: 10px;
  }

  .extraction-header {
    flex-wrap: wrap;
    gap: 10px;
  }
}

/* Prompt page */

.prompt-page {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 28px 24px 48px;
}

.prompt-explainer {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0 0 18px;
}

.prompt-explainer #config-meta {
  color: var(--text);
  font-weight: 500;
}

.prompt-textarea {
  width: 100%;
  min-height: 380px;
  padding: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  resize: vertical;
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.prompt-textarea:focus {
  outline: none;
  background: var(--bg);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.prompt-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}

.prompt-actions .prompt-mode-label {
  margin: 0;
}
