*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --coral: #C97272; --coral-dark: #B36262; --coral-light: #FDEAEA;
  --green: #4CAF82; --blue: #5B8EC4; --purple: #9B7EC8; --gold: #D4A853;
  --bg: #F2EDE8; --card: #FFFFFF; --border: #E5DED7;
  --text: #1C1C1E; --muted: #8E8E93; --subtle: #F5F0EB;
  --shadow: 0 1px 8px rgba(0,0,0,.08), 0 2px 16px rgba(0,0,0,.04);
  --r: 20px; --r-sm: 14px; --r-xs: 10px;
  --font: 'DM Sans', sans-serif;
  --font-display: 'Fraunces', serif;
}
/* V474 BUG 88/89/93 (third pass): overscroll-behavior:none kills iOS Safari's
   default horizontal pan past the layout viewport. overflow:hidden alone is
   not enough on iOS Safari when content is touched outside an active scroll
   container — the OS lets you horizontally drag the visual viewport. Setting
   overscroll-behavior:none on html and body (the only two elements that
   directly govern document-level scroll) tells iOS to clamp scroll exactly
   at the layout edges. body also gets right:0;bottom:0 explicitly (was just
   top:0;left:0 — incomplete pin) and `touch-action: pan-y` to permit only
   vertical touch-pan. */
html { height: 100%; overflow: hidden; overflow-x: hidden; background: #F0EBE3; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overscroll-behavior: none; overscroll-behavior-x: none; }
body { height: 100%; overflow: hidden; overflow-x: hidden; background: #F0EBE3; position: fixed; width: 100%; max-width: 100vw; top: 0; left: 0; right: 0; bottom: 0; font-family: var(--font); color: var(--text); -webkit-font-smoothing: antialiased; font-size: 15px; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overscroll-behavior: none; overscroll-behavior-x: none; touch-action: pan-y; }
.tab-panel { background: #F0EBE3; }
#tab-network { background: #F0EBE3; }

/* ── Auth ── */
#auth-screen { position: fixed; inset: 0; background: var(--bg); display: flex; justify-content: center; align-items: center; z-index: 100; padding: 24px; }
.auth-card { background: white; border-radius: 28px; padding: 40px 32px; width: 100%; max-width: 380px; box-shadow: 0 12px 48px rgba(0,0,0,.12); }
.auth-logo { width: 52px; height: 52px; background: var(--coral); border-radius: 14px; display: flex; align-items: center; justify-content: center; margin: 0 auto 18px; }
.auth-logo svg { width: 28px; height: 28px; fill: white; }
.auth-card h1 { text-align: center; font-size: 24px; font-weight: 700; font-family: var(--font-display); margin-bottom: 4px; letter-spacing: -.3px; }
.auth-card > p { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 28px; }
.auth-tabs { display: flex; background: var(--subtle); border-radius: 12px; padding: 3px; margin-bottom: 20px; }
.auth-tab { flex: 1; padding: 8px; text-align: center; font-size: 14px; font-weight: 600; border-radius: 10px; cursor: pointer; color: var(--muted); transition: all .18s; }
.auth-tab.active { background: white; color: var(--text); box-shadow: 0 1px 6px rgba(0,0,0,.1); }
.auth-form input { width: 100%; padding: 13px 16px; border: 1.5px solid var(--border); border-radius: 12px; font-size: 15px; font-family: var(--font); outline: none; margin-bottom: 10px; color: var(--text); background: white; transition: border-color .15s; }
.auth-form input:focus { border-color: var(--coral); }
.auth-form input::placeholder { color: #C0B8B0; }
.btn { display: block; width: 100%; padding: 14px; background: var(--coral); color: white; border: none; border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer; transition: background .15s; font-family: var(--font); }
.btn:hover { background: var(--coral-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.auth-error { color: #D4574E; font-size: 13px; text-align: center; margin-top: 8px; min-height: 18px; }

/* ── App ── */
#app { display: none; height: 100vh; height: 100dvh; flex-direction: column; overflow: hidden; }
#app.visible { display: flex; }

/* ── Tab Bar — SVG icons, no emoji ── */
.tab-bar { display: flex; background: rgba(255,255,255,.96); border-top: 1px solid var(--border); padding: 8px 0 max(10px, env(safe-area-inset-bottom)); flex-shrink: 0; backdrop-filter: blur(20px); }
.tab-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: none; cursor: pointer; font-family: var(--font); padding: 2px 0; }
.tab-icon-wrap { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 8px; transition: background .15s; }
.tab-btn.active .tab-icon-wrap { background: var(--coral-light); }
.tab-icon-wrap svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: stroke .15s; }
.tab-btn.active .tab-icon-wrap svg { stroke: var(--coral); }
.tab-label { font-size: 10px; font-weight: 600; color: var(--muted); letter-spacing: .2px; transition: color .15s; }
.tab-btn.active .tab-label { color: var(--coral); }

/* ── Panels ── */
.tab-panel { display: none; flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; flex-direction: column; }
.tab-panel.active { display: flex; }
#tab-chat { overflow: hidden; }
#tab-dashboard { padding-top: calc(60px + env(safe-area-inset-top)); }
#tab-network { padding-top: calc(60px + env(safe-area-inset-top)); }
.scroll-area { flex: 1; overflow-y: auto; padding: 16px; padding-bottom: 28px; }

/* ── Chat header ── */
.chat-header { background: rgba(240,235,227,.96); padding: env(safe-area-inset-top) 16px 12px; box-shadow: 0 2px 10px rgba(0,0,0,.09); flex-shrink: 0; backdrop-filter: blur(20px); }
.chat-header-row { display: flex; align-items: center; gap: 10px; height: 60px; }
.ralli-wordmark { font-family: var(--font-display); font-weight: 700; font-size: 26px; color: #1A1218; letter-spacing: -.3px; line-height: 1; }
/* ── Carousel collapse ── */
.carousel-header { display:flex; align-items:center; gap:6px; padding:10px 44px 0 0; cursor:pointer; user-select:none; -webkit-user-select:none; }
.carousel-header-label { font-size:15px; font-weight:600; font-family:var(--font-display); color:#1A1218; letter-spacing:-0.2px; }
.carousel-count-badge { background:#E8E4DF; color:#6B6572; font-size:11px; font-weight:700; padding:2px 7px; border-radius:10px; }
.carousel-toggle-text { font-size:14px; color:#B0AAB8; line-height:1; }
.carousel-body { overflow:hidden; max-height:200px; transition:max-height .25s ease; }
.carousel-body.collapsed { max-height:0; }

/* ── Messages ── */
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px 0; display: flex; flex-direction: column; overscroll-behavior-y: contain; }
.msg { display: flex; flex-direction: column; margin-bottom: 8px; }
.msg.user { align-items: flex-end; }
.msg.assistant { align-items: flex-start; }
.msg-bubble { padding: 11px 15px; border-radius: 20px; font-size: 15px; line-height: 1.5; max-width: 82%; word-wrap: break-word; }
.msg.user .msg-bubble { background: var(--coral); color: white; border-bottom-right-radius: 4px; }
.msg.assistant .msg-bubble { background: white; color: var(--text); border-bottom-left-radius: 4px; box-shadow: 0 1px 6px rgba(0,0,0,.08); }
.msg-time { font-size: 11px; color: var(--muted); margin-top: 3px; padding: 0 4px; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(201,114,114,.25); }
  50% { box-shadow: 0 0 0 8px rgba(201,114,114,.1); }
}
@keyframes msgIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes ralliSlideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.msg { }
.msg-anim { animation: ralliSlideIn .25s ease-out both; }
@keyframes helperSlideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
/* V465 BUG 93: word-break + max-width so a long word in a message bubble
   or a long URL in a request card cannot push the row wider than the
   scroll container, which would otherwise allow horizontal scroll inside
   #helper-messages-tab even though the document body has overflow:hidden. */
.helper-feed-item { animation: helperSlideIn .2s ease-out both; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; max-width: 100%; box-sizing: border-box; word-break: break-word; overflow-wrap: anywhere; }
#helper-app-container, #helper-messages-tab, #helper-tasks-tab { overflow-x: hidden; }
.action-badge { display: inline-flex; align-items: center; gap: 6px; background: #EEF7F2; color: var(--green); font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 12px; margin-top: 5px; }

/* ── Quick chips ── */
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; padding: 6px 14px 10px; }
.chip { background: white; border: 1.5px solid var(--border); border-radius: 18px; padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; transition: all .15s; font-family: var(--font); white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.chip:hover { border-color: var(--coral); color: var(--coral); background: var(--coral-light); }
.chip:active { opacity: 0.75; }
.chip.primary { background: var(--coral); border-color: var(--coral); color: white; }

/* ── Input ── */
.chat-input-wrap { background: white; border-top: none; padding: 8px 12px 8px; display: none; flex-shrink: 0; gap: 8px; align-items: center; }
.chat-input-wrap.visible { display: flex; }
.chat-input-wrap textarea { flex: 1; border: 1.5px solid var(--border); border-radius: 20px; padding: 9px 15px; font-size: 15px; font-family: var(--font); resize: none; outline: none; max-height: 120px; line-height: 1.45; color: var(--text); background: var(--subtle); transition: border-color .15s, background .15s; }
.chat-input-wrap textarea:focus { border-color: var(--coral); background: white; }
.send-btn { width: 36px; height: 36px; background: var(--coral); border: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: all .15s; }
.send-btn:hover { background: var(--coral-dark); }
.send-btn:active { opacity: 0.75; }
.send-btn:disabled { opacity: .4; }
.send-btn svg { width: 15px; height: 15px; fill: white; margin-left: 2px; }

/* ── Typing ── */
.typing-wrap { display: flex; margin-bottom: 8px; animation: msgIn .2s ease; }
.typing-bubble { background: white; padding: 13px 16px; border-radius: 20px; border-bottom-left-radius: 4px; box-shadow: 0 1px 6px rgba(0,0,0,.08); display: flex; gap: 5px; align-items: center; }
.typing-dot { width: 7px; height: 7px; background: #C5BDB5; border-radius: 50%; animation: tdot 1.4s infinite; }
.typing-dot:nth-child(2) { animation-delay: .18s; }
.typing-dot:nth-child(3) { animation-delay: .36s; }
@keyframes tdot { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }
.ralli-thinking-dot { width:8px; height:8px; border-radius:50%; background:var(--coral); display:inline-block; animation:ralliPulse 1.2s ease-in-out infinite; flex-shrink:0; }
@keyframes ralliPulse { 0%,100% { opacity:0.3; transform:scale(0.9); } 50% { opacity:1.0; transform:scale(1.1); } }

/* ── Wizard ── */
.wizard-bubble { background: white; border-radius: 20px; box-shadow: 0 1px 6px rgba(0,0,0,.08); overflow: hidden; touch-action: manipulation; overscroll-behavior-y: contain; display: flex; flex-direction: column; }
.wizard-content { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; }
.wizard-header { padding: 16px 20px 12px; font-family: var(--font-display); font-weight: 600; font-size: 20px; color: #1A1218; letter-spacing: -0.3px; }
.wizard-choices { padding: 6px 20px; display: flex; flex-direction: column; gap: 4px; }
.wizard-choice { touch-action: manipulation; -webkit-tap-highlight-color: transparent; padding: 11px 12px; background: var(--subtle); border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: all .15s; border: 1.5px solid transparent; color: var(--text); }
.wizard-lbl { font-size: 12px; font-weight: 600; color: #9A94A6; text-transform: uppercase; letter-spacing: .6px; display: block; margin-bottom: 6px; }
@media (hover: hover) { .wizard-choice:hover { background: var(--coral-light); border-color: var(--coral); color: var(--coral-dark); } }
.wizard-choice:active { opacity: 0.75; }
.wizard-scale { padding: 12px 16px 6px; }
.wizard-scale-label { font-size: 11px; font-weight: 700; color: #9A94A6; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .7px; }
.scale-btns { display: flex; gap: 3px; }
.scale-btn { flex: 1; height: 34px; border-radius: 7px; background: var(--subtle); border: 1.5px solid transparent; font-size: 13px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; font-family: var(--font); transition: all .12s; }
/* V461 BUG 78: selected state colors are set inline per-button by the
   wizard from a unified polarity-aware function. The hardcoded
   data-val→color rules used to paint the SAME background for any
   dimension regardless of polarity, so a Mobility=3 selection rendered
   green when it should be red. The unified function in wizard.js now
   computes the correct background and writes it as inline style on
   click, so no CSS per-value rules are needed. */
.scale-btn.selected { color: white !important; border-color: transparent; }
.wizard-input { padding: 4px 20px; }
.wizard-input input, .wizard-input textarea { width: 100%; border: 1.5px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 14px; font-family: var(--font); resize: none; outline: none; line-height: 1.4; color: var(--text); box-sizing: border-box; }
.wizard-input input:focus, .wizard-input textarea:focus { border-color: var(--coral); }
.wizard-confirm { padding: 8px 16px 10px; }
.confirm-card { background: var(--subtle); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: 13px; line-height: 1.7; }
.confirm-card strong { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-top: 6px; }
.confirm-card strong:first-child { margin-top: 0; }
.wizard-actions { display: flex; gap: 6px; }
.wiz-btn { flex: 1; padding: 11px; border: none; border-radius: 10px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: var(--font); transition: all .15s; }
.wiz-btn.confirm { background: var(--coral); color: white; }
.wiz-btn.confirm:hover { background: var(--coral-dark); }
.wiz-btn.cancel { background: var(--subtle); color: var(--muted); }

/* ── Dashboard ── */
.section-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin: 4px 0 10px; }
.vitality-card { background: white; border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); margin-bottom: 12px; display: flex; align-items: center; gap: 16px; }
.ring-wrap { position: relative; width: 82px; height: 82px; flex-shrink: 0; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--subtle); stroke-width: 7; }
.ring-fill { fill: none; stroke-width: 7; stroke-linecap: round; transition: stroke-dasharray .9s cubic-bezier(.4,0,.2,1); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-score { font-size: 22px; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.ring-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.vitality-info { flex: 1; min-width: 0; }
.vitality-title { font-size: 15px; font-weight: 800; margin-bottom: 3px; }
.vitality-summary { font-size: 13px; color: var(--muted); margin-bottom: 9px; line-height: 1.4; }
.breakdown-bars { display: flex; flex-direction: column; gap: 6px; }
.breakdown-row { display: flex; align-items: center; gap: 8px; }
/* V446: widened label column + word-break so longer dimension names like
   "Sleep quality" / "Mental clarity" wrap cleanly instead of overlapping
   the bar. line-height tightened so two-line wraps stay compact. */
.breakdown-label { font-size: 10px; font-weight: 700; color: var(--muted); width: 84px; text-transform: uppercase; flex-shrink: 0; line-height: 1.25; word-break: break-word; }
.breakdown-bar-wrap { flex: 1; height: 5px; background: var(--subtle); border-radius: 3px; overflow: hidden; min-width: 0; }
.breakdown-bar { height: 100%; border-radius: 3px; background: var(--coral); transition: width .8s cubic-bezier(.4,0,.2,1); }
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.chart-card { background: white; border-radius: var(--r-sm); padding: 14px; box-shadow: var(--shadow); }
.chart-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 4px; }
.chart-value { font-size: 22px; font-weight: 800; line-height: 1.1; margin-bottom: 8px; letter-spacing: -.5px; }
.chart-svg { width: 100%; height: 44px; overflow: visible; }
.procedure-card { background: white; border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; display: flex; gap: 14px; align-items: center; }
.countdown-circle { width: 56px; height: 56px; border-radius: 50%; background: var(--coral-light); display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; }
.countdown-num { font-size: 19px; font-weight: 900; color: var(--coral-dark); line-height: 1; }
.countdown-unit { font-size: 9px; font-weight: 700; text-transform: uppercase; color: var(--coral); }
.procedure-name { font-size: 15px; font-weight: 800; margin-bottom: 2px; }
.procedure-date { font-size: 13px; color: var(--muted); }
.procedure-phase { font-size: 12px; color: var(--coral); font-weight: 600; margin-top: 3px; }
.weather-card { background: white; border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.weather-temp { font-size: 34px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.weather-desc { font-size: 13px; color: var(--muted); margin-top: 3px; text-transform: capitalize; }
.weather-details { text-align: right; font-size: 12px; color: var(--muted); line-height: 1.9; }
.checkin-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.checkin-item { background: white; border-radius: var(--r-sm); padding: 12px 14px; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: space-between; }
.checkin-date { font-size: 12px; color: var(--muted); font-weight: 600; }
.checkin-scores { display: flex; gap: 14px; }
.score-pill { display: flex; flex-direction: column; align-items: center; }
.score-val { font-size: 16px; font-weight: 800; line-height: 1; }
.score-lbl { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); margin-top: 2px; }

/* ── Profile ── */
.profile-section { background: white; border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); margin-bottom: 12px; }
.profile-section h3 { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.field-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field-row label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.field-row input, .field-row textarea, .field-row select { border: 1.5px solid var(--border); border-radius: 12px; padding: 10px 12px; font-size: 14px; font-family: var(--font); color: var(--text); outline: none; background: white; width: 100%; transition: border-color .15s; }
.field-row input:focus, .field-row textarea:focus, .field-row select:focus { border-color: var(--coral); }
.field-row textarea { resize: vertical; min-height: 70px; }
.save-btn { background: var(--coral); color: white; border: none; border-radius: 12px; padding: 11px 22px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: var(--font); transition: all .15s; }
.save-btn:hover { background: var(--coral-dark); }
.save-btn.saved { background: var(--green); }
.helper-list { display: flex; flex-direction: column; gap: 8px; }
.helper-item { background: var(--subtle); border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.helper-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--coral); display: flex; align-items: center; justify-content: center; color: white; font-weight: 800; font-size: 15px; flex-shrink: 0; }
.helper-name { font-size: 15px; font-weight: 700; }
.helper-role { font-size: 12px; color: var(--muted); margin-top: 1px; }
.helper-badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 10px; background: var(--coral-light); color: var(--coral-dark); }
.add-helper-btn { background: var(--subtle); border: 1.5px dashed var(--border); border-radius: 12px; padding: 12px; text-align: center; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; width: 100%; font-family: var(--font); margin-top: 8px; transition: all .15s; }
.add-helper-btn:hover { border-color: var(--coral); color: var(--coral); }
.connection-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.connection-item { background: var(--subtle); border-radius: 12px; padding: 12px; display: flex; align-items: center; gap: 10px; }
.conn-icon { width: 30px; height: 30px; border-radius: 8px; background: white; display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.conn-icon svg { width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.conn-name { font-size: 13px; font-weight: 700; }
.conn-status { font-size: 11px; color: var(--muted); margin-top: 1px; }
.conn-status.ok { color: var(--green); }
.conn-btn { font-size: 11px; font-weight: 700; color: var(--coral); background: white; border: 1.5px solid var(--border); border-radius: 8px; padding: 4px 8px; cursor: pointer; font-family: var(--font); }
.signout-btn { background: transparent; border: 1.5px solid var(--border); color: var(--muted); border-radius: 12px; padding: 11px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: var(--font); width: 100%; margin-top: 10px; transition: all .15s; }
.signout-btn:hover { border-color: #D4574E; color: #D4574E; }

/* ── Utils ── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state p { font-size: 14px; line-height: 1.6; }
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--text); color: white; font-size: 14px; font-weight: 600; padding: 10px 20px; border-radius: 20px; z-index: 999; opacity: 0; transition: opacity .2s; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; }

/* ── Suggestion chips (inside message thread) ── */
.msg-suggestions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; max-width: 82%; }
.suggestion-chip { background: var(--coral); border: none; border-radius: 18px; padding: 9px 16px; font-size: 13px; font-weight: 600; color: white; cursor: pointer; font-family: var(--font); white-space: nowrap; transition: background .15s; box-shadow: 0 2px 8px rgba(201,114,114,.3); touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; }
.suggestion-chip:hover { background: var(--coral-dark); }
.suggestion-chip:active { opacity: 0.75; }
.suggestion-chip:not(:active) { opacity: 1; }
.ghost-protected { pointer-events: none !important; }
.ghost-protected * { pointer-events: none !important; }
button { touch-action: manipulation; }
.check-row { touch-action: manipulation; }
input[type="radio"] { touch-action: manipulation; }
input[type="checkbox"] { touch-action: manipulation; }
@keyframes chipFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.suggestion-chip { animation: chipFadeIn 0.15s ease-out both; }
.suggestion-chip:visited { background: var(--coral); }
/* V461 BUG 71+79+84: unified nudge chip style. Every chip rendered inside
   a proactive nudge bubble (.msg-suggestions inside .msg-bubble) shares
   ONE class — `.nudge-chip` — with consistent border-radius (13px,
   matching the soft rounded-rectangle of the message bubble itself —
   not a pill, not a tight square corner), white fill, coral outline,
   coral text. Applied universally across medication, daily routines,
   check-in, appointment, and every other nudge type. The legacy
   `.msg-suggestions .suggestion-chip` and `.msg-bubble .suggestion-chip`
   selectors remain for backward compat (they target the same elements)
   but the canonical class is `.nudge-chip`. */
.nudge-chip,
.msg-suggestions .suggestion-chip,
.msg-bubble .suggestion-chip {
  background: white !important;
  color: var(--coral) !important;
  border: 1.5px solid var(--coral) !important;
  border-radius: 13px !important;
  box-shadow: none !important;
  padding: 9px 14px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  font-family: var(--font) !important;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.nudge-chip:hover,
.msg-suggestions .suggestion-chip:hover,
.msg-bubble .suggestion-chip:hover { background: rgba(201,114,114,.08) !important; }
.nudge-chip:active,
.msg-suggestions .suggestion-chip:active,
.msg-bubble .suggestion-chip:active { opacity: 0.75; }
.msg-suggestions .reply-chip { background: white !important; color: var(--coral) !important; border: 1.5px solid var(--coral) !important; border-radius: 13px !important; }
.msg-suggestions .reply-chip:hover { background: rgba(201,114,114,.08) !important; }
/* Subtitle chips: two-line label/subtitle stacked. Same border-radius,
   relaxed white-space so the pair wraps cleanly. */
.nudge-chip.has-subtitle,
.suggestion-chip.has-subtitle { white-space: normal !important; line-height: 1.2 !important; padding: 8px 14px !important; text-align: left; }
.nudge-chip .chip-subtitle,
.suggestion-chip .chip-subtitle { display: block; font-size: 11px; font-weight: 500; opacity: 0.75; margin-top: 2px; }

/* ── Activity carousel ── */
.carousel-strip { display:flex; overflow-x:auto; scrollbar-width:none; padding:3px 0 4px; padding-left:20px; }
.carousel-strip::-webkit-scrollbar { display:none; }
@keyframes carouselDrift { 0%,100% { transform:translateX(0); } 50% { transform:translateX(-168px); } }
.carousel-strip.drifting { animation:carouselDrift 20s linear infinite; }
.carousel-strip.drifting:hover, .carousel-strip.drifting.paused { animation-play-state:paused; }
.activity-chip { background:white; border:1.5px solid #E8E4DF; border-radius:14px; padding:9px 12px; min-width:136px; max-width:150px; box-shadow:0 1px 4px rgba(0,0,0,.05); flex-shrink:0; cursor:pointer; transition:border-color .15s; }
.activity-chip:active { opacity:.85; }
.chip-connector { width:14px; flex-shrink:0; display:flex; align-items:center; }
.chip-connector::after { content:''; width:100%; height:1.5px; background:#E8E4DF; display:block; }
.activity-status-pill { display:inline-flex; font-size:9px; font-weight:700; padding:2px 7px; border-radius:20px; text-transform:uppercase; letter-spacing:.4px; margin-top:5px; }
.activity-modal-backdrop { position:fixed; inset:0; background:rgba(26,26,46,.35); backdrop-filter:blur(2px); z-index:300; display:flex; align-items:flex-end; justify-content:center; }
.activity-modal-card { background:white; border-radius:24px 24px 0 0; width:100%; max-width:480px; animation:sheetUp .22s ease-out both; }
@keyframes sheetUp { from { transform:translateY(100%); } to { transform:translateY(0); } }

/* ── Request carousel (inside header) ── */
.req-carousel-wrap { overflow-x:auto; scrollbar-width:none; -webkit-overflow-scrolling:touch; padding:14px 14px 4px 0; }
.req-carousel-wrap::-webkit-scrollbar { display:none; }
.req-chip-row { display:flex; gap:8px; width:max-content; }
.req-chip { flex-shrink:0; background:white; border-radius:12px; border:1.5px solid #E8E4DF; padding:8px 13px; min-width:130px; max-width:175px; cursor:pointer; transition:border-color .15s, box-shadow .15s; box-shadow:0 1px 4px rgba(0,0,0,.05); }
.req-chip:active { opacity:.82; }
.req-chip.open { border-color:var(--coral); box-shadow:0 2px 8px rgba(0,0,0,.1); }
.req-chip.ralli-flash { animation:ralliFlash 1.6s ease-out both; }

/* V418: Ralli Actions toggle (iOS-style) — used in profile settings + onboarding sheet. */
.ralli-action-card { background:#fff; border:1px solid var(--border); border-radius:12px; padding:12px 14px; margin-bottom:8px; display:flex; align-items:center; gap:12px; }
.ralli-action-card .ra-text { flex:1; min-width:0; }
.ralli-action-card .ra-title { font-family:'DM Sans',sans-serif; font-size:13px; font-weight:600; color:#1A1218; }
.ralli-action-card .ra-desc { font-family:'DM Sans',sans-serif; font-size:12px; font-weight:300; color:#6B6572; line-height:1.5; margin-top:2px; }
.ralli-toggle { width:46px; height:28px; background:var(--border); border-radius:14px; position:relative; cursor:pointer; flex-shrink:0; transition:background .18s; -webkit-tap-highlight-color:transparent; }
.ralli-toggle.on { background:var(--coral); }
.ralli-toggle::after { content:''; position:absolute; top:3px; left:3px; width:22px; height:22px; background:white; border-radius:50%; box-shadow:0 2px 4px rgba(0,0,0,.18); transition:transform .18s; }
.ralli-toggle.on::after { transform:translateX(18px); }
@keyframes ralliFlash {
  0%   { box-shadow:0 1px 4px rgba(0,0,0,.05), 0 0 0 0 rgba(201,114,114,0); border-color:#E8E4DF; }
  20%  { box-shadow:0 0 0 4px rgba(201,114,114,.18), 0 4px 14px rgba(201,114,114,.35); border-color:var(--coral); }
  60%  { box-shadow:0 0 0 8px rgba(201,114,114,.06), 0 4px 14px rgba(201,114,114,.12); border-color:var(--coral); }
  100% { box-shadow:0 1px 4px rgba(0,0,0,.05), 0 0 0 0 rgba(201,114,114,0); border-color:#E8E4DF; }
}
.req-dot { width:7px; height:7px; border-radius:50%; flex-shrink:0; }
.req-inline-detail { background:white; border-radius:12px; border:1.5px solid #E8E4DF; padding:12px 14px; margin-top:8px; animation:expansionIn .16s ease both; box-shadow:0 2px 8px rgba(0,0,0,.06); }
.req-detail-row { display:flex; align-items:center; gap:10px; padding:6px 0; border-bottom:1px solid #F0EDE9; }
.req-detail-row:last-of-type { border-bottom:none; }
.req-detail-label { font-size:10px; font-weight:700; color:#B0AAB8; text-transform:uppercase; letter-spacing:.5px; min-width:64px; flex-shrink:0; }
.req-detail-btns { display:flex; gap:7px; margin-top:10px; }
.req-detail-btn-cancel { flex:1; padding:9px; border:1.5px solid #E8E4DF; border-radius:10px; background:white; font-size:12px; font-weight:700; font-family:var(--font); color:#6B6572; cursor:pointer; }
.req-detail-btn-save { flex:2; padding:9px; border:none; border-radius:10px; background:var(--coral); color:white; font-size:12px; font-weight:700; font-family:var(--font); cursor:pointer; }

/* ── Primary chip bar ── */
#chip-expansion-container { flex-shrink:0; padding:0 12px; background:white; }
#primary-chip-bar { display:flex; gap:8px; padding:8px 14px 0; background:white; border-top:1px solid #E8E4DF; flex-shrink:0; }
.primary-chip { flex:1; border-radius:12px; padding:10px 10px; display:flex; flex-direction:row; align-items:center; justify-content:center; gap:7px; cursor:pointer; transition:all .15s; font-family:var(--font); border:none; }
.primary-chip svg { width:17px; height:17px; fill:none; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; transition:stroke .15s; flex-shrink:0; }
.primary-chip span { font-size:13px; font-weight:700; white-space:nowrap; }
#pchip-myday { background:transparent; border:1.5px solid #D4CEC8; color:#6B6572; }
#pchip-myday svg { stroke:#6B6572; }
#pchip-help { background:var(--coral); color:white; }
#pchip-help svg { stroke:white; }
#pchip-log { background:transparent; border:1.5px solid #D4CEC8; color:#6B6572; }
#pchip-log svg { stroke:#6B6572; }
.primary-chip.active-coral { background:var(--coral) !important; }
.primary-chip.active-green { background:#EEF8F3 !important; border:1.5px solid #4CAF82 !important; color:#2D8A5E !important; }
.primary-chip.active-green svg { stroke:#2D8A5E !important; }
.chip-expansion-bubble { background:white; border:1.5px solid #E8E4DF; border-radius:16px; padding:12px 16px; box-shadow:0 3px 14px rgba(0,0,0,.09); margin-bottom:6px; animation:expansionIn .16s ease both; }
@keyframes expansionIn { from { opacity:0; transform:translateY(3px); } to { opacity:1; transform:translateY(0); } }
.expansion-label { font-size:17px; font-weight:600; color:#1A1218; letter-spacing:-0.2px; margin-bottom:10px; font-family:var(--font-display); }
.sub-chip-grid { display:grid; grid-template-columns:1fr 1fr; gap:7px; }
.sub-chip { background:#F5F3F0; border:1.5px solid #E8E4DF; border-radius:12px; padding:11px 12px; font-size:13px; font-weight:600; color:#1A1A2E; display:flex; align-items:center; gap:8px; cursor:pointer; transition:all .15s; font-family:var(--font); }
.sub-chip:active { opacity:.8; }
.sub-chip svg { opacity:.4; flex-shrink:0; width:16px; height:16px; fill:none; stroke:#1A1A2E; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.sub-chip.full-width { grid-column:1 / -1; }
.sub-chip.green-variant { background:#EEF8F3; border-color:#B8DFD0; color:#2D8A5E; }
.sub-chip.green-variant svg { opacity:.65; stroke:#2D8A5E; }

/* ── Mic button ── */
.mic-btn { width:44px; height:44px; border-radius:9px; border:1.5px solid #D8D4CE; background:transparent; display:flex; align-items:center; justify-content:center; cursor:pointer; flex-shrink:0; transition:border-color .15s, opacity .15s; }
.mic-btn:active { opacity:.7; }
.mic-btn.recording { border-color:var(--coral); animation:micPulse 1s ease-in-out infinite; }
.mic-btn.mic-armed { border-color:var(--coral); animation:none; }
.chat-input-wrap textarea.compose-armed { border-color:var(--coral); background:white; }
@keyframes micPulse { 0%,100% { transform:scale(1); } 50% { transform:scale(1.08); } }

/* ── Confirmation card ── */
.conf-card { background:white; border:1.5px solid #E8E4DF; border-radius:16px; margin:6px 0 10px; overflow:hidden; box-shadow:0 2px 10px rgba(0,0,0,.07); animation:ralliSlideIn .25s ease-out both; flex-shrink:0; }

/* ── Profile hero ── */
.profile-hero { display: flex; flex-direction: column; align-items: center; padding: 28px 20px 20px; }
.profile-photo-wrap { position: relative; cursor: pointer; margin-bottom: 12px; }
.profile-photo { width: 88px; height: 88px; border-radius: 50%; background: var(--coral); display: flex; align-items: center; justify-content: center; overflow: hidden; box-shadow: 0 4px 16px rgba(201,114,114,.3); }
.profile-photo img { width: 100%; height: 100%; object-fit: cover; }
.profile-photo svg { width: 44px; height: 44px; }
.photo-edit-badge { position: absolute; bottom: 2px; right: 2px; width: 24px; height: 24px; background: var(--text); border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg); }
.profile-hero-name { font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.profile-hero-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* ── Profile view mode ── */
.view-field { padding: 10px 0; border-bottom: 1px solid var(--border); }
.view-field:last-child { border-bottom: none; }
.view-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-bottom: 3px; }
.view-val { font-size: 15px; color: var(--text); }
.view-empty { font-size: 13px; color: var(--muted); padding: 8px 0; }

.edit-profile-btn { margin-top: 12px; background: var(--coral); color: white; border: none; border-radius: 20px; padding: 9px 24px; font-size: 14px; font-weight: 700; cursor: pointer; letter-spacing: .2px; }
.edit-profile-btn:active { opacity: .85; }

/* ── Wizard task row ── */
.task-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; align-items: flex-start; }
.task-row:last-child { border-bottom: none; }
.task-row input[type=checkbox] { margin-top: 2px; flex-shrink: 0; }

/* ── My day rows ── */
.myday-row { display: flex; gap: 10px; align-items: center; padding: 8px 14px; font-size: 14px; color: var(--text); }
.coral-row { color: var(--coral); font-weight: 600; }

/* ── Confirm card ── */
.confirm-card { margin: 0 14px 10px; border-radius: 12px; background: var(--bg); overflow: hidden; }
.confirm-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.confirm-row:last-child { border-bottom: none; }
.confirm-key { font-weight: 700; min-width: 80px; color: var(--muted); }

/* ── Wizard choice disabled ── */
.wizard-choice.disabled { opacity: .4; pointer-events: none; }

/* ── Photo edit visible in edit mode ── */
.profile-photo-wrap.editable { cursor: pointer; }

/* ── Photo crop modal ── */
.crop-modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 300; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; }
.crop-modal h3 { color: white; font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: -0.3px; margin-bottom: 16px; }
.crop-container { position: relative; width: min(320px, 90vw); height: min(320px, 90vw); border-radius: 50%; overflow: hidden; background: #000; cursor: grab; touch-action: none; }
.crop-container:active { cursor: grabbing; }
.crop-img { position: absolute; transform-origin: center center; user-select: none; pointer-events: none; }
.crop-ring { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 9999px rgba(0,0,0,.55); pointer-events: none; z-index: 2; }
.crop-actions { display: flex; gap: 12px; margin-top: 20px; }
.crop-btn { padding: 11px 28px; border-radius: 20px; border: none; font-size: 15px; font-weight: 700; cursor: pointer; }
.crop-btn.cancel { background: rgba(255,255,255,.15); color: white; }
.crop-btn.confirm { background: var(--coral); color: white; }
.crop-zoom { margin-top: 14px; width: min(280px, 80vw); accent-color: var(--coral); }

/* ── Dashboard animations ── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.dash-anim { animation: fadeUp .4s ease both; }
@keyframes ringGrow { from { stroke-dasharray: 0 220; } }
.ring-fill { animation: ringGrow .8s cubic-bezier(.4,0,.2,1) both; }
@keyframes barGrow { from { width: 0 !important; } }
.breakdown-bar { animation: barGrow .6s cubic-bezier(.4,0,.2,1) both; }
@keyframes lineIn { from { stroke-dashoffset: 1000; } to { stroke-dashoffset: 0; } }
.chart-line { stroke-dasharray: 1000; animation: lineIn .8s ease both; }

body, * { font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif; }

/* ── Boot greeting ── */
.boot-greeting { display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; padding:60px 24px 40px; flex:1; min-height:280px; }
.boot-greeting-h2 { font-family:var(--font-display); font-size:24px; font-weight:600; color:#1A1218; margin-bottom:6px; }
.boot-greeting-sub { font-size:14px; color:#9A94A6; font-weight:400; max-width:240px; line-height:1.5; }

/* ── Milestone select ── */
.milestone-row select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  background: white;
  outline: none;
}
.milestone-row select:focus { border-color: var(--coral); }

/* ── Places search results ── */
.place-result {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.place-result:last-child { border-bottom: none; }
.place-result:hover, .place-result:active { background: var(--subtle); }

/* Ralli Plan slot edit — place results container: invisible when empty, styled only when populated */
.rp-places-results:not(:empty) {
  background: white;
  border: 1px solid #E8E4DF;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
  overflow: hidden;
}

/* ── Availability chips ── */
.avail-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--subtle);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  user-select: none;
}
.avail-chip input[type="checkbox"] { accent-color: var(--coral); }
.avail-chip:has(input:checked) {
  background: var(--coral-light, #fde8e8);
  color: var(--coral);
  font-weight: 700;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
