:root {
  color-scheme: light;
  --forest: #082e26;
  --forest-2: #0d4a3b;
  --mint: #a5e6cb;
  --mint-2: #dff8ed;
  --coral: #ff735f;
  --coral-dark: #d84f3f;
  --cream: #fbf8f0;
  --paper: #ffffff;
  --ink: #122721;
  --muted: #64766f;
  --line: #dce8e2;
  --shadow: 0 22px 70px rgba(8, 46, 38, 0.13);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--cream);
  color: var(--ink);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--cream); }
body { min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; background: radial-gradient(circle at 15% 12%, #eefbf5 0, transparent 30%), var(--cream); }
.topbar { height: 78px; display: flex; align-items: center; justify-content: space-between; padding: 0 5vw; border-bottom: 1px solid rgba(8,46,38,.08); background: rgba(251,248,240,.88); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--forest); text-decoration: none; }
.brand img { object-fit: contain; }
.brand span { display: grid; line-height: 1.05; }
.brand strong { font-size: 19px; letter-spacing: -.03em; }
.brand small { font-size: 10px; color: var(--muted); margin-top: 5px; letter-spacing: .04em; text-transform: uppercase; }
.top-actions, .session-controls { display: flex; align-items: center; gap: 10px; }
.version-label { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .04em; }
.credit-balance { border-radius: 999px; padding: 8px 11px; background: var(--mint-2); color: var(--forest-2); font-size: 11px; font-weight: 800; white-space: nowrap; }

.view { width: min(1180px, 92vw); margin: 0 auto; }
.onboarding-view { min-height: calc(100vh - 78px); display: grid; grid-template-columns: 1.08fr .92fr; gap: clamp(36px, 7vw, 96px); align-items: center; padding: 64px 0 80px; }
.hero-copy h1, .ready-view h1 { font-family: Georgia, "Times New Roman", serif; color: var(--forest); font-weight: 500; letter-spacing: -.045em; line-height: .98; font-size: clamp(46px, 5.6vw, 78px); margin: 14px 0 24px; }
.hero-copy h1 em { color: var(--coral-dark); font-weight: 500; }
.hero-copy > p:not(.eyebrow) { color: var(--muted); font-size: 18px; line-height: 1.65; max-width: 610px; }
.eyebrow, .step-label { margin: 0; color: var(--coral-dark); font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.trust-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; }
.trust-row span { border: 1px solid var(--line); background: rgba(255,255,255,.72); color: var(--forest-2); font-size: 12px; font-weight: 650; padding: 9px 12px; border-radius: 999px; }

.card { background: rgba(255,255,255,.94); border: 1px solid rgba(8,46,38,.08); border-radius: 26px; box-shadow: var(--shadow); }
.onboarding-card { padding: clamp(26px, 4vw, 44px); display: grid; gap: 20px; }
.onboarding-card h2, .profile-dialog h2, .session-status h2 { color: var(--forest); font-size: 27px; margin: 5px 0 7px; letter-spacing: -.03em; }
.muted { color: var(--muted); line-height: 1.55; margin: 0; }
.max-copy { max-width: 650px; }
label, fieldset { color: var(--forest); font-size: 12px; font-weight: 750; letter-spacing: .02em; }
input, select { width: 100%; margin-top: 7px; min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: #fbfdfc; padding: 0 13px; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: #55a98a; box-shadow: 0 0 0 3px rgba(85,169,138,.14); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { margin-bottom: 8px; }
.voice-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.voice-card { min-height: 60px; border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; gap: 9px; align-items: center; background: #fbfdfc; }
.voice-card:has(input:checked) { border-color: #51a486; background: #effaf5; box-shadow: inset 0 0 0 1px #51a486; }
.voice-card input { width: 17px; min-height: 17px; margin: 0; accent-color: var(--forest-2); }
.voice-card span { display: grid; gap: 3px; }
.voice-card small { color: var(--muted); font-weight: 500; }

.primary-button, .quiet-button, .listen-button, .icon-button { border: 0; border-radius: 12px; font-weight: 750; }
.primary-button { min-height: 50px; padding: 0 20px; background: var(--coral); color: #fff; box-shadow: 0 10px 22px rgba(216,79,63,.2); }
.primary-button:hover { background: #f0614d; }
.primary-button:disabled { opacity: .5; cursor: wait; }
.primary-button.large { font-size: 17px; min-height: 56px; padding-inline: 28px; }
.quiet-button { min-height: 39px; padding: 0 14px; border: 1px solid var(--line); background: #fff; color: var(--forest); }
.quiet-button:hover:not(:disabled) { border-color: #97b9aa; background: var(--mint-2); }
.quiet-button:disabled { opacity: .42; cursor: default; }
.quiet-button.danger { color: #9a342a; }
.error { color: #a42e25; background: #fff0ed; border: 1px solid #ffd2cb; border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 0; }

.ready-view { min-height: calc(100vh - 78px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 60px 0 100px; }
.ready-view h1 { font-size: clamp(44px, 5vw, 68px); margin-bottom: 18px; }
.ready-view .primary-button { margin-top: 28px; }
.ready-krab { width: 180px; height: 140px; position: relative; display: grid; place-items: center; margin-bottom: 15px; }
.ready-krab img { z-index: 2; object-fit: contain; }
.halo { position: absolute; width: 145px; height: 145px; border-radius: 50%; background: var(--mint-2); box-shadow: 0 0 0 18px rgba(165,230,203,.18); }

.session-view { min-height: calc(100vh - 78px); max-width: 850px; padding: 50px 0 70px; display: flex; flex-direction: column; }
.session-status { display: flex; align-items: center; gap: 18px; padding: 0 4px 28px; border-bottom: 1px solid var(--line); }
.status-orb { width: 60px; height: 60px; flex: 0 0 auto; border-radius: 50%; background: var(--forest); display: grid; place-items: center; box-shadow: 0 0 0 9px rgba(8,46,38,.08); }
.status-orb span, .status-orb span::before, .status-orb span::after { display: block; width: 3px; height: 18px; border-radius: 9px; background: var(--mint); content: ""; }
.status-orb span { position: relative; animation: pulse-wave .9s ease-in-out infinite alternate; }
.status-orb span::before { position: absolute; left: -8px; height: 10px; top: 4px; }
.status-orb span::after { position: absolute; right: -8px; height: 13px; top: 2px; }
.status-orb.idle span { animation-play-state: paused; opacity: .55; }
@keyframes pulse-wave { from { transform: scaleY(.55); } to { transform: scaleY(1.35); } }
.conversation { flex: 1; display: flex; flex-direction: column; gap: 13px; padding: 28px 0; min-height: 320px; }
.guide-ready-card, .standby-card { margin-top: 22px; border: 1px solid var(--line); border-radius: 20px; background: #fff; display: flex; align-items: center; gap: 16px; padding: 18px 20px; box-shadow: 0 12px 34px rgba(8,46,38,.08); }
.guide-ready-card { border-color: rgba(255,115,95,.42); background: linear-gradient(135deg, #fff 0%, #fff6f3 100%); }
.guide-ready-card img { animation: krab-dance 1.05s ease-in-out infinite; transform-origin: 50% 88%; object-fit: contain; }
.guide-ready-card h3, .standby-card h3 { color: var(--forest); font-size: 18px; margin: 4px 0 3px; letter-spacing: -.02em; }
.guide-ready-card p:last-child, .standby-card p:last-child { color: var(--muted); font-size: 12px; line-height: 1.45; margin: 0; }
.standby-card { background: var(--mint-2); border-color: #bfe8d5; }
.standby-card img { opacity: .82; object-fit: contain; }
.guide-complete #pdf-button { background: var(--coral); color: #fff; border-color: var(--coral); box-shadow: 0 8px 20px rgba(216,79,63,.2); }
.standby-mode { justify-content: flex-start; }
.standby-mode .session-status { margin-top: 20px; }
.standby-mode .session-controls { margin-top: 22px; }
.message { max-width: 78%; padding: 14px 17px; border-radius: 17px; line-height: 1.5; font-size: 15px; box-shadow: 0 5px 18px rgba(8,46,38,.05); }
.message.krab { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; color: var(--ink); }
.message.user { align-self: flex-end; background: var(--forest); color: #fff; border-bottom-right-radius: 5px; }
.message.system { align-self: center; background: transparent; color: var(--muted); box-shadow: none; font-size: 12px; padding: 6px; text-align: center; }
.session-controls { border-top: 1px solid var(--line); padding-top: 18px; flex-wrap: wrap; }
.listen-button { min-height: 42px; padding: 0 15px; color: var(--forest); background: var(--mint-2); display: flex; align-items: center; gap: 9px; margin-right: auto; }
.listen-button[aria-pressed="true"] { background: #f3f3ef; color: var(--muted); }
.mic-dot { width: 9px; height: 9px; border-radius: 50%; background: #23a16e; box-shadow: 0 0 0 5px rgba(35,161,110,.12); }
.listen-button[aria-pressed="true"] .mic-dot { background: #9baaa4; box-shadow: none; }
.privacy-note { color: var(--muted); font-size: 11px; text-align: center; margin: 14px 0 0; }

.profile-dialog { width: min(520px, 92vw); border: 0; border-radius: 22px; padding: 0; color: var(--ink); box-shadow: 0 30px 90px rgba(8,46,38,.3); }
.profile-dialog::backdrop { background: rgba(5,29,24,.48); backdrop-filter: blur(5px); }
.profile-dialog form { padding: 30px; display: grid; gap: 17px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.icon-button { width: 35px; height: 35px; background: #edf4f0; color: var(--forest); font-size: 23px; }

.web-krab { position: fixed; right: 20px; bottom: 18px; width: 92px; height: 69px; object-fit: contain; pointer-events: none; z-index: 99999; filter: drop-shadow(0 8px 10px rgba(8,46,38,.18)); transition: left .85s cubic-bezier(.4,0,.2,1), top .85s cubic-bezier(.4,0,.2,1), transform .18s ease; }
.web-krab.running { transform: translateY(-3px) rotate(-2deg); }
.web-krab.celebrating { animation: krab-dance .62s ease-in-out 6; transform-origin: 50% 88%; }
@keyframes krab-dance {
  0%, 100% { transform: translateY(0) rotate(-5deg) scale(1); }
  25% { transform: translateY(-13px) rotate(6deg) scale(1.04); }
  50% { transform: translateY(0) rotate(5deg) scale(.98); }
  75% { transform: translateY(-9px) rotate(-7deg) scale(1.03); }
}

body.pip-mode .topbar { height: 58px; padding-inline: 13px; }
body.pip-mode .brand img { width: 42px; height: 32px; }
body.pip-mode .brand small, body.pip-mode .version-label, body.pip-mode #float-button, body.pip-mode #settings-button { display: none; }
body.pip-mode .top-actions { display: flex; }
body.pip-mode .view { width: calc(100% - 28px); }
body.pip-mode .session-view { padding: 14px 0 18px; min-height: calc(100vh - 58px); }
body.pip-mode .session-status { gap: 12px; padding-bottom: 16px; }
body.pip-mode .status-orb { width: 44px; height: 44px; }
body.pip-mode .session-status h2 { font-size: 19px; }
body.pip-mode .conversation { min-height: 120px; padding: 13px 0; }
body.pip-mode .message { max-width: 92%; font-size: 13px; padding: 10px 12px; }
body.pip-mode .session-controls { gap: 7px; }
body.pip-mode .session-controls .quiet-button { font-size: 11px; padding-inline: 9px; }
body.pip-mode .privacy-note { display: none; }
body.pip-mode .guide-ready-card, body.pip-mode .standby-card { margin-top: 12px; padding: 11px 12px; gap: 9px; border-radius: 14px; }
body.pip-mode .guide-ready-card img, body.pip-mode .standby-card img { width: 62px; height: auto; }
body.pip-mode .guide-ready-card h3, body.pip-mode .standby-card h3 { font-size: 14px; }
body.pip-mode .guide-ready-card p:last-child, body.pip-mode .standby-card p:last-child { display: none; }

@media (max-width: 820px) {
  .topbar { padding-inline: 4vw; }
  .onboarding-view { grid-template-columns: 1fr; padding-top: 42px; }
  .hero-copy { text-align: center; }
  .hero-copy > p:not(.eyebrow) { margin-inline: auto; }
  .trust-row { justify-content: center; }
}

@media (max-width: 560px) {
  .topbar { height: 68px; }
  .brand small { display: none; }
  .onboarding-view, .ready-view, .session-view { min-height: calc(100vh - 68px); }
  .form-grid, .voice-options { grid-template-columns: 1fr; }
  .hero-copy h1, .ready-view h1 { font-size: 42px; }
  .session-controls { align-items: stretch; }
  .listen-button { width: 100%; justify-content: center; margin: 0; }
  .session-controls .quiet-button { flex: 1; }
}
