/* 《幽壤》工具集 · 公共样式 —— 中式暗黑：枯黑、土黄、灰褐、暗青、少量污绿 */
:root {
  --bg: #0f0d0b;
  --bg2: #17140f;
  --panel: #1c1813;
  --panel2: #241f18;
  --line: #3a3126;
  --line2: #54452f;
  --text: #d9ccb0;
  --text2: #9d8f74;
  --dim: #6c614f;
  --gold: #b48c4e;
  --gold2: #d2aa62;
  --ochre: #8a6a3a;
  --teal: #4f7a72;
  --green: #5d7a4a;
  --rot: #6e8a4c;
  --red: #8e3a2a;
  --radius: 4px;
  --font: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; }
body { overscroll-behavior: none; }
a { color: var(--gold2); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* 背景肌理：土纸 + 暗角 */
.paper {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(140, 105, 55, 0.13), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(60, 80, 50, 0.12), transparent 60%),
    url("../assets/textures/terrain_cracked.jpg") center/420px repeat,
    var(--bg);
  background-blend-mode: normal, normal, multiply, normal;
}
.paper::before { content: ""; position: fixed; inset: 0; background: rgba(12, 10, 8, 0.86); pointer-events: none; z-index: 0; }
.paper > * { position: relative; z-index: 1; }

/* ---------------------------------------------------- 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--line2); background: linear-gradient(#2a241b, #1f1a14);
  color: var(--text); cursor: pointer; white-space: nowrap; user-select: none; transition: .15s;
}
.btn:hover { border-color: var(--gold); color: var(--gold2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(#6b5130, #4a3720); border-color: var(--gold); color: #f0e2c0; }
.btn.danger { border-color: #6a2c22; background: linear-gradient(#3a1d17, #2a1511); color: #e0b0a0; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 28px; padding: 0 10px; font-size: 12px; }
.btn.icon { padding: 0; width: 34px; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn.on { border-color: var(--gold); color: var(--gold2); background: linear-gradient(#3b2f1e, #2a2116); box-shadow: inset 0 0 0 1px rgba(180, 140, 78, .25); }

input[type=text], input[type=search], input[type=number], select, textarea {
  background: #120f0c; border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 9px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
textarea { resize: vertical; line-height: 1.6; }
input[type=range] { width: 100%; accent-color: var(--gold); }
input[type=color] { width: 36px; height: 26px; padding: 0; border: 1px solid var(--line); background: none; }
label.chk { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
input[type=checkbox] { accent-color: var(--gold); width: 16px; height: 16px; }

/* ---------------------------------------------------- 标题、分隔 */
.seal {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border: 2px solid var(--red); color: #c05a44;
  font-family: var(--font); font-weight: 700; font-size: 18px; border-radius: 3px; transform: rotate(-4deg); opacity: .9;
}
.hr { height: 1px; background: linear-gradient(90deg, transparent, var(--line2), transparent); margin: 12px 0; }
.tag { display: inline-block; padding: 1px 7px; border: 1px solid var(--line2); border-radius: 2px; font-size: 11px; color: var(--text2); margin: 0 4px 4px 0; }
.tag.used { border-color: var(--teal); color: #8fbfb5; }
.tag.unused { border-color: #4a3b2a; color: var(--dim); }
.tag.rot { border-color: #4a5f36; color: #a2bb84; }
.muted { color: var(--text2); }
.dim { color: var(--dim); }

/* ---------------------------------------------------- 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(8px + var(--safe-t)) 14px 8px; background: rgba(15, 13, 11, .92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar .title { font-family: var(--font); font-size: 18px; letter-spacing: 3px; color: var(--gold2); }
.topbar .sub { color: var(--text2); font-size: 12px; }
.topbar .sp { flex: 1; }
.back { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line2); border-radius: var(--radius); color: var(--text2); }

/* ---------------------------------------------------- toast & modal */
.toast-box { position: fixed; left: 50%; top: calc(56px + var(--safe-t)); transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { padding: 9px 16px; background: rgba(28, 24, 19, .96); border: 1px solid var(--line2); border-left: 3px solid var(--gold); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0, 0, 0, .5); transition: .35s; font-size: 13px; max-width: 86vw; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast.out { opacity: 0; transform: translateY(-8px); }
.modal-mask { position: fixed; inset: 0; background: rgba(5, 4, 3, .72); z-index: 900; display: grid; place-items: center; padding: 14px; }
.modal { width: min(920px, 100%); max-height: 92vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line2); border-radius: 6px; box-shadow: 0 20px 60px rgba(0, 0, 0, .7); overflow: hidden; }
.modal.small { width: min(420px, 100%); }
.modal-head { padding: 12px 16px; border-bottom: 1px solid var(--line); font-family: var(--font); font-size: 16px; color: var(--gold2); display: flex; align-items: center; gap: 8px; }
.modal-head .x { margin-left: auto; cursor: pointer; color: var(--text2); font-size: 20px; line-height: 1; }
.modal-body { padding: 14px 16px; overflow: auto; }
.modal-foot { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------------------------------------------------- 表单行 */
.row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.row > label:first-child { width: 64px; flex: none; color: var(--text2); font-size: 12px; }
.row .val { width: 44px; text-align: right; color: var(--text2); font-size: 12px; font-variant-numeric: tabular-nums; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sec { margin-bottom: 14px; }
.sec > h4 { margin: 0 0 8px; font-weight: normal; font-family: var(--font); color: var(--gold); font-size: 13px; letter-spacing: 2px; display: flex; align-items: center; gap: 6px; }
.sec > h4::before { content: ""; width: 3px; height: 12px; background: var(--gold); opacity: .7; }

.loading-mask { position: fixed; inset: 0; z-index: 800; display: grid; place-items: center; background: var(--bg); transition: opacity .5s; }
.loading-mask .inner { text-align: center; }
.loading-mask .t { font-family: var(--font); font-size: 28px; letter-spacing: 12px; color: var(--gold2); }
.loading-mask .bar { width: 220px; height: 2px; background: var(--line); margin: 18px auto 8px; overflow: hidden; }
.loading-mask .bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .2s; }
.loading-mask .msg { color: var(--text2); font-size: 12px; }

/* ---------------------------------------------------- 导航 / 文档页：提亮（日间也看得清）
   仅作用于 body.paper（首页、路线、剧情、工程、素材库、图鉴）；游戏与编辑器不受影响 */
body.paper {
  --bg: #3a342c; --bg2: #443d34; --panel: #4a4238; --panel2: #554c41;
  --line: #6a5e4e; --line2: #85745c;
  --text: #f1e8d6; --text2: #d2c5aa; --dim: #ab9d84;
  --gold: #d6ae6a; --gold2: #ecc785;
  background: linear-gradient(#423b32, #36302a 60%, #322c26);
}
body.paper::before { display: none; }
body.paper .topbar { background: rgba(58, 52, 44, .94); }
body.paper input[type=text], body.paper input[type=search], body.paper input[type=number], body.paper select, body.paper textarea { background: #2f2a24; }
body.paper .btn { background: linear-gradient(#5a5044, #4a4238); }
body.paper .btn.primary { background: linear-gradient(#8a6a3e, #6b5130); }
