/* ==========================================================
   全站主题变量
   ========================================================== */

/* -------- 蓝色（默认） -------- */
:root,
html[data-theme="light"] {
  --bg: #f6f6f6;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #8590a6;
  --border: #ebebeb;
  --accent: #0084ff;
  --navbar-bg: rgba(255, 255, 255, 0.82);

  --accent-04: rgba(0, 132, 255, 0.04);
  --accent-05: rgba(0, 132, 255, 0.05);
  --accent-06: rgba(0, 132, 255, 0.06);
  --accent-08: rgba(0, 132, 255, 0.08);
  --accent-10: rgba(0, 132, 255, 0.1);
  --accent-12: rgba(0, 132, 255, 0.12);
  --accent-16: rgba(0, 132, 255, 0.16);
  --accent-18: rgba(0, 132, 255, 0.18);
  --accent-28: rgba(0, 132, 255, 0.28);
  --accent-35: rgba(0, 132, 255, 0.35);

  --soft: #f2f3f5;
  --soft-2: #f4f5f7;
  --soft-hover: #eef0f1;
  --dot: #ddd;

  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;

  --shadow-sm: 0 1px 3px rgba(18, 18, 18, 0.05);
  --shadow-md: 0 4px 14px rgba(18, 18, 18, 0.08);
  --shadow-lg: 0 6px 18px rgba(18, 18, 18, 0.09);
}

/* -------- 夜间模式 -------- */
html[data-theme="dark"] {
  --bg: #17181c;
  --card: #232428;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --border: #34363c;
  --accent: #4a9eff;
  --navbar-bg: rgba(35, 36, 40, 0.82);

  --accent-04: rgba(74, 158, 255, 0.06);
  --accent-05: rgba(74, 158, 255, 0.08);
  --accent-06: rgba(74, 158, 255, 0.1);
  --accent-08: rgba(74, 158, 255, 0.12);
  --accent-10: rgba(74, 158, 255, 0.16);
  --accent-12: rgba(74, 158, 255, 0.2);
  --accent-16: rgba(74, 158, 255, 0.24);
  --accent-18: rgba(74, 158, 255, 0.28);
  --accent-28: rgba(74, 158, 255, 0.36);
  --accent-35: rgba(74, 158, 255, 0.44);

  --soft: #2c2e34;
  --soft-2: #1e2025;
  --soft-hover: #33353b;
  --dot: #4a4d54;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 6px 18px rgba(0, 0, 0, 0.55);
}

/* -------- 粉色 -------- */
html[data-theme="pink"] {
  --bg: #f7f5f6;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #8f8a90;
  --border: #ece7ea;
  --accent: #fb7299;
  --navbar-bg: rgba(247, 245, 246, 0.82);

  --accent-04: rgba(251, 114, 153, 0.04);
  --accent-05: rgba(251, 114, 153, 0.05);
  --accent-06: rgba(251, 114, 153, 0.06);
  --accent-08: rgba(251, 114, 153, 0.08);
  --accent-10: rgba(251, 114, 153, 0.1);
  --accent-12: rgba(251, 114, 153, 0.12);
  --accent-16: rgba(251, 114, 153, 0.16);
  --accent-18: rgba(251, 114, 153, 0.18);
  --accent-28: rgba(251, 114, 153, 0.28);
  --accent-35: rgba(251, 114, 153, 0.35);

  --soft: #f2eef0;
  --soft-2: #f4f0f2;
  --soft-hover: #ebe5e8;
  --dot: #ddd5d9;

  --shadow-sm: 0 1px 3px rgba(18, 18, 18, 0.05);
  --shadow-md: 0 4px 14px rgba(18, 18, 18, 0.08);
  --shadow-lg: 0 6px 18px rgba(18, 18, 18, 0.09);
}

/* -------- 绿色 -------- */
html[data-theme="green"] {
  --bg: #f5f9f6;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #7e9188;
  --border: #e3ece6;
  --accent: #2dbe60;
  --navbar-bg: rgba(255, 255, 255, 0.82);

  --accent-04: rgba(45, 190, 96, 0.04);
  --accent-05: rgba(45, 190, 96, 0.05);
  --accent-06: rgba(45, 190, 96, 0.06);
  --accent-08: rgba(45, 190, 96, 0.08);
  --accent-10: rgba(45, 190, 96, 0.1);
  --accent-12: rgba(45, 190, 96, 0.12);
  --accent-16: rgba(45, 190, 96, 0.16);
  --accent-18: rgba(45, 190, 96, 0.18);
  --accent-28: rgba(45, 190, 96, 0.28);
  --accent-35: rgba(45, 190, 96, 0.35);

  --soft: #ecf5f1;
  --soft-2: #edf6f0;
  --soft-hover: #e3efe9;
  --dot: #d5e3da;

  --shadow-sm: 0 1px 3px rgba(20, 120, 90, 0.06);
  --shadow-md: 0 4px 14px rgba(20, 120, 90, 0.1);
  --shadow-lg: 0 6px 18px rgba(20, 120, 90, 0.12);
}

/* -------- 橙色 -------- */
html[data-theme="orange"] {
  --bg: #f7f5f3;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #908a83;
  --border: #ece8e3;
  --accent: #eb7350;
  --navbar-bg: rgba(247, 245, 243, 0.82);

  --accent-04: rgba(255, 130, 0, 0.04);
  --accent-05: rgba(255, 130, 0, 0.05);
  --accent-06: rgba(255, 130, 0, 0.06);
  --accent-08: rgba(255, 130, 0, 0.08);
  --accent-10: rgba(255, 130, 0, 0.1);
  --accent-12: rgba(255, 130, 0, 0.12);
  --accent-16: rgba(255, 130, 0, 0.16);
  --accent-18: rgba(255, 130, 0, 0.18);
  --accent-28: rgba(255, 130, 0, 0.28);
  --accent-35: rgba(255, 130, 0, 0.35);

  --soft: #f2eee9;
  --soft-2: #f5f1ec;
  --soft-hover: #ebe5de;
  --dot: #ddd6cc;

  --shadow-sm: 0 1px 3px rgba(18, 18, 18, 0.05);
  --shadow-md: 0 4px 14px rgba(18, 18, 18, 0.08);
  --shadow-lg: 0 6px 18px rgba(18, 18, 18, 0.09);
}

/* -------- 黄色 -------- */
html[data-theme="yellow"] {
  --bg: #f7f6f3;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #8f8d87;
  --border: #ecebe5;
  --accent: #e6a817;
  --navbar-bg: rgba(247, 246, 243, 0.82);

  --accent-04: rgba(230, 168, 23, 0.04);
  --accent-05: rgba(230, 168, 23, 0.05);
  --accent-06: rgba(230, 168, 23, 0.06);
  --accent-08: rgba(230, 168, 23, 0.08);
  --accent-10: rgba(230, 168, 23, 0.1);
  --accent-12: rgba(230, 168, 23, 0.12);
  --accent-16: rgba(230, 168, 23, 0.16);
  --accent-18: rgba(230, 168, 23, 0.18);
  --accent-28: rgba(230, 168, 23, 0.28);
  --accent-35: rgba(230, 168, 23, 0.35);

  --soft: #f2f1ec;
  --soft-2: #f5f4ef;
  --soft-hover: #ebe9e2;
  --dot: #ddd9d0;

  --shadow-sm: 0 1px 3px rgba(18, 18, 18, 0.05);
  --shadow-md: 0 4px 14px rgba(18, 18, 18, 0.08);
  --shadow-lg: 0 6px 18px rgba(18, 18, 18, 0.09);
}

/* -------- 紫色 -------- */
html[data-theme="purple"] {
  --bg: #f5f4f7;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #8b8890;
  --border: #e9e7ec;
  --accent: #946ce6;
  --navbar-bg: rgba(245, 244, 247, 0.82);

  --accent-04: rgba(148, 108, 230, 0.04);
  --accent-05: rgba(148, 108, 230, 0.05);
  --accent-06: rgba(148, 108, 230, 0.06);
  --accent-08: rgba(148, 108, 230, 0.08);
  --accent-10: rgba(148, 108, 230, 0.1);
  --accent-12: rgba(148, 108, 230, 0.12);
  --accent-16: rgba(148, 108, 230, 0.16);
  --accent-18: rgba(148, 108, 230, 0.18);
  --accent-28: rgba(148, 108, 230, 0.28);
  --accent-35: rgba(148, 108, 230, 0.35);

  --soft: #f0eef4;
  --soft-2: #f3f1f7;
  --soft-hover: #e9e6ef;
  --dot: #dbd6e3;

  --shadow-sm: 0 1px 3px rgba(18, 18, 18, 0.05);
  --shadow-md: 0 4px 14px rgba(18, 18, 18, 0.08);
  --shadow-lg: 0 6px 18px rgba(18, 18, 18, 0.09);
}

/* ==========================================================
   基础样式
   ========================================================== */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

html.theme-transition,
html.theme-transition * {
  transition:
    background-color 0.25s ease,
    color 0.25s ease,
    border-color 0.25s ease !important;
}

/* ==========================================================
   通用导航栏
   ========================================================== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--navbar-bg);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.navbar-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  max-width: 800px;
  margin: 0 auto;
  padding: 8px 16px;
  min-height: 50px;
}

.navbar-left {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
}
.navbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

/* 返回按钮 */
.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  margin-left: -6px;
  background: var(--soft);
  color: var(--text);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background 0.15s,
    color 0.15s,
    transform 0.1s;
  cursor: pointer;
  border: none;
  font-family: inherit;
  line-height: 1.4;
}
.nav-btn:hover {
  background: var(--accent-10);
  color: var(--accent);
}
.nav-btn:active {
  transform: scale(0.97);
}

/* 顶部标题：位置提示，轻量克制 */
.navbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  margin: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  padding: 0 4px;
  letter-spacing: 0.01em;
}

/* 右侧下拉 */
.nav-select {
  font-size: 13px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
  line-height: 1.4;
}
.nav-select:hover {
  background: var(--soft);
  border-color: var(--accent-35);
}
.nav-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* 右侧开关 */
.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color 0.15s;
  line-height: 1.4;
}
.nav-toggle input {
  cursor: pointer;
  margin: 0;
}
.nav-toggle input:checked ~ span {
  color: var(--accent);
  font-weight: 600;
}

/* ==========================================================
   通用错误页
   ========================================================== */
:root { --navbar-h: 50px; }
@media (max-width: 480px) { :root { --navbar-h: 46px; } }

.site-error {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--navbar-h);
  bottom: 0;
  z-index: 90;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 64px 16px 24px;
  background: var(--bg);
  overflow-y: auto;
}
.site-error[hidden] { display: none; }

.site-error-inner {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 48px 32px 40px;
  text-align: center;
  max-width: 800px;
  width: 100%;
}

.site-error-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--muted);
}
.site-error-icon svg { width: 72px; height: 72px; }
.site-error-icon .bg { fill: var(--soft); }

.site-error-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}

.site-error-msg {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.7;
  margin: 0 0 22px;
  word-break: break-word;
}
.site-error-msg b { color: var(--text); font-weight: 600; }
.site-error-msg code {
  background: var(--soft);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: Consolas, Menlo, monospace;
  font-size: 0.9em;
}

.site-error-btn {
  display: inline-block;
  font-size: 14px;
  color: var(--accent);
  text-decoration: none;
  padding: 8px 22px;
  border-radius: 999px;
  background: var(--accent-08);
  transition: background 0.15s;
  cursor: pointer;
  border: none;
  font-family: inherit;
}
.site-error-btn:hover { background: var(--accent-16); }
.site-error-btn + .site-error-btn { margin-left: 8px; }

@media (max-width: 480px) {
  .navbar-inner {
    padding: 6px 12px;
    gap: 8px;
    min-height: 46px;
  }
  .navbar-title {
    font-size: 14px;
    padding: 0 2px;
  }
  .nav-btn {
    padding: 5px 8px;
    font-size: 12.5px;
  }
  .nav-select {
    padding: 4px 10px;
    font-size: 12.5px;
  }
  .nav-toggle {
    font-size: 12.5px;
    gap: 4px;
  }
  .site-error { padding: 40px 12px 16px; }
  .site-error-inner { padding: 40px 24px 32px; }
  .site-error-icon svg { width: 60px; height: 60px; }
}
