:root {
  color-scheme: dark;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --ink: #fff7ed;
  --muted: #eee5df;
  --dim: #d2c6c3;
  --gold: #f6deb2;
  --border: #f2dfcb5c;
  --glass-edge: #fff0d79c;
  --glass-depth: inset 0 1px 0 #ffeddb38, inset 0 -1px 1px #f9d6af27,
    inset 0 0 22px #f2dec41a, 0 10px 28px #17131f47;
  --serif: "Songti SC", "Noto Serif CJK SC", "SimSun", serif;
  --dorm-night: url("/assets/dorm-night.webp");
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: #22212e; }
body {
  margin: 0; min-height: 100svh; color: var(--ink);
  background: radial-gradient(ellipse at 50% 30%, #4b4559, #22212e 74%) fixed;
}
button, textarea, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
img { display: block; width: 100%; }
h1, h2, p, figure { margin: 0; }
.device {
  width: min(100%, 476px);
  min-height: 100svh;
  margin: 0 auto;
  position: relative;
  isolation: isolate;
  background:
    linear-gradient(180deg, #221d2b05, #2c25351c 70%, #211e2c38),
    url("/assets/glass-ambient.webp") center top / 100% max(100svh, 100%) no-repeat,
    #3b3746;
  box-shadow: 0 0 100px #17141e90;
}
.screen {
  position: relative;
  padding: max(14px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom));
}
.glass {
  border: 1px solid var(--border);
  border-top-color: var(--glass-edge);
  background: linear-gradient(152deg, #ffeddb32 0%, #cfc7d126 42%, #d9c5ca1e 77%, #fff0dc33 100%),
    #4b405536;
  box-shadow: var(--glass-depth);
  -webkit-backdrop-filter: blur(23px) saturate(138%);
  backdrop-filter: blur(23px) saturate(138%);
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid #f1e2d685;
  border-radius: 999px;
  background: linear-gradient(160deg, #ede1dd3d, #a6a1b31c 45%, #e8d9d32e), #362d4736;
  color: var(--ink);
  box-shadow: inset 0 1px 0 #fff4e541, inset 0 -2px 8px #f5dfcd25, 0 3px 12px #25202e45;
  font-size: .9rem;
}
.button:hover { border-color: #f6dfbb; }
.button--gold {
  color: #36251c;
  border-color: #fff2d3;
  background: radial-gradient(ellipse at 23% 5%, #fff7e0 0%, transparent 55%),
    linear-gradient(115deg, #c79b65 0%, #efd2a5 49%, #fff0cc 76%, #d6ae7b 100%);
  box-shadow: inset 0 1px 2px #fff9e8d0, inset 0 -2px 9px #b8874f40,
    0 0 15px #ffd4954f, 0 5px 16px #25202e55;
  font-weight: 650;
}
.button--wide { width: 100%; min-height: 48px; }
.button--icon { width: 44px; padding: 0; font-size: 1.55rem; }
.button--text { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.status-dot {
  display: inline-block; width: 7px; height: 7px; margin-inline-end: 4px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 8px #f6d899;
}
.status-dot--green { background: #83deb1; box-shadow: 0 0 8px #83deb17a; }

.setup { display: grid; gap: 12px; padding-top: max(26px, env(safe-area-inset-top)); }
.setup-heading { text-align: center; position: relative; z-index: 1; }
.setup-heading h1 {
  font: 500 clamp(2.35rem, 10vw, 3.1rem)/1.15 var(--serif);
  letter-spacing: .16em;
  color: #fff4df;
  text-shadow: 0 0 19px #eac09478;
}
.setup-heading p { margin-top: 6px; font-size: .81rem; color: var(--muted); letter-spacing: .08em; }
.portrait-view {
  position: relative;
  overflow: hidden;
  container-type: size;
  background: var(--dorm-night) center var(--portrait-focus, 36%) / cover no-repeat #514148;
}
.portrait-frame {
  position: absolute;
  width: 100%;
  width: max(100%, 80cqh);
  aspect-ratio: 4 / 5;
  top: var(--portrait-focus, 36%);
  left: 50%;
  transform: translate(var(--portrait-shift, -50%), calc(0% - var(--portrait-focus, 36%)))
    scale(var(--portrait-scale, 1));
  background-repeat: no-repeat;
  transition: transform .35s ease;
}
.portrait-frame--animated::before, .portrait-frame--animated::after {
  position: absolute;
  pointer-events: none;
  visibility: hidden;
  transform: translate(-50%, -50%);
  -webkit-mask-image: radial-gradient(ellipse closest-side, black 61%, transparent 100%);
  mask-image: radial-gradient(ellipse closest-side, black 61%, transparent 100%);
}
.portrait-frame--animated::before, .portrait-frame--animated::after {
  content: "";
  width: 16%;
  height: 9%;
  background: var(--blink-atlas, none) 0 0 / 200% 100% no-repeat;
}
.portrait-frame--animated::before { left: 42.5%; top: 38.2%; }
.portrait-frame--animated::after { left: 62.5%; top: 40.5%; background-position: 100% 0; }
.portrait-frame--animated[data-blink="true"]::before,
.portrait-frame--animated[data-blink="true"]::after { visibility: visible; }
.setup-visual {
  height: clamp(158px, 27svh, 246px);
  margin: 1px 1px -34px;
  border: 1px solid #e2d2f061;
  border-radius: 27px;
  background:
    linear-gradient(180deg, transparent 62%, #302a3b6e),
    url("/assets/selection-night-mist.webp") center 35% / cover no-repeat #3d354f;
  box-shadow: inset 0 0 28px #17122156, 0 0 26px #cdb3ed23;
}
.setup-card { z-index: 1; border-radius: 25px; padding: 16px; display: grid; gap: 12px; }
.setup-card h2 { font: 600 1.2rem/1.4 var(--serif); letter-spacing: .02em; }
.photo-picker {
  position: relative; min-height: 53px; display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border: 1px dashed #f2d7b268; border-radius: 12px;
  background: linear-gradient(120deg, #e9c8b023, #312c453f); color: #f7e5d2; cursor: pointer; font-size: .83rem;
}
.photo-picker:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }
.photo-picker img, .photo-symbol {
  width: 35px; height: 35px; flex: 0 0 35px; border-radius: 8px; object-fit: cover;
}
.photo-symbol { display: grid; place-items: center; background: #e5c7a128; font-size: 1.15rem; }
.photo-picker img:not([hidden]) + .photo-symbol { display: none; }
.photo-picker input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.photo-actions { display: flex; align-items: center; justify-content: space-between; gap: 7px; color: var(--muted); font-size: .74rem; }
.photo-actions:has(#photo-status:empty):has(button[hidden]) { display: none; }
.photo-actions button { min-height: 38px; padding: 0 3px; color: var(--gold); font-size: .74rem; flex-shrink: 0; }
.field { display: grid; gap: 5px; }
.field > span { color: var(--ink); font-size: .82rem; }
.field small { color: var(--dim); font-size: .72rem; margin-left: 5px; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid #eedcd35c; border-radius: 11px; padding: 8px 10px;
  color: var(--ink); background: #24202f7d; resize: vertical; font-size: 1rem;
  box-shadow: inset 0 2px 7px #14101b36, 0 1px 0 #ffe5ce19;
}
.field textarea { min-height: 54px; max-height: 145px; }
input::placeholder, textarea::placeholder { color: #cdbeb6; opacity: 1; }
.hint { color: var(--muted); font-size: .75rem; line-height: 1.55; }

.small-header {
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  gap: 10px; text-align: center;
}
.small-header h2 { font: 600 1.27rem/1.2 var(--serif); letter-spacing: .08em; }
.profile { display: grid; gap: 14px; }
.profile-card { overflow: hidden; border-radius: 25px; position: relative; min-height: 280px; }
.profile-visual { height: clamp(280px, 54svh, 520px); }
.profile-card figcaption {
  position: absolute; inset: auto 0 0; padding: 46px 16px 19px;
  background: linear-gradient(transparent, #211923ed); text-align: center;
}
.profile-card h2 { font: 600 1.9rem/1.3 var(--serif); color: #fff1d7; }
.profile-card p { margin-top: 5px; color: var(--muted); font-size: .8rem; }
.profile-details { border-radius: 14px; padding: 12px 14px; line-height: 1.6; font-size: .87rem; overflow-wrap: anywhere; }
.profile-details .hint { margin-top: 3px; }

.incoming {
  min-height: 100dvh; padding: max(28px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
  display: grid; grid-template-rows: auto 1fr; justify-items: center; align-items: center; gap: 24px;
}
.incoming-time {
  color: #fff2d9; font: 500 1rem/1.15 var(--serif);
  letter-spacing: .08em; text-shadow: 0 0 14px #f7d2a179;
}
.incoming-time time { font-size: 1.52rem; font-variant-numeric: tabular-nums; }
.incoming-card {
  position: relative; isolation: isolate; overflow: hidden;
  width: 100%; border-radius: 30px; text-align: center;
  padding: clamp(30px, 6svh, 58px) 22px clamp(28px, 5svh, 45px);
  border-color: #f2dfc698; border-top-color: #fff0d9dc;
  box-shadow: var(--glass-depth), 0 0 25px #efbe853c, inset 0 0 28px #ffd3a02b;
}
.incoming-card::before {
  content: ""; position: absolute; inset: -22px; z-index: -1; opacity: .65;
  background: radial-gradient(ellipse at 91% 57%, #e9bb7e55, transparent 32%),
    linear-gradient(180deg, #332c40b0 5%, #51445934 58%, #41364f9e),
    var(--dorm-night) 72% 43% / cover;
  filter: blur(14px) saturate(.7);
}
.incoming-card::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: url("/assets/glass-ribbon.webp") left -13px top -13px / 100% 115px no-repeat,
    url("/assets/glass-ribbon.webp") right -20px bottom -21px / 110% 120px no-repeat;
  opacity: .8;
}
.incoming-card h2 {
  font: 500 2.18rem/1.2 var(--serif); letter-spacing: .14em;
  overflow-wrap: anywhere; text-shadow: 0 0 16px #f6d4a94f;
}
.incoming-state {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 10px 0 22px; font: 500 .96rem/1.35 var(--serif); color: #ffe9c9; letter-spacing: .08em;
}
.incoming-state::before, .incoming-state::after {
  content: ""; width: 30px; height: 1px; background: linear-gradient(90deg, transparent, #e9c6997d);
}
.incoming-state::after { transform: scaleX(-1); }
.portrait-ring {
  position: relative; width: min(100%, 229px); aspect-ratio: 1; border-radius: 50%; margin: 0 auto;
  padding: 2px; background: conic-gradient(from -54deg, #fff3d7, #b88656, #fff4de 44%, #c99f69, #fff3d7);
  box-shadow: 0 0 20px #f7cd9170, 0 12px 28px #31243765;
}
.portrait-ring::after {
  content: ""; position: absolute; inset: -6px -4px -4px -6px;
  border: 1px solid #e7cba16e; border-bottom-color: #fff2d4be; border-radius: 50%;
  transform: rotate(-12deg) scaleX(1.012); pointer-events: none;
}
.incoming-visual { --portrait-focus: 35%; height: 100%; border-radius: 50%; }
.incoming-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: clamp(24px, 4.6svh, 40px); }
.incoming-actions .button { font: 600 1rem/1.15 var(--serif); }
#choose-another { margin-top: 9px; }

.call {
  min-height: 100dvh;
  display: flex; flex-direction: column; gap: 9px;
}
.clocks {
  margin: 4px 6px 3px; border-radius: 38px; text-align: center; padding: 10px 10px 9px;
  background: url("/assets/glass-ribbon.webp") center bottom -31px / 100% 58px no-repeat,
    linear-gradient(158deg, #fbecdc2c, #bdb2c12d 49%, #f2d3b339), #37304341;
}
.clock-primary {
  color: #fff3dd; font: 500 clamp(1.17rem, 5.45vw, 1.65rem)/1.18 var(--serif);
  letter-spacing: .065em; text-shadow: 0 0 11px #f8c99283; white-space: nowrap;
}
.clock-primary strong { font-variant-numeric: tabular-nums; }
.clock-secondary {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  margin-top: 5px; padding-top: 5px; color: var(--muted); font-size: .72rem;
  background: linear-gradient(90deg, transparent, #e7d3c260 38%, #e7d3c260 62%, transparent) center top / 88% 1px no-repeat;
}
.clock-secondary i { width: 1px; height: 11px; background: #d4bcb465; margin: 0 4px; }
.clock-secondary b { color: #ffbfbd; font-weight: 650; }
.call-scene {
  isolation: isolate;
  flex: 0 0 auto; height: clamp(234px, calc(100dvh - 335px), 570px); min-height: 234px;
  overflow: hidden; position: relative; border: 1px solid #f6e4cb9c; border-radius: 18px;
  background: #514148; box-shadow: 0 0 19px #ecb98038, 0 6px 26px #21172454;
}
.call-art { position: absolute; inset: 0; }
.call-motion-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center 36%;
  opacity: 0; pointer-events: none; transition: opacity .6s ease;
}
.call-motion-video[data-visible="true"] { opacity: 1; }
.call-motion-video[data-loading="true"]:not([data-visible="true"]) { opacity: .001; }
.call-scene[data-action="lean_closer"] .portrait-frame { --portrait-scale: 1.035; }
.call-scene[data-action="look_away"] .portrait-frame { --portrait-shift: -50.45%; --portrait-scale: 1.012; }
.call-scene::after {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: url("/assets/glass-ribbon.webp") center bottom -21px / 120% 80px no-repeat,
    linear-gradient(#17111b68, transparent 23%, transparent 76%, #241a2b45);
  box-shadow: inset 0 0 14px #ffe2c842, inset 0 -1px 0 #fff1d495;
}
.scene-top {
  z-index: 1; position: absolute; inset: 10px 10px auto; display: flex; justify-content: space-between;
  color: #fff5e9; font-size: .75rem; text-shadow: 0 1px 5px #140d1c;
}
.scene-top > span {
  border: 1px solid #f3e1c554; border-radius: 999px; padding: 5px 9px;
  background: #28203087; box-shadow: inset 0 1px 0 #fff0d62b;
  -webkit-backdrop-filter: blur(11px); backdrop-filter: blur(11px);
}
.scene-top > span:first-child { flex-shrink: 0; }
.scene-top > span:last-child { max-width: 65%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bond-stage {
  position: absolute; z-index: 1; left: 9px; bottom: 9px;
  border: 1px solid #f3e1c554; border-radius: 999px; padding: 7px 10px;
  background: #282030b8; color: #fff5e9; font-size: .75rem;
  -webkit-backdrop-filter: blur(11px); backdrop-filter: blur(11px);
}
.history { position: absolute; z-index: 2; inset: auto 9px 9px; }
.history summary {
  list-style: none; cursor: pointer; width: fit-content; margin-left: auto;
  border: 1px solid #f3d8af78; border-radius: 999px; color: var(--ink);
  background: linear-gradient(140deg, #f5d9bd36, #25202f91), #3b3245a8;
  -webkit-backdrop-filter: blur(13px); backdrop-filter: blur(13px);
  padding: 8px 12px; font-size: .75rem; box-shadow: var(--glass-depth);
}
.history summary::-webkit-details-marker { display: none; }
.history[open] summary { margin-bottom: 6px; }
.history-list {
  display: flex; flex-direction: column; gap: 7px; overflow: auto; overscroll-behavior: contain;
  max-height: min(29dvh, 260px); min-height: 60px; padding: 10px;
  border: 1px solid #ead2b478; border-radius: 14px;
  background: linear-gradient(155deg, #64596de8, #2b2335e8);
  -webkit-backdrop-filter: blur(22px); backdrop-filter: blur(22px);
}
.message {
  max-width: 87%; overflow-wrap: anywhere; white-space: pre-wrap;
  padding: 7px 9px; border-radius: 11px; font-size: .82rem; line-height: 1.5;
}
.message--assistant { align-self: flex-start; background: #b4a6be38; border: 1px solid #eedee140; }
.message--user { align-self: flex-end; background: linear-gradient(143deg, #faecd3, #e2be92); color: #302225; }
.message:has(img) { max-width: min(87%, 210px); }
.message img {
  display: block; width: auto; max-width: 100%; max-height: 150px;
  object-fit: contain; border-radius: 8px;
}
.message button:has(img) { display: block; border: 0; padding: 0; background: transparent; }
.message :is(button, img) + :not(button, img) { margin-top: 4px; }
.dialogue {
  flex: 0 0 auto; border-left: 1px solid #fff0d7b8; min-height: 43px;
  padding: 4px 10px; margin: 4px 8px 0; line-height: 1.57;
  text-shadow: 0 1px 3px #211925a8;
}
.dialogue p { font-family: var(--serif); font-size: clamp(.96rem, 4.2vw, 1.07rem); white-space: pre-wrap; overflow-wrap: anywhere; }
.connection { min-height: 17px; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .74rem; }
.connection:has(#connection-status:empty):has(#speech-status:empty):not(:has(button:not([hidden]))) { display: none; }
.connection button { min-height: 24px; padding: 2px 8px; color: var(--gold); font-size: .74rem; }
.composer {
  display: grid; grid-template-columns: 42px 42px minmax(0, 1fr) 42px 43px; align-items: center;
  gap: 2px; margin-top: auto; padding: 4px 5px; border-radius: 27px;
  background: linear-gradient(153deg, #fff3e246, #cebed134 45%, #f3d8bf3d), #45394c4f;
}
.composer-tool {
  min-height: 42px; display: grid; place-items: center; padding: 0;
  border: 1px solid transparent; border-radius: 50%; background: transparent;
  color: var(--gold); font-size: 1.45rem;
}
.composer-tool:hover, .composer-tool[aria-expanded="true"] { background: #f3d9a829; }
.speech-input[aria-pressed="true"] { background: #f3d9a829; border-color: var(--gold); }
.mic-icon { position: relative; width: 14px; height: 15px; border: 1.5px solid currentColor; border-top: 0; border-radius: 0 0 9px 9px; margin-top: 2px; }
.mic-icon::before { content: ""; position: absolute; width: 6px; height: 12px; top: -3px; left: 50%; transform: translateX(-50%); border: 1.5px solid currentColor; border-radius: 6px; }
.mic-icon::after { content: ""; position: absolute; width: 1.5px; height: 4px; top: 100%; left: 50%; transform: translateX(-50%); background: currentColor; }
#speech-status:empty { display: none; }
#speech-status { color: var(--gold); }
.photo-icon {
  display: block; width: 19px; height: 15px; position: relative;
  border: 1.5px solid currentColor; border-radius: 4px;
}
.photo-icon::after {
  content: ""; position: absolute; inset: 3px 0 0; margin: 0 auto;
  border: 1.4px solid currentColor; width: 6px; height: 6px; border-radius: 50%;
}
.chat-photo-draft {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 8px;
  padding: 5px 8px 8px; border-bottom: 1px solid #e6c9a947;
}
.chat-photo-draft img { width: 55px; height: 55px; object-fit: cover; border-radius: 7px; }
.chat-photo-draft button { min-height: 40px; font-size: .75rem; }
.emoji-picker {
  grid-column: 1 / -1; display: grid; grid-template-columns: repeat(6, 1fr);
  padding: 6px 8px 4px; gap: 3px; border-top: 1px solid #e6c9a94d;
}
.emoji-picker button {
  min-height: 42px; display: grid; place-items: center; padding: 0; font-size: 1.32rem;
  border: 0; border-radius: 9px; background: #f0dac514; color: var(--ink);
}
.emoji-picker button:hover { background: #f3d9a82e; }
.image-viewer {
  width: min(93%, 560px); max-height: 89dvh; padding: 12px; border-radius: 16px;
  text-align: center; color: var(--ink);
}
.image-viewer::backdrop { background: #160f1cdb; }
.image-viewer img { max-height: 70dvh; width: auto; max-width: 100%; object-fit: contain; margin: 0 auto 10px; }
.composer textarea {
  min-height: 40px; max-height: 99px; resize: none; overflow-y: auto; padding: 9px 3px;
  field-sizing: content;
  border: 0; background: transparent; color: var(--ink); font-size: 1rem; line-height: 1.35;
}
.composer textarea:focus-visible { outline-offset: 1px; border-radius: 5px; }
.button--send { min-height: 41px; padding: 0; font-size: 1.3rem; }
.call-footer {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 3px; padding: 5px 6px; border-radius: 24px;
  background: url("/assets/glass-ribbon.webp") center top -20px / 110% 65px no-repeat,
    linear-gradient(150deg, #f5dbc530, #b6a6bd24 48%, #f3dcbd27), #3e344743;
}
.call-footer .button { min-height: 40px; font-size: .76rem; padding: 3px 4px; white-space: nowrap; }
#voice-toggle { border-color: #dfc6ac57; background: #c8b4bf20; }
#voice-toggle[aria-checked="true"] {
  color: #ffedd0; border-color: #f5dba285; background: linear-gradient(140deg, #eac3923b, #d4a77924);
  box-shadow: inset 0 0 10px #e7b98238, 0 0 11px #edba6c2c;
}
#voice-toggle[aria-checked="false"] { opacity: .72; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
@media (max-height: 700px) {
  .call-scene { height: clamp(166px, 48dvh, 350px); min-height: 166px; }
  .call { gap: 6px; }
}
@media (max-width: 500px) {
  .call:has(.composer textarea:focus, #emoji-picker:not([hidden]), #chat-photo-draft:not([hidden])) .call-scene {
    flex: 0 0 auto; height: min(35dvh, 260px); min-height: 130px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::after, *::before { transition-duration: 0s !important; }
}
