:root {
  color-scheme: dark;
  --bg: #040b14;
  --surface: rgba(9, 24, 41, .88);
  --surface-strong: #0b2035;
  --line: rgba(95, 199, 255, .18);
  --cyan: #63d8ff;
  --cyan-strong: #18aee9;
  --green: #57e6bc;
  --red: #ff6f7f;
  --text: #ebf8ff;
  --muted: #8ea9bc;
  --shadow: 0 20px 70px rgba(0, 0, 0, .35);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 50% -10%, #12324e 0, #06111f 34%, var(--bg) 70%); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.ambient { position: fixed; inset: 0; pointer-events: none; background-image: linear-gradient(rgba(90,190,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(90,190,255,.035) 1px, transparent 1px); background-size: 34px 34px; mask-image: linear-gradient(to bottom, black, transparent 70%); }
.app-shell { position: relative; width: min(100%, 680px); margin: 0 auto; min-height: 100vh; padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; background: rgba(4,11,20,.82); border-bottom: 1px solid var(--line); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 10px; letter-spacing: .08em; }
.brand > div:last-child { display: grid; gap: 1px; }
.brand strong { font-size: 13px; }
.brand span { color: var(--muted); font-size: 10px; letter-spacing: .02em; }
.brand-mark { width: 66px; height: 66px; border: 1px solid rgba(99,216,255,.38); border-radius: 20px; display: grid; place-items: center; background: radial-gradient(circle, rgba(62,189,241,.22), rgba(5,19,33,.7)); box-shadow: inset 0 0 30px rgba(33,174,234,.16), 0 0 35px rgba(33,174,234,.14); }
.brand-mark.small { width: 38px; height: 38px; border-radius: 12px; }
.brand-mark img { width: 78%; height: 78%; object-fit: contain; }
.account-chip, .icon-button { border: 1px solid var(--line); border-radius: 999px; background: rgba(10,31,50,.8); padding: 9px 12px; display: flex; align-items: center; gap: 7px; font-size: 12px; cursor: pointer; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: #627384; box-shadow: 0 0 0 3px rgba(98,115,132,.11); }
.status-dot.online { background: var(--green); box-shadow: 0 0 12px var(--green); }
.status-dot.warning { background: #f7c267; box-shadow: 0 0 12px rgba(247,194,103,.7); }
.status-dot.error { background: var(--red); box-shadow: 0 0 12px rgba(255,111,127,.75); }

.system-notices { position: fixed; z-index: 180; top: calc(10px + env(safe-area-inset-top)); left: 50%; width: min(calc(100% - 24px), 620px); display: grid; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.system-notice { min-height: 56px; padding: 10px 10px 10px 12px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; border: 1px solid rgba(255,111,127,.32); border-radius: 14px; background: rgba(17,25,37,.97); box-shadow: 0 14px 42px rgba(0,0,0,.46); backdrop-filter: blur(16px); pointer-events: auto; }
.system-notice > div { min-width: 0; display: grid; gap: 2px; }
.system-notice strong { color: #f2f8fc; font-size: 11px; }
.system-notice small { color: var(--muted); font-size: 9px; line-height: 1.35; }
.system-notice button { min-height: 34px; padding: 7px 10px; border: 1px solid rgba(99,216,255,.24); border-radius: 9px; background: rgba(17,61,88,.72); color: #c5eafa; font-size: 9px; font-weight: 720; }
.system-notice button:disabled { cursor: wait; opacity: .5; }
.notice-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 12px rgba(255,111,127,.65); }
.system-notice.checking { border-color: rgba(247,194,103,.28); }
.system-notice.checking .notice-dot { background: #f7c267; box-shadow: 0 0 12px rgba(247,194,103,.55); }
.update-notice { border-color: rgba(87,230,188,.28); }
.update-notice .notice-dot { background: var(--green); box-shadow: 0 0 12px rgba(87,230,188,.65); }

main { padding: 0 14px 24px; }
.connection-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 12px 0 0; }
.connection-strip > div { min-width: 0; border: 1px solid var(--line); background: rgba(7,20,34,.72); border-radius: 13px; padding: 9px 8px; display: grid; grid-template-columns: auto 1fr; gap: 2px 7px; align-items: center; }
.connection-strip strong { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.connection-strip small { color: var(--muted); grid-column: 2; font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.view { animation: view-in .26s ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } }
.hero { min-height: 290px; padding: 32px 18px 22px; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.orb { position: relative; width: 118px; height: 118px; border: 1px solid rgba(99,216,255,.28); border-radius: 50%; display: grid; place-items: center; margin-bottom: 22px; background: radial-gradient(circle, #d5f8ff 0 3%, #49bcf4 7%, #163b76 26%, rgba(12,40,76,.82) 43%, rgba(5,18,32,.25) 67%); box-shadow: 0 0 35px rgba(44,175,241,.42), inset 0 0 25px rgba(96,220,255,.55); }
.orb::before, .orb::after { content: ""; position: absolute; border: 1px solid rgba(90,203,255,.16); border-radius: 50%; }
.orb::before { inset: -22px; }
.orb::after { inset: -48px; border-style: dashed; animation: orbit 15s linear infinite; }
.orb span { width: 54px; height: 54px; border-radius: 50%; background: repeating-conic-gradient(from 0deg, rgba(209,248,255,.8) 0 2deg, transparent 2deg 7deg); filter: drop-shadow(0 0 7px #78dcff); animation: orbit 9s linear infinite reverse; }
.orb.live { animation: pulse 1.6s ease-in-out infinite; }
@keyframes orbit { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { transform: scale(1.045); box-shadow: 0 0 60px rgba(44,175,241,.75), inset 0 0 30px rgba(96,220,255,.7); } }
.eyebrow { margin: 0 0 7px; color: var(--cyan); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
h1, h2, p { margin-top: 0; }
.hero h1 { margin-bottom: 10px; font-size: clamp(23px, 7vw, 32px); line-height: 1.15; letter-spacing: -.03em; }
.muted { color: var(--muted); line-height: 1.45; font-size: 13px; }
.hero .muted { max-width: 450px; }
.pilot-limit { margin: -4px 0 14px; padding: 13px 14px; border: 1px solid rgba(247,194,103,.2); border-radius: 15px; background: rgba(63,43,16,.18); }
.pilot-limit strong { color: #f2d29b; font-size: 11px; }
.pilot-limit p { margin: 5px 0 0; color: #a9a08e; font-size: 10px; line-height: 1.5; }
.card { border: 1px solid var(--line); border-radius: 20px; background: linear-gradient(145deg, rgba(10,29,48,.94), rgba(6,18,31,.92)); box-shadow: var(--shadow); }
.setup-card, .live-card, .draft-form { padding: 18px; }
.card-heading, .section-head, .live-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.card-heading h2, .section-head h1 { margin: 0; font-size: 20px; }
.mode-badge, .save-state { border: 1px solid rgba(87,230,188,.28); color: var(--green); background: rgba(87,230,188,.08); border-radius: 999px; padding: 6px 9px; font-size: 9px; font-weight: 800; letter-spacing: .08em; white-space: nowrap; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label { display: grid; gap: 7px; color: #afc5d5; font-size: 11px; }
input, select, textarea { width: 100%; border: 1px solid rgba(117,200,246,.2); border-radius: 12px; outline: none; padding: 12px 13px; color: var(--text); background: rgba(3,13,23,.72); }
input:focus, select:focus, textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(99,216,255,.08); }
textarea { resize: vertical; }
.check-row { display: flex; align-items: flex-start; gap: 10px; }
.check-row input { width: 18px; height: 18px; margin: 0; accent-color: var(--cyan-strong); flex: 0 0 auto; }
.consent { margin: 14px 0; line-height: 1.4; }
.primary, .secondary, .danger { border-radius: 13px; border: 1px solid transparent; padding: 13px 16px; font-weight: 750; cursor: pointer; }
.primary { width: 100%; color: #00131f; background: linear-gradient(135deg, #7de4ff, #20a9ed); box-shadow: 0 9px 26px rgba(24,174,233,.25); }
.primary:disabled { cursor: not-allowed; opacity: .42; filter: saturate(.5); }
.secondary { border-color: var(--line); background: rgba(13,38,61,.75); color: #d8effc; }
.danger { border-color: rgba(255,111,127,.3); background: rgba(255,111,127,.1); color: #ffafba; }
.danger.full { width: 100%; margin-top: 9px; }
.call-start { font-size: 15px; }
.mic-icon { color: #07304a; margin-right: 6px; }
.inline-note { min-height: 17px; margin: 9px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.inline-note.error, .error { color: #ff9daa; }

.live-card { margin-top: 4px; }
.live-head > div { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 8px; }
.live-head small { color: var(--muted); grid-column: 2; }
.recording-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--red); box-shadow: 0 0 15px rgba(255,111,127,.8); grid-row: span 2; animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }
.coach-card { margin: 18px 0 13px; padding: 16px; border: 1px solid rgba(99,216,255,.36); border-radius: 16px; background: linear-gradient(135deg, rgba(23,96,137,.26), rgba(8,32,54,.55)); }
.coach-question { margin: 0; font-size: 18px; line-height: 1.35; }
.missing-wrap > span { color: var(--muted); font-size: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 13px; }
.chip { border: 1px solid rgba(247,194,103,.24); border-radius: 999px; padding: 6px 9px; color: #f6cd83; background: rgba(247,194,103,.06); font-size: 9px; }
.chip.done { color: var(--green); border-color: rgba(87,230,188,.22); }
.transcript { height: 210px; overflow: auto; padding: 3px; scrollbar-color: rgba(99,216,255,.35) transparent; }
.transcript-row { margin: 0 0 8px; padding: 10px 11px; border-left: 2px solid rgba(99,216,255,.45); background: rgba(2,12,22,.42); border-radius: 0 10px 10px 0; font-size: 12px; line-height: 1.45; }
.transcript-row small { color: var(--cyan); display: block; margin-bottom: 3px; font-size: 8px; letter-spacing: .08em; }
.empty { color: var(--muted); text-align: center; padding: 54px 12px; font-size: 11px; }
.quick-note { display: grid; grid-template-columns: 1fr 42px; gap: 8px; margin-top: 10px; }
.quick-note button { border: 1px solid var(--line); border-radius: 12px; background: rgba(22,113,162,.28); color: var(--cyan); }
.quality-line { margin: 9px 0 0; color: var(--muted); font-size: 9px; }
.retry-microphone { width: 100%; margin-top: 10px; }

.section-head { padding: 28px 3px 16px; }
.draft-form { display: grid; gap: 13px; }
.crm-preview { display: flex; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(3,13,23,.5); }
.crm-preview > div { display: grid; gap: 3px; }
.crm-preview small { color: var(--muted); }
.history-list { display: grid; gap: 10px; }
.history-card { padding: 15px; display: grid; gap: 9px; }
.history-card header, .history-card footer { display: flex; justify-content: space-between; gap: 10px; }
.history-card p { margin: 0; font-size: 12px; color: #bfd2df; line-height: 1.4; }
.history-card small { color: var(--muted); }
.empty-card { padding: 50px 20px; color: var(--muted); text-align: center; }

.chat-view { min-height: calc(100dvh - 158px); display: flex; flex-direction: column; }
.chat-messages { min-height: 280px; flex: 1; display: flex; flex-direction: column; gap: 10px; overflow: auto; padding: 4px 2px 116px; scrollbar-color: rgba(99,216,255,.35) transparent; }
.chat-message { max-width: 88%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 16px; background: rgba(7,23,39,.9); box-shadow: 0 8px 26px rgba(0,0,0,.15); }
.chat-message.user { align-self: flex-end; border-color: rgba(99,216,255,.28); background: rgba(21,67,96,.72); }
.chat-message.assistant { align-self: flex-start; }
.chat-message.pending { opacity: .7; }
.chat-message strong { display: block; margin-bottom: 5px; color: var(--cyan); font-size: 8px; letter-spacing: .12em; }
.chat-message.user strong { color: #d7f3ff; }
.chat-message p { margin: 0; color: #e2f2fb; font-size: 13px; line-height: 1.48; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message small { display: block; margin-top: 7px; color: var(--muted); font-size: 8px; line-height: 1.35; }
.chat-message img { display: block; max-width: 100%; max-height: 280px; margin-top: 9px; border: 1px solid var(--line); border-radius: 11px; object-fit: contain; background: #02070c; }
.chat-image-preview { position: sticky; bottom: 79px; z-index: 8; display: grid; grid-template-columns: 54px minmax(0,1fr) 32px; align-items: center; gap: 9px; margin: 0 0 8px; padding: 8px; border: 1px solid rgba(99,216,255,.28); border-radius: 14px; background: rgba(8,27,44,.98); box-shadow: 0 12px 35px rgba(0,0,0,.35); }
.chat-image-preview img { width: 54px; height: 54px; border-radius: 9px; object-fit: cover; background: #02070c; }
.chat-image-preview > div { min-width: 0; display: grid; gap: 3px; }
.chat-image-preview strong, .chat-image-preview small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-image-preview strong { font-size: 10px; }
.chat-image-preview small { color: var(--muted); font-size: 8px; }
.chat-image-preview button { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; background: rgba(10,35,56,.9); color: #dff5ff; }
.chat-composer { position: sticky; bottom: 70px; z-index: 7; display: grid; grid-template-columns: 42px minmax(0,1fr) 42px; align-items: end; gap: 7px; padding: 8px; border: 1px solid var(--line); border-radius: 16px; background: rgba(5,18,31,.97); box-shadow: 0 13px 38px rgba(0,0,0,.4); }
.chat-composer textarea { min-height: 42px; max-height: 128px; resize: none; padding: 11px 12px; line-height: 1.35; }
.chat-attach, .chat-send { width: 42px; height: 42px; border: 1px solid rgba(99,216,255,.24); border-radius: 12px; background: rgba(22,113,162,.25); color: var(--cyan); font-size: 20px; }
.chat-send { color: #00131f; border-color: transparent; background: linear-gradient(135deg, #7de4ff, #20a9ed); font-weight: 900; }
.chat-attach:disabled, .chat-send:disabled { cursor: not-allowed; opacity: .4; }
.chat-privacy { margin: 9px 4px 0; color: var(--muted); font-size: 8px; line-height: 1.4; }

.bottom-nav { position: fixed; z-index: 30; left: 50%; bottom: 0; width: min(100%, 680px); transform: translateX(-50%); display: grid; grid-template-columns: repeat(4, 1fr); padding: 7px 10px calc(7px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(4,11,20,.9); backdrop-filter: blur(20px); }
.bottom-nav button { border: 0; border-radius: 12px; color: var(--muted); background: transparent; padding: 7px; display: grid; gap: 3px; place-items: center; font-size: 9px; }
.bottom-nav button span { font-size: 18px; }
.bottom-nav button.active { color: var(--cyan); background: rgba(42,157,211,.12); }

.auth-gate { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; overflow: auto; padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom)); background: radial-gradient(circle at 50% 0, #123451, #040b14 64%); }
.auth-card { width: min(100%, 410px); padding: 28px 22px; border: 1px solid var(--line); border-radius: 26px; background: rgba(7,20,34,.94); box-shadow: var(--shadow); }
.auth-card .brand-mark { margin: 0 auto 18px; }
.auth-card h1 { text-align: center; margin-bottom: 8px; }
.auth-card > .eyebrow, .auth-card > .muted { text-align: center; }
.stack { display: grid; gap: 13px; margin-top: 22px; }
.stack .primary, .stack .secondary { width: 100%; }
.auth-step-copy, .auth-step-hint { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.auth-step-copy { color: #cce5f3; }
.error { min-height: 18px; margin: 0; font-size: 11px; }
.auth-footnote { color: var(--muted); text-align: center; margin: 18px 0 0; font-size: 10px; line-height: 1.5; }
.request-state { margin-top: 16px; padding: 13px; border: 1px solid rgba(247,194,103,.22); border-radius: 14px; display: grid; gap: 8px; color: #f5d497; font-size: 12px; }

.account-dialog { width: min(calc(100% - 32px), 410px); color: var(--text); border: 1px solid var(--line); border-radius: 20px; padding: 22px; background: #081827; box-shadow: var(--shadow); }
.account-dialog::backdrop { background: rgba(0,5,10,.72); backdrop-filter: blur(5px); }
.dialog-close { float: right; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: rgba(12,36,58,.8); color: var(--text); }
.install-hint { margin: 7px 0 2px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: calc(82px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(calc(100% - 30px), 520px); padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; background: rgba(12,36,58,.96); box-shadow: var(--shadow); font-size: 12px; text-align: center; }

@media (max-width: 390px) {
  .connection-strip { grid-template-columns: 1fr; }
  .connection-strip > div { grid-template-columns: auto auto 1fr; }
  .connection-strip small { grid-column: 3; }
  .hero { min-height: 250px; }
  .field-grid { grid-template-columns: 1fr; }
}

@media (display-mode: standalone) {
  .app-shell { min-height: 100dvh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
