/* Base Theme */
:root {
  --bg: #0a0f0f;
  --fg: #c9d1d9;
  --muted: #7d8b93;
  --accent: #00ffd1;
  --accent2: #ff375f;
  --panel: #0d1416;
  --border: #1b2a2f;
  --shadow: rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1500px 800px at 20% 0%, #071012 0%, var(--bg) 35%, #060b0c 100%);
  color: var(--fg);
  font-family: Consolas, "Courier New", monospace;
}

/* Subtle noise overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="2" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23n)" opacity="0.06"/></svg>');
  mix-blend-mode: overlay;
}

.site-header { padding: 28px 20px 12px; border-bottom: 1px solid var(--border); }
.title { font-size: 28px; letter-spacing: 2px; }
.subtitle { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* Glitch effect */
.glitch {
  position: relative;
  color: var(--fg);
  text-shadow: 0 0 6px rgba(0,255,209,0.25);
}
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0; top: 0;
  color: var(--fg);
  clip-path: polygon(0 2%, 100% 0, 100% 98%, 0 100%);
}
.glitch::before { transform: translate(1px, -1px); color: #00ffc3; opacity: .5; }
.glitch::after { transform: translate(-1px, 1px); color: #ff2e63; opacity: .4; }
.glitch { animation: glitch 3s infinite linear; }
@keyframes glitch {
  0%, 8%, 100% { filter: none; }
  1% { filter: hue-rotate(20deg) contrast(1.1); }
  2% { transform: skewX(1deg); }
  5% { transform: skewX(-1deg); }
}

.topbar { margin-top: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.search { display: flex; align-items: center; gap: 8px; }

input[type="text"], input[type="password"] {
  background: #0b1316;
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 10px;
  border-radius: 6px;
  outline: none;
  min-width: 240px;
}
input[type="text"]::placeholder, input[type="password"]::placeholder { color: #5e6c73; }

.btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.btn-primary { border-color: var(--accent); color: var(--accent); }
.btn-secondary { border-color: #3a4a53; color: #87a1ad; }
.btn-danger { border-color: var(--accent2); color: var(--accent2); }
.btn-ghost { border-color: #3a4a53; color: #637682; }
.btn:hover { box-shadow: 0 0 10px rgba(0,255,209,0.12); }

.user-info { color: #87a1ad; margin-right: 6px; }

main { padding: 18px 20px 40px; }
.posts { display: grid; grid-template-columns: 1fr; gap: 14px; }

.post {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px var(--shadow);
  border-left: 3px solid rgba(0,255,209,0.25);
  padding: 16px 16px 14px;
}
.post-title { margin: 0 0 10px 0; font-size: 18px; }
.post-author { font-size: 12px; color: var(--muted); margin-left: 10px; }
.post-body { color: var(--fg); line-height: 1.65; }
.post-body ol { padding-left: 20px; }

.keyword { font-weight: 700; color: var(--accent); }

.locked {
  margin: 16px 0 0;
  border: 1px dashed #3a4a53;
  border-left: 3px solid var(--accent2);
  padding: 12px;
  background: #0b1316;
}
.locked-head { color: #caa; margin-bottom: 8px; }
.locked-controls { display: flex; gap: 8px; align-items: center; }

.hidden-content { margin-top: 14px; border: 1px solid #13464f; padding: 12px; background: #071214; box-shadow: 0 0 12px rgba(0,255,209,0.08) inset; }

.error { margin-top: 8px; color: var(--accent2); font-size: 12px; }
.empty { color: var(--muted); padding: 16px; }

/* Search results */
.search-results { display: grid; grid-template-columns: 1fr; gap: 14px; }

/* Modal */
.modal {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: rgba(0,0,0,0.55);
  z-index: 1000;
}
.modal-content {
  width: 340px; max-width: 90vw;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px var(--shadow);
  padding: 16px;
}
.modal-title { font-size: 16px; margin-bottom: 12px; color: var(--accent); }
.modal-actions { display: flex; gap: 10px; margin-top: 12px; }

/* Responsive */
@media (max-width: 640px) {
  input[type="text"], input[type="password"] { min-width: 1px; width: 100%; }
  .search { width: 100%; }
}

/* List-only homepage: hide bodies, make titles clickable */
.posts .post .post-title { cursor: pointer; }
.posts .post .post-title:hover { color: var(--accent); }
.posts .post .post-body { display: none; }

/* 首页《复活秘法》标题字号增强（仅列表页） */
#posts-list #post-cost .post-title {
  font-size: clamp(22px, 3.4vw, 34px);
  line-height: 1.12;
  letter-spacing: 0.8px;
}

/* Search results list: titles clickable, bodies hidden */
.search-results .post .post-title { cursor: pointer; }
.search-results .post .post-title:hover { color: var(--accent); }
.search-results .post .post-body { display: none; }

/* Detail view */
.post-detail { margin-top: 18px; }
.post-detail .detail-actions { margin-bottom: 12px; }
.post-detail .post .post-body { display: block; }

/* 外部字体应用到《代价》恐怖风格 */
#post-cost .post-title { font-family: 'Zhi Mang Xing','Ma Shan Zheng','STKaiti','KaiTi',serif; }
#post-cost .post-body { font-family: 'Zhi Mang Xing','Ma Shan Zheng','STKaiti','KaiTi',serif; }
#post-cost {
  position: relative;
  overflow: hidden;
  background: #0b0607;
  border: 1px solid #2b0f14;
  border-left: 4px solid rgba(255, 32, 72, 0.55);
  box-shadow: 0 6px 24px rgba(0,0,0,0.6), 0 0 40px rgba(255,0,72,0.06) inset;
  animation: costPulse 4.2s ease-in-out infinite;
}
#post-cost::before {
  content: "";
  position: absolute; inset: -20px; pointer-events: none;
  background:
    radial-gradient(13px 13px at 14% 12%, rgba(160,0,14,.55) 40%, transparent 44%),
    radial-gradient(9px 9px at 28% 18%, rgba(160,0,14,.6) 40%, transparent 44%),
    radial-gradient(16px 16px at 72% 10%, rgba(160,0,14,.5) 38%, transparent 42%),
    radial-gradient(11px 11px at 55% 40%, rgba(160,0,14,.55) 40%, transparent 44%),
    radial-gradient(20px 20px at 84% 62%, rgba(160,0,14,.45) 36%, transparent 42%),
    radial-gradient(12px 12px at 10% 78%, rgba(160,0,14,.5) 40%, transparent 44%);
  opacity: .35; filter: blur(.2px); mix-blend-mode: screen;
}
#post-cost::after {
  content: "";
  position: absolute; top: 0; left: 18%; width: 3px; height: 72px;
  background: linear-gradient(to bottom, rgba(200,0,24,.85), rgba(200,0,24,0));
  filter: blur(.3px); opacity:.45; pointer-events:none;
  box-shadow: 90px 0 0 rgba(200,0,24,.35), 220px 0 0 rgba(200,0,24,.3), 310px 0 0 rgba(200,0,24,.25);
}
#post-cost .post-title {
  color: #ff1038;
  font-weight: 800;
  letter-spacing: 1px;
  text-shadow: 0 0 10px rgba(255,0,80,.35), 0 2px 0 #2a0006, 0 4px 0 #2a0006, 0 8px 14px rgba(0,0,0,.55);
  transform: skewX(-1deg);
}
#post-cost .post-title:hover { color: #ff2a4a; }
#post-cost .post-body { color: #e23a49; text-shadow: 0 0 8px rgba(255,0,64,.25); }
#post-cost .post-body p { margin: 10px 0; }
@keyframes costPulse { 0%, 100% { filter: none; } 50% { filter: brightness(1.06) saturate(1.2); } }
/* Login form alignment */
#login-form label { display: block; margin: 8px 0 4px; color: var(--muted); }
#login-form input[type="text"],
#login-form input[type="password"] { width: 100%; margin-bottom: 8px; }

/* 登录错误时的输入高亮 */
#login-form .input-error {
  border-color: var(--accent2);
  box-shadow: 0 0 0 2px rgba(255,0,64,0.15);
}
/* 代价详情视图：大字手写填充效果 */
.post-detail #post-cost { padding: 20px; }
.post-detail #post-cost .post-title { font-size: 22px; margin-bottom: 12px; }
/* 复活秘法详情：签订按钮容器居中与红色风格 */
.post-detail #post-cost .cost-actions { margin-top: 18px; display: grid; place-items: center; }
.post-detail #post-cost #cost-sign-btn {
  background: linear-gradient(180deg, rgba(255,24,64,0.92), rgba(185,0,28,0.92));
  border-color: rgba(255,24,64,0.95);
  color: #fff;
  text-shadow: 0 1px 0 #2a0006;
  box-shadow: 0 0 16px rgba(255,0,64,0.25), 0 8px 24px rgba(0,0,0,0.45);
  padding: 10px 18px;
  font-weight: 800;
  letter-spacing: 0.8px;
}
.post-detail #post-cost #cost-sign-btn:hover {
  filter: brightness(1.08) saturate(1.08);
  box-shadow: 0 0 22px rgba(255,0,64,0.35), 0 10px 30px rgba(0,0,0,0.5);
}
.post-detail #post-cost #cost-sign-btn:active {
  transform: translateY(1px);
}
.post-detail #post-cost .post-title {
  font-family: 'Zhi Mang Xing','Ma Shan Zheng','STKaiti','KaiTi',serif;
  font-size: clamp(32px, 4.8vw, 76px);
}
.post-detail #post-cost .post-body {
  font-size: clamp(36px, 6.8vw, 84px);
  line-height: 1.08;
}

.post-detail #post-cost .post-body {
  font-family: 'Zhi Mang Xing','Ma Shan Zheng','STKaiti','KaiTi',serif;
  font-size: clamp(28px, 5.2vw, 62px);
  line-height: 1.22;
  letter-spacing: 0.6px;
  text-align: justify;
  -webkit-text-stroke: 0.3px rgba(255,0,64,0.15);
}
.post-detail #post-cost .post-body p { margin: 0.25em 0; transform: rotate(-0.5deg); }
.post-detail #post-cost .post-body p:nth-child(odd) { transform: rotate(-0.7deg) translateX(-1px); }
.post-detail #post-cost .post-body p:nth-child(even) { transform: rotate(-0.3deg) translateX(1px); }
@keyframes costPulse { 0%, 100% { filter: none; } 50% { filter: brightness(1.06) saturate(1.2); } }
/* Login form alignment */
#login-form label { display: block; margin: 8px 0 4px; color: var(--muted); }
#login-form input[type="text"],
#login-form input[type="password"] { width: 100%; margin-bottom: 8px; }

/* 新人必读：引导式风格（详情页，保留原文本） */
.post-detail #post-rules { padding: 18px; }
.post-detail #post-rules .post-title { color: var(--accent); letter-spacing: 0.5px; }
.post-detail #post-rules .post-body ol { list-style: none; padding: 0; margin: 0; counter-reset: step; display: grid; gap: 12px; }
.post-detail #post-rules .post-body ol li { background: #081114; border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 12px 12px 12px 44px; position: relative; color: var(--fg); }
.post-detail #post-rules .post-body ol li::before { counter-increment: step; content: counter(step); position: absolute; left: 12px; top: 12px; width: 24px; height: 24px; border-radius: 50%; background: rgba(0,255,209,0.16); color: var(--accent); display: grid; place-items: center; font-weight: 700; }
.post-detail #post-rules .guide-steps h3 { margin: 0 0 8px; font-size: 18px; color: var(--fg); }
.post-detail #post-rules .guide-checklist { list-style: none; padding-left: 0; display: grid; gap: 6px; }
.post-detail #post-rules .guide-checklist li { position: relative; padding-left: 22px; color: var(--fg); }
.post-detail #post-rules .guide-checklist li::before { content: '✓'; position: absolute; left: 0; top: 0; color: var(--accent); }
.post-detail #post-rules .callout { border: 1px solid var(--border); padding: 10px 12px; background: #0b1316; }
.post-detail #post-rules .callout-warning { border-left: 3px solid var(--accent2); }
.post-detail #post-rules .callout-tip { border-left: 3px solid var(--accent); }
.post-detail #post-rules .guide-footer { color: #87a1ad; font-size: 13px; }

 /* 给陈医生的汇报：简单淡色密码提示 */
 .post-detail #post-report .rules-hint {
   display: block;
   text-align: right;
   margin-top: 8px;
   font-size: 12px;
   color: #4a5358;
   opacity: 0.3;
   letter-spacing: 0.2px;
   user-select: text;
   font-family: 'Courier New', monospace;
   cursor: text;
 }

/* 隐藏数字（黑色方块，悬停显示） */
.hidden-code { margin-top: 8px; }
.hidden-number {
  display: inline-block;
  width: 9ch;
  height: 1.35em;
  font-size: 1.12em;
  line-height: 1.35em;
  background: #000;
  color: transparent;
  border-radius: 3px;
  vertical-align: baseline;
  cursor: crosshair;
  user-select: none;
  transition: color .18s ease, background-color .18s ease, filter .18s ease;
}
.hidden-number.revealed { color: var(--fg); background: transparent; }
/* 确保子元素也跟随显示（防止子节点自定义颜色覆盖） */
.hidden-number.revealed * { color: var(--fg) !important; background: transparent !important; }
/* 兼容降级：按下时也可短暂显示 */
.hidden-number:active { color: var(--fg); background: transparent; }
.feature-hidden-codes-disabled .hidden-number { display: none !important; }

/* Danger Theme: 全局红色风格（启用隐藏数字时） */
body.theme-danger {
  /* 覆盖主题变量为红色调 */
  --bg: #12090c; /* 更暗红背景 */
  --fg: #f1e9ea; /* 保持文本清晰 */
  --muted: #a97b82;
  --accent: #d0022b; /* 更深的危险红 */
  --accent2: #b90024;
  --panel: #160c0f; /* 面板略暗 */
  --border: #2a0f15; /* 边框更暗以贴合主题 */
  --shadow: rgba(0, 0, 0, 0.6);
  /* 背景微调为红色渐变 */
  background: radial-gradient(1500px 800px at 20% 0%, #210c11 0%, var(--bg) 35%, #1a0a0f 100%);
}

/* 红色主题下的强调线与交互细节 */
body.theme-danger .post { border-left: 3px solid rgba(255, 32, 72, 0.35); }
body.theme-danger .btn:hover { box-shadow: 0 0 10px rgba(255,32,72,0.14); }
body.theme-danger .glitch::before { color: #ff2a4a; }
body.theme-danger .glitch::after { color: #ff2a4a; }
