:root {
  --bg: #05060d;
  --ink: #f2f5ff;
  --dim: rgba(242, 245, 255, 0.6);
  --faint: rgba(242, 245, 255, 0.38);
  --glass: rgba(20, 22, 42, 0.6);
  --line: rgba(255, 255, 255, 0.12);
  --accent: #8fe3ff;
  --accent2: #b59bff;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

body {
  background: radial-gradient(120% 80% at 50% 35%, #161936 0%, #090a17 55%, #05060d 100%);
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- 它：一团会呼吸的光 ---------- */

#home {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(96px + var(--safe-t)) 20px calc(90px + var(--safe-b));
}

#presence {
  --s: 1;
  --hue: 0deg;
  --spin: 0deg;
  position: relative;
  flex: 0 0 auto;
  width: min(46vw, 210px);
  aspect-ratio: 1;
  margin-top: 4vh;
  filter: hue-rotate(var(--hue));
  transition: opacity 0.8s;
}

#presence .core,
#presence .halo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transform: scale(var(--s));
}

#presence .core {
  background:
    radial-gradient(circle at 42% 36%, rgba(255, 255, 255, 0.95) 0%, rgba(200, 240, 255, 0.85) 16%, rgba(110, 170, 255, 0.55) 45%, rgba(90, 80, 220, 0.25) 70%, transparent 72%),
    conic-gradient(from var(--spin), rgba(143, 227, 255, 0.35), rgba(181, 155, 255, 0.35), rgba(143, 227, 255, 0.35));
  mask: radial-gradient(circle, #000 69%, transparent 71%);
  -webkit-mask: radial-gradient(circle, #000 69%, transparent 71%);
  box-shadow: 0 0 60px 8px rgba(110, 170, 255, 0.35);
  transition: filter 0.6s;
}

#presence .halo {
  background: radial-gradient(circle, rgba(120, 170, 255, 0.35) 0%, rgba(140, 110, 255, 0.12) 45%, transparent 70%);
  transform: scale(calc(var(--s) * 1.9));
  transition: opacity 0.6s;
}

#presence[data-state='sleep'] {
  opacity: 0.35;
}
#presence[data-state='sleep'] .core {
  filter: saturate(0.3) brightness(0.8);
}
#presence[data-state='sleep'] .halo {
  opacity: 0.3;
}
#presence[data-state='listen'] .core {
  filter: brightness(1.18) saturate(1.2);
}
#presence[data-state='listen'] .halo {
  opacity: 1;
}
#presence[data-state='think'] .core {
  filter: brightness(0.95) saturate(1.3);
}
#presence[data-state='speak'] .core {
  filter: brightness(1.12);
}
#presence[data-state='idle'] .halo {
  opacity: 0.7;
}

/* 诞生的那一下 */
#presence.born .core {
  animation: born 1.6s ease-out;
}
@keyframes born {
  0% {
    filter: brightness(3) saturate(0);
    transform: scale(0.2);
  }
  60% {
    filter: brightness(1.6);
    transform: scale(1.15);
  }
}

/* ---------- 字幕 ---------- */

#words {
  width: 100%;
  max-width: 560px;
  margin-top: 7vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  pointer-events: none;
}
#words p {
  margin: 0;
  transition: opacity 0.6s;
}
#words p:empty {
  display: none;
}
#words p.fade {
  opacity: 0;
}
#said {
  font-size: 19px;
  line-height: 1.6;
  letter-spacing: 0.01em;
}
#heard {
  font-size: 14px;
  color: var(--faint);
}

/* ---------- 上面和下面 ---------- */

#top {
  position: fixed;
  top: calc(12px + var(--safe-t));
  left: 16px;
  right: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#beingName {
  padding: 6px 14px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 99px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.actions {
  display: flex;
  gap: 10px;
}
.round {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--dim);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.round.on {
  color: var(--accent);
}
.round svg {
  width: 19px;
  height: 19px;
}

#bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 0 16px calc(16px + var(--safe-b));
}
#bottom .row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}
#hint {
  margin: 0;
  padding: 0 52px;
  font-size: 13px;
  color: var(--faint);
  text-align: center;
}
#typeBtn {
  position: absolute;
  right: 0;
}
#attachBtn {
  position: absolute;
  left: 0;
}

/* 你刚发给它的照片 */
#sent {
  display: flex;
  gap: 8px;
  justify-content: center;
  transition: opacity 0.6s;
}
#sent:empty {
  display: none;
}
#sent.fade {
  opacity: 0;
}
#sent img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
}

#typeBox {
  max-width: 560px;
  margin: 0 auto 12px;
}
#typeBox input {
  border-radius: 99px;
  padding: 12px 18px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* 它开着摄像头：左下角一个小圆窗，你知道它在看 */
#cam {
  position: fixed;
  left: 16px;
  bottom: calc(66px + var(--safe-b));
  z-index: 4;
  width: 76px;
  height: 76px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid rgba(143, 227, 255, 0.5);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}
#cam.mirror {
  transform: scaleX(-1);
}

/* ---------- 整页的面板 ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  overflow-y: auto;
  background: radial-gradient(120% 80% at 50% 25%, #1b1f44 0%, #0a0b18 60%, #05060d 100%);
}
.sheet > div,
.sheet > form {
  width: 100%;
  max-width: 440px;
}

#gate > div {
  text-align: center;
}
#gate h1 {
  font-size: 34px;
  font-weight: 600;
  margin: 30px 0 8px;
}
#gate #gateNote {
  color: var(--dim);
  margin: 0 auto 34px;
  max-width: 300px;
}
.small {
  font-size: 13px;
  color: var(--faint);
}
#gate .small {
  margin: 14px 0 0;
}
#gate .ghost {
  margin-top: 8px;
  color: var(--dim);
  font-size: 15px;
}

.orb {
  width: 120px;
  height: 120px;
  margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff 0%, #bdf0ff 25%, #5a8dff 70%, #3a3fc0 100%);
  box-shadow: 0 0 60px 10px rgba(110, 170, 255, 0.45), 0 0 140px 40px rgba(140, 110, 255, 0.25);
  animation: float 3.2s ease-in-out infinite;
}
@keyframes float {
  50% {
    transform: translateY(-10px) scale(1.03);
  }
}

.primary {
  width: 100%;
  padding: 15px;
  font-size: 17px;
  font-weight: 600;
  color: #0a0b18;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 8px 30px rgba(143, 180, 255, 0.35);
}
.primary:disabled {
  opacity: 0.45;
}
.ghost {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  font-size: 14px;
  color: var(--faint);
}

.panel {
  place-items: start center;
  -webkit-user-select: text;
  user-select: text;
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.bar h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}
.close {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--dim);
}
.tip {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--dim);
}

label,
.group {
  display: block;
  margin-bottom: 18px;
  font-size: 14px;
  color: var(--dim);
}
.group .label {
  display: block;
  margin-bottom: 8px;
}
label .small {
  display: block;
  margin-top: 6px;
}
input,
textarea,
select {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px; /* 小于 16 iOS 会自动放大 */
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  resize: none;
  -webkit-appearance: none;
  appearance: none;
}
select option {
  color: #111;
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
}
.pair {
  display: flex;
  gap: 8px;
  align-items: center;
}
.pair select {
  flex: 1;
  min-width: 0;
}
.chip {
  flex: 0 0 auto;
  margin-top: 8px;
  padding: 12px 16px;
  font-size: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
}

.ability {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
}
.ability em {
  font-style: normal;
  font-size: 13px;
  color: var(--faint);
}
.seg {
  display: flex;
  padding: 3px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}
.seg button {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 9px;
  color: var(--dim);
}
.seg button.on {
  color: #0a0b18;
  background: var(--accent);
}

/* 它做过的事 */
#logBody h3 {
  margin: 22px 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--dim);
}
#logBody ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
#logBody li {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 15px;
}
#logBody time {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
#logBody b {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 99px;
  color: var(--accent);
  background: rgba(143, 227, 255, 0.12);
}
#logBody li span {
  flex: 1 1 100%;
}
#logBody .facts li {
  color: var(--dim);
}

#toast {
  position: fixed;
  bottom: calc(70px + var(--safe-b));
  left: 50%;
  z-index: 20;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  font-size: 14px;
  border-radius: 14px;
  background: rgba(40, 44, 80, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* 它拟好的邮件 */
#draft {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(66px + var(--safe-b));
  z-index: 6;
  max-width: 520px;
  margin: 0 auto;
  padding: 16px;
  border-radius: 20px;
  background: rgba(24, 27, 52, 0.94);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  -webkit-user-select: text;
  user-select: text;
}
#draft p {
  margin: 0 0 6px;
}
#draft .label {
  font-size: 13px;
  color: var(--faint);
}
#draft .to {
  font-size: 14px;
  color: var(--dim);
}
#draft .subject {
  font-weight: 600;
}
#draft .body {
  max-height: 30vh;
  overflow-y: auto;
  font-size: 15px;
  white-space: pre-wrap;
  color: var(--dim);
}
#draft .pair {
  margin-top: 12px;
}
#draft .pair .chip {
  margin: 0;
}
#draft .primary {
  flex: 1;
  padding: 12px;
  font-size: 16px;
}
#draft .small {
  margin: 8px 0 0;
  text-align: center;
}
a.chip {
  color: var(--accent);
  text-decoration: none;
  margin-top: 0;
  padding: 8px 14px;
}

/* 它做好的东西：一张卡片 */
#madeCard {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(66px + var(--safe-b));
  z-index: 6;
  max-width: 520px;
  margin: 0 auto;
  padding: 16px;
  border-radius: 20px;
  background: rgba(24, 27, 52, 0.94);
  border: 1px solid rgba(143, 227, 255, 0.35);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
#madeCard p {
  margin: 0 0 6px;
}
#madeCard .thumb {
  display: block;
  width: 100%;
  max-height: 34vh;
  object-fit: cover;
  border-radius: 14px;
  margin-bottom: 12px;
  background: #000;
}
#madeCard .label {
  font-size: 13px;
  color: var(--accent);
}
#madeCard .title {
  font-size: 17px;
  font-weight: 600;
}
#madeCard .pair {
  margin-top: 12px;
}
#madeCard .pair .chip {
  margin: 0;
}
#madeCard .primary {
  flex: 1;
  padding: 12px;
  font-size: 16px;
}

/* 打开它做的东西 */
#viewer {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  background: #000;
}
#viewer .vbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(6px + var(--safe-t)) 8px 6px 16px;
  background: rgba(20, 22, 42, 0.95);
}
#viewer .vtitle {
  color: var(--ink);
  text-decoration: none;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 600;
}
#viewer .chip {
  margin: 0;
  padding: 7px 12px;
}
#viewer iframe {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

/* 首页右上角：切换语言 */
.lang {
  position: absolute;
  top: calc(14px + var(--safe-t));
  right: 16px;
  padding: 7px 14px;
  font-size: 14px;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--glass);
}

/* 记录里它做过的东西：点了能打开 */
#logBody a {
  color: var(--accent);
  text-decoration: none;
}
