/* Dr. Ed 0.2.0 "Liquid Glass" theme, matched to drsexed.ai (WordPress): pastel pink/lilac/sky/peach gradient, purple ->
   pink headings and primary buttons (#6d28d9 -> #be185d), white frosted cards and pill chips, green logo (#74D16B).
   System fonts only (no external font/CDN requests; CSP stays 'self'). Blur needs backdrop-filter (+ -webkit- for iOS);
   without it the panels fall back to near-solid white. Text colours meet WCAG AA on the panel colours. */
:root {
  --purple: #6d28d9; --purple-d: #5b21b6; --pink: #be185d; --ink: #1f1235; --muted: #4a3f5c; --green: #3f8f37;
  --glass: rgba(255,255,255,.58); --glass-strong: rgba(255,255,255,.78); --solid: #fdf7ff;
  --edge: rgba(255,255,255,.75); --edge-dim: rgba(109,40,217,.16); --shadow: 0 10px 40px rgba(91,33,182,.16), 0 2px 8px rgba(91,33,182,.08);
  --r-lg: 28px; --r-md: 18px; --r-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: var(--font); color: var(--ink); -webkit-font-smoothing: antialiased; }
body { background: linear-gradient(135deg, #ffb3dd 0%, #c9b6ff 30%, #9fe3ff 62%, #ffd59e 100%); background-attachment: fixed; }
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; }
.b1 { width: 46vmax; height: 46vmax; left: -14vmax; top: -12vmax; background: #ff4fa8; }
.b2 { width: 40vmax; height: 40vmax; right: -12vmax; bottom: -14vmax; background: #8b5cf6; opacity: .4; }
.b3 { width: 28vmax; height: 28vmax; right: 18vmax; top: 10vmax; background: #9fe3ff; opacity: .5; }

/* glass surfaces */
.glass, .msg.bot, .chip, .pill-btn, .ghost-btn, .composer, .disclaimer, .donate-box, .controls, .hello-bubble {
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(180%); backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--edge);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass, .msg.bot, .chip, .pill-btn, .ghost-btn, .composer, .disclaimer, .donate-box, .controls, .hello-bubble { background: var(--solid); }
}
.sofia { max-width: 780px; height: calc(100% - 32px); margin: 16px auto; display: flex; flex-direction: column; border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.sofia-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--edge-dim); background: rgba(255,255,255,.35); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { width: 40px; height: 40px; flex: 0 0 40px; }
h1 { font-size: 19px; margin: 0; font-weight: 800; letter-spacing: -.2px; background: linear-gradient(120deg, var(--purple), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.tagline strong { color: var(--purple-d); }
.muted { color: var(--muted); font-size: 13px; }

/* welcome (tap to start, returning visitor) */
.welcome { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 28px 22px; gap: 10px; }
.hero-avatar { width: 112px; height: 112px; border-radius: 24px; display: block; object-fit: cover; box-shadow: 0 8px 24px rgba(139,92,246,.35); }
.hello-bubble { margin: 0; padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: 14px; box-shadow: 0 4px 14px rgba(91,33,182,.12); }
.hero-title { margin: 6px 0 0; font-size: clamp(26px, 5vw, 40px); line-height: 1.12; font-weight: 800; letter-spacing: -.6px; background: linear-gradient(120deg, var(--purple), var(--pink), var(--purple)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { max-width: 520px; margin: 4px auto 10px; font-size: 16px; line-height: 1.5; color: var(--muted); }
.hero-sub.strong { color: var(--ink); font-weight: 700; font-size: 18px; }
.hero-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 14px 0 0; }
.hero-chips span { font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.8); color: var(--ink); box-shadow: 0 2px 8px rgba(91,33,182,.08); }
#startBox, #resumeBox { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.primary-btn { border: 0; cursor: pointer; color: #fff; font-weight: 700; font-size: 17px; padding: 14px 30px; border-radius: 999px; background: linear-gradient(120deg, var(--purple), var(--pink)); box-shadow: 0 10px 26px rgba(190,24,93,.32), inset 0 1px 0 rgba(255,255,255,.35); min-height: 48px; }
.primary-btn:hover { filter: brightness(1.06); } .primary-btn:active { transform: scale(.98); }
.ghost-btn { cursor: pointer; color: var(--purple-d); font-weight: 700; font-size: 15px; padding: 11px 22px; border-radius: 999px; min-height: 44px; }

/* top controls: save / delete / end */
.controls { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 16px; border-width: 0 0 1px; border-color: var(--edge-dim); border-radius: 0; background: rgba(255,255,255,.28); }
.pill-btn { cursor: pointer; color: var(--ink); font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: 999px; min-height: 32px; }
.pill-btn[aria-pressed="true"] { background: rgba(63,143,55,.14); border-color: rgba(63,143,55,.45); color: #1d4f19; }
.pill-btn.danger { color: #9f1239; }
.pill-btn:focus-visible, .chip:focus-visible, .primary-btn:focus-visible, .ghost-btn:focus-visible, .talk-btn:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }

.disclaimer { margin: 6px 16px 8px; padding: 6px 12px; border-radius: var(--r-sm); font-size: .7rem; line-height: 1.4; color: var(--ink); }
.progress { display: flex; align-items: center; gap: 10px; padding: 8px 18px; font-size: 12px; color: var(--muted); }
.progress .bar { flex: 1; height: 6px; background: rgba(109,40,217,.12); border-radius: 3px; overflow: hidden; }
.progress .bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--purple), var(--pink)); transition: width .3s; }

/* chat */
.log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.msg { max-width: 85%; padding: 11px 15px; border-radius: var(--r-md); line-height: 1.5; font-size: 15px; white-space: pre-wrap; word-wrap: break-word; }
.msg.bot { align-self: flex-start; border-top-left-radius: 6px; box-shadow: 0 2px 10px rgba(91,33,182,.08); color: var(--ink); }
.msg.bot .who { display: block; font-size: 11px; font-weight: 800; letter-spacing: .3px; color: var(--purple-d); margin-bottom: 3px; text-transform: uppercase; }
.msg.user { align-self: flex-end; color: #fff; border-top-right-radius: 6px; background: linear-gradient(135deg, var(--purple), #9d174d); box-shadow: 0 4px 14px rgba(109,40,217,.25); }
.msg.typing { color: var(--muted); font-style: italic; }
.msg a { color: var(--purple-d); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 10px; }
.chip { cursor: pointer; color: var(--purple-d); font-weight: 600; font-size: 14px; padding: 9px 16px; border-radius: 999px; min-height: 40px; box-shadow: 0 2px 8px rgba(91,33,182,.08); transition: transform .12s, background .12s; }
.chip:hover { background: rgba(255,255,255,.9); transform: translateY(-1px); }
.chip:active { transform: scale(.97); }

.composer { display: flex; gap: 8px; margin: 0 14px 10px; padding: 8px; border-radius: 999px; box-shadow: 0 4px 18px rgba(91,33,182,.1); }
.composer input { flex: 1; min-width: 0; padding: 11px 14px; border: 0; background: transparent; font-size: 16px; outline: none; color: var(--ink); font-family: var(--font); }
.composer input::placeholder { color: #6b5e80; }
.mic, .send { border: 0; border-radius: 999px; cursor: pointer; font-size: 15px; min-height: 44px; }
.mic { width: 46px; flex: 0 0 46px; background: rgba(109,40,217,.1); } .mic.listening { background: #ff8fd0; animation: pulse 1s infinite; }
.mic:disabled { opacity: .4; cursor: not-allowed; }
.send { flex: 0 0 auto; padding: 0 20px; color: #fff; font-weight: 700; background: linear-gradient(120deg, var(--purple), var(--pink)); }
.footnote { margin: 0; padding: 0 20px 10px; font-size: 11.5px; line-height: 1.45; color: var(--muted); }
.footnote summary { cursor: pointer; list-style: none; display: inline-block; opacity: .85; text-decoration: underline; text-underline-offset: 2px; }
.footnote summary::-webkit-details-marker { display: none; }
.footnote p { margin: 6px 0 0; }

/* talk button + video panel */
.header-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.talk-btn { cursor: pointer; border: 0; color: #fff; font-weight: 700; font-size: 14px; padding: 9px 16px; border-radius: 999px; white-space: nowrap; background: linear-gradient(120deg, var(--purple), var(--pink)); box-shadow: 0 6px 18px rgba(190,24,93,.28); min-height: 40px; }
.talk-btn.on { background: rgba(255,255,255,.85); color: var(--pink); box-shadow: inset 0 0 0 2px var(--pink); }
.mini-btn { background: rgba(255,255,255,.85); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); color: var(--ink); border: 1px solid var(--edge); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.talk-mic { margin-right: 6px; } .talk-mic[aria-pressed="true"] { background: #ffe4f1; }
.avatar-panel { position: relative; height: 280px; flex: 0 0 auto; margin: 12px 16px 0; border-radius: var(--r-md); overflow: hidden; display: flex; align-items: center; justify-content: center; background: #4a1650 url("dred-bg.webp") center / cover no-repeat; box-shadow: var(--shadow), inset 0 0 0 1px rgba(255,255,255,.35); }
/* 0.2.2: video and the chroma-keyed canvas sit in the same box; when .keyed the canvas (green removed) shows and the video
   keeps playing underneath at near-zero opacity (never display:none, so iOS Safari keeps decoding frames). */
.avatar-panel video, .avatar-canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.avatar-canvas { display: none; pointer-events: none; }
.avatar-panel.keyed .avatar-canvas { display: block; }
.avatar-panel.keyed video { opacity: .01; }
.avatar-panel .ai-label, .avatar-panel .avatar-status, .avatar-panel .avatar-bar { z-index: 2; }
.ai-label, .avatar-status, .countdown { color: #fff; background: rgba(20,8,40,.5); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.25); border-radius: 999px; }
.ai-label { position: absolute; top: 10px; left: 10px; font-size: 11px; font-weight: 700; padding: 4px 10px; letter-spacing: .3px; }
.avatar-status { position: absolute; font-size: 14px; padding: 7px 14px; } .avatar-status:empty { display: none; }
.avatar-bar { position: absolute; bottom: 10px; left: 10px; right: 10px; display: flex; gap: 6px; align-items: center; }
.countdown { font-size: 12px; padding: 4px 10px; margin-right: auto; }

/* donations */
.donate-box { margin: 8px 16px; padding: 12px 14px; border-radius: var(--r-md); }
.donate-box p { margin: 0 0 8px; }
.cta { display: inline-block; padding: 12px 20px; font-size: 15px; font-weight: 700; color: #fff; text-decoration: none; border: 0; border-radius: 999px; cursor: pointer; background: linear-gradient(120deg, var(--purple), var(--pink)); margin-bottom: 8px; }
.unlock { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .9rem; }
.unlock input { flex: 1 1 220px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--edge-dim); font-size: 16px; }
.unlock .send { min-height: 38px; }
.msg a.donate-link { font-weight: 700; }
.summary-card { align-self: stretch; border-radius: var(--r-md); padding: 16px 18px; background: var(--glass-strong); white-space: normal; }

body.teen .hero-chips span:nth-child(3) { display: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255,79,168,.25); } }
@media (prefers-reduced-motion: reduce) { .chip, .primary-btn { transition: none; } .mic.listening { animation: none; } }
@media (max-width: 640px) {
  .sofia { margin: 0; height: 100%; border-radius: 0; border: 0; }
  .sofia-header { padding: calc(10px + env(safe-area-inset-top)) 14px 10px; }
  h1 { font-size: 16px; } .tagline { font-size: 11.5px; } .logo { width: 32px; height: 32px; flex-basis: 32px; }
  .talk-btn { padding: 8px 12px; font-size: 13px; }
  .msg { max-width: 92%; }
  .avatar-panel { height: 220px; margin: 10px 10px 0; }
  .composer { margin: 0 10px calc(8px + env(safe-area-inset-bottom)); }
  .controls { padding: 6px 10px; }
}
body:not(.started) .log, body:not(.started) .chips, body:not(.started) .header-btns, body:not(.started) .progress { display: none !important; }
@media (max-width: 640px) {
  .disclaimer { margin: 4px 10px 6px; font-size: 10.5px; padding: 7px 11px; }
  body.started .footnote { font-size: 10.5px; padding-bottom: 6px; }
}
