/* ============================================================================
   520,000 Stars · 主样式
   风格:深黑 / 深蓝 / 极简 / 低干扰(技术架构设计文档 06、07 章)
   Phase 2 起由星空引擎接管 canvas,本文件仅定义 UI 层
   ========================================================================== */

:root {
  --bg: #05070d;
  --panel: rgba(16, 22, 38, 0.72);
  --panel-border: rgba(127, 178, 229, 0.18);
  --ink: #e8ecf4;
  --muted: #8b9bb4;
  --accent: #f5c76a;
  --accent2: #7fb2e5;
  --danger: #e06c75;
  --font: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* 3D 星空容器(全屏) */
#starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none; /* 移动端:触摸直接控制相机,阻止浏览器手势/滚动干扰 */
  -webkit-user-select: none;
  user-select: none;
}
#starfield:active { cursor: grabbing; }

/* ---------- 顶部搜索 ---------- */
.ui-top {
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ui-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}
.ui-icon:hover { border-color: var(--accent2); transform: scale(1.05); }

.search-panel {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 0 16px;
}
.search-panel input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font-size: 14px;
  width: 200px;
  height: 40px;
  font-family: var(--font);
}
.search-panel input::placeholder { color: var(--muted); }

/* 搜索结果下拉 */
.search-results {
  position: absolute;
  top: 46px;
  left: 0;
  right: 0;
  max-height: 300px;
  overflow-y: auto;
  background: rgba(10, 16, 30, 0.96);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  z-index: 40;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}
.search-result-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(157, 180, 216, 0.08);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: rgba(245, 199, 106, 0.1); }
.search-result-item .sr-num { color: var(--accent); font-size: 12px; font-family: monospace; white-space: nowrap; }
.search-result-item .sr-msg { color: var(--ink); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .sr-empty { padding: 14px; color: var(--muted); font-size: 13px; text-align: center; }
.search-results .sr-status { padding: 10px 14px; color: var(--muted); font-size: 12px; text-align: center; }
.search-results .sr-count { padding: 8px 14px 4px; color: var(--muted); font-size: 11px; letter-spacing: 0.06em; }
.search-results .sr-empty.sr-placeholder { color: var(--accent); font-style: italic; }
.search-results .sr-go {
  display: block;
  width: calc(100% - 28px);
  margin: 4px 14px 12px;
  padding: 10px;
  border: 1px solid rgba(245, 199, 106, 0.45);
  background: rgba(245, 199, 106, 0.1);
  color: var(--accent);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.search-results .sr-go:hover { background: rgba(245, 199, 106, 0.22); }

/* 搜索框清空按钮 */
.search-box { display: flex; align-items: center; gap: 2px; }
.search-clear {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  width: 22px;
  height: 22px;
}
.search-clear:hover { color: var(--ink); }
.search-clear.hidden { display: none; }

/* ---------- 中央标题 ---------- */
.ui-title {
  position: fixed;
  top: calc(40% - 90px);
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 10;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.ui-title h1 {
  font-size: clamp(20px, 5vw, 30px);
  font-weight: 400;
  letter-spacing: 0.28em;
  color: var(--ink);
  text-shadow: 0 0 24px rgba(127, 178, 229, 0.25);
}
.ui-title .star-count {
  margin-top: 12px;
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ui-title .star-count .msg-count { color: var(--ink); }
.ui-title .star-count .msg-count span { color: var(--accent); font-weight: 700; }
.ui-title .star-count .slot-count { font-size: 12px; color: var(--muted); }
.ui-title .star-count span { color: var(--accent); font-weight: 600; }
.ui-title.dim { opacity: 0.35; }

/* ---------- 主操作按钮 ---------- */
.ui-action {
  position: fixed;
  bottom: calc(28px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  text-align: center;
  transition: opacity 0.4s ease;
}
.ui-action.dim { opacity: 0.3; pointer-events: none; }

.btn-primary {
  border: 1px solid rgba(245, 199, 106, 0.45);
  background: rgba(245, 199, 106, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--accent);
  font-size: 15px;
  letter-spacing: 0.06em;
  padding: 12px 30px;
  border-radius: 30px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  font-family: var(--font);
}
.btn-primary:hover { background: rgba(245, 199, 106, 0.2); transform: scale(1.03); }
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
/* Phase 6:今日已发布,入口锁定 */
.btn-primary.done {
  border-color: rgba(126, 217, 178, 0.45);
  background: rgba(126, 217, 178, 0.1);
  color: #7ed9b2;
  opacity: 0.9;
  cursor: default;
}
.btn-primary.done:hover { transform: none; background: rgba(126, 217, 178, 0.1); }

.btn-ghost {
  border: 1px solid rgba(157, 180, 216, 0.4);
  background: rgba(13, 20, 34, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.05em;
  padding: 10px 20px;
  border-radius: 30px;
  cursor: pointer;
  margin-left: 10px;
  transition: background 0.2s, transform 0.15s;
  font-family: var(--font);
}
.btn-ghost:hover { background: rgba(157, 180, 216, 0.15); color: var(--ink); transform: scale(1.03); }

/* ---------- 星群形状选择面板 ---------- */
.shape-panel {
  position: fixed;
  left: 50%;
  bottom: calc(90px + var(--safe-bottom));
  transform: translateX(-50%);
  width: min(400px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 18px 20px;
  z-index: 30;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
  animation: rise 0.35s ease;
}
.shape-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.shape-item {
  border: 1px solid rgba(157, 180, 216, 0.25);
  background: rgba(157, 180, 216, 0.06);
  border-radius: 10px;
  padding: 10px 6px;
  color: var(--ink);
  font-size: 12.5px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  font-family: var(--font);
}
.shape-item small { display: block; color: var(--muted); font-size: 10.5px; margin-top: 3px; }
.shape-item:hover { border-color: rgba(245, 199, 106, 0.5); transform: scale(1.03); }
.shape-item.active {
  border-color: var(--accent);
  background: rgba(245, 199, 106, 0.12);
  color: var(--accent);
}

/* ---------- 玻璃面板(发布) ---------- */
.glass-panel {
  position: fixed;
  left: 50%;
  bottom: calc(90px + var(--safe-bottom));
  transform: translateX(-50%);
  width: min(440px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 20px 22px;
  z-index: 30;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
  animation: rise 0.35s ease;
}
@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.glass-panel .panel-head {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.glass-panel textarea {
  width: 100%;
  background: rgba(5, 7, 13, 0.5);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  padding: 12px;
  resize: none;
  outline: none;
  font-family: var(--font);
}
.glass-panel textarea:focus { border-color: var(--accent2); }
.glass-panel .counter {
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  margin: 6px 2px 14px;
}
.glass-panel .nickname-input {
  width: 100%;
  box-sizing: border-box;
  background: rgba(5, 7, 13, 0.5);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--ink);
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  margin-bottom: 14px;
  font-family: var(--font);
}
.glass-panel .nickname-input:focus { border-color: var(--accent2); }
.report-target {
  font-size: 13px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.glass-panel .counter.over { color: var(--danger); }
/* ---------- 昵称编辑弹层(替代 window.prompt) ---------- */
.nick-panel {
  width: min(360px, calc(100vw - 32px));
  padding: 18px 20px;
  z-index: 60;
}
.nick-panel input {
  width: 100%;
  box-sizing: border-box;
  margin: 12px 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font-size: 14px;
  outline: none;
}
.nick-panel input:focus { border-color: var(--accent2); }
.nick-actions { display: flex; gap: 10px; justify-content: flex-end; }
.nick-actions .btn-primary { width: auto; padding: 8px 20px; }
.nick-actions .btn-ghost { padding: 8px 16px; }

/* ---------- 留言卡片 ---------- */
.star-card {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  width: min(360px, calc(100vw - 48px));
  background: rgba(16, 22, 38, 0.52);
  border: 1px solid rgba(127, 178, 229, 0.22);
  border-radius: 16px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 26px 26px 22px;
  z-index: 40;
  text-align: center;
  box-shadow: 0 0 60px rgba(245, 199, 106, 0.12), 0 12px 48px rgba(0,0,0,0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.star-card.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}
.card-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.card-close:hover { color: var(--ink); }
.card-number {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}

/* 主星昵称(星主可点击编辑) */
.card-nickname {
  display: inline-block;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  background: rgba(245, 199, 106, 0.1);
  border: 1px solid rgba(245, 199, 106, 0.28);
  border-radius: 20px;
  padding: 4px 14px;
  margin-bottom: 12px;
}
.card-nickname.mine {
  cursor: pointer;
  transition: border-color 0.2s;
}
.card-nickname.mine:hover {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(245, 199, 106, 0.2);
}
.card-nickname.empty {
  border-style: dashed;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 400;
}
.card-message {
  font-size: 16px;
  line-height: 1.8;
  color: var(--ink);
  margin-bottom: 16px;
  word-break: break-word;
  min-height: 3.6em;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-message.silent { color: var(--muted); }
.card-message.placeholder {
  color: var(--muted);
  font-style: italic;
  letter-spacing: 0.06em;
}
.card-message.placeholder::before { content: '✦ '; color: var(--accent); font-style: normal; }
.card-message.placeholder::after { content: ' ✦'; color: var(--accent); font-style: normal; }
.card-action {
  margin-top: 4px;
  padding: 9px 16px;
  border: 1px solid rgba(245, 199, 106, 0.45);
  background: rgba(245, 199, 106, 0.1);
  color: var(--accent);
  border-radius: 8px;
  font-size: 13px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s ease;
}
.card-action:hover { background: rgba(245, 199, 106, 0.22); }
.card-action.hidden { display: none; }
.card-date {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

/* ---------- 星星标识(占位留言 / 封禁) ---------- */
.card-tag {
  display: inline-block;
  margin-bottom: 10px;
  padding: 3px 12px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.card-tag.placeholder-tag {
  color: var(--muted);
  border: 1px solid var(--muted);
  background: rgba(147, 160, 186, 0.1);
}
.card-tag.banned-tag {
  color: #e06c75;
  border: 1px solid rgba(224, 108, 117, 0.5);
  background: rgba(224, 108, 117, 0.1);
}
.card-tag.hidden { display: none; }

.card-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-top: 4px;
}
.card-report {
  padding: 9px 16px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.card-report:hover { color: #e06c75; border-color: rgba(224, 108, 117, 0.5); }
.card-report.hidden { display: none; }

/* ---------- 评论与星链(功能升级:评论产生星链) ---------- */
.card-comments {
  margin-top: 14px;
  border-top: 1px solid var(--panel-border);
  padding-top: 10px;
  text-align: left;
}
.cm-head {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.cm-list {
  max-height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.cm-item {
  font-size: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 6px 10px;
  line-height: 1.5;
}
.cm-item .cm-meta {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}
.cm-empty { font-size: 12px; color: var(--muted); opacity: 0.7; }
.cm-form { display: flex; gap: 6px; align-items: center; }
.cm-link-input {
  width: 110px;
  padding: 8px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font-size: 12px;
}
.cm-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font-size: 12px;
}
.cm-hint {
  font-size: 10px;
  color: var(--muted);
  opacity: 0.65;
  margin-top: 6px;
}

/* ---------- 每日主题(功能升级 2.1) ---------- */
.theme-pill {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border: 1px solid rgba(245, 199, 106, 0.4);
  background: rgba(10, 14, 24, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  border-radius: 99px;
  font-size: 13px;
  letter-spacing: 0.04em;
  cursor: pointer;
  z-index: 30;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.theme-pill:hover { border-color: var(--accent); background: rgba(245, 199, 106, 0.12); }
.theme-pill.hidden { display: none; }
.theme-pill .t-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.theme-pill .t-count { color: var(--muted); font-size: 12px; }
.theme-pill .t-count b { color: var(--accent2); font-family: monospace; }

.theme-bigword {
  font-family: 'PoiretOne', 'GeistMono', sans-serif;
  font-size: 30px;
  color: var(--accent);
  text-align: center;
  margin: 4px 0 2px;
  letter-spacing: 0.1em;
}
.theme-guide {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 12px;
}
.panel-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  align-items: center;
}
.panel-row .btn-primary { flex: 1; }

.theme-group-list {
  max-height: 300px;
  overflow-y: auto;
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tg-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.tg-item:hover { border-color: var(--accent); }
.tg-item .tg-num { color: var(--accent); font-family: monospace; font-size: 12px; white-space: nowrap; }
.tg-item .tg-msg {
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.tg-empty { color: var(--muted); text-align: center; font-size: 13px; padding: 16px 0; }

/* ---------- 今日之星轮播(功能升级 2.4) ---------- */
.featured-bar {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 28;
  width: min(560px, calc(100vw - 40px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.featured-bar.hidden { display: none; }
.feat-card-mini {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: rgba(10, 14, 24, 0.82);
  border: 1px solid rgba(245, 199, 106, 0.35);
  border-radius: 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}
.feat-ico {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  border: 1px solid rgba(245, 199, 106, 0.4);
  border-radius: 50%;
  background: rgba(245, 199, 106, 0.08);
  flex-shrink: 0;
}
.feat-body { flex: 1; min-width: 0; }
.feat-num { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; }
.feat-msg {
  font-size: 15px;
  color: var(--ink);
  line-height: 1.6;
  margin: 3px 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.feat-meta { color: var(--muted); font-size: 11px; letter-spacing: 0.04em; }
.feat-reason {
  color: var(--accent2);
  font-size: 12px;
  margin-top: 3px;
  line-height: 1.5;
}
.feat-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
}
.feat-close:hover { color: var(--ink); }
.feat-dots { display: flex; gap: 6px; }
.feat-dots .fd {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: background 0.2s ease;
}
.feat-dots .fd.on { background: var(--accent); }

/* ---------- 成就徽章(功能升级 2.2) ---------- */
.badge-progress { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 8px; }
.badge-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  max-height: 340px;
  overflow-y: auto;
  margin: 12px 0;
}
.bdg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  text-align: center;
  transition: border-color 0.2s ease;
}
.bdg .ico { font-size: 22px; line-height: 1; }
.bdg .nm { font-size: 12px; font-weight: 700; color: var(--ink); }
.bdg .ds { font-size: 10px; color: var(--muted); line-height: 1.4; }
.bdg.lock { opacity: 0.42; filter: grayscale(0.9); }
.bdg.new-badge {
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(245, 199, 106, 0.25);
  animation: badge-pop 0.5s ease;
}
@keyframes badge-pop {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}
/* 解锁弹窗(右下角 3 秒动效) */
.badge-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(10, 14, 24, 0.92);
  border: 1px solid rgba(245, 199, 106, 0.5);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: badge-pop 0.45s ease;
}
.badge-toast .bt-ico { font-size: 28px; }
.badge-toast .bt-t {
  font-size: 12px; color: var(--muted); letter-spacing: 0.06em;
}
.badge-toast .bt-n {
  font-size: 15px; font-weight: 700; color: var(--accent);
}

/* ---------- 限时活动(功能升级 2.5) ---------- */
.camp-banner {
  position: fixed;
  left: 50%;
  top: 118px;
  transform: translateX(-50%);
  width: min(480px, calc(100vw - 40px));
  z-index: 27;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(30, 20, 48, 0.92), rgba(10, 14, 24, 0.9));
  border: 1px solid rgba(150, 130, 220, 0.45);
  border-radius: 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  text-align: center;
}
.camp-banner.hidden { display: none; }
.camp-banner .cb-k {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: #9d86e6;
  margin-bottom: 4px;
}
.camp-banner h4 { color: var(--ink); font-size: 17px; margin: 0 0 4px; }
.camp-banner .cb-d { color: var(--muted); font-size: 12px; line-height: 1.5; }
.camp-banner .cb-count { color: var(--accent2); font-size: 12px; margin: 6px 0 8px; }
.camp-banner .cb-count b { font-family: monospace; color: var(--accent); }
.camp-banner .cb-actions { display: flex; gap: 10px; justify-content: center; }

.camp-list {
  max-height: 300px;
  overflow-y: auto;
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.camp-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.camp-item:hover { border-color: #9d86e6; }
.camp-item .cp-num { color: #9d86e6; font-family: monospace; font-size: 12px; white-space: nowrap; }
.camp-item .cp-msg { font-size: 13px; color: var(--ink); flex: 1; word-break: break-word; }

/* ---------- 离线标记(功能升级 3.1) ---------- */
.offline-tag {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 35;
  padding: 6px 14px;
  border: 1px solid rgba(224, 108, 117, 0.5);
  background: rgba(10, 14, 24, 0.85);
  color: #e06c75;
  border-radius: 99px;
  font-size: 12px;
  letter-spacing: 0.04em;
}
.offline-tag.hidden { display: none; }

/* ---------- 高对比模式(功能升级 3.4) ---------- */
body.high-contrast {
  --bg: #000000;
  --ink: #ffffff;
  --muted: #d0d0d0;
  --accent: #ffd94d;
  --accent2: #7fd4ff;
  --panel: rgba(0, 0, 0, 0.92);
  --panel-border: #666666;
}
@media (prefers-contrast: more) {
  body { --ink: #ffffff; --muted: #d0d0d0; --accent: #ffd94d; --accent2: #7fd4ff; }
}
/* 减少动效(功能升级 3.4):跟随系统偏好 */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}

/* ---------- PWA 安装引导(功能升级 3.1) ---------- */
.install-bar {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 36;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(10, 14, 24, 0.92);
  border: 1px solid rgba(245, 199, 106, 0.4);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 12px;
  color: var(--ink);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  animation: badge-pop 0.4s ease;
}
.install-bar .btn-primary { padding: 6px 12px; font-size: 12px; }
.install-bar .btn-ghost { padding: 6px 12px; font-size: 12px; margin-left: 0; }

/* ---------- 性能 HUD(功能升级 3.2,?debug=perf) ---------- */
.perf-hud {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 38;
  padding: 10px 14px;
  background: rgba(10, 14, 24, 0.9);
  border: 1px solid rgba(127, 178, 229, 0.35);
  border-radius: 10px;
  font-size: 12px;
  min-width: 150px;
}
.perf-hud .row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin: 3px 0;
  color: var(--muted);
}
.perf-hud .row b { color: var(--accent); font-family: monospace; }

/* ---------- 星座图鉴(功能升级 2.3) ---------- */
.cons-list {
  max-height: 320px;
  overflow-y: auto;
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cons-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.cons-item:hover { border-color: var(--accent2); }
.cons-item .cn-name { font-weight: 700; color: var(--accent); font-size: 14px; }
.cons-item .cn-meta { color: var(--muted); font-size: 11px; margin-top: 2px; }
.cons-item .cn-arrow { margin-left: auto; color: var(--muted); }

/* ---------- 预览气泡(Hover/长按) ---------- */
.preview-bubble {
  position: fixed;
  z-index: 45;
  background: var(--panel);
  border: 1px solid rgba(245, 199, 106, 0.35);
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.08em;
  padding: 6px 14px;
  border-radius: 16px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: bubbleIn 0.2s ease;
}
@keyframes bubbleIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: calc(70px + var(--safe-top));
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--ink);
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 20px;
  z-index: 50;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: rise 0.3s ease;
}
.toast.error { border-color: rgba(224, 108, 117, 0.5); color: #f0a6ad; }

.hidden { display: none !important; }

/* ============================================================================
   全屏模式
   ========================================================================== */
/* 进入全屏后淡化中央标题与底部按钮,星空更沉浸 */
body.fullscreen-active .ui-title { opacity: 0.18; }
body.fullscreen-active .ui-action { opacity: 0.5; }
body.fullscreen-active .ui-action:hover { opacity: 1; }
/* iOS Safari 等不支持 Fullscreen API 时由 JS 隐藏按钮 */
#btn-fullscreen.hidden { display: none; }

/* ============================================================================
   移动端适配(手机竖屏 / 小屏)
   原则:按钮更小、面板贴近屏幕边缘、不遮挡星空主体
   ========================================================================== */
@media (max-width: 640px) {

  /* 顶部:搜索按钮在左、全屏按钮在右,中间输入框自适应 */
  .ui-top {
    top: calc(8px + var(--safe-top));
    left: 8px;
    right: 8px;
    gap: 8px;
  }
  .ui-icon {
    width: 34px;
    height: 34px;
    font-size: 14px;
    flex: 0 0 auto;
  }
  #btn-fullscreen { margin-left: auto; }

  .search-panel {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0 10px;
  }
  .search-panel input {
    width: 100%;
    height: 34px;
    font-size: 13px;
  }
  .search-results {
    top: 40px;
    max-height: 45vh;
    min-width: 0;
  }

  /* 中央标题:更小、更靠上,给星空留空间 */
  .ui-title { top: calc(32% - 52px); }
  .ui-title h1 { font-size: clamp(16px, 4.5vw, 22px); letter-spacing: 0.2em; }
  .ui-title .star-count { font-size: 11px; margin-top: 8px; gap: 3px; }

  /* 底部主操作:紧凑,不遮挡画面 */
  .ui-action { bottom: calc(14px + var(--safe-bottom)); }
  .btn-primary { font-size: 13px; padding: 9px 20px; }
  .btn-ghost { font-size: 12px; padding: 8px 15px; margin-left: 8px; }

  /* 面板:贴底、全宽、内边距收窄 */
  .glass-panel {
    width: calc(100vw - 20px);
    bottom: calc(70px + var(--safe-bottom));
    padding: 16px;
    border-radius: 14px;
  }
  .glass-panel .panel-head { font-size: 14px; }
  .glass-panel textarea { font-size: 14px; min-height: 56px; }
  .glass-panel .counter { font-size: 11px; }
  .glass-panel .btn-primary { width: 100%; padding: 11px; font-size: 14px; }

  .shape-panel {
    width: calc(100vw - 20px);
    bottom: calc(66px + var(--safe-bottom));
    padding: 14px;
  }
  .shape-panel .panel-head { font-size: 13px; }

  /* 留言卡片:更贴近屏幕,内容居中不拥挤 */
  .star-card {
    width: calc(100vw - 24px);
    padding: 20px 18px 16px;
    border-radius: 14px;
  }
  .card-number { font-size: 14px; }
  .card-message { font-size: 14px; min-height: 3em; }
  .card-close { width: 30px; height: 30px; font-size: 15px; }
  .card-action { font-size: 12px; padding: 8px 14px; }

  .toast { top: calc(50px + var(--safe-top)); font-size: 12px; padding: 8px 16px; }
  .preview-bubble { font-size: 11px; padding: 4px 9px; }
}

/* 超矮视口(手机横屏 / 键盘弹出):面板与按钮进一步压缩,保证可见 */
@media (max-height: 480px) {
  .ui-title { display: none; }
  .ui-action { bottom: calc(10px + var(--safe-bottom)); }
  .glass-panel {
    bottom: calc(64px + var(--safe-bottom));
    max-height: 70vh;
    overflow-y: auto;
  }
  .star-card { top: 42%; }
}
