:root {
  --bg: #0a0908;
  --panel: #0f0d0b;
  --text: #f2e9df;
  --muted: #b5a398;
  --muted-2: #75665c;
  --line: rgba(241, 225, 207, 0.1);
  --line-soft: rgba(241, 225, 207, 0.06);
  --amber: #d9a074;
  --amber-bright: #f0c29d;
  --green: #3ddb72;
  --green-deep: #1eae52;
  --red: #ff5148;
  --red-deep: #d8322a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "STSong", "Songti TC", serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  min-height: 100%;
}

body {
  min-height: 100dvh;
  margin: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(62% 52% at 50% 4%, rgba(126, 79, 48, 0.18), transparent 72%),
    radial-gradient(46% 42% at 86% 100%, rgba(118, 74, 43, 0.08), transparent 70%),
    #080706;
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(44% 42% at 50% 27%, rgba(203, 146, 101, 0.12), transparent 70%),
    linear-gradient(180deg, rgba(9, 8, 7, 0) 0%, rgba(4, 4, 3, 0.5) 100%);
}

.grain {
  position: fixed;
  inset: -20%;
  z-index: 1;
  pointer-events: none;
  opacity: 0.14;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 220 220' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.86' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.46'/%3E%3C/svg%3E");
  background-size: 170px 170px;
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ */
/* 手机容器 / 屏幕                                                     */
/* ------------------------------------------------------------------ */

.app {
  position: relative;
  z-index: 2;
  width: min(430px, calc(100vw - 32px));
  height: min(860px, calc(100dvh - 40px));
  overflow: hidden;
  isolation: isolate;
  border: 1px solid rgba(241, 225, 207, 0.11);
  border-radius: 46px;
  background:
    radial-gradient(90% 52% at 50% 0%, rgba(69, 50, 36, 0.32), transparent 70%),
    linear-gradient(180deg, #12100e 0%, #0b0a08 64%, #080706 100%);
  box-shadow:
    0 50px 110px -34px rgba(0, 0, 0, 0.9),
    0 20px 46px -26px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 245, 232, 0.06);
}

.app::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(52% 32% at 50% 28%, rgba(192, 126, 75, 0.1), transparent 72%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 24%);
}

.app::after {
  content: "";
  position: absolute;
  z-index: 4;
  top: 9px;
  left: 50%;
  width: 92px;
  height: 25px;
  border-radius: 999px;
  background: #080706;
  transform: translateX(-50%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.035), inset 0 -1px 3px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  padding:
    calc(var(--safe-top) + 34px)
    28px
    calc(var(--safe-bottom) + 26px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(7px);
  transition:
    opacity 0.42s ease,
    visibility 0.42s ease,
    transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

body[data-phase="idle"] .screen--dial,
body[data-phase="connecting"] .screen--dial,
body[data-phase="live"] .screen--call,
body[data-phase="closing"] .screen--call {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

/* ------------------------------------------------------------------ */
/* 拨号                                                               */
/* ------------------------------------------------------------------ */

.screen--dial {
  align-items: center;
  text-align: center;
}

.dial-top {
  width: 100%;
  display: flex;
  justify-content: center;
  padding-top: 13px;
}

.eyebrow {
  color: var(--muted-2);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
}

.dial-portrait {
  width: clamp(190px, 55vw, 238px);
  height: clamp(190px, 55vw, 238px);
  margin-top: auto;
  margin-bottom: clamp(24px, 4.4vh, 38px);
}

.portrait-wrap {
  position: relative;
  display: grid;
  place-items: center;
}

.halo {
  position: absolute;
  inset: -24%;
  border-radius: 50%;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 44%, rgba(224, 166, 118, 0.3) 0%, rgba(156, 97, 57, 0.12) 34%, transparent 68%);
  filter: blur(19px);
  opacity: 0.92;
  transform: scale(calc(1 + var(--level, 0) * 0.16 + var(--speak, 0) * 0.04));
  transition: transform 0.18s ease-out, opacity 0.5s ease;
}

.portrait-ring {
  position: absolute;
  inset: 5%;
  border: 1px solid rgba(236, 206, 177, 0.16);
  border-radius: 50%;
  pointer-events: none;
}

.portrait-ring::after {
  content: "";
  position: absolute;
  inset: 9%;
  border: 1px solid rgba(236, 206, 177, 0.07);
  border-radius: 50%;
}

.portrait {
  position: relative;
  z-index: 1;
  width: 82%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(244, 218, 193, 0.13);
  border-radius: 50%;
  background:
    radial-gradient(circle at 42% 32%, rgba(247, 211, 178, 0.24) 0%, transparent 34%),
    radial-gradient(circle at 47% 45%, #4a3528 0%, #2e2119 46%, #160f0c 100%);
  box-shadow:
    0 27px 52px -22px rgba(0, 0, 0, 0.9),
    0 0 46px rgba(184, 119, 73, 0.14),
    inset 0 0 0 8px rgba(247, 225, 203, 0.025),
    inset 0 -18px 34px rgba(0, 0, 0, 0.45);
  transition: transform 0.16s ease-out, filter 0.4s ease;
}

.portrait::before {
  content: "";
  position: absolute;
  inset: 14% 20% 20%;
  border-radius: 52% 48% 46% 54%;
  background:
    radial-gradient(circle at 44% 28%, rgba(242, 208, 177, 0.16), transparent 44%),
    linear-gradient(160deg, rgba(220, 170, 130, 0.08), rgba(85, 48, 30, 0.18));
  filter: blur(7px);
  transform: rotate(-8deg);
}

.portrait::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.09), transparent 30%),
    radial-gradient(circle at 50% 105%, rgba(0, 0, 0, 0.5), transparent 54%);
  pointer-events: none;
}

.portrait span {
  position: relative;
  z-index: 2;
  margin-top: 2%;
  color: rgba(248, 230, 211, 0.93);
  font-family: var(--serif);
  font-size: clamp(54px, 16vw, 74px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.08em;
  text-indent: -0.08em;
  text-shadow:
    0 2px 20px rgba(20, 11, 7, 0.6),
    0 0 30px rgba(234, 193, 156, 0.16);
}

.dial-id {
  width: 100%;
  margin-bottom: auto;
}

.dial-id h1 {
  margin: 0;
  color: #f6ede4;
  font-family: var(--serif);
  font-size: clamp(32px, 9vw, 38px);
  font-weight: 400;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  line-height: 1.12;
}

.status {
  min-height: 1.4em;
  margin: 17px 0 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.05em;
}

.hint {
  min-height: 1.4em;
  margin: 7px 0 0;
  color: var(--muted-2);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.dial-actions {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(44px, 16vw, 68px);
  margin-top: 10px;
}

.call-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  font-family: inherit;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.call-action__icon {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  transition: transform 0.16s ease, box-shadow 0.25s ease, filter 0.25s ease;
}

.call-action__icon svg {
  width: 27px;
  height: 27px;
  fill: currentColor;
}

.call-action--decline .call-action__icon {
  background: linear-gradient(155deg, #ff625a, #d8312a);
  box-shadow:
    0 15px 28px -12px rgba(231, 49, 42, 0.62),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.call-action--accept {
  color: #b6cfb9;
}

.call-action--accept .call-action__icon {
  background: linear-gradient(155deg, #55e783, #1bb54f);
  box-shadow:
    0 15px 32px -12px rgba(38, 205, 93, 0.54),
    inset 0 1px 0 rgba(255, 255, 255, 0.34);
  animation: acceptGlow 3s ease-in-out infinite;
}

.call-action--accept:disabled {
  cursor: default;
  color: var(--muted-2);
}

.call-action--accept:disabled .call-action__icon {
  animation: none;
  filter: saturate(0.58) brightness(0.78);
}

.call-action:active .call-action__icon {
  transform: scale(0.92);
}

.call-action__label {
  color: currentColor;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
}

.dial-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 27px;
  color: #5e5149;
  font-size: 10px;
  letter-spacing: 0.13em;
  text-indent: 0.13em;
}

.foot-dot {
  color: #4e433c;
}

/* ------------------------------------------------------------------ */
/* 通话                                                               */
/* ------------------------------------------------------------------ */

.screen--call {
  padding-right: 24px;
  padding-left: 24px;
}

.call-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  width: 100%;
  padding-top: 9px;
}

.call-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(61, 219, 114, 0.08);
  animation: livePulse 2.4s ease-in-out infinite;
}

body[data-phase="closing"] .live-dot {
  background: var(--amber);
  animation: none;
}

.call-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text);
}

.call-title strong {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
}

.call-title small {
  color: var(--muted-2);
  font-size: 10px;
  letter-spacing: 0.13em;
  text-indent: 0.13em;
}

.call-head-spacer {
  justify-self: end;
  width: 38px;
}

.call-stage {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 4vh, 42px);
  min-height: 0;
  padding-bottom: 2vh;
}

.call-portrait {
  width: clamp(206px, 58vw, 256px);
  height: clamp(206px, 58vw, 256px);
}

.halo--call {
  inset: -27%;
  opacity: 0.8;
}

.orb {
  --level: 0;
  --speak: 0;
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.orb .ring {
  position: absolute;
  border: 1px solid rgba(240, 200, 166, 0.12);
  border-radius: 50%;
  pointer-events: none;
}

.orb .ring--outer {
  inset: 0;
  opacity: 0.7;
}

.orb .ring--inner {
  inset: 8%;
  border-color: rgba(240, 200, 166, 0.17);
  opacity: 0.6;
}

body[data-phase="live"] .orb[data-speak="1"] .ring--outer,
body[data-phase="live"] .orb[data-speak="1"] .ring--inner {
  animation: voiceRing 2.1s ease-out infinite;
}

body[data-phase="live"] .orb[data-speak="1"] .ring--inner {
  animation-delay: 0.36s;
}

.orb .portrait {
  width: 76%;
  transform: scale(calc(1 + var(--level) * 0.045 + var(--speak) * 0.014));
  transition: transform 0.14s ease-out;
}

.portrait-ring--call {
  inset: -4%;
  opacity: 0.5;
}

.portrait-ring--call::after {
  inset: 6%;
  opacity: 0.55;
}

.call-hint {
  min-height: 1.5em;
  max-width: 270px;
  margin: 0;
  color: var(--muted-2);
  font-size: 11.5px;
  line-height: 1.55;
  letter-spacing: 0.04em;
  text-align: center;
}

.call-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-bottom: 1px;
}

.call-controls {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(42px, 14vw, 60px);
}

.call-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  font-family: inherit;
  cursor: pointer;
}

.call-control__icon {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(241, 225, 207, 0.12);
  border-radius: 50%;
  color: rgba(242, 233, 223, 0.84);
  background: rgba(242, 233, 223, 0.065);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.16s ease, background 0.2s ease, color 0.2s ease;
}

.call-control__icon svg {
  width: 25px;
  height: 25px;
  fill: currentColor;
}

.call-control__label {
  color: currentColor;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-indent: 0.1em;
}

.call-control:active .call-control__icon {
  transform: scale(0.93);
}

.call-control.is-active .call-control__icon,
.call-control.is-muted .call-control__icon {
  color: #2a1510;
  background: #f1e2d4;
  border-color: transparent;
}

.call-control--hangup .call-control__icon {
  width: 66px;
  height: 66px;
  border: 0;
  color: #fff;
  background: linear-gradient(155deg, #ff625a, #d8312a);
  box-shadow:
    0 16px 30px -13px rgba(231, 49, 42, 0.62),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.call-control--hangup .call-control__label {
  color: #db837d;
}

.call-metrics {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #5f524a;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

/* ------------------------------------------------------------------ */
/* 字幕：能力保留，前端不展示                                           */
/* ------------------------------------------------------------------ */

.transcript {
  display: none !important;
}

/* ------------------------------------------------------------------ */
/* 结束 / 汇总                                                         */
/* ------------------------------------------------------------------ */

.modal {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(7, 6, 5, 0.7);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}

.modal-card {
  width: min(320px, 100%);
  padding: 0;
  text-align: center;
  animation: cardIn 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-kicker {
  margin: 0;
  color: var(--muted-2);
  font-size: 10.5px;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
}

.modal-card h2 {
  margin: 16px 0 8px;
  color: #f1e4d6;
  font-family: var(--serif);
  font-size: 48px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  line-height: 1;
}

.modal-cost {
  margin: 0;
  color: var(--muted-2);
  font-size: 11.5px;
}

.modal-cost strong {
  color: var(--muted);
  font-weight: 500;
}

.modal-note {
  margin: 17px 0 25px;
  color: #5f5149;
  font-size: 10.5px;
  line-height: 1.7;
}

.modal-btn {
  width: min(214px, 100%);
  height: 52px;
  border: 1px solid rgba(241, 225, 207, 0.13);
  border-radius: 999px;
  color: #21130d;
  background: linear-gradient(155deg, #f6e5d5, #d9b89e);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  box-shadow: 0 16px 30px -14px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.2s ease;
}

.modal-btn:active {
  transform: scale(0.96);
}

/* ------------------------------------------------------------------ */
/* Toast / 无脚本                                                      */
/* ------------------------------------------------------------------ */

.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: max(96px, calc(var(--safe-bottom) + 92px));
  max-width: min(390px, calc(100vw - 44px));
  padding: 10px 17px;
  border: 1px solid rgba(241, 225, 207, 0.1);
  border-radius: 999px;
  color: #e8d9cd;
  background: rgba(24, 19, 16, 0.9);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(16px);
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
  transform: translateX(-50%);
  animation: toastIn 0.22s ease-out;
}

.noscript {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
}

/* ------------------------------------------------------------------ */
/* 动画                                                               */
/* ------------------------------------------------------------------ */

@keyframes acceptGlow {
  0%,
  100% {
    box-shadow:
      0 15px 32px -12px rgba(38, 205, 93, 0.52),
      inset 0 1px 0 rgba(255, 255, 255, 0.34);
  }
  50% {
    box-shadow:
      0 15px 38px -10px rgba(38, 205, 93, 0.7),
      0 0 0 7px rgba(54, 218, 112, 0.045),
      inset 0 1px 0 rgba(255, 255, 255, 0.34);
  }
}

@keyframes livePulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.42;
  }
}

@keyframes voiceRing {
  0% {
    transform: scale(0.91);
    opacity: 0.62;
  }
  100% {
    transform: scale(1.17);
    opacity: 0;
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 6px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@media (max-width: 560px), (max-height: 720px) {
  .app {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .app::after {
    display: none;
  }

  .screen {
    padding-top: calc(var(--safe-top) + 18px);
    padding-bottom: calc(var(--safe-bottom) + 22px);
  }

  .dial-portrait {
    width: clamp(178px, 48vw, 218px);
    height: clamp(178px, 48vw, 218px);
  }

  .call-portrait {
    width: clamp(188px, 50vw, 224px);
    height: clamp(188px, 50vw, 224px);
  }
}

@media (max-height: 720px) {
  .screen--dial {
    padding-top: calc(var(--safe-top) + 22px);
  }

  .dial-portrait {
    width: clamp(148px, 39vw, 184px);
    height: clamp(148px, 39vw, 184px);
    margin-bottom: 22px;
  }

  .dial-id h1 {
    font-size: 28px;
  }

  .status {
    margin-top: 12px;
  }

  .dial-foot {
    margin-top: 14px;
  }

  .call-portrait {
    width: clamp(168px, 42vw, 216px);
    height: clamp(168px, 42vw, 216px);
  }

  .call-stage {
    gap: 18px;
  }

  .call-control__icon {
    width: 56px;
    height: 56px;
  }

  .call-control--hangup .call-control__icon {
    width: 60px;
    height: 60px;
  }
}

@media (min-width: 561px) and (min-height: 821px) {
  .app {
    height: min(860px, calc(100dvh - 54px));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
