/* MedSkin Youth Concierge
   Layout: phone = full screen · tablet portrait = centered card ·
           tablet landscape and computer = brand panel + conversation */

@font-face {
  font-family: "Cormorant";
  src: url("/static/fonts/cormorant-garamond-latin-500-normal.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Cormorant";
  src: url("/static/fonts/cormorant-garamond-latin-600-normal.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Cormorant";
  src: url("/static/fonts/cormorant-garamond-latin-500-italic.woff2") format("woff2");
  font-weight: 500; font-style: italic; font-display: swap;
}

:root {
  --bg: #F6EFE7;
  --bg-deep: #EBDFD1;
  --surface: rgba(255, 252, 248, .74);
  --surface-solid: #FFFDFA;
  --ink: #2B211A;
  --ink-soft: #75675B;
  --ink-faint: #A4978B;
  --line: rgba(92, 64, 40, .13);
  --gold: #B38250;
  --gold-deep: #8E6034;
  --gold-soft: #EBDCC8;
  --rose: #EBCDBF;
  --user-a: #BC8D5B;
  --user-b: #906236;
  --on-gold: #FFFDF9;
  --glow-1: rgba(226, 184, 140, .55);
  --glow-2: rgba(236, 200, 188, .55);
  --glow-3: rgba(250, 232, 200, .7);
  --shadow: 0 1px 2px rgba(70, 45, 20, .05), 0 12px 32px -16px rgba(70, 45, 20, .22);
  --shadow-lift: 0 2px 6px rgba(70, 45, 20, .06), 0 24px 60px -24px rgba(70, 45, 20, .35);
  --serif: "Cormorant", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --app-h: 100dvh;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14100D;
    --bg-deep: #0E0B09;
    --surface: rgba(32, 26, 21, .72);
    --surface-solid: #221C17;
    --ink: #F4ECE3;
    --ink-soft: #B3A597;
    --ink-faint: #85786C;
    --line: rgba(240, 214, 184, .13);
    --gold: #D8B084;
    --gold-deep: #E6C49C;
    --gold-soft: #3A2E23;
    --rose: #4A372F;
    --user-a: #B98B5A;
    --user-b: #8A5D33;
    --glow-1: rgba(150, 100, 55, .34);
    --glow-2: rgba(120, 70, 60, .30);
    --glow-3: rgba(90, 70, 40, .30);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -16px rgba(0, 0, 0, .6);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, .3), 0 24px 60px -24px rgba(0, 0, 0, .8);
  }
}

* { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold-deep); }
img { display: block; max-width: 100%; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7;
      stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* ── ambient background ─────────────────────────────── */
.aurora { position: fixed; inset: 0; overflow: hidden; pointer-events: none;
          background: linear-gradient(160deg, var(--bg) 0%, var(--bg-deep) 100%); }
.aurora span { position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%;
               will-change: transform; }
.aurora span:nth-child(1) { left: -22vmax; top: -26vmax;
  background: radial-gradient(closest-side, var(--glow-1), transparent);
  animation: drift-a 34s ease-in-out infinite alternate; }
.aurora span:nth-child(2) { right: -26vmax; top: 8vmax;
  background: radial-gradient(closest-side, var(--glow-2), transparent);
  animation: drift-b 41s ease-in-out infinite alternate; }
.aurora span:nth-child(3) { left: 12vmax; bottom: -38vmax;
  background: radial-gradient(closest-side, var(--glow-3), transparent);
  animation: drift-c 47s ease-in-out infinite alternate; }
@keyframes drift-a { to { transform: translate3d(14vmax, 10vmax, 0) scale(1.15); } }
@keyframes drift-b { to { transform: translate3d(-12vmax, 14vmax, 0) scale(.9); } }
@keyframes drift-c { to { transform: translate3d(10vmax, -12vmax, 0) scale(1.1); } }

/* ── frame ──────────────────────────────────────────── */
.shell { position: relative; height: var(--app-h); display: grid; grid-template-columns: 1fr; }
.brand { display: none; }
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0;
        background: var(--surface);
        -webkit-backdrop-filter: blur(22px) saturate(1.2); backdrop-filter: blur(22px) saturate(1.2); }

@media (min-width: 640px) {
  .shell { padding: 22px; justify-items: center; }
  .chat { width: 100%; max-width: 780px; border-radius: 30px; border: 1px solid var(--line);
          box-shadow: var(--shadow-lift); overflow: hidden; }
}
@media (min-width: 1024px) {
  .shell { grid-template-columns: minmax(330px, 36%) minmax(0, 1fr); gap: 26px; padding: 26px;
           max-width: 1500px; margin: 0 auto; justify-items: stretch; }
  .brand { display: flex; }
  .chat { max-width: none; }
  .icon-btn.only-compact { display: none; }
}

/* ── brand panel ────────────────────────────────────── */
.brand { flex-direction: column; justify-content: center; padding: 10px 14px 10px 22px;
         min-height: 0; overflow: hidden; animation: fade-in 1s var(--ease) both; }
.eyebrow { margin: 0 0 10px; font-size: .72rem; letter-spacing: .26em; text-transform: uppercase;
           color: var(--gold-deep); }
.wordmark { margin: 0; font: 500 clamp(2.9rem, 4.6vw, 4.4rem)/.98 var(--serif); letter-spacing: -.01em; }
.wordmark em { font-style: italic; color: var(--gold-deep); }
.wordmark.small { font-size: 2.3rem; }
.tagline { margin: 16px 0 0; max-width: 24em; color: var(--ink-soft); font-size: 1.02rem; }
.portrait { margin: 28px 0; width: min(74%, 300px); aspect-ratio: 4 / 5; flex: 0 1 auto; min-height: 0;
            border-radius: 999px 999px 26px 26px; overflow: hidden; position: relative;
            box-shadow: var(--shadow-lift); border: 1px solid var(--line); }
.portrait img { width: 100%; height: 100%; object-fit: cover; object-position: 62% 30%;
                animation: breathe 18s ease-in-out infinite alternate; }
@keyframes breathe { from { transform: scale(1.02); } to { transform: scale(1.1); } }
.details { margin: 0; display: grid; gap: 12px; }
.details div { display: grid; grid-template-columns: 9.6em 1fr; gap: 12px; align-items: baseline; }
.details dt { font-size: .7rem; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-faint); }
.details dd { margin: 0; color: var(--ink); font-size: .95rem; }
.brand-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
@media (min-width: 1024px) and (max-height: 760px) {
  .portrait { width: 190px; margin: 18px 0; }
  .tagline { margin-top: 10px; }
}
@media (min-width: 1024px) and (max-height: 620px) { .portrait { display: none; } }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: 999px;
       font-weight: 600; font-size: .92rem; text-decoration: none; border: 1px solid transparent;
       transition: transform .25s var(--ease), box-shadow .25s var(--ease), background .25s; }
.btn svg { width: 17px; height: 17px; }
.btn-solid { background: linear-gradient(135deg, var(--user-a), var(--user-b)); color: var(--on-gold);
             box-shadow: 0 10px 24px -12px var(--user-b); }
.btn-ghost { border-color: var(--line); color: var(--ink); background: var(--surface); }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }

/* ── conversation header ────────────────────────────── */
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
             padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
             border-bottom: 1px solid var(--line); }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar-ring { position: relative; width: 44px; height: 44px; border-radius: 50%; padding: 2px; flex: none;
               background: conic-gradient(from 210deg, var(--gold), var(--rose), var(--gold-soft), var(--gold)); }
.avatar-ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: 62% 22%;
                   border: 2px solid var(--surface-solid); }
.who-name { margin: 0; font: 600 1.32rem/1.1 var(--serif); letter-spacing: .01em; }
.who-role { margin: 2px 0 0; font-size: .74rem; letter-spacing: .14em; text-transform: uppercase;
            color: var(--ink-soft); display: flex; align-items: center; gap: 7px; }
.online { width: 7px; height: 7px; border-radius: 50%; background: #5DAA7B; position: relative; }
.online::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1px solid #5DAA7B;
                 animation: ping 2.6s ease-out infinite; }
@keyframes ping { from { transform: scale(.5); opacity: .9; } to { transform: scale(1.5); opacity: 0; } }
.head-actions { display: flex; gap: 6px; }
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%;
            border: 1px solid var(--line); background: transparent; color: var(--ink-soft);
            text-decoration: none; transition: background .2s, color .2s, transform .25s var(--ease); }
.icon-btn:hover { background: var(--gold-soft); color: var(--ink); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.accent { color: var(--gold-deep); }

/* ── scroll area ────────────────────────────────────── */
.scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
          -webkit-overflow-scrolling: touch; scroll-behavior: smooth; }
.column { max-width: 720px; margin: 0 auto;
          padding: 18px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); }

/* ── welcome ────────────────────────────────────────── */
.welcome { text-align: center; padding: clamp(10px, 5vh, 54px) 4px 6px;
           transition: opacity .35s, transform .45s var(--ease), max-height .5s var(--ease), padding .5s;
           max-height: 900px; overflow: hidden; }
.welcome.leaving { opacity: 0; transform: translateY(-12px) scale(.98); max-height: 0; padding-top: 0; padding-bottom: 0; }
.welcome-portrait { display: inline-block; width: 92px; height: 92px; border-radius: 50%; padding: 3px;
                    background: conic-gradient(from 210deg, var(--gold), var(--rose), var(--gold-soft), var(--gold));
                    box-shadow: 0 18px 40px -18px var(--user-b); animation: rise .9s var(--ease) both; }
.welcome-portrait img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: 62% 22%;
                        border: 3px solid var(--surface-solid); }
.welcome h2 { margin: 18px auto 6px; max-width: 13em; font: 500 clamp(1.9rem, 6vw, 2.6rem)/1.08 var(--serif);
              animation: rise .9s .08s var(--ease) both; }
.welcome p { margin: 0 auto; max-width: 26em; color: var(--ink-soft); animation: rise .9s .16s var(--ease) both; }
@media (min-width: 1024px) { .welcome-portrait { display: none; } .welcome h2 { margin-top: 0; } }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin: 24px auto 0; max-width: 560px; }
.chip { padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-solid);
        color: var(--ink); font-size: .92rem; box-shadow: var(--shadow);
        transition: transform .25s var(--ease), border-color .2s, background .2s;
        animation: rise .7s var(--ease) both; }
.chip:nth-child(1) { animation-delay: .22s; } .chip:nth-child(2) { animation-delay: .28s; }
.chip:nth-child(3) { animation-delay: .34s; } .chip:nth-child(4) { animation-delay: .40s; }
.chip:nth-child(5) { animation-delay: .46s; } .chip:nth-child(6) { animation-delay: .52s; }
.chip:hover { transform: translateY(-2px); border-color: var(--gold); }
.chip:active { transform: scale(.97); background: var(--gold-soft); }

/* ── messages ───────────────────────────────────────── */
.thread { list-style: none; margin: 0; padding: 0; }
.msg { display: flex; gap: 10px; margin: 0 0 16px; animation: rise .55s var(--ease) both; }
.msg.user { justify-content: flex-end; }
.msg.restored { animation: none; }
.msg-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; object-position: 62% 22%;
              flex: none; margin-top: 2px; border: 1px solid var(--line); }
.msg-main { min-width: 0; max-width: min(100%, 580px); }
.bubble { padding: 12px 16px; border-radius: 20px; overflow-wrap: anywhere; }
.assistant .bubble { background: var(--surface-solid); border: 1px solid var(--line);
                     border-top-left-radius: 7px; box-shadow: var(--shadow); }
.user .bubble { max-width: min(84%, 520px); color: var(--on-gold); border-bottom-right-radius: 7px;
                background: linear-gradient(135deg, var(--user-a), var(--user-b));
                box-shadow: 0 12px 26px -16px var(--user-b); white-space: pre-wrap; }
.bubble p { margin: 0 0 .65em; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0 0 .65em; padding-left: 1.2em; }
.bubble li { margin: .2em 0; } .bubble li::marker { color: var(--gold); }
.bubble strong { font-weight: 650; }
.bubble a { color: var(--gold-deep); text-underline-offset: 2px; font-weight: 600; }
.bubble.error { border-color: rgba(190, 90, 70, .4); }
.caret::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 4px; border-radius: 50%;
                background: var(--gold); vertical-align: baseline; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }

.thinking { display: flex; gap: 6px; align-items: center; height: 1.55em; padding: 0 2px; }
.thinking i { width: 8px; height: 8px; border-radius: 50%;
              background: linear-gradient(135deg, var(--user-a), var(--user-b));
              animation: pearl 1.3s ease-in-out infinite; }
.thinking i:nth-child(2) { animation-delay: .16s; } .thinking i:nth-child(3) { animation-delay: .32s; }
@keyframes pearl { 0%, 70%, 100% { transform: translateY(0) scale(.8); opacity: .4; }
                   35% { transform: translateY(-5px) scale(1); opacity: 1; } }

/* photos under an answer */
.photos { display: flex; align-items: flex-start; gap: 10px; margin-top: 10px; padding: 2px 2px 8px; overflow-x: auto;
          scroll-snap-type: x proximity; scrollbar-width: none; }
.photos::-webkit-scrollbar { display: none; }
.photo { flex: none; padding: 0; text-align: left; border-radius: 18px; overflow: hidden; scroll-snap-align: start;
         background: var(--surface-solid); border: 1px solid var(--line); box-shadow: var(--shadow);
         transition: transform .3s var(--ease), box-shadow .3s; animation: rise .6s var(--ease) both; }
.photo:nth-child(2) { animation-delay: .08s; } .photo:nth-child(3) { animation-delay: .16s; }
.photo:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.photo img { width: 100%; height: 168px; object-fit: cover; object-position: 50% 30%; background: #fff; }
.photo.fit img { object-fit: contain; object-position: 50% 50%; }
.photo span { display: block; padding: 9px 12px 11px; font: 500 italic 1.02rem/1.25 var(--serif); color: var(--ink-soft); }
.photo-note { margin: 0 2px; font-size: .72rem; color: var(--ink-faint); }

/* buttons under an answer */
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; animation: rise .5s var(--ease) both; }
.action { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px;
          border: 1px solid var(--line); background: var(--surface-solid); color: var(--gold-deep);
          font-size: .86rem; font-weight: 600; text-decoration: none;
          transition: transform .25s var(--ease), border-color .2s; }
.action svg { width: 15px; height: 15px; }
.action:hover { transform: translateY(-1px); border-color: var(--gold); }

@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ── composer ───────────────────────────────────────── */
.composer { padding: 10px max(14px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
.composer-field { display: flex; align-items: flex-end; gap: 8px; max-width: 720px; margin: 0 auto;
                  padding: 6px 6px 6px 18px; border-radius: 26px; background: var(--surface-solid);
                  border: 1px solid var(--line); box-shadow: var(--shadow);
                  transition: border-color .2s, box-shadow .3s; }
.composer-field:focus-within { border-color: var(--gold); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 16%, transparent), var(--shadow); }
#input { flex: 1; min-width: 0; resize: none; border: 0; outline: 0; background: transparent;
         padding: 9px 0; max-height: 132px; font-size: 16px; line-height: 1.4; }
#input::placeholder { color: var(--ink-faint); }
#send { width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; display: grid; place-items: center;
        color: var(--on-gold); background: linear-gradient(135deg, var(--user-a), var(--user-b));
        box-shadow: 0 8px 18px -8px var(--user-b);
        transition: transform .25s var(--ease), opacity .2s, filter .2s; }
#send svg { stroke-width: 2.2; }
#send:disabled { opacity: .35; filter: grayscale(.4); cursor: default; box-shadow: none; }
#send:not(:disabled):hover { transform: translateY(-1px) scale(1.04); }
#send:not(:disabled):active { transform: scale(.92); }
.fineprint { margin: 7px 0 0; text-align: center; font-size: .7rem; color: var(--ink-faint); }

/* ── sheet and lightbox ─────────────────────────────── */
dialog { border: 0; padding: 0; color: var(--ink); background: transparent; max-width: none; max-height: none; }
dialog::backdrop { background: rgba(30, 20, 12, .46); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
                   animation: fade-in .3s both; }
.sheet { width: min(100%, 460px); margin: auto auto 0; }
.sheet-body { position: relative; background: var(--surface-solid); border-radius: 28px 28px 0 0;
              padding: 28px 24px calc(26px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lift);
              animation: sheet-up .45s var(--ease) both; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) { .sheet { margin: auto; } .sheet-body { border-radius: 28px; } }
.sheet .details { margin-top: 20px; }
.sheet-close { position: absolute; top: 14px; right: 14px; width: 38px; height: 38px; border-radius: 50%;
               border: 1px solid var(--line); background: var(--surface-solid); color: var(--ink-soft);
               display: grid; place-items: center; }

.lightbox { width: 100vw; height: var(--app-h); }
.lightbox[open] { display: grid; place-items: center; padding: 60px 14px 96px; }
.lightbox figure { margin: 0; display: grid; justify-items: center; gap: 12px; min-width: 0;
                   animation: zoom-in .4s var(--ease) both; }
@keyframes zoom-in { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.lightbox img { max-width: 100%; max-height: calc(var(--app-h) - 250px); width: auto; min-width: min(80vw, 520px);
                object-fit: contain; border-radius: 18px; background: #fff; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .6); }
.lightbox figcaption { font: 500 italic 1.25rem/1.3 var(--serif); color: #FBF3E9; text-align: center; padding: 0 12px; }
.lb-nav { position: absolute; bottom: calc(26px + env(safe-area-inset-bottom)); width: 48px; height: 48px;
          border-radius: 50%; border: 0; display: grid; place-items: center;
          background: rgba(255, 250, 244, .16); color: #FBF3E9; }
.lb-prev { left: calc(50% - 58px); } .lb-next { left: calc(50% + 10px); }
.lb-nav:disabled { visibility: hidden; }
.lightbox .sheet-close { top: calc(10px + env(safe-area-inset-top)); background: rgba(255, 250, 244, .16); color: #FBF3E9; border: 0; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
#input:focus-visible { outline: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important;
                           transition-duration: .001s !important; }
  .scroll { scroll-behavior: auto; }
}
