:root {
  color-scheme: light;
  --ink: #181421;
  --muted: #625a70;
  --brand: #6332dc;
  --line: #eae5f1;
  background: #fff;
  color: var(--ink);
  font: 16px/1.45 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .48; cursor: default; }
a { color: inherit; }
:focus-visible { outline: 3px solid #8758ee; outline-offset: 3px; }
.masthead, main, footer { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.masthead { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.wordmark { display: flex; align-items: center; text-decoration: none; gap: 5px; font-size: 15px; font-weight: 850; letter-spacing: .065em; white-space: nowrap; }
.wordmark-accent { color: var(--brand); }
.brand-mark { display: grid; place-items: center; margin-right: 5px; width: 31px; aspect-ratio: 1; background: #201631; color: #fff; border-radius: 10px; font-size: 24px; line-height: 1; }
.privacy-link { color: var(--muted); font-size: 13px; text-underline-offset: 4px; text-align: right; }
.hero { position: relative; isolation: isolate; overflow: hidden; text-align: center; margin: 26px 0 42px; padding: 45px 16px 51px; border: 1px solid #eee8fa; border-radius: 32px; background: #fcfaff; }
.hero-wash { position: absolute; inset: 0; z-index: -1; background: radial-gradient(ellipse at 42% 0%, #edddff 0%, transparent 58%), radial-gradient(ellipse at 97% 95%, #ffeff3 0%, transparent 50%), radial-gradient(ellipse at 5% 90%, #e6f4ff 0%, transparent 47%); }
.portrait-row { display: flex; justify-content: center; align-items: center; margin-bottom: 18px; }
.avatar { display: block; flex-shrink: 0; aspect-ratio: 1; border-radius: 50%; background: #e8ddff url('/portraits.webp') no-repeat; background-size: 400% 300%; }
.portrait-row .avatar { width: 49px; border: 2px solid #fff; margin-inline: -3px; box-shadow: 0 5px 13px #32156725; }
.portrait-row .avatar:nth-child(3) { width: 61px; z-index: 1; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2.5rem, 7vw, 5rem); font-weight: 790; line-height: 1.02; letter-spacing: -.075em; }
h1 em { font-style: normal; color: #6537cb; }
.hero p { margin-top: 15px; color: var(--muted); font-size: clamp(.88rem, 2vw, 1.06rem); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 310px); align-items: start; gap: 30px; }
.selectors { display: grid; gap: 30px; min-width: 0; }
.choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.choice { position: relative; min-width: 0; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inline-size: 1px; block-size: 1px; }
.tile { display: flex; align-items: center; gap: 8px; height: 100%; min-height: 59px; padding: 8px; border: 1px solid var(--line); border-radius: 13px; overflow-wrap: anywhere; font-size: .79rem; font-weight: 625; line-height: 1.19; transition: background .2s, border-color .2s, transform .2s; }
.choice input:checked + .tile { background: hsl(var(--hue) 100% 97%); border-color: hsl(var(--hue) 68% 58%); box-shadow: inset 0 0 0 1px hsl(var(--hue) 68% 58%); }
.choice input:focus-visible + .tile { outline: 3px solid #8758ee; outline-offset: 2px; }
.choice:active .tile { transform: scale(.98); }
select, textarea { min-width: 0; padding: 8px 10px; border: 1px solid #e3daee; background: #fff; border-radius: 9px; font-size: 1rem; }
.primary, .secondary, .hangup { border: 0; border-radius: 13px; padding: 11px 15px; min-height: 44px; font-weight: 720; transition: filter .2s, transform .2s; }
.primary { background: linear-gradient(125deg,#7041e7,#5525ca); color: #fff; box-shadow: 0 6px 16px #592bd237; }
.primary span { margin-right: .25rem; }
.primary:active, .secondary:active, .hangup:active { transform: scale(.98); }
.primary:hover { filter: brightness(1.08); }
.secondary { background: #f0e9fb; color: #49209e; }
.hangup { background: #b4244b; color: #fff; }
.text-button { border: 0; background: transparent; padding: 8px 3px; color: #5525bf; font-weight: 680; text-underline-offset: 3px; }
.text-button:hover { text-decoration: underline; }
.privacy { margin-block: 35px; border-top: 1px solid var(--line); padding-top: 18px; scroll-margin-top: 18px; }
summary { color: var(--muted); cursor: pointer; }
.memory { margin-top: 10px; display: grid; justify-items: start; gap: 10px; max-width: 33rem; }
.memory textarea { width: 100%; }
footer { display: flex; flex-wrap: wrap; column-gap: 16px; justify-content: space-between; border-top: 1px solid var(--line); padding-block: 19px max(19px,env(safe-area-inset-bottom)); color: var(--muted); font-size: .78rem; }
dialog { width: min(440px, calc(100% - 24px)); max-height: calc(var(--call-viewport-height, 100dvh) - 24px); overflow: auto; overscroll-behavior: contain; border: 1px solid #e8ddf6; border-radius: 25px; padding: 25px 20px max(25px,env(safe-area-inset-bottom)); color: var(--ink); background: linear-gradient(155deg,#f6efff,#fff 67%); text-align: center; box-shadow: 0 15px 70px #27104745; }
dialog::backdrop { background: #21143175; backdrop-filter: blur(7px); }
html:has(dialog[open]) { overflow: hidden; }
.close { position: absolute; right: 12px; top: 10px; width: 44px; height: 44px; background: transparent; border: 0; border-radius: 11px; font-size: 1.7rem; }
#call-avatar { width: 104px; margin: 5px auto 14px; box-shadow: 0 8px 20px #481d7130; }
#call-title { font-size: 1.85rem; letter-spacing: -.04em; }
#call-status { min-height: 1.45em; margin: 11px 0 16px; }
#call-panel[data-state="error"] #call-status { color: #a62245; }
#call-controls { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
#call-play { margin-top: 8px; }
#call-timer { font-variant-numeric: tabular-nums; color: #5123b5; font-weight: 700; }
.wave { display: flex; align-items: center; justify-content: center; gap: 5px; height: 52px; }
.wave i { width: 5px; height: 39px; border-radius: 9px; background: linear-gradient(#784df0,#db81e1); transform: scaleY(.26); }
[data-state="live"] .wave i { animation: wave .9s ease-in-out infinite alternate; }
.wave i:nth-child(2n) { animation-delay: -.32s; }
.wave i:nth-child(3n) { animation-delay: -.64s; }
@keyframes wave { 0% { transform: scaleY(.25); } 75%,100% { transform: scaleY(.93); } }
@media (max-width: 700px) {
  .masthead, main, footer { width: calc(100% - 32px); }
  .masthead { min-height: 60px; }
  .hero { border-radius: 24px; padding: 24px 12px 28px; margin: 17px 0 25px; }
  .hero p { margin-top: 10px; }
  .workspace { grid-template-columns: minmax(0,1fr); gap: 17px; }
  .selectors { gap: 18px; }
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .tile { min-height: 48px; }
  .privacy { margin-block: 23px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.intro { text-align: center; padding: clamp(42px, 8vh, 105px) 0 28px; }
.intro h1 { font-size: clamp(2.35rem, 7vw, 5.4rem); letter-spacing: -.065em; }
.intro p { margin: 16px 0 0; color: var(--muted); font-size: clamp(1rem, 2vw, 1.25rem); }
.companions { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; }
.companion {
  display: grid;
  justify-items: center;
  width: min(100%, 360px);
  padding: clamp(18px, 4vw, 30px);
  border: 1px solid #eee8f5;
  border-radius: 32px;
  background: radial-gradient(ellipse at 50% 7%, #f4edff, #fff 70%);
}
.companion .avatar {
  width: clamp(140px, 22vw, 195px);
  background-position: 33.333% 50%;
  border: 4px solid white;
  box-shadow: 0 9px 36px #57278e27;
}
.companion h2 { margin-top: 17px; font-size: 1.6rem; letter-spacing: -.035em; }
.companion .primary { width: min(100%, 238px); min-height: 53px; margin-top: 5px; }
.idle-wave i { animation: wave 2s ease-in-out infinite alternate; height: 23px; }
.wave.metered i { animation: none; transform: scaleY(calc(.16 + var(--level, 0) * var(--gain, .9))); transition: transform 110ms linear; }
.wave.metered i:nth-child(2n) { --gain: .63; }
.wave.metered i:nth-child(3n) { --gain: .76; }
.wave.metered i:first-child, .wave.metered i:last-child { --gain: .41; }
#home-status { text-align: center; margin-top: 14px; color: var(--muted); }
#memory-status:empty, #home-status:empty, #samples:empty { display: none; }
.memory p, .lab-section p { color: var(--muted); font-size: .9rem; }
.memory-actions, .lab-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.laboratory { padding-block: 36px; display: grid; gap: 24px; }
.laboratory h1 { font-size: clamp(2rem, 6vw, 3.8rem); overflow-wrap: anywhere; }
.lab-section { display: grid; gap: 14px; padding: clamp(14px, 3vw, 25px); border: 1px solid var(--line); border-radius: 18px; }
.lab-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 13px; }
.lab-grid label { display: grid; align-content: start; gap: 5px; }
.lab-grid audio { max-width: 100%; margin-top: 4px; }


#call-dialog.ear-mode {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #000;
  overflow: hidden;
}
.ear-mode::backdrop { background: #000; }
.ear-mode #call-panel, .ear-mode #call-close { visibility: hidden; }
#ear-shade { position: absolute; inset: 0; background: #000; touch-action: none; }
#ear-unlock {
  position: absolute;
  bottom: max(28px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  min-height: 48px;
  max-width: 90%;
  color: #b7b7bf;
  background: #14141a;
  border: 1px solid #343438;
  border-radius: 24px;
  padding: 8px 18px;
  user-select: none;
}
#call-input-label { align-self: center; }
#memory-excerpt { white-space: pre-wrap; overflow-wrap: anywhere; }
#call-panel[data-state="ringing"] .wave { opacity: .7; }
#call-panel[data-state="reconnecting"] .wave { opacity: .45; }
@media (prefers-reduced-motion: reduce) {
  #call-panel .wave i { animation: none; }
}
.memory select, #in-call-preferences select { max-width: 100%; }
#in-call-preferences { margin-top: 12px; }
#in-call-preferences label { display: block; margin-block: 8px; }
#call-panel[data-state="reconnecting"] #call-timer { opacity: .7; }

/* Public home and call screen */
body:has(.phone-call) {
  --ink: #17191f;
  --muted: #565e6b;
  --brand: #1658bc;
  --line: #e2e7ef;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: radial-gradient(ellipse at 50% 24%, #eaf2fe 0%, transparent 58%), #f8fafc;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body:has(.phone-call) :focus-visible { outline-color: #3478dc; }
body:has(.phone-call) .masthead {
  min-height: calc(64px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
}
body:has(.phone-call) .brand-mark { background: #1c2433; }
body:has(.phone-call) .privacy-link { text-decoration: none; }
body:has(.phone-call) .privacy-link:hover { text-decoration: underline; }
body:has(.phone-call) .intro { padding: clamp(32px, 7vh, 85px) 0 29px; }
body:has(.phone-call) .intro h1 { font-size: clamp(2.4rem, 7vw, 5rem); font-weight: 720; }
body:has(.phone-call) .intro p { margin-top: 12px; }
body:has(.phone-call) .companion {
  width: min(100%, 340px);
  padding: clamp(20px, 4vw, 30px);
  border: 1px solid #fff;
  border-radius: 32px;
  background: linear-gradient(155deg, #fff, #f8fbff);
  box-shadow: 0 14px 45px #263d6520, 0 2px 6px #263d650a;
  animation: ui-enter .52s cubic-bezier(.22, 1, .36, 1) both;
}
body:has(.phone-call) .companion .avatar {
  width: clamp(126px, 20vw, 164px);
  box-shadow: 0 10px 24px #1e345e24;
}
body:has(.phone-call) .companion .wave { height: 36px; }
body:has(.phone-call) .wave i { background: #6289c1; }
body:has(.phone-call) .primary {
  border-radius: 100px;
  background: #1959ba;
  box-shadow: 0 5px 15px #1959ba31;
  font-weight: 650;
}
body:has(.phone-call) .secondary { background: #e9f0fa; color: #204478; }
body:has(.phone-call) .text-button { color: var(--brand); }
body:has(.phone-call) footer { margin-top: auto; }
body:has(.phone-call) .privacy { margin-block: 18px; padding-top: 0; border: 0; }
body:has(.phone-call) .privacy details {
  max-width: 460px;
  margin: 8px auto;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
body:has(.phone-call) .privacy summary {
  padding: 12px 0;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 630;
}
body:has(.phone-call) .privacy details > p { padding-bottom: 14px; color: var(--muted); font-size: .9rem; }
body:has(.phone-call) .memory { margin-top: 0; padding-bottom: 14px; width: 100%; }
body:has(.phone-call) .memory > label:has(select) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  font-size: .9rem;
}
body:has(.phone-call) :is(select, textarea) { border-color: var(--line); background: #f7f9fc; }
body:has(.phone-call) input[type="checkbox"] { accent-color: var(--brand); }

.phone-call {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: var(--call-viewport-height, 100dvh);
  max-width: none;
  max-height: none;
  margin: 0;
  padding: max(66px, calc(env(safe-area-inset-top) + 52px))
    max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  border: 0;
  border-radius: 0;
  background: radial-gradient(ellipse at 50% 8%, #dbeafe, transparent 62%),
    linear-gradient(155deg, #f7faff, #edf2fa 70%, #f9fafc);
}
.phone-call[open] { animation: ui-enter .32s cubic-bezier(.22, 1, .36, 1) both; }
@keyframes ui-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.phone-call #call-panel { width: min(100%, 420px); margin-inline: auto; }
.phone-call #call-avatar {
  width: clamp(88px, 22vh, 180px);
  margin: clamp(0px, 4vh, 38px) auto 15px;
  border: 3px solid #fff;
  box-shadow: 0 14px 40px #2b487039;
}
.phone-call #call-title { font-size: clamp(2rem, 7vw, 3.2rem); line-height: 1.08; }
.phone-call #call-orb { height: 42px; }
.phone-call #call-orb i { height: 30px; }
.phone-call #call-timer { color: var(--muted); font-weight: 600; }
.phone-call #call-status { color: var(--muted); margin: 6px 0 18px; }
.phone-call #call-panel[data-state="error"] #call-status { color: #a62245; }
.phone-call #call-close {
  top: max(12px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 14px #263d6518;
}
.phone-call #call-controls { align-items: center; gap: 14px; }
.phone-call #call-controls button {
  position: relative;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  padding: 0;
  border-radius: 50%;
  box-shadow: 0 5px 16px #263d6520;
}
.phone-call #call-controls button:hover:not(:disabled) { filter: brightness(.94); }
.phone-call #call-controls .secondary { background: #fff; color: #25334b; font-size: 0; }
.phone-call #call-controls #call-mute[aria-pressed="true"] { background: #243650; color: #fff; }
.phone-call #call-mute::before {
  content: "";
  position: absolute;
  top: 17px;
  width: 9px;
  height: 16px;
  border-radius: 8px;
  background: currentColor;
}
.phone-call #call-mute::after {
  content: "";
  position: absolute;
  top: 23px;
  width: 17px;
  height: 15px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 12px 12px;
}
.phone-call #call-output::before {
  content: "";
  width: 24px;
  height: 23px;
  background: currentColor;
  clip-path: polygon(0 35%, 23% 35%, 53% 8%, 53% 92%, 23% 65%, 0 65%);
}
.phone-call #call-output::after {
  content: "";
  position: absolute;
  right: 17px;
  width: 9px;
  height: 18px;
  border-right: 2px solid currentColor;
  border-radius: 50%;
}
.phone-call #call-end { background: #c92e42; color: #fff; }
.phone-call #call-end span { font-size: 27px; line-height: 1; transform: rotate(135deg); }
.phone-call #call-input-label { order: 1; flex-basis: 100%; font-size: .9rem; }
.phone-call #call-input-label select { max-width: min(100%, 260px); }
.phone-call #in-call-preferences {
  width: min(100%, 340px);
  margin: 16px auto 0;
  padding: 8px 14px;
  border-radius: 18px;
  background: #ffffffc9;
  font-size: .9rem;
}
.phone-call #in-call-preferences summary { padding: 5px; }
.phone-call #live-preferences-status:empty { display: none; }
@media (max-height: 500px) and (orientation: landscape) {
  .phone-call { padding-top: max(26px, env(safe-area-inset-top)); }
  .phone-call #call-avatar { margin-top: 0; width: 74px; }
}


/* DIDI LIQUID ORB */
#companions .idle-wave,
#call-dialog #call-orb {
    --energy: 0;
    position: relative !important;
    isolation: isolate;
    overflow: hidden !important;
    display: block !important;
    width: 100px !important;
    height: 100px !important;
    min-height: 100px !important;
    flex-shrink: 0 !important;
    margin: 20px auto 24px !important;
    border-radius: 50% !important;
    border: 1px solid #ffffff;
    background: radial-gradient(
        circle at 28% 18%,
        #e7faff,
        #7197f1 52%,
        #c5a1ff 100%
    ) !important;
    box-shadow:
        0 10px 32px #7095e855,
        inset 0 0 15px #ffffff99;
    transform: scale(calc(1 + var(--energy) * .10));
    transition: transform .12s ease;
}

#call-dialog #call-orb {
    width: 116px !important;
    height: 116px !important;
    min-height: 116px !important;
}

#companions .idle-wave i,
#call-dialog #call-orb i {
    opacity: 0 !important;
}

#companions .idle-wave::before,
#call-dialog #call-orb::before {
    content: "";
    position: absolute;
    z-index: 1;
    width: 155%;
    height: 100%;
    top: 24%;
    left: -27%;
    border-radius: 43%;
    background: linear-gradient(
        130deg,
        #50dff5,
        #536bf0,
        #b17cf5,
        #f3caff
    );
    filter: blur(9px);
    animation: didi-liquid-flow 6s ease-in-out infinite alternate;
    pointer-events: none;
}

#companions .idle-wave::after,
#call-dialog #call-orb::after {
    content: "";
    position: absolute;
    z-index: 2;
    inset: -10%;
    border-radius: 50%;
    background:
        radial-gradient(
            ellipse at 25% 14%,
            #ffffffdf,
            transparent 28%
        ),
        radial-gradient(
            ellipse at 75% 65%,
            #d3a8ffbb,
            transparent 48%
        ),
        radial-gradient(
            ellipse at 30% 75%,
            #97f2ffbb,
            transparent 42%
        );
    animation: didi-liquid-light 8s ease-in-out infinite alternate;
    pointer-events: none;
}

#companions .companion {
    padding-top: 28px !important;
    padding-bottom: 32px !important;
}

@keyframes didi-liquid-flow {
    from {
        transform: rotate(-35deg) translateY(-12px);
    }
    to {
        transform: rotate(35deg)
        translateY(calc(10px + var(--energy) * 18px));
    }
}

@keyframes didi-liquid-light {
    from { transform: rotate(-20deg) scale(1); }
    to { transform: rotate(40deg) scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
    #companions .idle-wave::before,
    #companions .idle-wave::after,
    #call-dialog #call-orb::before,
    #call-dialog #call-orb::after {
        animation: none !important;
    }
}

:root {
  color-scheme: dark;
  --ink: #f5f5f5;
  --muted: #b6b6b6;
  --line: #333;
  --brand: #eee;
  color: #f5f5f5;
  background: #000;
}
#admin :is(.lab-section,.tile) { background: #000; border-color: #333; }
#admin :is(select,textarea,.primary,.secondary) { background: #151515; color: #f5f5f5; border-color: #595959; box-shadow: none; }
#admin .text-button { color: #eee; }
#admin :focus-visible { outline-color: #eee; }
