:root {
  color-scheme: light;
  --ink: #1c211c;
  --muted: #6f746d;
  --paper: #f4f0e7;
  --panel: #fffdf8;
  --line: #dcd6ca;
  --green: #315c3c;
  --green-light: #dce8d9;
  --orange: #c96636;
  --red: #a73d35;
  --shadow: 0 22px 70px rgba(40, 38, 31, 0.09);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 3% 8%, rgba(210, 225, 204, .62), transparent 28rem),
    radial-gradient(circle at 92% 96%, rgba(237, 210, 185, .5), transparent 32rem),
    var(--paper);
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.shell { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding-bottom: 48px; }

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(106, 104, 95, .22);
}

.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; font: 700 17px/1 ui-serif, Georgia, serif; }
.brand-mark { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: white; font: 18px/1 sans-serif; }

.system-strip { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.system-pill { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px; background: rgba(255,255,255,.48); font-size: 12px; color: var(--muted); }
.system-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #aaa; }
.system-pill.good::before { background: #4d8b58; box-shadow: 0 0 0 3px rgba(77,139,88,.12); }
.system-pill.warn::before { background: #cf8536; }

.setup-grid { display: grid; grid-template-columns: minmax(300px, .82fr) minmax(580px, 1.18fr); gap: clamp(36px, 6vw, 96px); align-items: center; padding: clamp(48px, 7vh, 88px) 2vw; }
.intro-panel { align-self: stretch; display: flex; flex-direction: column; justify-content: center; max-width: 560px; }
.eyebrow { margin: 0 0 12px; font-size: 11px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; color: var(--green); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 22px; font: 500 clamp(46px, 5.3vw, 78px)/.98 ui-serif, Georgia, serif; letter-spacing: -.045em; }
.lede { max-width: 520px; color: var(--muted); font-size: 18px; line-height: 1.55; }

.flow-card { margin: 30px 0; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.flow-card > div { padding: 18px 12px 17px 0; }
.flow-card span { display: block; margin-bottom: 9px; color: var(--orange); font: 700 11px/1 ui-monospace, monospace; }
.flow-card p { margin: 0; font-size: 13px; font-weight: 700; }
.privacy-note { display: flex; align-items: flex-start; gap: 13px; max-width: 510px; }
.privacy-note .lock { width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--green-light); color: var(--green); }
.privacy-note p { color: var(--muted); font-size: 13px; line-height: 1.5; }
.privacy-note strong { color: var(--ink); }

.brief-card, .mission-card, .live-card { background: rgba(255,253,248,.93); border: 1px solid rgba(204,198,186,.78); border-radius: 22px; box-shadow: var(--shadow); }
.brief-card { padding: clamp(26px, 3vw, 42px); }
.card-heading, .live-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.card-heading h2, .mission-card h2, .live-header h2 { margin: 0; font: 500 29px/1.15 ui-serif, Georgia, serif; letter-spacing: -.02em; }
.draft-badge { padding: 6px 9px; border-radius: 999px; background: #eee9df; color: var(--muted); font: 700 10px/1 sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.field { display: flex; flex-direction: column; gap: 8px; margin-top: 22px; }
.field > span { font-size: 12px; font-weight: 800; }
.field b { margin-left: 4px; color: var(--orange); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.field input, .field textarea, .manual-turn input { width: 100%; border: 1px solid var(--line); border-radius: 11px; background: #fbf9f3; color: var(--ink); outline: none; transition: .18s border, .18s box-shadow, .18s background; }
.field input { height: 46px; padding: 0 13px; }
.field textarea { padding: 12px 13px; resize: vertical; line-height: 1.45; }
.field input:focus, .field textarea:focus, .manual-turn input:focus { border-color: #6a866d; background: white; box-shadow: 0 0 0 3px rgba(67,104,73,.1); }
.field input::placeholder, .field textarea::placeholder, .manual-turn input::placeholder { color: #a19f97; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.consent-row { display: flex; gap: 11px; align-items: flex-start; margin-top: 25px; padding: 13px; border-radius: 11px; background: #edf3e9; color: #4c5b4d; }
.consent-row .check { display: grid; place-items: center; width: 18px; height: 18px; flex: 0 0 auto; border-radius: 50%; background: var(--green); color: white; font-size: 11px; }
.consent-row p { margin: 0; font-size: 12px; line-height: 1.45; }
.form-actions { display: flex; justify-content: flex-end; gap: 11px; margin-top: 24px; }
.button { min-height: 46px; padding: 0 18px; border: 0; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; gap: 18px; font-size: 13px; font-weight: 800; text-decoration: none; transition: transform .15s, box-shadow .15s, opacity .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .48; transform: none; }
.button.primary { background: var(--green); color: white; box-shadow: 0 9px 22px rgba(49,92,60,.18); }
.button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.button.dark { background: var(--ink); color: white; }
.button.wide { width: 100%; }
.error { margin: 14px 0 0; color: var(--red); font-size: 12px; }

.call-layout { display: grid; grid-template-columns: 355px minmax(0, 1fr); gap: 24px; min-height: calc(100vh - 130px); padding-top: 32px; }
.mission-card { padding: 28px; }
.back-button { margin: 0 0 34px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.mission-copy { margin: 16px 0 28px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.mission-meta { margin: 0; border-top: 1px solid var(--line); }
.mission-meta > div { padding: 16px 0; border-bottom: 1px solid var(--line); }
.mission-meta dt { margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.mission-meta dd { margin: 0; font-size: 13px; line-height: 1.45; }
.mission-actions { display: grid; gap: 10px; margin-top: 26px; }
.call-instructions { margin-top: 24px; padding: 15px; border-radius: 12px; background: #f2eee5; }
.call-instructions strong { display: block; margin-bottom: 5px; font-size: 12px; }
.call-instructions p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.live-card { min-height: 720px; display: flex; flex-direction: column; overflow: hidden; }
.live-header { padding: 29px 32px 20px; }
.call-state-row { display: flex; align-items: center; gap: 10px; }
.call-state-row h2 { font-size: 26px; }
.call-dot { width: 9px; height: 9px; border-radius: 50%; background: #aba9a1; }
.call-dot.live { background: #4c995d; box-shadow: 0 0 0 5px rgba(76,153,93,.14); animation: pulse 1.8s infinite; }
.call-dot.thinking { background: #d18a43; box-shadow: 0 0 0 5px rgba(209,138,67,.13); }
.call-dot.ended { background: #9a403a; }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px rgba(76,153,93,.04); } }
.elapsed { font: 600 15px/1 ui-monospace, SFMono-Regular, monospace; color: var(--muted); }
.audio-meter { min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 4px; border-top: 1px solid #efebe2; border-bottom: 1px solid #efebe2; background: #faf7f0; }
.audio-meter i { display: block; width: 3px; height: 6px; border-radius: 2px; background: #95aa96; transition: height .08s; }
.audio-meter.listening i { animation: listen 1s ease-in-out infinite alternate; }
.audio-meter.listening i:nth-child(2n) { animation-delay: -.3s; }
.audio-meter.listening i:nth-child(3n) { animation-delay: -.55s; }
@keyframes listen { from { height: 5px; } to { height: 24px; } }

.transcript { flex: 1; min-height: 360px; max-height: calc(100vh - 330px); padding: 30px 32px; overflow-y: auto; scroll-behavior: smooth; }
.turn { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; max-width: 780px; margin-bottom: 24px; }
.turn.recipient { margin-left: auto; grid-template-columns: minmax(0, 1fr) 34px; }
.turn-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--green-light); color: var(--green); font: 800 10px/1 sans-serif; }
.turn.recipient .turn-avatar { grid-column: 2; background: #ece7dc; color: #6d685f; }
.turn-body { padding-top: 2px; }
.turn.recipient .turn-body { grid-row: 1; text-align: right; }
.turn-label { margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.turn-text { display: inline-block; margin: 0; padding: 12px 15px; border-radius: 4px 15px 15px 15px; background: #edf3e9; font-size: 15px; line-height: 1.48; text-align: left; }
.turn.recipient .turn-text { border-radius: 15px 4px 15px 15px; background: #f0ece3; }
.turn-time { display: block; margin-top: 5px; color: #aaa69e; font-size: 9px; }

.manual-turn { display: flex; gap: 9px; padding: 0 32px 20px; }
.manual-turn input { height: 46px; padding: 0 15px; }
.manual-turn button { width: 46px; flex: 0 0 auto; border: 0; border-radius: 50%; background: var(--green); color: white; font-size: 18px; }
.control-bar { min-height: 70px; display: flex; align-items: center; gap: 8px; padding: 12px 24px; border-top: 1px solid var(--line); background: #f8f5ed; }
.control { min-height: 38px; padding: 0 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--ink); display: inline-flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 800; text-decoration: none; }
.control.danger { margin-left: auto; color: var(--red); }
.takeover-panel { margin: 0 24px 22px; padding: 16px 18px; border: 1px solid #dbc89b; border-radius: 12px; background: #fff5d9; }
.takeover-panel div { display: flex; justify-content: space-between; gap: 20px; }
.takeover-panel span { color: #946e31; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.takeover-panel strong { font-size: 12px; }
.takeover-panel p { margin: 8px 0 0; color: #6f624d; font-size: 12px; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 10; transform: translateX(-50%); max-width: min(440px, calc(100% - 30px)); padding: 12px 16px; border-radius: 999px; background: var(--ink); color: white; box-shadow: 0 10px 35px rgba(0,0,0,.2); font-size: 12px; }

@media (max-width: 980px) {
  .setup-grid { grid-template-columns: 1fr; }
  .intro-panel { max-width: none; }
  h1 { max-width: 720px; }
  .call-layout { grid-template-columns: 1fr; }
  .mission-card { display: grid; grid-template-columns: 1fr 1fr; gap: 0 26px; }
  .mission-card .back-button, .mission-card .eyebrow, .mission-card h2 { grid-column: 1 / -1; }
  .mission-actions { align-self: end; }
}

@media (max-width: 650px) {
  .shell { width: min(100% - 24px, 1440px); }
  .topbar { align-items: flex-start; flex-direction: column; padding: 18px 0; }
  .system-strip { justify-content: flex-start; }
  .setup-grid { padding: 40px 0; }
  h1 { font-size: 45px; }
  .brief-card { padding: 22px 18px; border-radius: 17px; }
  .two-col { grid-template-columns: 1fr; gap: 0; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
  .call-layout { padding-top: 18px; }
  .mission-card { display: block; }
  .live-header, .transcript { padding-left: 18px; padding-right: 18px; }
  .manual-turn { padding-left: 18px; padding-right: 18px; }
  .control-bar { overflow-x: auto; padding-left: 14px; padding-right: 14px; }
  .control { flex: 0 0 auto; }
  .control.danger { margin-left: 0; }
}
