/* =========================================================================
   Recall — prototype styles
   Minimal, dark, legible. NOT the real design system — just a calm,
   premium-ish functional skin so the prototype demos well.
   Self-contained: no imports, no CDNs, no webfonts.
   ========================================================================= */

/* ---------- Design tokens ---------- */
:root {
  /* Surfaces */
  --bg:        #0B0F14;   /* near-black page background */
  --surface-1: #111722;   /* cards / raised panels */
  --surface-2: #161E2B;   /* inputs / hover surfaces */
  --surface-3: #1D2735;   /* chips / subtle fills */

  /* Text */
  --text:      #E6EAF0;   /* primary text */
  --text-dim:  #A3AEC0;   /* secondary text */
  --text-mute: #6B7689;   /* tertiary / labels */

  /* Lines */
  --border:    #232E3E;
  --border-strong: #33425A;

  /* Accent (cyan) */
  --accent:      #16E0C8;
  --accent-ink:  #04201C;  /* text on accent fills */
  --accent-soft: rgba(22, 224, 200, 0.14);
  --accent-line: rgba(22, 224, 200, 0.35);

  /* Status / semantic */
  --warn:      #F2B544;   /* amber (mock badge) */
  --warn-soft: rgba(242, 181, 68, 0.15);
  --danger:    #FF5C72;   /* recording / risk */
  --danger-soft: rgba(255, 92, 114, 0.15);

  /* Insight type hues */
  --t-opportunity: #3FD27A;  /* green  */
  --t-risk:        #FF5C72;  /* red    */
  --t-stakeholder: #5AA8FF;  /* blue   */
  --t-next_step:   #16E0C8;  /* cyan   */
  --t-fact:        #9AA6B8;  /* grey   */
  --t-relationship:#B98BFF;  /* purple */

  /* Sentiment dots */
  --s-positive: #3FD27A;
  --s-neutral:  #9AA6B8;
  --s-cautious: #F2B544;
  --s-negative: #FF5C72;

  /* Shape & motion */
  --radius:    10px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
          "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Subtle top glow so the dark page doesn't feel flat */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 360px;
  background: radial-gradient(120% 120% at 50% -20%,
              rgba(22, 224, 200, 0.10), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.4em; font-weight: 650; }

a { color: var(--accent); }

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

/* Utility — contract requires this exact rule */
.hidden { display: none !important; }

/* ---------- Layout container ---------- */
.app-header,
.top-nav,
.app-main {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  margin-inline: auto;
  padding-inline: 20px;
}

.app-main { padding-bottom: 64px; }

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 28px;
  padding-bottom: 8px;
}

.brand { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.wordmark {
  font-size: 1.45rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--text);
}

.tagline {
  font-size: 0.8rem;
  color: var(--text-mute);
  letter-spacing: 0.01em;
}

/* Mode badge — neutral pill by default, amber when MOCK */
.mode-badge {
  flex: none;
  align-self: flex-start;
  padding: 4px 10px;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.mode-badge[hidden] { display: none; }

/* Amber warning treatment for MOCK mode.
   Works whether app.js flags it with a class (.is-mock / .mock) or a
   data attribute ([data-mode="mock"]). */
.mode-badge.is-mock,
.mode-badge.mock,
.mode-badge.warn,
.mode-badge[data-mode="mock"] {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: rgba(242, 181, 68, 0.4);
}

/* ---------- Top nav (tabs / pills) ---------- */
.top-nav {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  margin-bottom: 8px;
  padding: 4px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  max-width: 360px;
}

.nav-btn {
  flex: 1;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dim);
  background: transparent;
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.nav-btn:hover { color: var(--text); background: var(--surface-2); }

.nav-btn.is-active,
.nav-btn[aria-current="page"] {
  color: var(--accent-ink);
  background: var(--accent);
}

/* ---------- Views ---------- */
.view { padding-top: 18px; }
.view[hidden] { display: none; }

/* ---------- Buttons (shared) ---------- */
button { font-family: inherit; }

.recall-btn,
.memory-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-weight: 650;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease,
              border-color 0.15s ease, color 0.15s ease;
}
.recall-btn:active,
.memory-refresh:active { transform: translateY(1px); }

/* Primary (accent) */
.recall-btn {
  color: var(--accent-ink);
  background: var(--accent);
}
.recall-btn:hover { background: #2cead4; }

/* Secondary (subtle) */
.memory-refresh {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}
.memory-refresh:hover { background: var(--surface-3); border-color: var(--border-strong); }

/* Focus visibility for all interactive elements */
.nav-btn:focus-visible,
.record-btn:focus-visible,
.recall-btn:focus-visible,
.memory-refresh:focus-visible,
.account-row:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ========================================================================
   CAPTURE VIEW
   ======================================================================== */
.capture-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 36px 0 12px;
}

/* Big circular record button */
.record-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 132px;
  height: 132px;
  padding: 12px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--accent-ink);
  background:
    radial-gradient(120% 120% at 50% 0%, #3af0db, var(--accent) 70%);
  border: none;
  box-shadow:
    0 0 0 8px var(--accent-soft),
    0 14px 36px rgba(22, 224, 200, 0.28);
  transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.record-btn:hover { transform: scale(1.03); }
.record-btn:active { transform: scale(0.98); }

.record-btn .mic-glyph { width: 40px; height: 40px; }

.record-label {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  max-width: 92px;
  text-align: center;
  line-height: 1.2;
}

/* Recording state — red + pulse */
.record-btn.recording {
  color: #fff;
  background: radial-gradient(120% 120% at 50% 0%, #ff7d8e, var(--danger) 70%);
  box-shadow:
    0 0 0 8px var(--danger-soft),
    0 14px 36px rgba(255, 92, 114, 0.3);
  animation: recall-pulse 1.5s ease-in-out infinite;
}

@keyframes recall-pulse {
  0%, 100% { box-shadow: 0 0 0 8px var(--danger-soft), 0 14px 36px rgba(255,92,114,0.3); }
  50%      { box-shadow: 0 0 0 18px rgba(255,92,114,0), 0 14px 36px rgba(255,92,114,0.45); }
}

/* Timer */
.record-timer {
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.record-timer[hidden] { display: none; }

/* ---------- Status area + spinner ---------- */
.status-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 24px;
  margin: 10px 0;
  color: var(--text-dim);
  font-size: 0.92rem;
  text-align: center;
}
.status-area:empty { display: none; }

/* Error message convention (app.js may add .error / role=alert) */
.status-area.error,
.status-area [role="alert"],
.error-text {
  color: var(--danger);
}

.spinner {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--surface-3);
  border-top-color: var(--accent);
  animation: recall-spin 0.7s linear infinite;
}
@keyframes recall-spin { to { transform: rotate(360deg); } }

/* ---------- Capture result ---------- */
.capture-result { margin-top: 12px; }
.capture-result[hidden] { display: none; }

/* Summary — prominent accent callout */
.result-summary {
  margin-bottom: 20px;
  padding: 16px 18px;
  font-size: 1.06rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
}
.result-summary:empty { display: none; }

/* ---------- Insight cards ---------- */
.result-insights,
.insights-list { display: flex; flex-direction: column; gap: 12px; }

.insight-card {
  padding: 14px 16px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.insight-card:hover { border-color: var(--border-strong); }

.insight-card .insight-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.insight-card .account-name {
  font-weight: 650;
  font-size: 0.95rem;
  color: var(--text);
}

.insight-card .insight-text {
  margin: 4px 0 10px;
  color: var(--text);
  line-height: 1.5;
}

/* Type badge — color-coded */
.type-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--radius-pill);
  color: var(--t-fact);
  background: color-mix(in srgb, var(--t-fact) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--t-fact) 40%, transparent);
}
.type-badge.type-opportunity { color: var(--t-opportunity); background: color-mix(in srgb, var(--t-opportunity) 16%, transparent); border-color: color-mix(in srgb, var(--t-opportunity) 40%, transparent); }
.type-badge.type-risk        { color: var(--t-risk);        background: color-mix(in srgb, var(--t-risk) 16%, transparent);        border-color: color-mix(in srgb, var(--t-risk) 40%, transparent); }
.type-badge.type-stakeholder { color: var(--t-stakeholder); background: color-mix(in srgb, var(--t-stakeholder) 16%, transparent); border-color: color-mix(in srgb, var(--t-stakeholder) 40%, transparent); }
.type-badge.type-next_step   { color: var(--t-next_step);   background: color-mix(in srgb, var(--t-next_step) 16%, transparent);   border-color: color-mix(in srgb, var(--t-next_step) 40%, transparent); }
.type-badge.type-fact        { color: var(--t-fact);        background: color-mix(in srgb, var(--t-fact) 16%, transparent);        border-color: color-mix(in srgb, var(--t-fact) 40%, transparent); }
.type-badge.type-relationship{ color: var(--t-relationship);background: color-mix(in srgb, var(--t-relationship) 16%, transparent); border-color: color-mix(in srgb, var(--t-relationship) 40%, transparent); }

/* Sentiment dot */
.sentiment-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--s-neutral);
}
.sentiment-dot.sentiment-positive { background: var(--s-positive); }
.sentiment-dot.sentiment-neutral  { background: var(--s-neutral); }
.sentiment-dot.sentiment-cautious { background: var(--s-cautious); }
.sentiment-dot.sentiment-negative { background: var(--s-negative); }

/* Tier label (small muted) */
.tier-label {
  font-size: 0.7rem;
  color: var(--text-mute);
  letter-spacing: 0.02em;
}

/* Chips — people / topics */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 0.74rem;
  color: var(--text-dim);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.chip.chip-person::before { content: "@"; color: var(--text-mute); margin-right: 2px; }
.chip.chip-topic::before  { content: "#"; color: var(--text-mute); margin-right: 1px; }

/* Confidence bar */
.confidence {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 0.7rem;
  color: var(--text-mute);
}
.confidence-bar {
  flex: 1;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.confidence-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

/* ---------- Transcript (details) ---------- */
.result-transcript {
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  overflow: hidden;
}
.result-transcript > summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  user-select: none;
}
.result-transcript > summary::-webkit-details-marker { display: none; }
.result-transcript > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  color: var(--text-mute);
  transition: transform 0.15s ease;
}
.result-transcript[open] > summary::before { transform: rotate(90deg); }
.result-transcript > summary:hover { color: var(--text); }

.result-transcript .transcript-body {
  padding: 0 16px 14px;
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ========================================================================
   RECALL VIEW
   ======================================================================== */
.recall-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.recall-query { flex: 1 1 260px; }
.recall-account { flex: 0 1 180px; }
.recall-btn { flex: 0 0 auto; }

/* Inputs (shared) */
input[type="text"] {
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 13px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
input[type="text"]::placeholder { color: var(--text-mute); }
input[type="text"]:hover { border-color: var(--border-strong); }
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent-line);
  background: var(--surface-1);
}

/* Brief output */
.recall-result[hidden] { display: none; }

.brief-body {
  padding: 18px 20px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 1.65;
  color: var(--text);
}
.brief-body :first-child { margin-top: 0; }
.brief-body :last-child  { margin-bottom: 0; }
.brief-body h1, .brief-body h2, .brief-body h3 {
  font-size: 1.02rem;
  color: var(--text);
  margin: 1.1em 0 0.4em;
}
.brief-body p { margin: 0 0 0.8em; }
.brief-body ul, .brief-body ol { margin: 0 0 0.8em; padding-left: 1.3em; }
.brief-body li { margin-bottom: 0.3em; }
.brief-body strong { color: var(--text); font-weight: 700; }
.brief-body em { color: var(--text-dim); }
.brief-body code {
  font-family: var(--mono);
  font-size: 0.88em;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--accent);
}

/* Inline citation chips */
.citation-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-pill);
  text-decoration: none;
  vertical-align: baseline;
}
.citation-chip:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* Citations list (compact) */
.brief-citations {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}
.brief-citations:empty { display: none; }
.brief-citations .citation-item {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--text-dim);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.brief-citations .citation-id {
  flex: none;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--accent);
}

/* ========================================================================
   MEMORY VIEW
   ======================================================================== */
.memory-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.memory-heading {
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin: 22px 0 10px;
}

/* Accounts — clickable rows / pills with counts */
.accounts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.account-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.account-row:hover { background: var(--surface-2); border-color: var(--border-strong); }
.account-row.is-active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--text);
}
.account-row .account-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: var(--radius-pill);
  padding: 1px 8px;
  min-width: 20px;
  text-align: center;
}

/* Insights list reuses .insight-card; rows are slightly more compact */
.insights-list .insight-card { padding: 12px 14px; }

/* Empty states */
.empty-state {
  margin: 0;
  padding: 18px;
  text-align: center;
  color: var(--text-mute);
  font-size: 0.9rem;
  background: var(--surface-1);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ========================================================================
   RESPONSIVE
   ======================================================================== */
@media (max-width: 540px) {
  .app-header,
  .top-nav,
  .app-main { padding-inline: 16px; }

  .app-header { padding-top: 22px; }
  .wordmark { font-size: 1.3rem; }

  .top-nav { max-width: none; }

  .record-btn { width: 116px; height: 116px; }

  .recall-account { flex-basis: 140px; }
}

/* ========================================================================
   REDUCED MOTION — disable pulse/spin and transitions
   ======================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .record-btn.recording { animation: none; }
  .spinner { animation: none; border-top-color: var(--accent); }
}

/* ---- Integration reconciliation: app.js emits data-type/data-sentiment attrs
   on .type-badge and a .sentiment text span. Map those to the same palette so
   color-coding works without changing app.js. ---- */
.type-badge[data-type="opportunity"]  { color: var(--t-opportunity);  background: color-mix(in srgb, var(--t-opportunity) 16%, transparent);  border-color: color-mix(in srgb, var(--t-opportunity) 40%, transparent); }
.type-badge[data-type="risk"]         { color: var(--t-risk);         background: color-mix(in srgb, var(--t-risk) 16%, transparent);         border-color: color-mix(in srgb, var(--t-risk) 40%, transparent); }
.type-badge[data-type="stakeholder"]  { color: var(--t-stakeholder);  background: color-mix(in srgb, var(--t-stakeholder) 16%, transparent);  border-color: color-mix(in srgb, var(--t-stakeholder) 40%, transparent); }
.type-badge[data-type="next_step"]    { color: var(--t-next_step);    background: color-mix(in srgb, var(--t-next_step) 16%, transparent);    border-color: color-mix(in srgb, var(--t-next_step) 40%, transparent); }
.type-badge[data-type="fact"]         { color: var(--t-fact);         background: color-mix(in srgb, var(--t-fact) 16%, transparent);         border-color: color-mix(in srgb, var(--t-fact) 40%, transparent); }
.type-badge[data-type="relationship"] { color: var(--t-relationship); background: color-mix(in srgb, var(--t-relationship) 16%, transparent); border-color: color-mix(in srgb, var(--t-relationship) 40%, transparent); }

.sentiment { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--muted, #9aa7b4); text-transform: capitalize; }
.sentiment::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--s-neutral); flex: 0 0 auto; }
.sentiment[data-sentiment="positive"]::before { background: var(--s-positive); }
.sentiment[data-sentiment="neutral"]::before  { background: var(--s-neutral); }
.sentiment[data-sentiment="cautious"]::before { background: var(--s-cautious); }
.sentiment[data-sentiment="negative"]::before { background: var(--s-negative); }
