/* ZCOOL XiaoWei 个别字渲染坏（已知 U+56DE "回"），用系统中文字体兜底。
   往 unicode-range 里加范围或单字就能扩。浏览器对范围内的字符走 system-cjk-fix，
   其他字符正常用 ZCOOL XiaoWei。 */
@font-face {
  font-family: 'system-cjk-fix';
  src: local('PingFang SC'), local('Noto Sans SC'),
       local('Hiragino Sans GB'), local('Microsoft YaHei');
  unicode-range: U+56DE;
  font-display: swap;
}

/* ==== 暖色 palette ==== */
:root {
  --bg:          #FAF6F0;
  --bg-elevated: #FFFFFF;
  --bg-soft:     #F3E9DC;
  --border:      #E5D5C0;
  --text:        #3D2817;
  --text-sub:    #7A5A3E;
  --text-dim:    #B89F84;
  --accent:      #9B5A3E;
  --accent-soft: #C68B5C;
  --danger:      #B23A2A;
  --ok:          #6E8E3F;

  --heat-0: #EFE6DC;
  --heat-1: #ECD5BB;
  --heat-2: #D4A77A;
  --heat-3: #B47845;
  --heat-4: #8B4513;

  --radius:    14px;
  --radius-sm: 8px;
  --shadow:    0 1px 2px rgba(60,30,10,0.04), 0 4px 16px rgba(60,30,10,0.05);
  --font-sans:  "system-cjk-fix", "ZCOOL XiaoWei", -apple-system, "PingFang SC",
                "Noto Sans SC", "Hiragino Sans GB", "Microsoft YaHei",
                system-ui, sans-serif;
  --font-serif: "system-cjk-fix", "ZCOOL XiaoWei", "Noto Serif SC", "Songti SC",
                Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ==== 登录页 ==== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 420px;
  width: 100%;
}
.login-title {
  font-family: var(--font-serif);
  font-size: 32px;
  color: var(--accent);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
.login-sub {
  color: var(--text-sub);
  margin-bottom: 28px;
  font-size: 14px;
}
.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 16px;
  min-height: 20px;
}

/* ==== 主面板 ==== */
.dashboard {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  gap: 16px;
}
.brand {
  font-family: var(--font-serif);
  font-size: 34px;
  color: var(--accent);
  line-height: 1.1;
  letter-spacing: 0.04em;
}
.brand-sub {
  color: var(--text-sub);
  font-size: 13px;
  margin-top: 4px;
}

/* ==== 卡片基础 ==== */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 16px;
}
.card-title {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--accent);
  letter-spacing: 0.03em;
}
.card-title.small-title { font-size: 18px; }
.card-sub {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 4px;
}

/* ==== 按钮 ==== */
.ghost-btn {
  background: transparent;
  color: var(--text-sub);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.ghost-btn:hover { color: var(--accent); border-color: var(--accent-soft); }
.ghost-btn.small { padding: 4px 10px; font-size: 12px; }
.primary-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.primary-btn:hover { background: var(--accent-soft); }
.seg-btn {
  background: var(--bg-soft);
  color: var(--text-sub);
  border: none;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 6px;
}
.seg-btn.active { background: var(--accent); color: #fff; }
.metric-switch { display: flex; }

/* ==== 热力图 ==== */
.heatmap-wrap { padding-top: 4px; }
.heatmap-months {
  display: flex;
  font-size: 11px;
  color: var(--text-sub);
  padding-left: 30px;
  margin-bottom: 4px;
  height: 14px;
}
.heatmap-months span { flex-shrink: 0; }
.heatmap-body {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.heatmap-rowlabels {
  display: grid;
  grid-template-rows: repeat(7, 14px);
  gap: 3px;
  font-size: 10px;
  color: var(--text-sub);
  text-align: right;
  padding-right: 6px;
  padding-top: 1px;
}
.heatmap-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 14px);
  gap: 3px;
  flex: 1;
  overflow-x: auto;
}
.cell {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--heat-0);
  cursor: default;
  transition: transform 0.1s;
}
.cell:hover { transform: scale(1.4); outline: 1px solid var(--accent); }
.cell.l0 { background: var(--heat-0); }
.cell.l1 { background: var(--heat-1); }
.cell.l2 { background: var(--heat-2); }
.cell.l3 { background: var(--heat-3); }
.cell.l4 { background: var(--heat-4); }
.cell.future { opacity: 0; pointer-events: none; }
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 14px;
  justify-content: flex-end;
}
.lc { width: 12px; height: 12px; border-radius: 2px; }
.lc-0 { background: var(--heat-0); }
.lc-1 { background: var(--heat-1); }
.lc-2 { background: var(--heat-2); }
.lc-3 { background: var(--heat-3); }
.lc-4 { background: var(--heat-4); }

/* ==== 两栏 layout ==== */
.row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.row-2col > .card { margin-bottom: 0; }
@media (max-width: 700px) {
  .row-2col { grid-template-columns: 1fr; }
}

/* ==== 数字面板 ==== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-top: 12px;
}
.stat-cell {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.stat-num {
  font-family: var(--font-serif);
  font-size: 32px;
  color: var(--accent);
  line-height: 1.1;
}
.stat-label {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 4px;
}

/* ==== 漂浮 ==== */
.drift-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  margin-top: 8px;
}
.drift-item {
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.drift-item:last-child { border-bottom: none; }
.drift-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.drift-title {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}

/* ==== 服务状态 ==== */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.svc-cell {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.svc-name {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--accent);
}
.svc-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.svc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); }
.svc-dot.online { background: var(--ok); }
.svc-dot.stopped, .svc-dot.errored { background: var(--danger); }
.svc-meta {
  font-size: 11px;
  color: var(--text-sub);
}

/* ==== 印象 ==== */
.impr-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.impr-item {
  padding: 12px 14px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s;
}
.impr-item:hover { background: #EBDFCB; }
.impr-date {
  font-size: 12px;
  color: var(--text-sub);
  margin-bottom: 4px;
}
.impr-title {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}
.impr-excerpt {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.5;
}

/* ==== 搜索 ==== */
.search-bar {
  display: flex;
  flex-wrap: wrap;          /* 窄屏按钮换到下一行而不是溢出 */
  gap: 8px;
  margin-top: 4px;
  margin-bottom: 14px;
}
.search-bar input {
  flex: 1 1 200px;          /* 至少 200px，宽屏跟按钮同行，窄屏占满 */
  min-width: 0;             /* 防止 flex item 撑破容器 */
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-elevated);
  color: var(--text);
}
.search-bar input:focus {
  outline: none;
  border-color: var(--accent-soft);
}
.search-bar .primary-btn {
  flex: 0 0 auto;
}
.search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.result-item {
  padding: 12px 14px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s;
}
.result-item:hover { background: #EBDFCB; }
.result-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-sub);
}
.result-channels { color: var(--accent); }
.result-title {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}
.result-excerpt {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.5;
}

/* ==== Modal ==== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(40,20,10,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 24px;
}
.modal {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  max-width: 700px; width: 100%; max-height: 80vh; overflow-y: auto;
  padding: 28px 32px; position: relative;
  box-shadow: 0 20px 60px rgba(40,20,10,0.25);
}
.modal-close {
  position: absolute; top: 14px; right: 18px;
  background: transparent; border: none; cursor: pointer;
  font-size: 24px; color: var(--text-sub); line-height: 1;
}
.modal-close:hover { color: var(--accent); }
.modal-content { color: var(--text); }
.modal-content h1 {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--accent);
  margin: 0 0 8px;
}
.modal-meta {
  font-size: 12px; color: var(--text-sub); margin-bottom: 16px;
}
.modal-body {
  white-space: pre-wrap;
  line-height: 1.75;
  font-size: 14px;
}
.modal-form { display: flex; flex-direction: column; gap: 6px; }
.modal-label { font-size: 12px; color: var(--text-sub); }
.modal-input, .modal-textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-elevated);
  color: var(--text);
  width: 100%;
}
.modal-input:focus, .modal-textarea:focus {
  outline: none; border-color: var(--accent-soft);
}
.modal-textarea { min-height: 220px; line-height: 1.75; resize: vertical; }
.modal-row { display: flex; gap: 12px; flex-wrap: wrap; }
.modal-col { flex: 1 1 140px; display: flex; flex-direction: column; gap: 4px; }
.modal-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; flex-wrap: wrap; gap: 8px;
}
.modal-actions-right { display: flex; gap: 8px; }
.ghost-btn.danger { color: var(--danger); border-color: rgba(178,58,42,0.3); }
.ghost-btn.danger:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
.modal-msg { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 6px; }
.modal-readonly-meta {
  font-size: 11px; color: var(--text-dim);
  border-top: 1px dashed var(--border); padding-top: 8px; margin-top: 4px;
}

/* ==== 纪念日 ==== */
.anniv-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.anniv-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  transition: transform 0.2s;
}
.anniv-row.next-up {
  background: linear-gradient(135deg, rgba(155,90,62,0.12), rgba(198,139,92,0.08));
  border: 1px solid rgba(155,90,62,0.25);
}
.anniv-row.today {
  background: linear-gradient(135deg, #FCE4A8 0%, #F8B96C 100%);
  border: 1px solid #D4A017;
  animation: anniv-glow 2.5s ease-in-out infinite;
}
@keyframes anniv-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212,160,23,0); }
  50%      { box-shadow: 0 0 18px 2px rgba(212,160,23,0.4); }
}
.anniv-emoji { font-size: 26px; line-height: 1; }
.anniv-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.anniv-name {
  font-family: var(--font-serif);
  color: var(--accent);
  font-size: 15px;
}
.anniv-meta { font-size: 11px; color: var(--text-sub); }
.anniv-count {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.anniv-count-unit { font-size: 11px; color: var(--text-sub); }

/* 纪念日模式：换色（金/玫瑰），全局 accent 变暖 */
body.anniversary-mode {
  --accent:      #C4860D;
  --accent-soft: #E5BC4A;
}

/* 撒花：emoji 从顶端飘落 */
.confetti {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  pointer-events: none; overflow: hidden; z-index: 100;
}
.confetti.hidden { display: none; }
.confetti span {
  position: absolute; top: -40px;
  font-size: 24px;
  opacity: 0.95;
  animation: fall linear infinite;
  will-change: transform;
}
@keyframes fall {
  0%   { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(110vh) rotate(720deg); }
}

/* ==== 里程碑 ==== */
.milestone-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  margin-left: 6px;
  vertical-align: middle;
}
.milestone-hint {
  font-size: 11px;
  color: var(--accent);
  margin-top: 4px;
}

/* ==== Footer ==== */
.page-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 11px;
  color: var(--text-dim);
}
