/* ============================================================
   魔女结社 · Coven of the Moon
   暗黑魔法主题 / Dark Arcane Theme
   ============================================================ */

:root {
  /* ---- 底色：深夜紫黑 ---- */
  --bg:          #0a0710;
  --card:        #150e21;
  --card-2:      #1d142c;
  --elev:        #241834;
  --track:       #2b1d3d;

  /* ---- 文字 ---- */
  --text:        #f2ecf9;
  --text-sub:    #b7a8ce;
  --text-weak:   #7f7299;

  /* ---- 魔法强调色 ---- */
  --brand:       #a855f7;
  --brand-2:     #d8b4fe;
  --brand-dark:  #7c3aed;
  --brand-soft:  rgba(168, 85, 247, .16);
  --accent:      #f072d0;
  --gold:        #e0b45c;

  /* ---- 线与边框 ---- */
  --border:      #2c1f40;
  --line:        rgba(168, 85, 247, .22);
  --line-strong: rgba(168, 85, 247, .45);

  /* ---- 状态色（暗底提亮版） ---- */
  --ok:     #4ade80;
  --warn:   #fbbf24;
  --danger: #f87171;
  --info:   #7dd3fc;

  /* ---- 形状与光影 ---- */
  --radius: 16px;
  --shadow: 0 4px 18px rgba(0, 0, 0, .45);
  --glow:   0 0 20px rgba(168, 85, 247, .28);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* ---- 字体：标题用衬线，营造古典神秘感 ---- */
  --font-serif: Georgia, "Times New Roman", "Songti SC", "STSong", "SimSun", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

html { background: var(--bg); }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* 星夜背景：光晕 + 星点 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 55% at 50% -12%, rgba(168, 85, 247, .22), transparent 70%),
    radial-gradient(ellipse 55% 40% at 88% 8%,   rgba(240, 114, 208, .12), transparent 70%),
    radial-gradient(ellipse 45% 35% at 8% 30%,   rgba(125, 211, 252, .07), transparent 70%);
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .6;
  background-image:
    radial-gradient(1.4px 1.4px at 11% 21%, rgba(255,255,255,.55), transparent),
    radial-gradient(1.1px 1.1px at 74% 13%, rgba(255,255,255,.40), transparent),
    radial-gradient(1.3px 1.3px at 33% 62%, rgba(255,255,255,.34), transparent),
    radial-gradient(1px 1px   at 88% 47%,  rgba(255,255,255,.42), transparent),
    radial-gradient(1.2px 1.2px at 57% 84%, rgba(255,255,255,.30), transparent),
    radial-gradient(1px 1px   at 19% 89%,  rgba(255,255,255,.36), transparent),
    radial-gradient(1.3px 1.3px at 46% 33%, rgba(255,255,255,.26), transparent),
    radial-gradient(1px 1px   at 92% 72%,  rgba(255,255,255,.32), transparent);
  background-repeat: no-repeat;
}

a { color: inherit; text-decoration: none; }
svg { width: 100%; height: 100%; display: block; }

/* 标题统一用衬线，增强仪式感 */
h1, h2, h3, .tile-name, .e-question strong { font-family: var(--font-serif); }

/* ============ 布局容器 ============ */
.page {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(24px + var(--safe-bottom));
}

/* ============ 顶部栏 ============ */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 10, 24, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
}
.appbar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto;
}
.appbar h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
  flex: 1;
  letter-spacing: .04em;
  color: var(--brand-2);
}
.appbar h1::before {
  content: '☾ ';
  color: var(--brand);
  font-size: 15px;
  margin-right: 1px;
}
.appbar .sub {
  font-size: 12px;
  color: var(--text-weak);
  font-weight: 400;
  margin-left: 7px;
  letter-spacing: 0;
  font-family: var(--font-sans);
}

.icon-btn {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--text-sub);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:active { background: var(--elev); color: var(--brand-2); }
.icon-btn svg { width: 20px; height: 20px; }

/* ============ 欢迎横幅 ============ */
.hero {
  position: relative;
  margin: 14px 12px 4px;
  padding: 24px 20px 20px;
  border-radius: var(--radius);
  background:
    radial-gradient(ellipse 70% 90% at 50% 0%, rgba(216, 180, 254, .16), transparent 70%),
    linear-gradient(150deg, #3b0764, #1e0f38 60%, #170b28);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .5), var(--glow);
  text-align: center;
  overflow: hidden;
}
.hero::before {
  content: '☾ ✦ ☾';
  display: block;
  font-size: 13px;
  letter-spacing: .5em;
  color: var(--gold);
  opacity: .85;
  margin-bottom: 10px;
  text-indent: .5em;
}
.hero-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .05em;
  color: #f7f0ff;
}
.hero-desc {
  font-size: 13px;
  color: var(--text-sub);
  margin-top: 6px;
  line-height: 1.7;
}

/* 标题与描述下方的金色细线，替代原统计行的分隔结构 */
.hero-flourish {
  display: block;
  width: 76px;
  height: 1px;
  margin: 15px auto 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: .75;
}

/* ============ 区块标题 ============ */
.section { margin-top: 22px; padding: 0 12px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 4px 10px;
}
.section-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--brand-2);
}
.section-title::before {
  content: '◆ ';
  font-size: 9px;
  color: var(--gold);
  vertical-align: 1px;
}
.section-more { font-size: 12px; color: var(--text-weak); }

/* ============ 功能九宫格 ============ */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (min-width: 400px) { .grid { grid-template-columns: repeat(4, 1fr); gap: 12px; } }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(5, 1fr); } }

.tile {
  position: relative;
  background: linear-gradient(165deg, var(--card-2), var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 6px 12px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .25s ease, border-color .25s ease;
  display: block;
  overflow: hidden;
}
.tile::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 50% 0%, rgba(168, 85, 247, .18), transparent 65%);
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
}
.tile:active { transform: scale(.96); }
@media (hover: hover) {
  .tile:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow), var(--glow);
    transform: translateY(-2px);
  }
  .tile:hover::after { opacity: 1; }
}

.tile-icon {
  position: relative;
  z-index: 1;
  width: 46px;
  height: 46px;
  margin: 0 auto 9px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, .07);
}
.tile-icon svg { width: 24px; height: 24px; }
.tile-name {
  position: relative;
  z-index: 1;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: .02em;
}
.tile-desc {
  position: relative;
  z-index: 1;
  font-size: 11px;
  color: var(--text-weak);
  margin-top: 2px;
}

.tile-badge {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 2;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: linear-gradient(135deg, #f072d0, #c026d3);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  font-weight: 500;
  box-shadow: 0 0 10px rgba(240, 114, 208, .5);
}

/* ============ 最近使用（横向滚动） ============ */
.recent-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 12px 6px;
  margin: 0 -12px;
  scrollbar-width: none;
}
.recent-scroll::-webkit-scrollbar { display: none; }
.recent-item {
  flex: 0 0 auto;
  width: 84px;
  background: linear-gradient(165deg, var(--card-2), var(--card));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 6px;
  text-align: center;
  box-shadow: var(--shadow);
  font-size: 12px;
}
.recent-item:active { transform: scale(.96); }
.recent-item .tile-icon { width: 32px; height: 32px; border-radius: 10px; margin-bottom: 6px; }
.recent-item .tile-icon svg { width: 17px; height: 17px; }
.recent-item span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============ 通用卡片 ============ */
.card {
  margin: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: linear-gradient(165deg, var(--card-2), var(--card));
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .05);
}
.card h3 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--brand-2);
}
.card p { margin: 0; font-size: 13px; color: var(--text-sub); }

/* ============ 功能页（通用模板） ============ */
.feature-hero {
  margin: 14px 12px;
  padding: 20px;
  border-radius: var(--radius);
  background: linear-gradient(165deg, var(--card-2), var(--card));
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .05);
  display: flex;
  align-items: center;
  gap: 14px;
}
.feature-hero .tile-icon { width: 56px; height: 56px; margin: 0; border-radius: 16px; }
.feature-hero .tile-icon svg { width: 28px; height: 28px; }
.feature-hero h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: .04em; }
.feature-hero p { margin: 4px 0 0; font-size: 13px; color: var(--text-sub); }

.list { list-style: none; margin: 6px 0 0; padding: 0; }
.list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.list li:last-child { border-bottom: none; }
.list .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--brand);
  flex: 0 0 6px;
  box-shadow: 0 0 8px var(--brand);
}
.list .time { margin-left: auto; font-size: 12px; color: var(--text-weak); }

.code-hint {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--elev);
  border: 1px dashed var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-sub);
  word-break: break-all;
}

.empty {
  margin: 60px 12px;
  text-align: center;
  color: var(--text-weak);
  font-size: 14px;
}
.btn-primary {
  display: inline-block;
  margin-top: 14px;
  padding: 10px 20px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  font-size: 14px;
  box-shadow: var(--glow);
}
.btn-primary:active { background: var(--brand-dark); }

/* 底部说明 */
.footer-tip {
  margin: 26px 12px 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-weak);
  line-height: 1.7;
}

::selection { background: rgba(168, 85, 247, .38); color: #fff; }

/* 页脚装饰符：金色微光 */
.footer-tip { color: var(--text-weak); }
.footer-tip::first-letter { color: var(--gold); }

/* ============ 滚动条 ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--track); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

/* ============ 入场动画：秘仪依次浮现 ============ */
@keyframes covenRise {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes covenGlow {
  0%, 100% { opacity: .5; }
  50%      { opacity: 1; }
}

.tile { animation: covenRise .45s cubic-bezier(.22, .9, .3, 1) both; }
.grid .tile:nth-child(1) { animation-delay: .03s; }
.grid .tile:nth-child(2) { animation-delay: .07s; }
.grid .tile:nth-child(3) { animation-delay: .11s; }
.grid .tile:nth-child(4) { animation-delay: .15s; }
.grid .tile:nth-child(5) { animation-delay: .19s; }
.grid .tile:nth-child(6) { animation-delay: .23s; }
.grid .tile:nth-child(7) { animation-delay: .27s; }
.grid .tile:nth-child(8) { animation-delay: .31s; }
.grid .tile:nth-child(n+9) { animation-delay: .35s; }

.hero::before { animation: covenGlow 4s ease-in-out infinite; }
.section { animation: covenRise .5s cubic-bezier(.22, .9, .3, 1) both; }
.section:nth-of-type(1) { animation-delay: .38s; }
.section:nth-of-type(2) { animation-delay: .44s; }

/* 尊重系统「减少动效」偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
