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

:root {
  --bg: #FAF7F1;
  --bg-deep: #F3EEE5;
  --surface: #FCFAF6;
  --surface2: #F5F1E9;
  --surface3: #EDE7DC;
  --border: #E6DED0;
  --text: #2B2620;
  --text-dim: #8C8378;
  --btn-text: #FFFFFF;
  --danger: #A3805B;
  --ok: #8AA07A;
  --gold: #C9A25A;
  --gold-strong: #B08A45;
  --gold-soft: rgba(201, 162, 90, 0.10);
  --accent: #C9A25A;
  --accent-strong: #B08A45;
  --accent-grad: linear-gradient(135deg, #C9A25A 0%, #B08A45 100%);
  --radius: 8px;
  --radius-s: 6px;
  --topbar-h: 60px;
  --tabbar-h: 60px;
  --chat-fs: 17px;
  --font-family: 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', 'STSong', 'SimSun', serif;
  --bg-rgb: 250, 247, 241;
  --surface-rgb: 252, 250, 246;
  --shadow: none;
  --shadow-lg: none;
}

:root[data-color="blue"] {
  --gold: #C9A25A;
  --gold-strong: #B08A45;
  --gold-soft: rgba(201, 162, 90, 0.10);
  --accent: #C9A25A;
  --accent-strong: #B08A45;
  --accent-grad: linear-gradient(135deg, #C9A25A 0%, #B08A45 100%);
}

:root[data-color="purple"] {
  --gold: #C9A25A;
  --gold-strong: #B08A45;
  --gold-soft: rgba(201, 162, 90, 0.10);
  --accent: #C9A25A;
  --accent-strong: #B08A45;
  --accent-grad: linear-gradient(135deg, #C9A25A 0%, #B08A45 100%);
}

:root[data-theme="dark"] {
  --bg: #1B1815;
  --bg-deep: #141210;
  --surface: #221E1A;
  --surface2: #2A251F;
  --surface3: #332D25;
  --border: #2A2622;
  --text: #E6DED2;
  --text-dim: #9A9086;
  --btn-text: #1B1815;
  --danger: #C9A25A;
  --ok: #8FA97D;
  --gold: #D8B876;
  --gold-strong: #E6C88A;
  --gold-soft: rgba(216, 184, 118, 0.09);
  --accent: #D8B876;
  --accent-strong: #E6C88A;
  --accent-grad: linear-gradient(135deg, #D8B876 0%, #C9A25A 100%);
  --bg-rgb: 27, 24, 21;
  --surface-rgb: 34, 30, 26;
}

:root[data-theme="dark"][data-color="blue"] {
  --accent: #D8B876;
  --accent-strong: #E6C88A;
  --gold: #D8B876;
  --gold-strong: #E6C88A;
  --accent-grad: linear-gradient(135deg, #D8B876 0%, #C9A25A 100%);
}

:root[data-theme="dark"][data-color="purple"] {
  --accent: #D8B876;
  --accent-strong: #E6C88A;
  --gold: #D8B876;
  --gold-strong: #E6C88A;
  --accent-grad: linear-gradient(135deg, #D8B876 0%, #C9A25A 100%);
}

html, body { height: 100dvh; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family);
  font-size: 16px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.4s ease, color 0.4s ease;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 85% -10%, var(--gold-soft), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, var(--gold-soft), transparent 55%);
  z-index: 0;
}

body.with-bg {
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  background: transparent;
}

@media (min-width: 660px) {
  #app {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }
}

/* ---------- top bar ---------- */
#topbar {
  flex: none;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  padding-top: env(safe-area-inset-top);
  transition: background-color 0.4s ease, border-color 0.4s ease;
}

.tb-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--topbar-h);
  padding: 0 12px;
}

#btn-back {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

#btn-back:active { transform: translateY(-50%) scale(0.9); background: var(--surface3); }

#btn-back.hidden { display: none; }

.tb-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  cursor: pointer;
}

.tb-center:active { opacity: 0.7; }

#tb-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent-grad);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  box-shadow: 0 4px 12px rgba(176, 138, 92, 0.35);
  transition: transform 0.3s ease;
}

#tb-avatar:active { transform: scale(0.92); }

#tb-text { text-align: center; min-width: 0; }

#tb-title {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.5px;
}

#tb-sub {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

#tb-sub .badge { color: var(--accent-strong); }

.header-actions {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 4px;
}

.action-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
}

.action-btn:active { background: var(--surface2); color: var(--accent); opacity: 0.7; }

.action-btn.spin {
  animation: spinOnce 0.6s ease;
}

@keyframes spinOnce {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ---------- main / tabs ---------- */
#view {
  flex: 1;
  overflow: hidden;
  position: relative;
}

#view-chat, #view-page { height: 100%; }

#tabbar {
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  display: flex;
  flex: none;
  transition: background-color 0.4s ease, border-color 0.4s ease;
}

#tabbar button {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 10.5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  font-family: inherit;
  position: relative;
  transition: color 0.25s ease, transform 0.15s ease;
}

#tabbar button:active { opacity: 0.7; }

#tabbar em { display: none; }

#tabbar button i {
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  filter: grayscale(0.6) opacity(0.55);
  transition: all 0.25s ease;
}

#tabbar button span { letter-spacing: 0.5px; }

#tabbar button.active { color: var(--accent-strong); }
#tabbar button.active i { filter: none; transform: translateY(-1px); }

#tabbar button.active::before {
  content: '';
  position: absolute;
  top: 6px;
  width: 34px;
  height: 30px;
  border-radius: 10px;
  background: var(--gold-soft);
  z-index: -1;
}

#tabbar em {
  position: absolute;
  top: 3px;
  right: calc(50% - 25px);
  background: var(--danger);
  color: #fff;
  border-radius: 9px;
  font-size: 10px;
  font-style: normal;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  padding: 0 4px;
  display: none;
  box-shadow: 0 2px 6px rgba(201, 79, 87, 0.4);
}

/* ---------- chat ---------- */
#view-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

.row.msg-selected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 10px;
}

.select-bar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 7px 14px;
  z-index: 30;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  font-size: 13px;
}

.select-bar button {
  border: none;
  background: transparent;
  color: var(--accent-strong);
  font-size: 13px;
  cursor: pointer;
  padding: 0 2px;
  font-family: inherit;
}

#view-chat.hidden, #view-page.hidden { display: none; }

.msgs {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.date-divider {
  display: flex;
  align-items: center;
  margin: 16px 0 8px;
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 1.5px;
}

.date-divider::before, .date-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.date-divider span {
  padding: 4px 14px;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border: 1px solid var(--border);
  border-radius: 20px;
}

.row {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: msgAppear 0.5s ease-out;
}

@keyframes msgAppear {
  from { opacity: 0; }
  to { opacity: 1; }
}

.row.me { align-self: flex-end; align-items: flex-end; }
.row.him { align-self: flex-start; align-items: flex-start; }
.ava-img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  display: block;
}

.row.him .head { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }

.ava {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-grad);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex: none;
}

.say {
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
  font-size: var(--chat-fs);
}

.row.me .say {
  color: #9C3D21;
  font-family: 'LXGW WenKai', 'KaiTi', '楷体', 'STKaiti', 'Kaiti SC', serif;
}
.row.him .say { color: var(--text); }

.punct-row {
  align-self: center;
  text-align: center;
  font-size: calc(var(--chat-fs) + 1px);
  color: #9C3D21;
  font-family: 'LXGW WenKai', 'KaiTi', '楷体', 'STKaiti', 'Kaiti SC', serif;
  padding: 6px 0;
  animation: msgAppear 0.5s ease-out;
}

.say.streaming::after {
  content: '▍';
  color: var(--accent-strong);
  margin-left: 1px;
  animation: streamBlink 0.8s steps(2) infinite;
}

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

.sticker-img {
  width: 96px;
  max-width: 55vw;
  display: block;
  border-radius: 4px;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 4px 0;
}

.sticker-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 4px;
  transition: opacity 0.2s ease;
}

.sticker-cell:active { opacity: 0.7; }

.sticker-cell .sticker-img {
  width: 100%;
  max-width: 72px;
}

.sticker-name {
  font-size: 10px;
  color: var(--text-dim);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sticker-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--danger);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sticker-rename {
  position: absolute;
  bottom: -6px;
  left: -6px;
  width: 22px;
  height: 18px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.album-cell {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}

.album-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

.album-caption {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
}

.moment-preview {
  max-height: 180px;
  border-radius: 6px;
  border: 1px solid var(--border);
  object-fit: contain;
  width: auto;
  max-width: 100%;
}

.moment-img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 6px;
  display: block;
  margin-top: 8px;
  cursor: pointer;
}

.say img.img-msg {
  max-width: 240px;
  max-height: 320px;
  border-radius: 6px;
  display: block;
  margin: -2px 0 6px;
  cursor: pointer;
}

.say .file-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  margin-bottom: 4px;
  font-size: 13px;
}

.say a.file-chip {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.say a.file-chip:active { opacity: 0.7; }

.row.him .say .file-chip { color: var(--accent-strong); }

.say .cap {
  font-size: 12.5px;
  opacity: 0.85;
}

a.lnk {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
  word-break: break-all;
}

.row.me .say a.lnk { color: #9C3D21; }

.time {
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 3px;
  padding: 0 2px;
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0.75;
}

.receipt { font-size: 10.5px; letter-spacing: -2px; }
.receipt.read { color: var(--accent-strong); }

.inner-line {
  margin-top: 6px;
  font-size: calc(var(--chat-fs) - 2px);
  color: var(--gold-strong);
  font-style: italic;
  line-height: 1.6;
  border-left: 2px solid var(--gold);
  padding-left: 10px;
  max-width: 100%;
  animation: msgAppear 0.6s ease;
}

.inner-line .tag {
  font-style: normal;
  font-size: 10px;
  opacity: 0.8;
  letter-spacing: 1px;
}

.sys-row {
  align-self: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 4px 0;
}

.inner-poke {
  color: var(--gold-strong);
  opacity: 0.85;
  font-style: italic;
  padding: 2px 12px;
  max-width: 86%;
  text-align: center;
}

.inner-card {
  align-self: center;
  width: 88%;
  margin: 6px 0;
  border: 1.5px dashed var(--gold);
  border-radius: 14px;
  background: var(--gold-soft);
  padding: 13px 15px;
  cursor: pointer;
  text-align: center;
  animation: msgAppear 0.5s ease;
  transition: transform 0.2s ease;
}

.inner-card:active { opacity: 0.85; }

.inner-card .hint {
  color: var(--gold-strong);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.inner-card .hint .dots::after {
  content: '…';
  animation: blink 1.2s infinite;
}

@keyframes blink { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }

.inner-card.revealed {
  cursor: default;
  text-align: left;
  border-style: solid;
  border-color: var(--gold);
  background: #faf4e8;
  animation: msgAppear 0.5s ease;
}

:root[data-theme="dark"] .inner-card.revealed { background: #221d15; }

.inner-card.revealed .ih-title {
  color: var(--gold-strong);
  font-size: 11px;
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.inner-card.revealed .ih-body {
  color: #5f4d2f;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
  font-size: var(--chat-fs);
}

:root[data-theme="dark"] .inner-card.revealed .ih-body { color: #e6d9c3; }

.typing .say { color: var(--text-dim); }

/* composer */
.composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  transition: background-color 0.4s ease, border-color 0.4s ease;
}

.composer textarea {
  flex: 1;
  resize: none;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  color: var(--text);
  font-family: inherit;
  font-size: var(--chat-fs);
  line-height: 1.6;
  padding: 8px 4px;
  max-height: 160px;
  min-height: 40px;
  outline: none;
  transition: border-color 0.25s ease;
}

.composer textarea:focus {
  border-bottom-color: var(--accent);
  background: transparent;
  box-shadow: none;
}

.composer button, .composer label {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  transition: opacity 0.2s ease;
  font-family: inherit;
}

.composer button:active, .composer label:active { opacity: 0.7; }

#btn-attach {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 20px;
}

#btn-talk {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 15px;
}

#btn-sticker {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 16px;
}

#tb-pat {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
}

#btn-send {
  background: var(--accent-grad);
  color: var(--btn-text);
  font-size: 18px;
}

#btn-send:disabled { opacity: 0.35; }

.cmd-pop {
  position: absolute;
  bottom: calc(var(--tabbar-h) + 72px);
  left: 12px;
  right: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  z-index: 20;
  box-shadow: var(--shadow-lg);
}

.cmd-pop .item {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.15s ease;
}

.cmd-pop .item:last-child { border-bottom: none; }
.cmd-pop .item:active { background: var(--surface2); }
.cmd-pop .item span:first-child { color: var(--accent-strong); font-weight: 600; }
.cmd-pop .item .desc { color: var(--text-dim); font-size: 12px; }
.cmd-pop.hidden { display: none; }

/* ---------- generic page ---------- */
.page {
  height: 100%;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.page > * { flex: none; }

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: background-color 0.4s ease, border-color 0.4s ease;
}

.section .sec-head {
  padding: 13px 16px;
  font-size: 12.5px;
  letter-spacing: 1px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
  background: color-mix(in srgb, var(--surface2) 55%, transparent);
}

.sec-head .gold { color: var(--accent-strong); }

.cell {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.15s ease;
}

.cell:last-child { border-bottom: none; }
.cell:active { background: var(--surface2); }

.cell .row1 { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 5px; align-items: center; }
.cell .row1 .t { font-weight: 600; font-size: 14.5px; }
.cell .meta { font-size: 12px; color: var(--text-dim); }
.cell .body {
  margin-top: 6px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
  font-size: 14px;
}

.cell input, .cell textarea, .cell select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
}

.cell input:focus, .cell textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.cell textarea { resize: vertical; min-height: 80px; line-height: 1.6; }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--accent-grad);
  color: var(--btn-text);
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.5px;
  transition: opacity 0.2s ease;
}

.btn:active { opacity: 0.8; }

.btn.ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 400;
  box-shadow: none;
}

.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); box-shadow: none; }
.btn.danger:active { background: rgba(163, 128, 91, 0.08); }
.btn.small { padding: 6px 13px; font-size: 12.5px; border-radius: 6px; font-weight: 400; box-shadow: none; }
.btn.gold { background: var(--accent-grad); color: var(--btn-text); }
.btn.ghost.gold { background: var(--gold-soft); color: var(--accent-strong); border-color: var(--gold); box-shadow: none; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* forms */
.form label {
  display: block;
  font-size: 12.5px;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin: 12px 0 5px;
}

.form input, .form textarea, .form select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
}

.form textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.form input:focus, .form textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.radio-row { display: flex; gap: 8px; }

.radio-row label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 12px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-dim);
  margin: 0;
  transition: all 0.25s ease;
}

.radio-row label:active { opacity: 0.7; }
.radio-row input { display: none; }
.radio-row label.on {
  border-color: var(--accent);
  background: var(--gold-soft);
  color: var(--accent-strong);
}

/* tags */
.tag {
  font-size: 10.5px;
  border-radius: 8px;
  padding: 3px 9px;
  flex: none;
  letter-spacing: 0.5px;
}

.tag.shared { background: rgba(138, 160, 122, 0.14); color: var(--ok); }
.tag.private { background: rgba(163, 128, 91, 0.12); color: var(--danger); }
.tag.you { background: var(--gold-soft); color: var(--gold-strong); border: 1px solid var(--gold); }
.tag.me { background: rgba(140, 131, 120, 0.10); color: var(--text-dim); border: 1px solid var(--border); }

:root[data-theme="dark"] .tag.me { color: #7FA6CD; }

.locked {
  color: var(--text-dim);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.7;
}

.empty {
  color: var(--text-dim);
  text-align: center;
  padding: 42px 0;
  font-size: 13.5px;
  line-height: 2;
}

.pred-card {
  background: linear-gradient(135deg, var(--gold-soft), transparent);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.pred-card .big { font-size: 26px; color: var(--gold-strong); font-weight: 700; margin: 6px 0; }
.pred-card .sub { color: var(--text-dim); font-size: 13px; line-height: 1.9; }

.tarot-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 10px 0;
}

.tarot-card {
  flex: 1;
  min-width: 82px;
  max-width: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 6px;
  background: var(--surface2);
}

.tarot-card .t {
  font-size: 16px;
  font-weight: 700;
  color: var(--gold-strong);
}

.mood-pick { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 6px; }

.mood-pick button {
  width: 44px;
  height: 44px;
  font-size: 23px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mood-pick button:active { opacity: 0.7; }

.mood-pick button.on {
  border-color: var(--accent);
  background: var(--gold-soft);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.mood-big { font-size: 16px; }

/* switch */
.switch {
  position: relative;
  width: 46px;
  height: 28px;
  flex: none;
}

.switch input { display: none; }

.switch .sl {
  position: absolute;
  inset: 0;
  background: var(--surface3);
  border-radius: 14px;
  transition: 0.25s;
  cursor: pointer;
}

.switch .sl::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: 0.25s;
}

.switch input:checked + .sl { background: var(--accent); }
.switch input:checked + .sl::after { left: 21px; }

/* theme color picker */
.theme-picker { display: flex; gap: 12px; align-items: center; }

.theme-color-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.theme-color-btn:active { opacity: 0.7; }
.theme-color-btn.active { border-color: var(--text); }
#tc-gold { background: linear-gradient(135deg, #d4b48c, #b08a5c); }
#tc-blue { background: linear-gradient(135deg, #93b7da, #648bb4); }
#tc-purple { background: linear-gradient(135deg, #ccb1d6, #a588b3); }

.font-size-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.font-size-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--surface3);
  outline: none;
  padding: 0;
  border: none;
}

.font-size-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.font-size-val { font-size: 13px; color: var(--text-dim); min-width: 38px; text-align: center; }

/* ---------- timeline ---------- */
.tl-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.tl-month {
  font-size: 15px;
  color: var(--accent-strong);
  min-width: 110px;
  text-align: center;
  letter-spacing: 1px;
}

.tl-curve {
  padding: 6px 4px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tl-day { cursor: pointer; }

.paper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  line-height: 1.9;
}

.paper-date {
  text-align: center;
  color: var(--text-dim);
  font-size: 12.5px;
  letter-spacing: 2px;
  margin-bottom: 14px;
}

.p-entry {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.p-entry:last-child { border-bottom: none; }

.p-tag {
  font-size: 10.5px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.p-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.p-body {
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
}

/* ---------- letters ---------- */
.letter-card .cell { position: relative; }

.letter-card .row1 .t { font-size: 15.5px; }

.letter-quote {
  margin-top: 8px;
  padding: 9px 13px;
  border-left: 3px solid var(--gold);
  background: var(--gold-soft);
  border-radius: 0 10px 10px 0;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.7;
  word-break: break-word;
}

.letter-quote .q-tag {
  display: block;
  font-size: 10.5px;
  letter-spacing: 1px;
  color: var(--gold-strong);
  margin-bottom: 3px;
}

.letter-body {
  margin-top: 10px;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
  font-size: 14.5px;
}

.letter-sign {
  margin-top: 12px;
  text-align: right;
  color: var(--gold-strong);
  font-size: 13px;
  letter-spacing: 1px;
}

.letter-empty-ico {
  font-size: 40px;
  margin-bottom: 10px;
  opacity: 0.5;
}

/* ---------- modal ---------- */
#modal-root:empty { display: none; }

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal-card {
  width: 100%;
  max-width: 640px;
  max-height: 88dvh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideUp 0.3s ease-out;
  position: relative;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-title {
  font-size: 16.5px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 2px;
  margin-top: 4px;
}

.modal-body { overflow-y: auto; max-height: 64dvh; }

.modal-actions { display: flex; gap: 10px; margin-top: 4px; }
.modal-actions .btn { flex: 1; }

/* ---------- toast ---------- */
#toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-h) + 26px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 8px;
  font-size: 13.5px;
  max-width: 86%;
  animation: fadeIn 0.3s ease;
}

.toast.err { border-left-color: var(--danger); color: var(--danger); }

/* ---------- message long-press menu ---------- */
.msg-menu {
  position: fixed;
  z-index: 260;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
  padding: 5px;
  min-width: 130px;
  animation: fadeIn 0.15s ease;
}

.msg-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 9px 14px;
  font-size: 14px;
  font-family: inherit;
  border-radius: 8px;
  cursor: pointer;
}

.msg-menu button:active { background: var(--surface2); }
.msg-menu button.danger { color: var(--danger); }

::-webkit-scrollbar { width: 0; height: 0; display: none; }
* { scrollbar-width: none; -ms-overflow-style: none; }
