*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --night: #0f1923; --deep: #1a2d42; --gold: #c9a84c; --gold-dim: rgba(201,168,76,0.15);
  --ivory: #ffffff; --ivory-dim: rgba(255,255,255,0.7); --slate: #2a3f55;
  --border: rgba(201,168,76,0.2);
  --placeholder: rgba(240,234,216,0.55);
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif; --chat-font-size: 14px;
}
body.theme-light {
  --night: #eaf4fb; --deep: #ffffff; --gold: #c9a84c; --gold-dim: rgba(201,168,76,0.15);
  --ivory: #1e3a5f; --ivory-dim: rgba(30,58,95,0.6); --slate: #cfe8f7;
  --border: rgba(201,168,76,0.25);
  --placeholder: rgba(30,58,95,0.45);
}
html, body { height: 100%; background: var(--night); color: var(--ivory); font-family: var(--font-body); font-size: 15px; line-height: 1.65; overflow: hidden; }
.shell { display: flex; height: 100vh; width: 100%; }
.refs-panel { width: 280px; min-width: 280px; background: var(--deep); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: relative; overflow: hidden; }
.refs-panel::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: linear-gradient(to bottom, transparent, var(--gold), transparent); animation: pillar 4s ease-in-out infinite; }
@keyframes pillar { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
.refs-header { padding: 20px 18px 14px 22px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.refs-header h2 { font-family: var(--font-display); font-size: 13px; font-weight: 400; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); opacity: 0.8; }
.refs-header p { font-size: 11px; color: var(--ivory-dim); margin-top: 4px; }
.refs-list { flex: 1; overflow-y: auto; padding: 12px 0; scrollbar-width: thin; scrollbar-color: var(--slate) transparent; }
.ref-item { padding: 10px 18px 10px 22px; border-bottom: 1px solid rgba(255,255,255,0.04); cursor: pointer; transition: background 0.15s; position: relative; }
.ref-item:hover { background: rgba(201,168,76,0.08); }
.ref-item.active { background: var(--gold-dim); }
.ref-item.active::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--gold); }
.ref-num { font-size: 10px; color: var(--gold); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 3px; }
.ref-chapter { font-family: var(--font-display); font-size: 13px; font-weight: 400; color: var(--ivory); line-height: 1.3; margin-bottom: 2px; }
.ref-sub { font-size: 11px; color: var(--ivory-dim); font-style: italic; line-height: 1.3; }
.ref-link { display: inline-block; margin-top: 5px; font-size: 10px; color: var(--gold); text-decoration: none; letter-spacing: 0.5px; opacity: 0.7; transition: opacity 0.15s; }
.ref-link:hover { opacity: 1; }
.refs-nav { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: center; gap: 8px; flex-shrink: 0; }
.refs-nav button { background: none; border: 1px solid var(--border); color: var(--ivory-dim); cursor: pointer; padding: 4px 10px; border-radius: 3px; font-size: 13px; transition: all 0.15s; }
.refs-nav button:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); }
.refs-nav button:disabled { opacity: 0.3; cursor: default; }
.refs-nav span { font-size: 12px; color: var(--ivory-dim); }
.chat-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-header { padding: 16px 28px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; background: var(--deep); backdrop-filter: blur(8px); }
.chat-header h1 { font-family: var(--font-display); font-size: 22px; font-weight: 300; letter-spacing: 1px; color: var(--ivory); }
.chat-header h1 em { color: var(--gold); font-style: italic; }
.mobile-only { display: none; }
.mobile-only-inline { display: none; }
.chat-meta { display: flex; align-items: center; gap: 16px; font-size: 12px; color: var(--ivory-dim); }
.quota-badge { background: var(--gold-dim); border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px; font-size: 11px; color: var(--gold); }
select.lang-switch { background: var(--deep); color: var(--ivory); border: 1px solid var(--border); border-radius: 4px; padding: 3px 6px; font-size: 11px; cursor: pointer; outline: none; }
select.lang-switch:hover { border-color: var(--gold); }
.cta-links { display: flex; gap: 8px; }
.cta-link { font-size: 11px; color: var(--ivory-dim); text-decoration: none; letter-spacing: 0.5px; padding: 3px 8px; border: 1px solid transparent; border-radius: 4px; transition: all 0.15s; }
.cta-link:hover { color: var(--gold); border-color: var(--gold-dim); }
.cta-link-highlight { background: var(--gold); color: var(--night) !important; font-weight: 600; }
.cta-link-highlight:hover { background: var(--gold-dim); border-color: transparent; color: var(--night) !important; }
.font-btn { background: var(--gold-dim); border: 1px solid var(--border); color: var(--ivory); cursor: pointer; border-radius: 6px; padding: 5px 12px; font-size: 15px; font-weight: 600; transition: all 0.15s; margin-left: 2px; letter-spacing: 0.5px; }
.font-btn:hover { background: var(--gold); color: var(--night); border-color: var(--gold); }
.chat-messages { flex: 1; overflow-y: auto; padding: 28px 32px; display: flex; flex-direction: column; gap: 24px; scrollbar-width: thin; scrollbar-color: var(--slate) transparent; }
.msg { display: flex; gap: 14px; max-width: 820px; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.assistant { align-self: flex-start; }
.msg-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; margin-top: 2px; }
.msg.user .msg-avatar { background: var(--gold-dim); border: 1px solid var(--border); color: var(--gold); }
.msg.assistant .msg-avatar { background: var(--slate); border: 1px solid var(--border); color: var(--ivory-dim); }
.msg-bubble { padding: 14px 18px; border-radius: 12px; font-size: var(--chat-font-size); line-height: 1.75; max-width: 680px; }
.msg.user .msg-bubble { background: var(--gold-dim); border: 1px solid var(--border); color: var(--ivory); border-radius: 12px 12px 2px 12px; }
.msg.assistant .msg-bubble { background: var(--deep); border: 1px solid rgba(255,255,255,0.06); color: var(--ivory); border-radius: 12px 12px 12px 2px; font-family: var(--font-body); font-size: var(--chat-font-size); font-weight: 400; text-align: justify; }
.msg.assistant .msg-bubble mark { background: rgba(201,168,76,0.3); color: var(--gold); border-radius: 2px; padding: 0 2px; }
.msg.assistant .msg-bubble a { color: var(--gold); text-decoration: none; font-size: 12px; font-family: var(--font-body); opacity: 0.7; }
.msg.assistant .msg-bubble a:hover { opacity: 1; }
.welcome { align-self: center; text-align: center; max-width: 500px; padding: 40px 20px; }
.welcome-icon { font-size: 40px; margin-bottom: 16px; opacity: 0.6; }
.welcome h2 { font-family: var(--font-display); font-size: 26px; font-weight: 300; color: var(--ivory); margin-bottom: 10px; line-height: 1.3; }
.welcome p { font-size: 13px; color: var(--ivory-dim); line-height: 1.7; }
.typing { display: flex; gap: 5px; padding: 14px 18px; background: var(--deep); border: 1px solid rgba(255,255,255,0.06); border-radius: 12px 12px 12px 2px; width: fit-content; }
.typing span { width: 6px; height: 6px; background: var(--ivory-dim); border-radius: 50%; animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-6px); opacity: 1; } }
.chat-input-area { padding: 16px 28px 20px; border-top: 1px solid var(--border); background: rgba(15,25,35,0.9); flex-shrink: 0; }
.error-bar { background: rgba(200,50,50,0.15); border: 1px solid rgba(200,50,50,0.3); border-radius: 6px; padding: 8px 14px; font-size: 13px; color: #e88; margin-bottom: 12px; }
.input-row { display: flex; gap: 10px; align-items: flex-end; }
.input-row textarea { flex: 1; background: var(--deep); border: 1px solid var(--border); border-radius: 10px; color: var(--ivory); font-family: var(--font-body); font-size: 14px; padding: 12px 16px; resize: none; min-height: 48px; max-height: 140px; line-height: 1.5; outline: none; transition: border-color 0.2s; }
.input-row textarea:focus { border-color: rgba(201,168,76,0.5); }
.input-row textarea::placeholder { color: var(--placeholder); }
.send-btn { background: var(--gold); border: none; border-radius: 10px; color: var(--night); cursor: pointer; font-size: 18px; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0; }
.send-btn:hover { background: #d4b060; transform: scale(1.05); }
.share-quote-btn:hover, .share-ig-btn:hover { transform: scale(1.05); }
@keyframes fadeInUp { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.send-btn:disabled { background: var(--slate); color: var(--ivory-dim); cursor: default; transform: none; }
.input-hint { font-size: 11px; color: rgba(240,234,216,0.25); margin-top: 8px; text-align: center; letter-spacing: 0.3px; }
.refs-empty { padding: 24px 20px; text-align: center; color: rgba(240,234,216,0.25); font-size: 12px; font-style: italic; line-height: 1.6; }
@media (max-width: 700px) {
html, body { overflow: hidden; }
.shell { flex-direction: column; height: 100vh; height: 100dvh; }
.chat-panel { order: 1; flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.chat-header { padding: 10px 10px; flex-shrink: 0; }
.chat-header h1 { font-size: 16px; line-height: 1.15; white-space: nowrap; }
.chat-header h1 em { display: inline; color: var(--gold); font-style: italic; }
.chat-meta { gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
.cta-links { flex-wrap: wrap; }
.cta-link { white-space: normal; font-size: 9px; padding: 1px 4px; }
.mobile-only { display: inline; }
.desktop-only { display: none; }
.mobile-only-inline { display: inline; }
.font-btn { font-size: 11px; padding: 2px 6px; }
.lang-switch { font-size: 9px; padding: 2px 4px; }
.quota-badge { font-size: 9px; padding: 2px 6px; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px; }
.chat-input-area { flex-shrink: 0; padding: 8px 10px 10px; }
.input-hint { display: none; }
.msg-bubble { max-width: 100% !important; text-align: justify !important; }
.refs-panel { order: 2; flex-shrink: 0; width: 100%; height: 190px; min-height: 190px; max-height: 190px; border-right: none; border-top: 1px solid var(--border); display: flex !important; flex-direction: column; overflow: hidden; }
.refs-panel::before { width: 100%; height: 2px; top: 0; left: 0; bottom: auto; background: linear-gradient(to right, transparent, var(--gold), transparent); }
.refs-header { padding: 8px 12px 6px; flex-shrink: 0; }
.refs-list { flex: 1; display: flex !important; flex-direction: row !important; overflow-x: auto !important; overflow-y: hidden !important; padding: 6px 4px; gap: 0; -webkit-overflow-scrolling: touch; scroll-snap-type: x mandatory; }
.ref-item { min-width: 240px; max-width: 240px; flex-shrink: 0; border-bottom: none; border-right: 1px solid rgba(255,255,255,0.08); scroll-snap-align: start; padding: 8px 12px; }
.refs-nav { display: none !important; }
}

/* Public controls retain the chat palette in both themes. */
.public-page.chat-page .refs-empty { color: var(--ivory-dim); }
.public-page.chat-page .input-hint { color: rgba(240,234,216,0.65); }
.chat-controls { display: flex; align-items: center; gap: 4px; }
#themeToggle { font-size: 14px; padding: 5px 8px; }
#refsNav { display: none; }
.chat-status { font-size: 12px; }
.chat-status:empty, .share-status:empty { display: none; }
.chat-status:not(:empty) { margin-bottom: 8px; }
.chat-error, .chat-status[data-state="error"] { color: #e88; }
.theme-light .chat-error, .theme-light .chat-status[data-state="error"] { color: #9c3333; }
.ref-select { display: block; width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer; font-family: inherit; }
.ref-select > span { display: block; }
.share-btn-group, .coaching-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.share-btn-group button, .chat-action { border: none; border-radius: 20px; padding: 8px 18px; background: var(--gold); color: var(--night); font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 8px; }
.share-quote-btn { box-shadow: 0 2px 8px rgba(201,168,76,0.25); }
.share-btn-group .share-ig-btn { background: linear-gradient(135deg,#405DE6,#5851DB,#833AB4,#C13584,#E1306C,#FD1D1D); color: #fff; box-shadow: 0 2px 8px rgba(225,48,108,0.3); }
.share-btn-group .share-wa-btn { background: #25D366; color: #fff; box-shadow: 0 2px 8px rgba(37,211,102,0.3); }
.share-status { font-size: 12px; text-align: left; }
.offer-intro { margin-bottom: 10px; }
.signup-box { display: flex; flex-direction: column; gap: 8px; max-width: 320px; }
.signup-box input { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--deep); color: var(--ivory); font-family: inherit; font-size: 13px; }
.signup-upgrade { display: block; text-align: center; margin-top: 6px; padding: 10px 16px; border-radius: 20px; border: 1px solid var(--gold); }
.signup-success { color: var(--gold); margin-top: 8px; }
.coaching-actions .coaching-no { border: 1px solid var(--border); background: transparent; color: var(--ivory-dim); }
.coaching-message p { margin-bottom: 14px; white-space: pre-line; }
.retry-question { margin-top: 10px; }
.msg.user .msg-bubble { white-space: pre-wrap; }

.share-icon { display: inline-flex; order: -1; }
.public-page.chat-page .public-status { color: var(--ivory-dim); padding: 4px 0; }
.public-page.chat-page .public-status[data-state="error"], .public-page.chat-page .chat-error { color: #e88; }
.public-page.chat-page.theme-light .public-status[data-state="error"], .public-page.chat-page.theme-light .chat-error { color: #9c3333; }

.public-page.chat-page .chat-status { color: rgba(240,234,216,0.85); }
.public-page.chat-page .chat-input-area .chat-status[data-state="error"] { color: #e88; }
