/* ---- Alaska (TD corporate font), self-hosted ---- */
@font-face {
  font-family: "Alaska";
  src: url("/assets/fonts/Alaska-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Alaska";
  src: url("/assets/fonts/Alaska-Italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Alaska";
  src: url("/assets/fonts/Alaska-Bold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Alaska";
  src: url("/assets/fonts/Alaska-BoldItalic.woff2") format("woff2");
  font-weight: 700; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Alaska";
  src: url("/assets/fonts/Alaska-Black.woff2") format("woff2");
  font-weight: 900; font-style: normal; font-display: swap;
}

:root {
  --brand-primary: #1f6f54;
  --brand-accent: #b3402f;
  --brand-bg: #0b0f0c;
  --text: #ececec;
  --muted: #8b938d;
  --line: color-mix(in srgb, var(--brand-primary) 26%, #000);
  --panel: color-mix(in srgb, var(--brand-bg) 82%, #fff 7%);
  font-family: "Alaska", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--brand-bg);
  color: var(--text);
  font-family: "Alaska", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---- Top bar ---- */
#topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 28px; position: relative;
}
#logo { height: 30px; width: auto; }
.wordmark {
  font-weight: 900; letter-spacing: 3px; font-size: 13px;
  color: #f5f5f5; flex: 1;
}
.settings-toggle {
  background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 50%; width: 56px; height: 56px; font-size: 34px;
  cursor: pointer; line-height: 1;
}
.settings-toggle:hover { color: var(--text); }
.settings-panel {
  position: absolute; top: 60px; right: 28px; z-index: 20;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px; display: flex; flex-direction: column;
  gap: 12px; min-width: 220px; font-size: 13px;
  box-shadow: 0 18px 40px rgba(0,0,0,.45);
}
.settings-panel label { display: flex; flex-direction: column; gap: 5px;
  color: var(--muted); }
.settings-panel select {
  background: var(--brand-bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px;
  font-family: inherit;
}
.settings-panel .switch { flex-direction: row; align-items: center; gap: 8px;
  color: var(--text); }

/* ---- Layout ---- */
main {
  display: flex; gap: 24px; align-items: stretch;
  padding: 8px 28px 28px; min-height: calc(100vh - 124px);
}
.stage {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px; text-align: center;
}
.persona-name {
  font-weight: 900; font-size: clamp(28px, 5vw, 46px); margin: 0;
  letter-spacing: .5px; color: #f4f4f2;
}
.persona-appearance {
  margin: 0; max-width: 320px; color: var(--muted); font-size: 13px;
  line-height: 1.5;
}
.status { color: #cfd6d1; font-size: 13px; letter-spacing: .3px; margin: 0; }

/* ---- Voice orb ---- */
.orb {
  --orb: var(--brand-primary); position: relative;
  width: 154px; height: 154px; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%,
    rgba(255,255,255,.35), var(--orb) 60%, rgba(0,0,0,.4));
}
.orb-portrait {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; border-radius: 50%;
}
.orb[data-state="idle"] { filter: saturate(.75) brightness(.85);
  box-shadow: 0 0 24px color-mix(in srgb, var(--orb) 22%, transparent); }
.orb[data-state="listening"] { animation: orb-breathe 2.8s ease-in-out infinite; }
.orb[data-state="speaking"] { --orb: var(--brand-accent);
  animation: orb-breathe 0.6s ease-in-out infinite; }
@keyframes orb-breathe {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--orb) 40%, transparent); }
  50% { box-shadow: 0 0 42px 8px color-mix(in srgb, var(--orb) 32%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .orb { animation: none !important; }
}

/* ---- Buttons ---- */
.stage-actions { display: flex; gap: 10px; }
button.primary {
  background: var(--brand-primary); color: #fff; border: 0;
  border-radius: 22px; padding: 11px 22px; font-family: inherit;
  font-size: 14px; cursor: pointer;
}
button.primary:disabled { opacity: .5; cursor: default; }
button.ghost {
  background: none; border: 1px solid var(--line); color: #c4ccc6;
  border-radius: 22px; padding: 8px 16px; font-family: inherit;
  font-size: 13px; cursor: pointer;
}

/* ---- Briefing (collapsed scenario) ---- */
.briefing { max-width: 360px; color: var(--muted); font-size: 12px;
  text-align: left; }
.briefing summary { cursor: pointer; color: #9aa39d; }
.briefing ul { margin: 8px 0 0; padding-left: 18px; }

/* ---- Transcript bubbles (right column) ---- */
.transcript-region {
  width: 300px; flex-shrink: 0; border-left: 1px solid var(--line);
  padding-left: 18px; display: flex;
}
.transcript {
  overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  width: 100%; max-height: calc(100vh - 160px); padding: 4px;
  scrollbar-width: thin;
}
.bubble {
  border-radius: 14px; padding: 9px 12px; font-size: 13px; line-height: 1.4;
  max-width: 92%; transition: opacity .35s ease;
}
.bubble.you { align-self: flex-end;
  background: color-mix(in srgb, var(--brand-primary) 20%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand-primary) 42%, transparent);
  color: #e7f1ec; }
.bubble.them { align-self: flex-start;
  background: color-mix(in srgb, var(--brand-accent) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand-accent) 42%, transparent);
  color: #f4ddd5; }

/* ---- Feedback scorecard ---- */
.feedback {
  position: fixed; inset: 0; z-index: 30; overflow-y: auto;
  background: var(--brand-bg); padding: 28px clamp(20px, 8vw, 120px);
}
.feedback-head { display: flex; align-items: baseline;
  justify-content: space-between; }
.overall { font-weight: 900; font-size: 40px; color: #f4f4f2; }
.link { background: none; border: 0; color: #8fb9a8; cursor: pointer;
  font-family: inherit; font-size: 13px; }
.dimensions { margin-top: 18px; }
details.dimension { border-top: 1px solid var(--line); padding: 12px 0; }
details.dimension summary { cursor: pointer; list-style: none; }
details.dimension summary::-webkit-details-marker { display: none; }
.dim-row { display: flex; justify-content: space-between; font-size: 14px;
  color: #dfe4e0; }
.dim-row .dim-score { font-weight: 700; }
.bar { height: 4px; background: #1c2620; border-radius: 2px; margin-top: 7px; }
.bar .fill { height: 100%; background: var(--brand-primary); border-radius: 2px; }
.rationale { font-size: 13px; color: #c7cec9; line-height: 1.5;
  margin: 10px 0 0; }
.evidence { margin: 8px 0 0; padding: 8px 12px; font-style: italic;
  font-size: 13px; color: #f0ddd6;
  border-left: 2px solid var(--brand-accent);
  background: color-mix(in srgb, var(--brand-accent) 8%, transparent); }
.adv-label { font-size: 10px; letter-spacing: 1px; color: var(--muted);
  text-transform: uppercase; margin: 22px 0 6px; }
.advice { margin: 0; padding-left: 18px; font-size: 14px; color: #dfe4e0;
  line-height: 1.6; }
.feedback-actions { margin-top: 28px; display: flex; justify-content: center; }

.spec-accuracy {
  margin-top: 18px; padding: 14px 16px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--brand-accent) 50%, transparent);
  background: color-mix(in srgb, var(--brand-accent) 10%, transparent);
}
.spec-accuracy-title {
  margin: 0 0 8px; font-size: 13px; letter-spacing: 1px;
  text-transform: uppercase; color: #f4ddd5;
}
.spec-correction { margin: 8px 0 0; font-size: 13px; }
.spec-claim { margin: 0; color: #f0c9c0; text-decoration: line-through; }
.spec-correct { margin: 2px 0 0; color: #e7f1ec; font-weight: 700; }
.spec-note { margin: 2px 0 0; color: var(--muted); }

.auth {
  position: fixed; inset: 0; z-index: 50; display: flex;
  align-items: center; justify-content: center; background: var(--brand-bg);
}
.auth-card {
  width: min(360px, 92vw); display: flex; flex-direction: column; gap: 12px;
  padding: 28px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--panel);
}
.auth-title { margin: 0 0 6px; font-size: 26px; color: #f4f4f2; }
.auth-field { display: flex; flex-direction: column; gap: 5px;
  color: var(--muted); font-size: 13px; }
.auth-field input {
  background: var(--brand-bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
  font-family: inherit; font-size: 14px;
}
.auth-hint { margin: 0; font-size: 12px; color: var(--muted); }
.auth-error { margin: 0; font-size: 13px; color: #f0a59a; }
body.unauthed #topbar, body.unauthed main { display: none !important; }
.history {
  position: fixed; inset: 0; z-index: 40; overflow-y: auto;
  background: var(--brand-bg); padding: 28px clamp(20px, 8vw, 120px);
}
.history-head { display: flex; align-items: baseline;
  justify-content: space-between; }
.history-title { font-size: 26px; color: #f4f4f2; margin: 0; }
.trend { width: 100%; height: 120px; margin: 18px 0;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.trend polyline { fill: none; stroke: var(--brand-primary); stroke-width: 2; }
.trend circle { fill: var(--brand-accent); }
.trend polyline.trend-overall { stroke: var(--brand-primary); }
.trend circle.trend-overall { fill: var(--brand-primary); }
.trend polyline.trend-craft { stroke: var(--brand-accent); stroke-dasharray: 4 3; }
.trend circle.trend-craft { fill: var(--brand-accent); }
.trend-legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted);
  margin: -6px 0 6px; }
.trend-legend span::before { content: ""; display: inline-block;
  width: 12px; height: 3px; margin-right: 6px; vertical-align: middle; }
.trend-legend .legend-overall::before { background: var(--brand-primary); }
.trend-legend .legend-craft::before { background: var(--brand-accent); }
.history-item .h-craft { color: var(--brand-accent); }
.history-list { list-style: none; padding: 0; margin: 0; }
.history-item {
  display: flex; justify-content: space-between; gap: 12px;
  border-top: 1px solid var(--line); padding: 12px 0; font-size: 14px;
  color: #dfe4e0;
}
.history-item .h-score { font-weight: 700; }
.history-empty { color: var(--muted); margin-top: 18px; }
.hidden { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---- Responsive (mobile / tablet) ---- */
@media (max-width: 720px) {
  #topbar { padding: 14px 18px; }
  main { flex-direction: column; padding: 6px 18px 96px; }
  .settings-panel { right: 18px; left: 18px; }
  /* Transcript is a top panel: below the top bar, down to 75% of the
     viewport, and BELOW the settings panel (z-index 20) so the gear stays
     usable. The bottom action bar sits in the open lower quarter, so Begin/
     End/Mute remain reachable while the transcript is open. */
  .transcript-region {
    position: fixed; left: 0; right: 0; top: 76px; bottom: 25vh;
    width: auto; height: auto; border-left: 0;
    border-bottom: 1px solid var(--line);
    background: var(--panel); padding: 14px 16px;
    border-radius: 0 0 16px 16px; z-index: 10;
    box-shadow: 0 14px 30px rgba(0,0,0,.4);
  }
  .transcript { max-height: 100%; }
  .stage-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 24;
    justify-content: center; padding: 14px; background: var(--brand-bg);
    border-top: 1px solid var(--line); }
}
