/* =========================================================
   全局基座：变量 / 重置 / 顶栏 / 视口 / 面板 / 通用按钮 / 导航
   所有页面共用的原子样式，其他模块样式在 js/ 下同名文件里。
   ========================================================= */

:root {
  --bg: #08090a;
  --panel: #0e1013;
  --border: #1a1d23;
  --border-light: #282d37;
  --text: #c0c6cf;
  --text-dim: #4e5562;
  --accent: #9e2a2b;
  --gold: #ffd24a;
  --r-common: #6e7681;
  --r-mutant: #388bfd;
  --r-hazard: #a371f7;
  --r-disaster: #d25e24;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  font-size: 13px;
  line-height: 1.4;
  padding-bottom: 56px;
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
}

/* 顶栏 */
.header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}

.rank-tag {
  font-size: 10px;
  font-family: monospace;
  padding: 1px 4px;
  border: 1px solid var(--border-light);
  color: var(--text-dim);
}

.currency-wrap {
  position: relative;
  display: inline-flex;
  align-items: baseline;
}

.currency-val {
  display: inline-block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
  color: #fff;
}

/* 单位：跟在总数后面，压小压暗，不抢数字 */
.currency-unit {
  margin-left: 3px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0;
}

.stats-row {
  font-size: 10.5px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  font-family: monospace;
}

/* 视口 */
.viewport {
  padding: 12px 14px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.box {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 10px 12px;
  margin-bottom: 10px;
}

.box-title {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 3px;
  display: flex;
  justify-content: space-between;
}

.box-title.collapsible {
  cursor: pointer;
  user-select: none;
}

.box-title-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.collapse-arrow {
  transition: transform 0.15s ease;
  font-size: 9px;
  line-height: 1.6;
}

/* 通用折叠：除标题外全部收起 */
.collapsed .collapse-arrow {
  transform: rotate(-90deg);
}

.box.collapsed > *:not(.box-title) {
  display: none;
}

.box.collapsed .btn-list {
  display: none;
}

/* 按钮系统 */
.btn-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn {
  width: 100%;
  background: #111418;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  cursor: pointer;
  text-align: left;
}

.btn:active:not(:disabled) {
  background: #1a1e24;
}

.btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.sub {
  font-size: 9.5px;
  color: var(--text-dim);
  font-family: monospace;
}

/* 套装集满（共鸣完成）时数字变金黄，档案与签收台通用 */
.num-done {
  color: var(--gold);
}

/* 稀有度配色：档案卡与签收结果共用 */
.tier-common { color: var(--r-common); }
.tier-mutant { color: var(--r-mutant); }
.tier-hazard { color: var(--r-hazard); }
.tier-disaster { color: var(--r-disaster); }
.tier-taboo { color: #ff2e4d; }

/* 导航 */
.navbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 460px;
  margin: 0 auto;
  height: 44px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.nav-btn {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 10.5px;
  cursor: pointer;
  border-right: 1px solid var(--border);
}

.nav-btn:last-child {
  border-right: none;
}

.nav-btn.active {
  color: #fff;
  background: #14171d;
}

/* 未解锁的导航：常驻显示但置灰、不可点，整颗按钮只显示一把锁 */
.nav-btn.locked {
  color: var(--text-dim);
  opacity: 0.6;
  cursor: not-allowed;
}

/* 扁平纯色锁：默认隐藏，锁定时才显示；同时藏掉「行动」文字 */
.nav-lock {
  display: none;
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.nav-btn.locked .nav-lock {
  display: inline-block;
}

.nav-btn.locked .nav-label {
  display: none;
}

/* =========================================================
   探知页：机加工触发键 + 回传日志终端屏
   ========================================================= */

.detect-btn {
  position: relative;
  display: block;
  width: 100%;
  padding: 8px;
  border: 1px solid #05070a;
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0) 38%),
    linear-gradient(180deg, #1d2128 0%, #14171c 50%, #0b0d11 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    inset 0 -1px 0 rgba(0, 0, 0, 0.9),
    0 1px 2px rgba(0, 0, 0, 0.8),
    0 9px 20px -9px rgba(0, 0, 0, 0.95);
  cursor: pointer;
  font: inherit;
  color: #fff;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

/* 拉丝纹理 */
.detect-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background: repeating-linear-gradient(
    to right,
    rgba(255, 255, 255, 0.022) 0 1px,
    rgba(0, 0, 0, 0.055) 1px 2px
  );
}

/* 沉槽：键帽陷进去的那圈凹坑 */
.db-well {
  position: relative;
  display: block;
  padding: 3px;
  border-radius: 2px;
  background: linear-gradient(180deg, #04060a 0%, #0c0f13 100%);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.95),
    inset 0 -1px 0 rgba(255, 255, 255, 0.05),
    0 1px 0 rgba(255, 255, 255, 0.045);
  transition: box-shadow 0.12s ease;
}

/* 键帽：凸起的实体键 */
.db-cap {
  position: relative;
  display: block;
  padding: 22px 10px;
  border-radius: 2px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 4px;
  text-indent: 4px;
  text-align: center;
  color: #e9eef6;
  text-shadow:
    0 -1px 1px rgba(0, 0, 0, 0.85),
    0 1px 0 rgba(255, 255, 255, 0.13);
  background:
    radial-gradient(140% 100% at 50% -30%, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 62%),
    linear-gradient(180deg, #3b414b 0%, #2a2f38 36%, #1c2027 70%, #15181d 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.30),
    inset 0 -2px 3px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 2px 0 #0b0e12,
    0 3px 1px rgba(0, 0, 0, 0.72),
    0 7px 14px rgba(0, 0, 0, 0.7);
  transition: transform 0.08s ease, box-shadow 0.12s ease, background 0.12s ease;
}

/* 按下：键帽下沉，槽口亮一圈 */
.detect-btn:active .db-well {
  box-shadow:
    inset 0 3px 6px rgba(0, 0, 0, 0.95),
    inset 0 -1px 0 rgba(255, 255, 255, 0.05),
    0 0 16px rgba(255, 255, 255, 0.09);
}

.detect-btn:active .db-cap {
  transform: translateY(3px);
  color: #c9d1dd;
  text-shadow:
    0 -1px 1px rgba(0, 0, 0, 0.9),
    0 1px 0 rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(140% 100% at 50% -30%, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0) 62%),
    linear-gradient(180deg, #1b1f25 0%, #161a20 44%, #111419 100%);
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.9),
    inset 0 -1px 0 rgba(255, 255, 255, 0.05),
    inset 0 0 0 1px rgba(0, 0, 0, 0.6);
}

@media (hover: hover) {
  .detect-btn:hover .db-cap {
    filter: brightness(1.07);
  }
}

.detect-btn:focus-visible {
  outline: 1px solid #4a525f;
  outline-offset: 2px;
}

/* =========================================================
   回传日志：内嵌终端屏
   ========================================================= */
.log-panel {
  position: relative;
  margin-top: 8px;
  border: 1px solid var(--border);
  background:
    radial-gradient(140% 80% at 50% 0%, rgba(255, 255, 255, 0.035), transparent 60%),
    linear-gradient(180deg, #0b0d11 0%, #07080a 100%);
  box-shadow: inset 0 0 26px rgba(0, 0, 0, 0.65);
  overflow: hidden;
}

/* 扫描线纹理：常驻，压在文字之上但极淡 */
.log-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.026) 0 1px,
    transparent 1px 3px
  );
}

/* 新消息抵达时横扫一次的光带 */
.log-panel::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 45%;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-110%);
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.045) 68%,
    rgba(255, 255, 255, 0.14) 100%
  );
}

.log-panel.pulse::after {
  animation: logSweep 0.55s ease-out;
}

@keyframes logSweep {
  0% { opacity: 0; transform: translateY(-110%); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translateY(260%); }
}

/* 顶栏 */
.log-head {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.018);
  font-family: monospace;
  font-size: 9px;
  letter-spacing: 1.2px;
  color: var(--text-dim);
}

.log-led {
  width: 4px;
  height: 4px;
  flex-shrink: 0;
  background: #7d8590;
  box-shadow: 0 0 7px rgba(255, 255, 255, 0.55);
  animation: logLed 2.6s ease-in-out infinite;
}

@keyframes logLed {
  0%, 100% { opacity: 0.35; box-shadow: 0 0 4px rgba(255, 255, 255, 0.25); }
  50% { opacity: 1; box-shadow: 0 0 9px rgba(255, 255, 255, 0.7); }
}

.log-head-title {
  color: #8b939f;
}

.log-head-meta {
  margin-left: auto;
  font-size: 8.5px;
  letter-spacing: 0.6px;
  color: #3f4653;
}

/* 日志体：column-reverse，新行贴着底边，旧行往上顶出视野 */
.log-box {
  position: relative;
  z-index: 2;
  height: 94px;
  padding: 6px 8px 8px;
  display: flex;
  flex-direction: column-reverse;
  gap: 3px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 10.5px;
  line-height: 1.5;
  -webkit-mask-image: linear-gradient(to top, #000 56%, transparent 100%);
  mask-image: linear-gradient(to top, #000 56%, transparent 100%);
  scrollbar-width: none;
}

.log-box::-webkit-scrollbar {
  display: none;
}

.log-line {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  gap: 5px;
  color: #5d6472;
  animation: logIn 0.26s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

@keyframes logIn {
  from {
    opacity: 0;
    transform: translateY(7px);
    filter: blur(1.5px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

.ll-tag {
  flex-shrink: 0;
  font-size: 8.5px;
  line-height: 1.6;
  padding: 0 3px;
  margin-top: 1px;
  border: 1px solid currentColor;
  color: #4e5562;
  opacity: 0.9;
  letter-spacing: 0.2px;
}

.ll-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

/* 正文里的收益与共鸣标记 */
.ll-gain {
  font-style: normal;
  color: #e6e9ee;
}

.ll-res {
  font-style: normal;
  color: var(--gold);
  opacity: 0.85;
}

/* 最新一行末尾的打字光标 */
.log-line.latest .ll-text::after {
  content: "";
  display: inline-block;
  width: 4px;
  height: 8px;
  margin-left: 3px;
  vertical-align: -1px;
  background: #c0c6cf;
  animation: logCaret 1.1s steps(1, end) infinite;
}

@keyframes logCaret {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* 标签配色：捕获金，行动红，四个行动程序一律白，其余默认灰 */
.log-line[data-tag="捕获"] .ll-tag,
.log-line[data-tag="重现"] .ll-tag { color: var(--gold); }
.log-line[data-tag="捕获"] .ll-text,
.log-line[data-tag="重现"] .ll-text { color: #d5d9e0; }

.log-line[data-tag="晋升"] .ll-tag,
.log-line[data-tag="改造"] .ll-tag,
.log-line[data-tag="申购"] .ll-tag,
.log-line[data-tag="测向"] .ll-tag,
.log-line[data-tag="同相"] .ll-tag,
.log-line[data-tag="回音"] .ll-tag,
.log-line[data-tag="下行"] .ll-tag { color: #cfd5dd; }

.log-line[data-tag="晋升"] .ll-text,
.log-line[data-tag="测向"] .ll-text,
.log-line[data-tag="同相"] .ll-text,
.log-line[data-tag="回音"] .ll-text,
.log-line[data-tag="下行"] .ll-text { color: #9aa2ad; }

.log-line[data-tag="行动"] .ll-tag,
.log-line[data-tag="签收"] .ll-tag { color: #d2484a; }

.log-line[data-tag="行动"] .ll-text,
.log-line[data-tag="签收"] .ll-text { color: #8d5a5c; }

.log-line[data-tag="调试"] .ll-tag { color: #3f4653; }

/* =========================================================
   行动页：解锁闸口 / 各层通用的标题与警示标记
   ========================================================= */

/* 行动：解锁闸口 */
.gate-box {
  text-align: center;
  padding: 18px 12px;
}

.gate-title {
  font-size: 11px;
  color: #fff;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.gate-box .sub {
  display: block;
  line-height: 1.5;
  margin-bottom: 8px;
}

.gate-box .btn {
  justify-content: center;
}

.tag-warn {
  color: var(--accent);
  letter-spacing: 0;
}

.mb6 {
  margin-bottom: 6px;
  line-height: 1.5;
}


/* 档案抹除：上膛状态（第二次点击才真的清） */
#btn-reset.armed {
  color: #ff2e4d;
  border-color: var(--accent);
  background: #1c0c0d;
  letter-spacing: 1px;
}

#btn-reset.armed:active {
  background: #2a1012;
}
