/* LUMI 暖纸主题 —— 复刻自 LUMI 设计令牌 */
:root {
  color-scheme: light;
  --paper: #f6f2eb;      /* 纸面 */
  --paper-deep: #e9e4dc; /* 外层背景 */
  --card: #fffdf8;       /* 卡片 */
  --ink: #302c29;        /* 暖墨 */
  --muted: #968e85;      /* 次要文字 */
  --line: #e7e0d7;       /* 描边 */
  --input-line: #c5cbb9;
  --rose: #d98d99;       /* 点缀 */
  --sage: #7b8170;
  --brown: #987d68;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--paper-deep);
  color: var(--ink);
  font: 16px/1.7 var(--font);
  -webkit-tap-highlight-color: transparent;
}
header { padding: 22px 16px 4px; text-align: center; }
header .tiny-brand { font-size: 12px; letter-spacing: 2px; color: var(--brown); }
header h1 { margin: 2px 0 0; font-size: 22px; font-weight: 600; }
header .sub { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
header .sub a { color: var(--brown); text-decoration: none; }
main { max-width: 560px; margin: 0 auto; padding: 10px 14px 60px; }

/* 通话舞台 */
.stage {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  aspect-ratio: 4 / 5;
  box-shadow: 0 10px 30px rgba(48, 44, 41, 0.06);
}
#remoteVideo { width: 100%; height: 100%; object-fit: cover; background: #000; }
#localVideo {
  position: absolute; right: 10px; top: 10px; width: 96px;
  border-radius: 12px; border: 1px solid var(--line); background: #000;
}
#statusBar {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 8px 14px;
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(transparent, rgba(48, 44, 41, 0.55));
  font-size: 12px; color: #fff;
}
.badge { padding: 2px 10px; border-radius: 999px; background: rgba(255,255,255,.85); color: var(--muted); }
.badge.ready { background: #eef2e6; color: #5a6b4d; }
.badge.missing { background: #f8e8e4; color: #b05a4e; }

/* 聊天字幕 */
.chat { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
#subtitle {
  min-height: 92px; max-height: 180px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 12px; font-size: 14px;
}
#subtitle .empty-hint { color: var(--muted); text-align: center; padding-top: 26px; }
#subtitle .line { margin: 6px 0; }
#subtitle .you { color: var(--brown); }
#subtitle .her { color: #b4637a; }
#subtitle .interim { color: var(--muted); font-style: italic; }

#inputForm { display: flex; gap: 8px; }
#inputForm input { flex: 1; min-width: 0; }
input, textarea {
  background: var(--card); border: 1px solid var(--input-line); border-radius: 24px;
  color: var(--ink); padding: 12px 16px; font: inherit; font-size: 15px;
}
input:focus, textarea:focus { outline: 1px solid var(--brown); }
.buttons { display: flex; gap: 8px; }
button {
  border: 1px solid var(--line); border-radius: 24px;
  background: var(--card); color: var(--ink);
  padding: 12px 16px; font: inherit; font-size: 15px; cursor: pointer;
}
button:disabled { opacity: .45; cursor: not-allowed; }
button.dark-button, #startButton {
  background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600;
}
button.cream-button { background: #f3ecdf; border-color: #e2d8c4; }
#hangupButton { background: #f8e8e4; border-color: #e5c5be; color: #a34e42; }
#interruptButton { color: var(--brown); }
#sendButton { color: #fff; background: var(--brown); border-color: var(--brown); }
#notice {
  background: #faf3e0; border: 1px solid #e8d9ae; border-radius: 16px;
  padding: 10px 14px; color: #8a6d2f; font-size: 13px;
}

/* 设置区 */
.config { margin-top: 12px; }
details {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; margin-bottom: 8px; padding: 10px 14px;
}
summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.config form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.config label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.config label input, .config label textarea, .config label button { margin-top: 2px; }
#eventLog { max-height: 200px; overflow-y: auto; margin: 8px 0; padding-left: 18px; font-size: 12px; color: var(--muted); }
#eventLog li { margin: 2px 0; word-break: break-all; }

/* 手写感文案 */
.handwritten {
  font-family: "Segoe Script", "Kaiti SC", "KaiTi", cursive;
  color: var(--ink); font-size: 18px;
}

/* ===== 文字聊天页（LUMI 风格） ===== */
.chat-topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--paper); border-bottom: 1px solid var(--line);
  padding: 12px 16px; position: sticky; top: 0; z-index: 5;
}
.chat-topbar h1 { margin: 0; font-size: 17px; font-weight: 600; }
.topbar-link { color: var(--brown); text-decoration: none; font-size: 14px; padding: 4px 6px; }

.chat-page { max-width: 560px; margin: 0 auto; padding: 12px 14px 80px; display: flex; flex-direction: column; gap: 12px; }

.relationship-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 14px 16px; box-shadow: 0 6px 20px rgba(48, 44, 41, 0.04);
}
.relationship-heart { font-size: 30px; color: var(--rose); line-height: 1; }
.relationship-card h3 { margin: 0; font-size: 15px; }
.relationship-card p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.chat-messages {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 14px; min-height: 220px; max-height: 48vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.chat-messages .bubble {
  max-width: 80%; padding: 9px 13px; border-radius: 16px;
  font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.chat-messages .bubble.you {
  align-self: flex-end; background: #efe7da; color: var(--ink);
  border-bottom-right-radius: 4px;
}
.chat-messages .bubble.her {
  align-self: flex-start; background: #fbe9ee; color: #a35367;
  border-bottom-left-radius: 4px;
}
.chat-empty { color: var(--muted); text-align: center; padding-top: 70px; font-size: 14px; }
.chat-status { margin: 0; font-size: 12px; color: var(--danger); min-height: 16px; }

.chat-composer { display: flex; gap: 8px; align-items: flex-end; }
.chat-composer textarea {
  flex: 1; resize: none; background: var(--card);
  border: 1px solid var(--input-line); border-radius: 20px;
  padding: 12px 16px; font: inherit; font-size: 15px; min-height: 46px;
}
.chat-composer .dark-button { height: 46px; padding: 0 22px; border-radius: 20px; }

.story-section { margin-top: 6px; }
.story-head .eyebrow { font-size: 10px; letter-spacing: 2px; color: var(--brown); }
.story-head h2 { margin: 2px 0 0; font-size: 18px; }
.story-head p { margin: 2px 0 10px; font-size: 13px; color: var(--muted); }
.story-filters { display: flex; gap: 6px; margin-bottom: 12px; }
.story-filters button {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 6px 16px; font-size: 13px; cursor: pointer;
}
.story-filters button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.story-timeline { display: flex; flex-direction: column; gap: 8px; }
.timeline-date { font-size: 12px; color: var(--muted); margin: 10px 0 2px; font-weight: 500; }
.timeline-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 14px;
}
.timeline-card h4 { margin: 0; font-size: 13px; color: var(--brown); font-weight: 600; }
.timeline-card p { margin: 3px 0; font-size: 14px; }
.timeline-card time { font-size: 11px; color: var(--muted); }
.timeline-card.kind-memory { border-left: 3px solid var(--rose); }
.timeline-card.kind-event { border-left: 3px solid var(--brown); }
.story-empty { color: var(--muted); text-align: center; padding: 24px 0; font-size: 14px; }

/* 首页的文字聊天入口 */
a.button-link {
  display: inline-block; border: 1px solid var(--line); border-radius: 24px;
  background: var(--card); color: var(--ink);
  padding: 12px 16px; font: inherit; font-size: 15px; text-decoration: none;
  text-align: center;
}

/* ===== 手机 App 风格 · 全屏通话页 ===== */
body[data-page="call"] {
  background: #0f0e0d;
  color: #fff;
  overscroll-behavior: none;
}
body[data-page="call"] main {
  max-width: none;
  margin: 0;
  padding: 0;
}
.call-shell {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
.call-stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #000;
}
#remoteVideo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.call-poster {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: radial-gradient(ellipse at 50% 30%, #3a2b26 0%, #17130f 60%, #0f0e0d 100%);
  background-size: cover;
  background-position: center;
  text-align: center;
  padding: 24px;
  transition: opacity 0.4s;
}
.call-poster[hidden] { display: none; }
.call-poster.has-photo::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,0.55) 100%);
}
.call-poster .poster-brand {
  font-size: 12px;
  letter-spacing: 3px;
  color: rgba(255,255,255,0.7);
  position: relative;
}
.call-poster p {
  margin: 0;
  font-size: 15px;
  color: rgba(255,255,255,0.85);
  position: relative;
}
.call-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0) 22%, rgba(0,0,0,0) 55%, rgba(0,0,0,0.65) 100%);
  pointer-events: none;
}
.call-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  z-index: 3;
}
.call-back {
  color: #fff;
  font-size: 26px;
  text-decoration: none;
  line-height: 1;
  padding: 4px 8px 4px 0;
}
.call-title { flex: 1; min-width: 0; }
.call-title h1 { margin: 0; font-size: 17px; font-weight: 600; }
.call-status-line { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.status-pill {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.16);
  color: #fff;
}
.call-status-line time { font-size: 11px; color: rgba(255,255,255,0.8); }
.call-tool-icon {
  background: rgba(255,255,255,0.14);
  border: none;
  color: #fff;
  font-size: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
}
.call-local {
  position: absolute;
  top: calc(54px + env(safe-area-inset-top));
  right: 12px;
  width: 92px;
  margin: 0;
  z-index: 3;
}
.call-local video {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.25);
  background: #000;
  display: block;
}
.call-local figcaption {
  text-align: center;
  font-size: 11px;
  color: rgba(255,255,255,0.85);
  margin-top: 3px;
}
.call-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 3;
}
.call-subtitle {
  max-height: 22vh;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.5;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}
.call-subtitle .line { margin: 3px 0; word-break: break-word; }
.call-subtitle .you { color: #9db7ff; }
.call-subtitle .her { color: #ffb6cc; }
.call-subtitle .interim { color: rgba(255,255,255,0.7); font-style: italic; }
.call-empty {
  text-align: center;
  color: rgba(255,255,255,0.85);
  padding: 14px 0;
  font-size: 15px;
}
.call-composer {
  display: flex;
  gap: 8px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 20px;
  padding: 6px;
  backdrop-filter: blur(8px);
}
.call-composer input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 15px;
  padding: 8px 10px;
  outline: none;
}
.call-composer input::placeholder { color: rgba(255,255,255,0.55); }
.call-composer button {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  border-radius: 16px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
}
#notice {
  background: rgba(255, 90, 90, 0.18);
  border: 1px solid rgba(255, 120, 120, 0.4);
  color: #ffd7d7;
  border-radius: 14px;
  padding: 8px 14px;
  font-size: 13px;
  backdrop-filter: blur(8px);
}
.call-buttons {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.call-main {
  border: none;
  color: #fff;
  font-size: 13px;
  line-height: 1.25;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  font-weight: 600;
}
.call-main.primary {
  background: #2fbf71;
  box-shadow: 0 4px 18px rgba(47, 191, 113, 0.4);
}
.call-main.primary:disabled { background: #3a5a48; box-shadow: none; opacity: 0.7; }
.call-main.danger {
  background: #e5484d;
  box-shadow: 0 4px 18px rgba(229, 72, 77, 0.4);
}
.call-main.danger:disabled { background: #5a3436; box-shadow: none; opacity: 0.7; }
.call-tool {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-size: 12px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  backdrop-filter: blur(8px);
}
.call-tool:disabled { opacity: 0.45; }

/* 设置弹窗 */
.settings-sheet {
  border: none;
  border-radius: 24px;
  padding: 0;
  width: min(92vw, 430px);
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
}
.settings-sheet::backdrop { background: rgba(0,0,0,0.5); }
.settings-sheet > header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 8px;
}
.settings-sheet > header h2 { margin: 0; font-size: 17px; }
.settings-sheet > header button {
  border: none;
  background: transparent;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 20px 20px;
}
.sheet-body label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}
.sheet-body input, .sheet-body textarea, .sheet-body select {
  background: #fff;
  border: 1px solid var(--input-line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
}
.sheet-body textarea { resize: vertical; }
.photo-row { display: flex; gap: 8px; align-items: center; }
.photo-row input { flex: 1; min-width: 0; }
.photo-row .dark-button { white-space: nowrap; padding: 10px 12px; }
.sheet-hint { font-size: 11px; color: var(--muted); margin: 0; }
.sheet-hint a { color: var(--brown); }
button.dark-button {
  background: var(--ink);
  border: 1px solid var(--ink);
  color: #fff;
  border-radius: 14px;
  padding: 12px 16px;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
