:root {
  --bg: #0b0710;
  --panel: #130c18;
  --card: #1b1121;
  --text: #f8eff6;
  --muted: #a895a3;
  --faint: #756372;
  --pink: #e84d8a;
  --pink-deep: #aa3569;
  --purple: #743e95;
  --border: rgba(255,255,255,.09);
  --danger: #f06c82;
  --success: #5ee09a;
  --radius: 18px;
  font-family: "Avenir Next", "Segoe UI", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; background: var(--bg); }
body { min-height: 100dvh; color: var(--text); overflow: hidden; }
button, input, textarea { font: inherit; }
button { color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.hidden, .visually-hidden { display: none !important; }
.mobile-only { display: none !important; }

.companion-shell {
  position: relative;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: radial-gradient(circle at 84% -15%, rgba(168,54,113,.23), transparent 38%), linear-gradient(145deg, #0b0710 0%, #110a16 50%, #0b0710 100%);
}
.ambient { position: absolute; border-radius: 999px; filter: blur(90px); pointer-events: none; opacity: .18; }
.ambient-one { width: 380px; height: 380px; right: 10%; top: -230px; background: #ff5f9e; }
.ambient-two { width: 320px; height: 320px; left: 20%; bottom: -240px; background: #8146b7; }

.companion-sidebar {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: max(24px, env(safe-area-inset-top)) 24px max(20px, env(safe-area-inset-bottom));
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(24,15,30,.98), rgba(13,8,17,.99));
  box-shadow: 18px 0 50px rgba(0,0,0,.22);
  overflow: hidden;
}
.sidebar-topline, .section-heading, .identity-card, .mode-row, .privacy-note, .chat-header, .header-actions, .composer, .pending-image, .modal-actions, .avatar-actions, .connection-pill, .settings-status, .eyebrow { display: flex; align-items: center; }
.sidebar-topline { gap: 10px; color: #f6e9f1; font-size: .88rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid rgba(255,134,182,.24); border-radius: 11px; color: #ff86b6; background: linear-gradient(145deg, rgba(232,77,138,.23), rgba(130,61,164,.2)); }
.brand-mark svg { width: 16px; fill: currentColor; }
.identity-card { gap: 14px; margin-top: 30px; }
.avatar { position: relative; display: grid; place-items: center; flex: none; overflow: hidden; color: white; background: linear-gradient(145deg, #c23773, #703d95); box-shadow: inset 0 1px rgba(255,255,255,.25), 0 10px 28px rgba(184,44,109,.24); }
.avatar::before { content: ""; position: absolute; inset: 3px; z-index: 1; border: 1px solid rgba(255,255,255,.2); border-radius: inherit; pointer-events: none; }
.avatar span { position: relative; font: italic 1em Georgia, serif; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar i { position: absolute; z-index: 2; right: 1px; bottom: 2px; width: 12px; height: 12px; border: 3px solid #17101d; border-radius: 50%; background: var(--success); }
.avatar-large { width: 68px; height: 68px; border-radius: 23px; font-size: 1.85rem; }
.avatar-small { width: 44px; height: 44px; border-radius: 15px; font-size: 1.15rem; }
.avatar-message { width: 34px; height: 34px; border-radius: 12px; font-size: .9rem; box-shadow: none; }
.avatar-switch { width: 30px; height: 30px; border-radius: 10px; font-size: .76rem; box-shadow: none; }
.identity-details { min-width: 0; }
.identity-name { margin: 0; overflow: hidden; color: #fff6fb; font: 600 1.4rem/1.2 Georgia, serif; text-overflow: ellipsis; white-space: nowrap; }
.identity-status { display: flex; align-items: center; gap: 7px; margin: 7px 0 0; color: #bdaeba; font-size: .8rem; }
.identity-status span { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 12px rgba(94,224,154,.7); }

.icon-button { display: inline-grid; place-items: center; flex: none; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 12px; color: #b9a5b3; background: transparent; cursor: pointer; text-decoration: none; transition: .16s ease; }
.icon-button:hover { color: white; background: rgba(255,255,255,.07); }
.icon-button:disabled { opacity: .45; cursor: not-allowed; }
.profile-edit { margin-left: auto; }
.companion-switcher { margin-top: 18px; }
.section-heading { justify-content: space-between; color: #9d8998; font-size: .7rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.section-heading .icon-button { width: 32px; height: 32px; color: #d4a0b8; }
.companion-list { display: flex; gap: 7px; margin-top: 7px; padding-bottom: 3px; overflow-x: auto; scrollbar-width: thin; }
.companion-item { display: flex; align-items: center; gap: 7px; flex: none; max-width: 138px; padding: 5px 10px 5px 5px; border: 1px solid rgba(255,255,255,.07); border-radius: 14px; color: #a28f9c; background: rgba(255,255,255,.025); cursor: pointer; }
.companion-item:hover { color: white; background: rgba(255,255,255,.055); }
.companion-item.active { color: white; border-color: rgba(232,77,138,.32); background: rgba(232,77,138,.12); }
.companion-item > span { overflow: hidden; font-size: .75rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.persona-copy { margin-top: 18px; padding: 16px; border: 1px solid rgba(255,255,255,.07); border-radius: 17px; background: rgba(255,255,255,.035); }
.persona-copy p { margin: 0; color: #f7e7f1; font: italic 1rem/1.4 Georgia, serif; }
.persona-copy span { display: block; margin-top: 6px; color: #9e8e9d; font-size: .76rem; line-height: 1.45; }
.sidebar-rule { height: 1px; margin: 21px 0; background: rgba(255,255,255,.07); }
.mode-row { justify-content: space-between; gap: 14px; }
.mode-row p { margin: 0; color: #efe1ea; font-size: .88rem; font-weight: 650; }
.mode-row div > span { display: block; margin-top: 4px; color: #907f8f; font-size: .74rem; }
.switch input { position: absolute; opacity: 0; }
.switch > span { position: relative; display: block; width: 39px; height: 22px; border-radius: 30px; background: #463342; cursor: pointer; transition: .2s; }
.switch > span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: white; transition: .2s; }
.switch input:checked + span { background: var(--pink); }
.switch input:checked + span::after { transform: translateX(17px); }
.privacy-note { gap: 11px; margin-top: 19px; padding: 14px; color: #c891ac; border-radius: 16px; background: rgba(232,77,138,.075); }
.privacy-note > svg { flex: none; width: 19px; }
.privacy-note p { margin: 0; color: #dec3d2; font-size: .8rem; font-weight: 650; }
.privacy-note span { display: block; margin-top: 3px; color: #8f7a89; font-size: .69rem; line-height: 1.4; }
.conversation-section { display: flex; flex: 1; min-height: 100px; flex-direction: column; margin-top: 18px; overflow: hidden; }
.conversation-list { min-height: 0; margin-top: 5px; overflow-y: auto; scrollbar-width: thin; }
.conversation-item { display: flex; align-items: center; gap: 9px; width: 100%; margin: 2px 0; padding: 10px 11px; border: 1px solid transparent; border-radius: 12px; color: #9f8f9b; background: transparent; cursor: pointer; text-align: left; }
.conversation-item:hover { color: #efe3eb; background: rgba(255,255,255,.04); }
.conversation-item.active { color: white; border-color: rgba(232,77,138,.18); background: linear-gradient(100deg, rgba(232,77,138,.14), rgba(128,64,156,.08)); }
.conversation-item svg { flex: none; width: 15px; }
.conversation-item span { min-width: 0; overflow: hidden; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-action { display: flex; align-items: center; gap: 9px; width: 100%; padding: 10px; border: 0; border-radius: 11px; color: #bda9b6; background: transparent; cursor: pointer; text-align: left; }
.sidebar-action:hover { color: white; background: rgba(255,255,255,.05); }
.sidebar-action svg { width: 16px; }
.danger-action:hover { color: #ffc2ce; }
.ai-note { margin: 9px 0 0; color: #6f606d; font-size: .68rem; text-align: center; }
.sidebar-scrim { display: none; }

.chat-panel { position: relative; z-index: 2; display: grid; grid-template-rows: 78px minmax(0, 1fr) auto; min-width: 0; height: 100%; min-height: 0; }
.chat-header { gap: 13px; min-width: 0; padding: env(safe-area-inset-top) 28px 0; border-bottom: 1px solid rgba(255,255,255,.07); background: rgba(11,7,16,.7); backdrop-filter: blur(18px); }
.header-copy { min-width: 0; }
.chat-header h1 { margin: 0; overflow: hidden; color: #fff5fa; font-size: 1rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.chat-header p { margin: 4px 0 0; overflow: hidden; color: #877787; font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { gap: 5px; margin-left: auto; }
.header-menu { display: none; }
.connection-pill { gap: 7px; margin-right: 6px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 999px; color: #9e8a98; background: rgba(255,255,255,.025); font-size: .7rem; }
.connection-pill i, .settings-status i { width: 7px; height: 7px; border-radius: 50%; background: #aa7a45; }
.connection-pill.ready i, .settings-status.ready i { background: var(--success); box-shadow: 0 0 10px rgba(94,224,154,.55); }
.connection-pill.missing i, .settings-status.missing i { background: var(--danger); }
.message-scroll { min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.messages { width: min(850px, calc(100% - 42px)); min-height: 100%; margin: 0 auto; padding: 34px 0 22px; }
.day-divider { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; color: #736270; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
.day-divider::before, .day-divider::after { content: ""; flex: 1; height: 1px; background: rgba(255,255,255,.06); }
.welcome-empty { max-width: 520px; margin: 11vh auto 0; color: #8f7f8d; text-align: center; }
.welcome-empty .avatar { margin: 0 auto 18px; }
.welcome-empty h2 { margin: 0; color: #f8eaf2; font: 600 1.55rem/1.3 Georgia, serif; }
.welcome-empty p { margin: 10px 0; line-height: 1.6; }
.message-row { display: flex; align-items: flex-end; gap: 11px; margin: 0 0 22px; }
.message-row.user { justify-content: flex-end; }
.message-stack { display: flex; flex-direction: column; align-items: flex-start; max-width: min(74%, 630px); }
.message-row.user .message-stack { align-items: flex-end; }
.message-bubble { padding: 13px 16px; border: 1px solid rgba(255,255,255,.08); border-radius: 8px 19px 19px 19px; color: #eadee6; background: rgba(37,24,44,.88); box-shadow: 0 12px 30px rgba(0,0,0,.14); font-size: .97rem; line-height: 1.58; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-bubble a { color: #ff9fcb; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.message-row.user .message-bubble { border: 0; border-radius: 19px 8px 19px 19px; color: white; background: linear-gradient(135deg, #c43772, #98406f); }
.message-stack time { margin-top: 6px; padding: 0 5px; color: #685966; font-size: .65rem; }
.message-image-link { display: block; max-width: min(420px, 100%); margin-bottom: 7px; overflow: hidden; border: 1px solid rgba(255,255,255,.12); border-radius: 20px; box-shadow: 0 18px 40px rgba(0,0,0,.25); }
.message-image { display: block; width: 100%; max-height: 480px; object-fit: cover; }
.typing-bubble { display: flex; gap: 5px; padding: 16px 18px; border: 1px solid var(--border); border-radius: 8px 19px 19px 19px; background: rgba(37,24,44,.88); }
.typing-bubble i { width: 6px; height: 6px; border-radius: 50%; background: #bb8fa6; animation: typing 1.2s infinite ease-in-out; }
.typing-bubble i:nth-child(2) { animation-delay: .16s; }
.typing-bubble i:nth-child(3) { animation-delay: .32s; }
@keyframes typing { 0%,65%,100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.composer-wrap { padding: 12px 28px max(15px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, transparent, rgba(11,7,16,.96) 26%); }
.composer { gap: 7px; width: min(880px, 100%); margin: 0 auto; padding: 8px; border: 1px solid rgba(255,255,255,.12); border-radius: 22px; background: rgba(27,17,33,.96); box-shadow: 0 20px 55px rgba(0,0,0,.34), inset 0 1px rgba(255,255,255,.04); backdrop-filter: blur(16px); }
.composer textarea { flex: 1; min-width: 0; min-height: 42px; max-height: 130px; padding: 10px 8px; border: 0; outline: none; resize: none; color: #f4e8f0; background: transparent; font-size: 1rem; line-height: 1.45; }
.composer textarea::placeholder { color: #7f6e7c; }
.composer-icon { align-self: flex-end; width: 42px; height: 42px; border-radius: 14px; }
.composer-icon.active { color: #ffe4f0; background: rgba(232,77,138,.22); box-shadow: inset 0 0 0 1px rgba(255,119,173,.24); }
.create-picture { color: #d37aa0; }
.send-button { display: grid; place-items: center; align-self: flex-end; flex: none; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 14px; color: white; background: linear-gradient(145deg, #e34f8a, #b93670); box-shadow: 0 8px 20px rgba(215,62,127,.28); cursor: pointer; }
.send-button:disabled { opacity: .5; cursor: not-allowed; }
.composer-hint { margin: 7px auto 0; color: #655662; font-size: .66rem; text-align: center; }
.chat-error { width: min(880px, 100%); margin: 0 auto 8px; padding: 9px 13px; border: 1px solid rgba(239,88,111,.24); border-radius: 12px; color: #ffc4d0; background: rgba(150,35,58,.16); font-size: .78rem; }
.pending-image { position: relative; gap: 10px; width: min(880px, 100%); margin: 0 auto 8px; color: #b9a3b2; font-size: .75rem; }
.pending-image img { width: 62px; height: 62px; border: 1px solid rgba(255,255,255,.12); border-radius: 13px; object-fit: cover; }
.pending-image button { position: absolute; left: 47px; top: -5px; display: grid; place-items: center; width: 21px; height: 21px; padding: 0; border: 1px solid rgba(255,255,255,.16); border-radius: 50%; color: white; background: #4d2638; cursor: pointer; }
.pending-image button svg { width: 12px; }

.modal { display: none; width: min(500px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); padding: 28px; overflow-y: auto; border: 1px solid rgba(255,255,255,.13); border-radius: 24px; color: var(--text); background: linear-gradient(155deg, #211327, #130d18); box-shadow: 0 30px 100px rgba(0,0,0,.72); }
.modal[open] { display: block !important; position: fixed !important; inset: auto !important; top: 50% !important; left: 50% !important; z-index: 2147483647 !important; margin: 0 !important; opacity: 1 !important; visibility: visible !important; transform: translate(-50%, -50%) !important; }
.modal::backdrop { display: none !important; background: transparent !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
body.modal-open { overflow: hidden; }
body.modal-open::before { content: ""; position: fixed; inset: 0; z-index: 2147483646; background: rgba(5,3,8,.88); }
.age-gate { position: fixed; inset: 0; z-index: 2147483647; display: grid; place-items: center; padding: 14px; overflow-y: auto; background: radial-gradient(circle at 50% 15%, #301226 0, #140b18 38%, #09060d 100%); }
.age-gate[hidden] { display: none !important; }
.age-gate-card { width: min(500px, 100%); max-height: calc(100dvh - 28px); padding: 28px; overflow-y: auto; border: 1px solid rgba(255,255,255,.13); border-radius: 24px; color: var(--text); background: linear-gradient(155deg, #211327, #130d18); box-shadow: 0 30px 100px rgba(0,0,0,.72); }
.age-gate-card h2 { margin: 8px 0; color: white; font: 600 1.55rem/1.25 Georgia, serif; }
.age-gate-card > p:not(.eyebrow) { margin: 0 0 20px; color: #aa97a5; font-size: .88rem; line-height: 1.6; }
.age-gate-card small { display: block; margin-top: 12px; color: #786775; font-size: .7rem; }
body.age-gated { overflow: hidden; }
.modal h2 { margin: 8px 0 8px; color: white; font: 600 1.55rem/1.25 Georgia, serif; }
.modal > p:not(.eyebrow) { margin: 0 0 20px; color: #aa97a5; font-size: .88rem; line-height: 1.6; }
.modal label, .auth-card label, .install-card label { display: block; margin: 15px 0 7px; color: #dccbd6; font-size: .78rem; font-weight: 700; }
.modal input:not([type="checkbox"]):not([type="radio"]), .modal textarea, .modal select, .auth-card input, .install-card input { width: 100%; padding: 12px 13px; border: 1px solid rgba(255,255,255,.12); border-radius: 13px; outline: none; color: #f8eef4; background: #211827; }
.modal textarea { resize: vertical; line-height: 1.5; }
.modal input:focus, .modal textarea:focus, .modal select:focus, .auth-card input:focus, .install-card input:focus { border-color: rgba(232,77,138,.58); box-shadow: 0 0 0 3px rgba(232,77,138,.1); }
.modal small { display: block; margin-top: 6px; color: #786775; font-size: .7rem; }
.modal-close { position: absolute; top: 16px; right: 16px; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 11px; color: #a891a0; background: transparent; cursor: pointer; }
.modal-close:hover { color: white; background: rgba(255,255,255,.07); }
.eyebrow { gap: 7px; margin: 0; color: #df77a3; font-size: .7rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.eyebrow svg { width: 14px; }
.modal-actions { justify-content: flex-end; gap: 9px; margin-top: 22px; }
.primary-button, .secondary-button, .danger-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 13px; cursor: pointer; font-weight: 650; }
.primary-button { color: white; background: linear-gradient(145deg, #e34f8a, #a9366b); box-shadow: 0 8px 20px rgba(215,62,127,.2); }
.primary-button:disabled { opacity: .45; cursor: not-allowed; }
.secondary-button { border: 1px solid var(--border); color: #d8c7d2; background: rgba(255,255,255,.05); }
.danger-button { color: #ffd6de; background: rgba(203,57,83,.18); }
.danger-button:hover { background: rgba(203,57,83,.28); }
.compact { min-height: 40px; padding: 0 14px; }
.compact svg { width: 17px; }
.accent-button { color: #ffdcea; border-color: rgba(232,77,138,.3); background: rgba(232,77,138,.13); }
.modal-icon { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 17px; border: 1px solid rgba(255,119,173,.23); border-radius: 20px; color: #ff77ad; background: rgba(232,77,138,.12); }
.modal-icon svg { width: 26px; fill: currentColor; }
.consent-modal { text-align: center; }
.consent-modal .eyebrow { justify-content: center; }
.consent-modal .consent-check { display: flex; align-items: flex-start; gap: 11px; margin: 15px 0; padding: 15px; border: 1px solid var(--border); border-radius: 15px; color: #d6c4d0; background: rgba(255,255,255,.035); cursor: pointer; text-align: left; line-height: 1.48; }
.consent-check input { margin-top: 3px; accent-color: var(--pink); }
.consent-modal .primary-button { width: 100%; }
.wide-modal { width: min(560px, calc(100vw - 28px)); }
.gender-options { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.gender-options label { margin: 0; }
.gender-options input { position: absolute; opacity: 0; }
.gender-options span { display: grid; place-items: center; min-height: 43px; border: 1px solid var(--border); border-radius: 12px; color: #aa98a5; background: rgba(255,255,255,.025); cursor: pointer; }
.gender-options input:checked + span { border-color: rgba(232,77,138,.4); color: #ffeef6; background: rgba(232,77,138,.14); }
.avatar-actions { flex-wrap: wrap; gap: 8px; }
.avatar-editor { display: flex; align-items: center; gap: 16px; padding: 14px; border: 1px solid var(--border); border-radius: 16px; background: rgba(255,255,255,.025); }
.avatar-profile-preview { width: 76px; height: 76px; border-radius: 24px; font-size: 2rem; }
.avatar-status { margin: 9px 0 0; color: #9e8c99; font-size: .72rem; line-height: 1.4; }
.avatar-status.success { color: #82d9b2; }
.avatar-status.error { color: #ff9daf; }
.profile-actions .danger-button { margin-right: auto; }
.settings-status { gap: 8px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 13px; color: #ad9ca8; background: rgba(255,255,255,.035); font-size: .78rem; }
.password-field { position: relative; }
.password-field input { padding-right: 48px !important; }
.password-field .icon-button { position: absolute; top: 3px; right: 3px; }
.form-grid { display: grid; gap: 12px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.settings-models { margin-top: 13px; }
.settings-models > label:first-child { margin-top: 0; }
.local-ai-card { margin-top: 12px; padding: 13px; border: 1px solid rgba(121,216,172,.18); border-radius: 14px; background: rgba(70,152,116,.07); }
.local-ai-card strong, .local-ai-card span { display: block; }
.local-ai-card strong { color: #e7fff3; font-size: .8rem; }
.local-ai-card span { margin-top: 4px; color: #94aa9e; font-size: .7rem; line-height: 1.45; }
.local-progress { height: 5px; margin: 11px 0; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.08); }
.local-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #e84d8a, #63d8a1); transition: width .2s ease; }
.local-ai-card .secondary-button { width: 100%; }
.gemini-settings { margin-top: 16px; padding: 12px 13px; border: 1px solid var(--border); border-radius: 13px; background: rgba(255,255,255,.025); }
.gemini-settings summary { color: #cdb9c7; font-weight: 700; cursor: pointer; }
.gemini-settings .remove-key { margin-bottom: 3px; }
.free-tier-note { margin-top: 14px; padding: 12px 13px; border: 1px solid rgba(255,255,255,.08); border-radius: 13px; color: #ae9ca9; background: rgba(255,255,255,.035); font-size: .75rem; line-height: 1.5; }
.remove-key { display: flex !important; align-items: center; gap: 8px; margin-top: 17px !important; font-weight: 500 !important; }
.remove-key input { accent-color: var(--danger); }
.settings-divider, .form-rule { height: 1px; margin: 23px 0 16px; background: var(--border); }
.settings-modal summary { color: #cab7c4; cursor: pointer; font-size: .82rem; font-weight: 650; }
.password-settings { padding-top: 5px; }
.danger-text { color: var(--danger); }
.toast { position: fixed; z-index: 100; right: 22px; bottom: 22px; max-width: min(380px, calc(100vw - 30px)); padding: 12px 16px; border: 1px solid rgba(255,255,255,.12); border-radius: 13px; color: white; background: #312039; box-shadow: 0 16px 45px rgba(0,0,0,.45); font-size: .82rem; }

.auth-page, .install-page { display: grid; min-height: 100dvh; padding: 28px; place-items: center; overflow-y: auto; background: radial-gradient(circle at 50% -20%, rgba(211,66,132,.25), transparent 43%), #0b0710; }
.auth-card, .install-card { width: min(430px, 100%); padding: 38px; border: 1px solid var(--border); border-radius: 26px; background: rgba(25,16,31,.94); box-shadow: 0 28px 90px rgba(0,0,0,.48); }
.install-card { width: min(620px, 100%); }
.auth-mark { display: grid; width: 54px; height: 54px; margin-bottom: 20px; border: 1px solid rgba(255,134,182,.24); border-radius: 18px; place-items: center; color: #ff86b6; background: rgba(232,77,138,.12); font: 1.9rem Georgia, serif; }
.auth-card h1, .install-card h1 { margin: 8px 0 10px; color: #fff5fa; font: 600 1.7rem/1.25 Georgia, serif; }
.auth-copy { margin: 0 0 22px; color: var(--muted); font-size: .88rem; line-height: 1.6; }
.auth-card .primary-button, .install-card .primary-button { width: 100%; margin-top: 18px; }
.auth-note { margin: 18px 0 0; color: var(--faint); font-size: .72rem; line-height: 1.5; text-align: center; }
.form-error { margin: 0 0 16px; padding: 11px 13px; border: 1px solid rgba(239,88,111,.24); border-radius: 12px; color: #ffc4d0; background: rgba(150,35,58,.16); font-size: .8rem; line-height: 1.45; }

@media (max-height: 760px) and (min-width: 861px) {
  .companion-sidebar { padding-top: 18px; padding-bottom: 14px; }
  .identity-card { margin-top: 18px; }
  .persona-copy { margin-top: 13px; padding: 12px 14px; }
  .sidebar-rule { margin: 15px 0; }
  .privacy-note { margin-top: 13px; padding: 11px; }
  .conversation-section { margin-top: 12px; }
}

@media (max-width: 860px) {
  .companion-shell { display: block; }
  .companion-sidebar { position: fixed; inset: 0 auto 0 0; width: min(320px, 88vw); transform: translateX(-105%); transition: transform .25s ease; }
  .companion-sidebar.is-open { transform: translateX(0); }
  .sidebar-scrim { position: fixed; z-index: 8; inset: 0; display: none; border: 0; background: rgba(0,0,0,.58); backdrop-filter: blur(3px); }
  .sidebar-scrim.is-open { display: block; }
  .mobile-only, .header-menu { display: inline-grid !important; }
  .sidebar-topline .mobile-only { margin-left: auto; }
  .chat-panel { grid-template-rows: max(72px, calc(58px + env(safe-area-inset-top))) minmax(0,1fr) auto; width: 100%; height: 100dvh; }
  .chat-header { padding: env(safe-area-inset-top) 14px 0; }
  .connection-pill span { display: none; }
  .connection-pill { padding: 8px; }
  .messages { width: calc(100% - 28px); padding-top: 24px; }
  .message-stack { max-width: 84%; }
  .composer-wrap { padding: 9px 10px max(10px, env(safe-area-inset-bottom)); }
  .composer { border-radius: 19px; }
  .composer-hint { display: none; }
}

@media (max-width: 520px) {
  .header-actions { gap: 0; }
  .header-actions > .icon-button { width: 34px; }
  .chat-header .avatar-small { width: 40px; height: 40px; }
  .message-bubble { font-size: .93rem; }
  .modal { padding: 24px 20px; }
  .form-grid.two { grid-template-columns: 1fr; gap: 0; }
  .avatar-editor { align-items: flex-start; }
  .avatar-actions { gap: 6px; }
  .avatar-actions .secondary-button { padding: 0 11px; }
  .profile-actions { flex-wrap: wrap; }
  .profile-actions .danger-button { width: 100%; margin-right: 0; order: 3; }
  .auth-page, .install-page { padding: 15px; }
  .auth-card, .install-card { padding: 28px 22px; }
}
