/* 放置奇兵工具箱 · 深色优先游戏伴侣风
   布局：PC 左侧栏 + 内容区；手机底部导航 + 内容区
   单强调色琥珀金；圆角体系 18/12/pill */

:root {
  color-scheme: dark;
  --bg: #121316;
  --bg-soft: #17181c;
  --card: #1d1f24;
  --card-hover: #23252b;
  --text: #e8eaed;
  --text-dim: #9a9da4;
  --text-faint: #66696f;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #e0aa4b;
  --accent-soft: rgba(224, 170, 75, 0.14);
  --on-accent: #20180a;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f5f4f0;
    --bg-soft: #eeede8;
    --card: #ffffff;
    --card-hover: #f7f6f2;
    --text: #1e1f22;
    --text-dim: #6b6e74;
    --text-faint: #a0a3a9;
    --line: rgba(30, 31, 34, 0.1);
    --accent: #a06b1f;
    --accent-soft: rgba(160, 107, 31, 0.12);
    --on-accent: #fff;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'HarmonyOS Sans SC', 'Microsoft YaHei UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- 布局骨架 ---------- */

.shell { display: flex; min-height: 100dvh; }

.side {
  width: 208px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100dvh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--accent-soft);
  position: relative;
  flex: none;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 9px;
  border: 2.5px solid var(--accent);
  transform: rotate(45deg);
}
.brand-name { font-weight: 700; font-size: 15.5px; letter-spacing: 0.02em; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  border: none;
  background: none;
  text-align: left;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease;
}
.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-sep { height: 1px; background: var(--line); margin: 8px 6px; }

.side-foot { margin-top: auto; padding: 0 8px; font-size: 11px; color: var(--text-faint); }

.main { flex: 1; min-width: 0; padding: 26px 30px 48px; }
.view-title { font-size: 19px; font-weight: 700; margin-bottom: 16px; letter-spacing: 0.01em; }
.view { max-width: 720px; }

/* ---------- 卡片与表单 ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
}

.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.field-row { display: flex; gap: 12px; margin-bottom: 14px; }
.field input, .field select {
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 16px;
  width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--accent); outline: none; }
.field input::placeholder { color: var(--text-faint); }

.duo { display: flex; gap: 12px; margin-top: 16px; }

.result {
  flex: 1;
  min-width: 0;
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.result-total { background: var(--accent-soft); margin-top: 16px; }
.r-label { font-size: 11.5px; color: var(--text-dim); }
.r-num {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-total .r-label { color: var(--text-dim); }
.result-total .r-num { color: var(--accent); }

.note { font-size: 12px; color: var(--text-faint); margin-top: 12px; line-height: 1.6; }

/* 核心清单 */
.core-list { display: flex; flex-direction: column; }
.core-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line);
}
.core-row:last-child { border-bottom: none; }
.core-name { font-size: 14px; }
.core-weight { font-size: 11.5px; color: var(--text-faint); margin-left: 8px; font-variant-numeric: tabular-nums; }
.core-row input {
  width: 120px;
  padding: 9px 13px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 15px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.core-row input:focus { border-color: var(--accent); outline: none; }

/* 殿堂表 */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 4px;
  -webkit-overflow-scrolling: touch;
}
.res-table { width: 100%; border-collapse: collapse; font-size: 12.5px; white-space: nowrap; }
.res-table th {
  text-align: right;
  padding: 10px 12px;
  font-size: 11px;
  color: var(--text-faint);
  border-bottom: 1.5px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--card);
  font-weight: 600;
}
.res-table th:first-child, .res-table td:first-child { text-align: left; }
.res-table td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.res-table tr.target td { color: var(--accent); font-weight: 700; }

/* 珍宝色板 */
.swatches { display: flex; gap: 8px; margin-bottom: 16px; }
.swatch {
  flex: 1;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 10px 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.swatch::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--sw); flex: none; }
.swatch.active { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }

/* ---------- 攻略图库 ---------- */

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.guide-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease;
}
.guide-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.guide-thumb {
  aspect-ratio: 4 / 3;
  width: 100%;
  object-fit: cover;
  display: block;
  background: var(--bg-soft);
}
.guide-name {
  padding: 10px 12px 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.guide-loading { color: var(--text-faint); padding: 24px 0; }
.guide-editions { font-size: 11px; color: var(--accent); margin-left: 6px; }

/* ---------- 图片查看器 ---------- */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 11, 13, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  animation: viewer-in 0.16s ease;
}
@keyframes viewer-in { from { opacity: 0; } to { opacity: 1; } }

.viewer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  flex: none;
}
.viewer-title { font-size: 14.5px; font-weight: 600; color: #fff; }
.viewer-close {
  border: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}
.viewer-close:hover { background: rgba(255, 255, 255, 0.18); }

.viewer-editions {
  display: flex;
  gap: 8px;
  padding: 0 18px 10px;
  flex-wrap: wrap;
}
.viewer-editions button {
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  background: none;
  color: #ddd;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  cursor: pointer;
}
.viewer-editions button.active { border-color: var(--accent); color: var(--accent); }

.viewer-scroll {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 0 12px;
  -webkit-overflow-scrolling: touch;
}
.viewer-scroll img { max-width: 100%; height: auto; border-radius: 8px; }

.viewer-nav { display: flex; justify-content: center; gap: 12px; padding: 12px 0 calc(14px + env(safe-area-inset-bottom)); flex: none; }
.btn-view {
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: #eee;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  cursor: pointer;
}
.btn-view:disabled { opacity: 0.35; cursor: default; }
.btn-view:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 移动端 ---------- */

.bottom-nav { display: none; }

@media (max-width: 767px) {
  .shell { flex-direction: column; }
  .side {
    width: auto;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 20;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .nav, .side-foot { display: none; }
  .main { padding: 18px 16px calc(76px + env(safe-area-inset-bottom)); }
  .view-title { font-size: 17px; }

  .bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    display: flex;
    background: color-mix(in srgb, var(--card) 92%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bn-item {
    flex: 1;
    border: none;
    background: none;
    padding: 10px 0 9px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-faint);
    cursor: pointer;
  }
  .bn-item.active { color: var(--accent); }

  .duo { flex-direction: column; }
  .guide-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .viewer { animation: none; }
  .guide-card, .btn-view, .nav-item { transition: none; }
}
