:root {
  --paper: #efece6;
  --paper-2: #f7f5f1;
  --paper-3: #e5e1d9;
  --veil: rgba(239, 236, 230, 0.94);
  --ink: #161616;
  --ink-2: #4d4b47;
  --ink-3: #8a8782;
  --ink-4: #b7b3ac;
  --line: rgba(22, 22, 22, 0.1);
  --line-2: rgba(22, 22, 22, 0.2);
  --accent: #c23b22;
  --pos: #3f7a5c;
  --neg: #a8432f;
  --warn: #a87414;
  --blue: #3d5a8a;
  /* legacy aliases used by inline styles */
  --bg: var(--paper);
  --text: var(--ink);
  --muted: var(--ink-3);
  --dim: var(--ink-4);
  --gold: var(--ink);
  --gold-2: var(--accent);
  --panel: rgba(247, 245, 241, 0.94);
  --panel-solid: var(--paper-2);
  --panel-2: rgba(255, 255, 255, 0.4);
  --radius: 2px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --latin: "Helvetica Neue", Helvetica, Arial, var(--font);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  --rail-w: 72px;
  --hud-h: 56px;
  --edge: 14px;
  --float-top: 84px;
  --drawer-w: 500px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; color: inherit; }
::selection { background: var(--ink); color: var(--paper); }
.hidden { display: none !important; }
#viewport { position: fixed; inset: 0; }
#viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; }

/* ---------- generic ---------- */
.glass { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(12px) saturate(1.05); -webkit-backdrop-filter: blur(12px) saturate(1.05);
  box-shadow: 0 1px 2px rgba(22, 22, 22, 0.04), 0 28px 60px -34px rgba(40, 32, 20, 0.38); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius); border: 1px solid var(--line-2); background: transparent; cursor: pointer;
  font-size: 13px; line-height: 1.2; letter-spacing: 0.04em; transition: background .2s, border-color .2s, color .2s; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:active:not(:disabled) { background: rgba(22, 22, 22, 0.05); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper-2); font-weight: 500; }
.btn.primary:hover:not(:disabled) { background: #000; }
.btn.danger { border-color: rgba(168, 67, 47, 0.45); color: var(--neg); }
.btn.danger:hover:not(:disabled) { border-color: var(--neg); background: rgba(168, 67, 47, 0.06); }
.btn.sm { padding: 6px 12px; font-size: 12px; line-height: 1.4; }
.btn.ghost { border-color: var(--line); color: var(--ink-2); }
/* 长条文按钮：允许折行、左对齐，宽高都由内容决定，不许撑出卡片。 */
.btn.wrapbtn { white-space: normal; text-align: left; justify-content: flex-start; max-width: 100%; line-height: 1.5; overflow-wrap: anywhere; }
.btn.ghost:hover:not(:disabled) { border-color: var(--line-2); }
.btn.ghost:hover:not(:disabled) { border-color: var(--line-2); color: var(--ink); }
.btn.block { width: 100%; }
.icon-btn { width: 32px; height: 32px; border-radius: var(--radius); border: 0; background: transparent; cursor: pointer; font-size: 22px; font-weight: 300; line-height: 1; color: var(--ink-3); transition: color .2s; }
.icon-btn:hover { color: var(--ink); }
.muted { color: var(--ink-3); }
.dim { color: var(--ink-4); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
p.warn { margin: 8px 0; padding: 8px 12px; background: rgba(168, 116, 20, 0.06); border-left: 2px solid var(--warn); color: #6e4c0d; font-size: 13px; }
.story { font-family: var(--serif); font-size: 15.5px; line-height: 1.9; color: var(--ink); margin: 0 0 14px; }
/* 城市动态：报纸样式的电头、引语和牵涉方 */
.news-slip { position: relative; }
.news-dateline { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: -4px 0 12px; padding-bottom: 9px; border-bottom: 1px solid var(--line); font-size: 11.5px; letter-spacing: 0.06em; color: var(--ink-3); }
.news-tag { display: inline-block; padding: 1px 7px; border: 1px solid var(--line-2); color: var(--ink-2); letter-spacing: 0.2em; font-size: 10.5px; }
.news-quote { margin: 0 0 14px; padding: 4px 0 4px 14px; border-left: 2px solid var(--accent); font-family: var(--serif); font-size: 14.5px; line-height: 1.8; color: var(--ink-2); }
.news-quote cite { display: block; margin-top: 2px; font-style: normal; font-family: var(--font); font-size: 12px; color: var(--ink-3); }
.news-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 0; }
.news-chips span { padding: 2px 8px; background: var(--paper-3); font-size: 11.5px; color: var(--ink-2); }
.kv { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv span { color: var(--ink-3); flex-shrink: 0; }
.kv b { font-weight: 500; text-align: right; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sec { margin: 22px 0 10px; font-size: 11px; letter-spacing: 0.26em; color: var(--ink-3); display: flex; align-items: center; gap: 12px; }
.sec::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.sec:first-child { margin-top: 0; }
.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 14px; margin-bottom: 8px; }
.card.click { cursor: pointer; transition: border-color .2s; }
.card.click:hover { border-color: var(--ink-3); }
.card h4 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.card .sub { font-size: 12px; color: var(--ink-3); }
/* 长句与长标识符一律在卡片内换行：宁可多一行，也不许画到边框外。 */
.card .sub, .card h4, .card p, .break { overflow-wrap: anywhere; word-break: break-word; min-width: 0; }
/* 标题行：左边名字，右边标签；标签放不下就换行，不撑破卡片。 */
.card h4.h4row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card h4.h4row .spacer { flex: 1; }
.card h4.h4row .tag { white-space: normal; max-width: 100%; }
/* 把柄正文：读起来要像一段备忘，不像工具提示。 */
.tell { margin: 8px 0 10px; font-family: var(--serif); font-size: 13.5px; line-height: 1.95; color: var(--ink-2); }
.tell p { margin: 0 0 3px; text-indent: 2em; }
.tell p:last-child { margin-bottom: 0; }
.empty { padding: 26px 14px; text-align: center; color: var(--ink-3); font-size: 13px; border: 1px dashed var(--line-2); border-radius: var(--radius); line-height: 1.8; }
.tag { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: var(--radius); font-size: 11px; border: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap; font-weight: 400; }
.tag.gold { border-color: var(--ink); color: var(--ink); }
.tag.red { border-color: rgba(168, 67, 47, 0.5); color: var(--neg); }
.tag.green { border-color: rgba(63, 122, 92, 0.5); color: var(--pos); }
.tag.blue { border-color: rgba(61, 90, 138, 0.5); color: var(--blue); }
.pdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.bar { height: 3px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ink); transition: width .4s var(--ease); }
.bar.green > i { background: var(--pos); }
.bar.red > i { background: var(--neg); }
.bar.blue > i { background: var(--blue); }
.tabs { display: flex; gap: 20px; margin-bottom: 16px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { padding: 8px 0 9px; border: 0; background: transparent; cursor: pointer; color: var(--ink-3); font-size: 13px; letter-spacing: 0.06em; white-space: nowrap; transition: color .2s; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--ink); box-shadow: inset 0 -1px 0 var(--ink); }
/* 组内页签放在标题行右侧：同一层级的导航不抢占正文第一屏。 */
.drawer-sub { display: flex; gap: 13px; margin-left: auto; margin-right: 4px; overflow-x: auto; scrollbar-width: none; }
.drawer-sub::-webkit-scrollbar { display: none; }
.drawer-sub button { border: 0; background: none; cursor: pointer; font-size: 12px; color: var(--ink-4); padding: 1px 0; letter-spacing: 0.04em; white-space: nowrap; transition: color .2s; }
.drawer-sub button:hover { color: var(--ink-2); }
.drawer-sub button.on { color: var(--ink); box-shadow: inset 0 -1px 0 var(--ink-3); }
table.t { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.t th { text-align: left; font-weight: 400; font-size: 11.5px; letter-spacing: 0.08em; color: var(--ink-3); padding: 7px 4px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.t td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: rgba(22, 22, 22, 0.03); }
table.t .num { text-align: right; font-variant-numeric: tabular-nums; }

/* attitude & confidence labels */
.att { font-weight: 600; }
.a5 { color: #2f6b4f; } .a4 { color: #5e8048; } .a3 { color: var(--ink-2); } .a2 { color: #b06a2c; } .a1 { color: var(--neg); } .a0 { color: var(--ink-3); }
.conf { font-size: 11px; color: var(--ink-4); }
.c4 { color: #2f6b4f; } .c3 { color: var(--ink-2); } .c2 { color: var(--ink-3); } .c1 { color: var(--ink-4); }

/* ---------- HUD ---------- */
#hud { position: fixed; top: var(--edge); left: var(--edge); right: var(--edge); height: auto; display: flex; align-items: stretch; gap: 10px; padding: 0; z-index: 20;
  background: none; border: none; pointer-events: none; }
#hud > * { pointer-events: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(22, 22, 22, 0.04), 0 18px 40px -28px rgba(40, 32, 20, 0.5); backdrop-filter: blur(14px) saturate(1.05); -webkit-backdrop-filter: blur(14px) saturate(1.05); }
.brand { display: flex; align-items: center; gap: 12px; padding: 8px 16px 8px 10px; margin: 0; border-right: 0; flex-shrink: 0; }
.brand .seal { width: 30px; height: 30px; border-radius: 3px; background: var(--accent); display: grid; place-items: center; color: #f7efe6; font-family: var(--serif); font-weight: 700; font-size: 16px;
  box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 0 3px rgba(247, 239, 230, 0.55); }
.brand .who b { display: block; max-width: 168px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-family: var(--serif); font-weight: 600; letter-spacing: 0.02em; }
.brand .who span { font-size: 11.5px; color: var(--ink-3); }
.hud-stats { display: flex; align-items: center; gap: 2px; overflow-x: auto; flex: 1; min-width: 0; padding: 2px 6px; scrollbar-width: none; }
.hud-stats::-webkit-scrollbar { display: none; }
.stat { padding: 4px 12px; min-width: 78px; flex-shrink: 0; cursor: default; border-right: 1px solid transparent; }
.stat label { display: block; font-size: 10.5px; letter-spacing: 0.14em; color: var(--ink-3); margin-bottom: 3px; white-space: nowrap; }
.stat b { font-size: 13.5px; font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat .bar { width: 64px; margin-top: 5px; height: 2px; }
.hud-date { text-align: right; padding: 8px 16px; border-left: 0; flex-shrink: 0; display: flex; flex-direction: column; justify-content: center; }
.hud-date b { display: block; font-size: 14px; font-family: var(--serif); font-weight: 600; letter-spacing: 0.04em; }
.hud-date span { font-size: 11px; color: var(--ink-3); }
#hud .icon-btn { width: 46px; height: auto; align-self: stretch; margin: 0; font-size: 18px; border-radius: var(--radius); }

/* ---------- rail ---------- */
#rail { position: fixed; top: var(--float-top); left: var(--edge); width: var(--rail-w); z-index: 20; display: flex; flex-direction: column; gap: 2px; padding: 6px; }
#rail button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 2px 8px; border: 0; border-radius: var(--radius); background: transparent; cursor: pointer; color: var(--ink-3); font-size: 11.5px; letter-spacing: 0.08em; transition: color .2s; }
#rail button svg { width: 21px; height: 21px; stroke-width: 1.4; }
#rail button:hover { color: var(--ink); }
#rail button.on { color: var(--ink); }
#rail button.on::before { content: ''; position: absolute; left: -6px; top: 22%; bottom: 22%; width: 2px; background: var(--ink); }
#rail button.locked { opacity: 0.4; }
#rail .badge { position: absolute; top: 5px; right: 9px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--neg); color: #fff; font-size: 10px; font-weight: 600; display: grid; place-items: center; font-family: var(--latin); }
#rail .badge.gold { background: var(--ink); color: var(--paper-2); }

/* ---------- drawer ---------- */
#drawer { position: fixed; top: var(--float-top); left: calc(var(--rail-w) + 28px); bottom: var(--edge); width: var(--drawer-w); z-index: 19; display: flex; flex-direction: column; animation: slideIn .35s var(--ease); }
@keyframes slideIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px 14px 22px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 19px; font-family: var(--serif); font-weight: 600; letter-spacing: 0.12em; }
#drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px 28px; }
#drawer-body::-webkit-scrollbar, .modal-body::-webkit-scrollbar, #inspector::-webkit-scrollbar, #title::-webkit-scrollbar { width: 6px; }
#drawer-body::-webkit-scrollbar-thumb, .modal-body::-webkit-scrollbar-thumb, #inspector::-webkit-scrollbar-thumb, #title::-webkit-scrollbar-thumb { background: rgba(22, 22, 22, 0.14); border-radius: 6px; }

/* ---------- schedule ---------- */
.week-grid { display: grid; grid-template-columns: 30px repeat(7, 1fr); gap: 4px; }
.week-grid .hd { font-size: 11px; letter-spacing: 0.1em; color: var(--ink-3); text-align: center; padding: 2px 0 4px; }
.week-grid .ph { font-size: 11px; color: var(--ink-3); display: flex; align-items: center; justify-content: center; writing-mode: vertical-rl; letter-spacing: 0.3em; }
.slot { min-height: 64px; border-radius: var(--radius); border: 1px dashed var(--line-2); background: transparent; padding: 6px 5px 5px 7px; cursor: pointer; display: flex; flex-direction: column; justify-content: space-between; font-size: 11.5px; line-height: 1.35; transition: border-color .2s, background .2s; position: relative; overflow: hidden; }
.slot:hover { border-color: var(--ink); }
.slot.filled { border-style: solid; border-color: var(--line); background: rgba(255, 255, 255, 0.45); }
.slot.filled::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--cat, var(--ink-4)); }
.slot.fixed { cursor: default; background: repeating-linear-gradient(135deg, rgba(22, 22, 22, 0.06) 0 1px, transparent 1px 6px); border-color: var(--line-2); }
.slot .nm { font-weight: 600; font-size: 12px; }
.slot .tg { color: var(--ink-3); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.slot .plus { margin: auto; color: var(--ink-4); font-size: 16px; font-weight: 300; }
.slot.weekend:not(.filled) { background: rgba(22, 22, 22, 0.018); }
.slot.running { box-shadow: 0 0 0 1px var(--ink) inset; }
.slot.done { opacity: 0.4; }
.cat-rest { --cat: var(--pos); }
.cat-district { --cat: var(--blue); }
.cat-politics { --cat: #6e6688; }
.cat-media { --cat: #a86c86; }
.cat-admin { --cat: #b48a4e; }
.cat-campaign { --cat: var(--neg); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 11.5px; color: var(--ink-3); margin-top: 10px; }
.legend i { display: inline-block; width: 2px; height: 11px; margin-right: 6px; vertical-align: -1px; border: 0; background: var(--cat, var(--ink-4)); }
.forecast { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.forecast .card { margin: 0; padding: 10px 12px; }
.forecast label { font-size: 11px; letter-spacing: 0.1em; color: var(--ink-3); }
.forecast b { display: block; font-size: 18px; font-weight: 500; margin: 3px 0 6px; font-variant-numeric: tabular-nums; }
.act-list { display: grid; gap: 6px; }
.act { display: flex; gap: 12px; align-items: flex-start; padding: 11px 13px; border-radius: var(--radius); border: 1px solid var(--line); background: rgba(255, 255, 255, 0.4); cursor: pointer; text-align: left; width: 100%; transition: border-color .2s; }
.act:hover:not(.off) { border-color: var(--ink); }
.act.off { opacity: 0.4; cursor: not-allowed; }
.act .body { flex: 1; min-width: 0; }
.act .nm { font-weight: 600; font-size: 13.5px; }
.act .ds { font-size: 12px; color: var(--ink-3); margin-top: 3px; line-height: 1.6; }
.act .cost { font-size: 11.5px; text-align: right; white-space: nowrap; line-height: 1.7; color: var(--ink-2); }
.act .why { font-size: 11.5px; color: var(--warn); margin-top: 3px; }
.act-cat { font-size: 11px; color: var(--ink-3); letter-spacing: 0.24em; margin: 16px 0 4px; }

/* ---------- council ---------- */
.hemi { display: block; margin: 0 auto 8px; max-width: 100%; }
.stages { display: flex; gap: 3px; margin: 10px 0 8px; }
.stages i { flex: 1; height: 2px; background: var(--line); }
.stages i.on { background: var(--ink); }
.stages i.bad { background: var(--neg); }
.bill h4 { display: flex; align-items: center; gap: 6px; }
.whip { display: flex; height: 4px; overflow: hidden; background: var(--line); margin: 8px 0 4px; }
.whip i { display: block; height: 100%; }
.seg-btns { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; }
.seg-btns button { border: 0; background: transparent; padding: 5px 10px; font-size: 12px; cursor: pointer; color: var(--ink-3); transition: color .2s; }
.seg-btns button:hover { color: var(--ink); }
.seg-btns button + button { border-left: 1px solid var(--line-2); }
.seg-btns button.on { background: var(--ink); color: var(--paper-2); }

/* ---------- people ---------- */
.npc { display: flex; gap: 12px; align-items: center; }
.avatar { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-family: var(--serif); font-weight: 600; font-size: 15px; color: var(--ink);
  background: var(--paper-2); box-shadow: inset 0 0 0 1.5px var(--pc, var(--ink-4)); }
.npc .info { flex: 1; min-width: 0; }
.npc .info b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.npc .info .sub { font-size: 12px; color: var(--ink-3); }
.npc .right { text-align: right; font-size: 12px; }

/* ---------- inspector ---------- */
#inspector { position: fixed; top: var(--float-top); right: var(--edge); width: 330px; max-height: calc(100vh - var(--float-top) - 230px); overflow-y: auto; z-index: 18; padding: 18px 20px; animation: fadeIn .3s var(--ease); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
#inspector h3 { margin: 0 0 4px; font-size: 18px; font-family: var(--serif); font-weight: 600; letter-spacing: 0.06em; padding-right: 28px; }
#inspector .close { position: absolute; top: 10px; right: 10px; }

/* ---------- map tools ---------- */
#maptools { position: fixed; bottom: var(--edge); left: 50%; transform: translateX(-50%); z-index: 17; display: flex; align-items: center; gap: 2px; padding: 4px 8px; max-width: min(780px, calc(100vw - 560px)); }
#maptools button { border: 0; background: transparent; color: var(--ink-3); padding: 7px 9px; cursor: pointer; font-size: 12.5px; letter-spacing: 0.06em; white-space: nowrap; transition: color .2s; }
#maptools button:hover { color: var(--ink); }
#maptools button.on { color: var(--ink); box-shadow: inset 0 -1px 0 var(--ink); }
#maptools .sep { width: 1px; height: 16px; background: var(--line-2); margin: 0 8px; }
.map-legend { position: fixed; bottom: 66px; left: 50%; transform: translateX(-50%); z-index: 17; padding: 10px 14px; font-size: 12px; color: var(--ink-2); max-width: 420px; }
.map-legend .grad { height: 4px; margin: 8px 0 4px; width: 200px; }

/* ---------- end card ---------- */
#endcard { position: fixed; right: var(--edge); bottom: var(--edge); width: 300px; z-index: 18; padding: 16px; }
#endcard .wk { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
#endcard .wk b { font-family: var(--serif); font-size: 18px; font-weight: 600; letter-spacing: 0.06em; }
#endcard .todo { font-size: 12.5px; margin: 0 0 12px; padding: 0; list-style: none; }
#endcard .todo li { padding: 4px 0 4px 14px; position: relative; color: var(--ink-2); cursor: pointer; transition: color .2s; }
#endcard .todo li:hover { color: var(--ink); }
#endcard .todo li::before { content: ""; position: absolute; left: 0; top: 11px; width: 5px; height: 5px; border-radius: 50%; background: var(--warn); }
#endcard .todo li.bad::before { background: var(--neg); }
#endcard .todo li.ok::before { background: var(--pos); }
.end-btn { width: 100%; padding: 13px; font-size: 14px; letter-spacing: 0.3em; }
#endcard .flow-row { font-size: 12px; }

.music-set { flex-direction: column; align-items: stretch; margin-top: 12px; }
.music-set > div:first-child { width: 100%; }
#set-track { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-ctl { width: 100%; margin-top: 8px; }
.music-ctl input[type=range] { width: 100%; margin: 0 0 6px; accent-color: var(--ink); }
.music-ctl .pl-row { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.music-ctl .pl-row button { border: 0; background: transparent; color: var(--ink-2); font-size: 13px; letter-spacing: 0.08em; cursor: pointer; padding: 4px 2px; }
.music-ctl .pl-row button:hover { color: var(--ink); }
.music-ctl .pl-row span { font-size: 12px; color: var(--ink-3); letter-spacing: 0.12em; }
.music-ctl #set-vol { flex: 1; margin: 0; }

/* ---------- 规划笔 palette (plan mode) ---------- */
#planbar { display: none; position: fixed; left: 50%; transform: translateX(-50%); bottom: var(--edge); z-index: 18; flex-direction: column; gap: 8px; padding: 10px 12px 10px 14px; width: min(780px, calc(100vw - 420px)); }
#planbar.on { display: flex; }
body.drawer-open #planbar { display: none; }
body.planning #maptools, body.planning .map-legend { display: none !important; }
body.planning #viewport canvas { cursor: crosshair; }
#planbar kbd, #planconfirm kbd, #maptools kbd { font-family: var(--latin); font-size: 10px; line-height: 1; padding: 2px 4px; margin-left: 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 3px; color: var(--ink-3); background: rgba(255,255,255,0.5); }
#planbar .pb-head { display: flex; align-items: center; gap: 10px; }
#planbar .pb-head > b { font-family: var(--serif); font-weight: 650; letter-spacing: 0.12em; font-size: 15px; white-space: nowrap; }
#planbar .pb-power { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#planbar .pb-cap { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
#planbar .pb-cap b { color: var(--ink); font-size: 14px; }
#planbar .pb-tools { display: flex; gap: 14px; flex-wrap: wrap; }
#planbar .pb-group { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
#planbar .pb-group label { font-size: 11px; color: var(--ink-3); letter-spacing: 0.1em; margin-right: 4px; }
#planbar .pb-tool { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: rgba(255,255,255,0.35); color: var(--ink-2); padding: 6px 8px 6px 7px; font-size: 12.5px; letter-spacing: 0.04em; cursor: pointer; border-radius: var(--radius); transition: border-color .15s, background .15s; }
#planbar .pb-tool i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15); }
#planbar .pb-tool kbd { margin-left: 2px; }
#planbar .pb-tool:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); }
#planbar .pb-tool.on { background: var(--ink); color: var(--paper-2); border-color: var(--ink); }
#planbar .pb-tool.on kbd { color: var(--paper-3); border-color: rgba(255,255,255,0.3); background: transparent; }
#planbar .pb-tool:disabled { opacity: 0.35; cursor: not-allowed; }
#planbar .pb-opts { display: flex; align-items: center; gap: 8px; font-size: 12px; min-height: 26px; }
#planbar .pb-opts > kbd { margin-left: -4px; }
#planbar .pb-hint { color: var(--ink-3); font-size: 11.5px; white-space: nowrap; }
#planbar .pb-law { display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--ink-2); border-top: 1px solid var(--line); padding-top: 7px; }
#planbar .pb-law .link, #planbar button.link { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 11.5px; padding: 0; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }

/* ---------- 建筑目录：一级类型 → 二级建筑 ---------- */
#planbar { width: min(980px, calc(100vw - 420px)); max-height: calc(100vh - 2 * var(--edge) - 130px); overflow: hidden; }
#planbar .pb-cats { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
#planbar .pb-cats::-webkit-scrollbar { display: none; }
#planbar .pb-cat { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; border: 1px solid var(--line-2); background: rgba(255,255,255,0.32); color: var(--ink-2); padding: 6px 9px 6px 8px; font: inherit; font-size: 12.5px; letter-spacing: 0.06em; cursor: pointer; border-radius: var(--radius); transition: border-color .15s, background .15s; }
#planbar .pb-cat svg { width: 15px; height: 15px; flex-shrink: 0; }
#planbar .pb-cat small { font-family: var(--latin); font-size: 10px; color: var(--ink-4); }
#planbar .pb-cat:hover { border-color: var(--ink); color: var(--ink); }
#planbar .pb-cat.on { background: var(--ink); color: var(--paper-2); border-color: var(--ink); }
#planbar .pb-cat.on small { color: var(--paper-3); }
#planbar .pb-cat.locked { opacity: 0.42; }
#planbar .pb-shelf { border-top: 1px solid var(--line); padding-top: 8px; }
#planbar .pb-shelf-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 7px; font-size: 11.5px; }
#planbar .pb-shelf-head b { font-family: var(--serif); font-size: 14px; font-weight: 600; letter-spacing: 0.1em; white-space: nowrap; }
#planbar .pb-shelf-head .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#planbar .pb-shelf-head .spacer { flex: 1; }
#planbar .pb-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; max-height: 176px; overflow-y: auto; padding-right: 2px; }
#planbar .pb-item { display: flex; flex-direction: column; align-items: stretch; gap: 2px; min-width: 0; text-align: left; font: inherit; line-height: 1.35; border: 1px solid var(--line-2); background: rgba(255,255,255,0.38); color: var(--ink-2); padding: 5px 6px 6px; cursor: pointer; border-radius: var(--radius); transition: border-color .15s, background .15s; }
#planbar .pb-thumb { display: block; height: 52px; border: 1px solid var(--line); border-left: 3px solid var(--tint); background: rgba(255,255,255,0.45); border-radius: 1px; overflow: hidden; }
#planbar .pb-thumb svg { display: block; width: 100%; height: 100%; }
#planbar .pb-nm { display: flex; align-items: center; gap: 4px; min-width: 0; font-size: 12.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; }
#planbar .pb-nm kbd { margin-left: auto; flex-shrink: 0; }
#planbar .pb-tag { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#planbar .pb-item:hover:not(:disabled) { border-color: var(--ink); }
#planbar .pb-item.on { background: var(--ink); border-color: var(--ink); }
#planbar .pb-item.on .pb-thumb { background: rgba(255,255,255,0.13); border-color: rgba(255,255,255,0.22); }
#planbar .pb-item.on .pb-nm { color: var(--paper-2); }
#planbar .pb-item.on .pb-tag { color: var(--paper-3); }
#planbar .pb-item.on kbd { color: var(--paper-3); border-color: rgba(255,255,255,0.3); background: transparent; }
#planbar .pb-item:disabled { opacity: 0.34; cursor: not-allowed; }
#maptools .pen { display: inline-flex; align-items: center; gap: 5px; color: var(--ink); font-weight: 600; }
#maptools .pen svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; }
#plantip { display: none; position: fixed; z-index: 19; pointer-events: none; padding: 7px 10px; font-size: 12px; line-height: 1.6; max-width: 250px; box-shadow: 0 6px 20px rgba(0,0,0,0.08); }
#plantip.on { display: block; }
#plantip b { font-family: var(--serif); letter-spacing: 0.06em; }
#plantip i, #planconfirm .pc-title i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
#planconfirm { display: none; position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--edge) + 178px); z-index: 19; width: min(460px, calc(100vw - 40px)); padding: 14px 16px 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); }
#planconfirm.on { display: block; }
#planconfirm .pc-title { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
#planconfirm .pc-title b { font-family: var(--serif); font-size: 17px; letter-spacing: 0.08em; }
#planconfirm .kv b { font-weight: 500; text-align: right; max-width: 70%; }
#planconfirm .pc-btns { margin-top: 10px; gap: 6px; }
.plan-tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0 12px; }
.plan-tools button { border: 1px solid var(--line-2); background: transparent; color: var(--ink-2); padding: 8px 4px; cursor: pointer; font-size: 13px; letter-spacing: 0.06em; }
.plan-tools button:hover { color: var(--ink); border-color: var(--ink); }
.plan-tools button.on { background: var(--ink); color: var(--paper-2); border-color: var(--ink); }
.plan-tools button:disabled { opacity: 0.35; cursor: not-allowed; }

#running { position: fixed; top: var(--float-top); left: 50%; transform: translateX(-50%); z-index: 25; padding: 10px 18px; display: flex; align-items: center; gap: 12px; font-size: 13px; letter-spacing: 0.06em; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-2); border-top-color: var(--ink); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 176px; right: 14px; z-index: 40; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; pointer-events: none; }
.toast { max-width: 340px; padding: 10px 14px; border-radius: var(--radius); background: var(--paper-2); border: 1px solid var(--line); border-left: 2px solid var(--ink); font-size: 13px; box-shadow: 0 20px 40px -24px rgba(40, 32, 20, 0.4); animation: fadeIn .3s var(--ease); }
.toast.bad { border-left-color: var(--neg); }
.toast.good { border-left-color: var(--pos); }

/* ---------- district labels ---------- */
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.dlabel { position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; text-align: center; padding: 2px 6px; white-space: nowrap;
  text-shadow: 0 0 2px var(--paper), 0 0 6px var(--paper), 0 0 12px var(--paper); }
.dlabel b { display: block; font-size: 13px; font-weight: 600; font-family: var(--serif); letter-spacing: 0.24em; color: var(--ink); }
.dlabel span { display: block; margin-top: 1px; font-size: 10.5px; letter-spacing: 0.1em; color: var(--ink-2); }
.dlabel span:empty { display: none; }
.dlabel:hover b { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
[data-time=night] .dlabel { text-shadow: 0 0 2px #0b0f17, 0 0 6px #0b0f17, 0 0 12px #0b0f17; }
[data-time=night] .dlabel b { color: #f1eee8; }
[data-time=night] .dlabel span { color: #b7b3ac; }
.dlabel.home b::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 7px; vertical-align: 2px; background: var(--accent); }

/* ---------- modal ---------- */
#modal-root { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.modal-wrap { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(226, 222, 214, 0.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); pointer-events: auto; animation: fadeBg .3s ease-out; }
@keyframes fadeBg { from { opacity: 0; } to { opacity: 1; } }
.modal { width: 100%; max-width: 580px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(22, 22, 22, 0.05), 0 50px 90px -40px rgba(40, 32, 20, 0.45); animation: pop .4s var(--ease); }
.modal.wide { max-width: 780px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.modal-head { padding: 22px 26px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; gap: 12px; }
.modal-head h3 { margin: 0; font-size: 20px; font-family: var(--serif); font-weight: 600; letter-spacing: 0.1em; flex: 1; }
.modal-kind { font-size: 11px; letter-spacing: 0.26em; color: var(--ink-3); }
.modal-body { padding: 20px 26px; overflow-y: auto; }
.modal-foot { padding: 14px 26px 20px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.modal-foot.inline { flex-direction: row; justify-content: flex-end; }
.choice { display: block; width: 100%; text-align: left; padding: 12px 15px; border-radius: var(--radius); border: 1px solid var(--line-2); background: transparent; cursor: pointer; font-size: 14px; transition: border-color .2s, background .2s; }
.choice:hover:not(:disabled) { border-color: var(--ink); background: rgba(22, 22, 22, 0.025); }
.choice.primary { border-color: var(--ink); }
.choice:disabled { opacity: 0.38; cursor: not-allowed; }
.choice small { display: block; margin-top: 4px; font-size: 12px; color: var(--ink-3); }
.npc-card { padding: 12px 14px; border-radius: var(--radius); background: rgba(255, 255, 255, 0.45); border: 1px solid var(--line); line-height: 1.85; font-size: 13px; }

.report-group { margin-bottom: 16px; }
.report-group h5 { margin: 0 0 8px; font-size: 11px; font-weight: 400; letter-spacing: 0.26em; color: var(--ink-3); }
.report-group ul { margin: 0; padding: 0; list-style: none; }
.report-group li { padding: 6px 0 6px 14px; border-left: 1px solid var(--line-2); margin-bottom: 3px; font-size: 13px; line-height: 1.7; }
.report-group li.lg-good { border-left: 2px solid var(--pos); }
.report-group li.lg-bad { border-left: 2px solid var(--neg); }
.report-group li.lg-politics { border-left: 2px solid #6e6688; }
.report-group li.lg-city { border-left: 2px solid var(--blue); }
/* v3.0 因果总线：政坛(NPC 之间) / 旧账 / 政体漂移三种新日志类型 */
.report-group li.lg-society { border-left: 2px solid #8a7b56; }
.report-group li.lg-ledger { border-left: 2px solid var(--accent); }
.report-group li.lg-regime { border-left: 2px solid #6e6688; background: rgba(110,102,136,.05); }

.grade { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius); font-family: var(--serif); font-size: 24px; font-weight: 600; border: 1px solid currentColor; }
.grade.A { color: var(--pos); }
.grade.B { color: var(--blue); }
.grade.C { color: var(--warn); }
.grade.D { color: var(--neg); }

.slider-row { display: grid; grid-template-columns: 74px 1fr 64px; gap: 12px; align-items: center; padding: 6px 0; font-size: 13px; }
.slider-row output { text-align: right; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--ink); }
input[type=text], select { width: 100%; padding: 9px 11px; border-radius: var(--radius); border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.5); color: var(--ink); font: inherit; outline: none; transition: border-color .2s; }
input[type=text]:focus, select:focus { border-color: var(--ink); }

.spark { display: block; width: 100%; height: 46px; }

/* ---------- title / setup ---------- */
.screen { position: fixed; inset: 0; z-index: 30; overflow-y: auto; }
#title { background: var(--veil); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#title.is-menu { overflow: hidden auto; backdrop-filter: none; -webkit-backdrop-filter: none;
  background: linear-gradient(90deg, rgba(239, 236, 230, 0.97) 0%, rgba(239, 236, 230, 0.9) 27%, rgba(239, 236, 230, 0.35) 47%, rgba(239, 236, 230, 0) 62%),
    linear-gradient(0deg, rgba(239, 236, 230, 0.96) 0%, rgba(239, 236, 230, 0) 24%); }
#title.is-menu::before, #boot::before { content: ''; position: fixed; inset: 0; pointer-events: none; background-image: var(--grain); opacity: 0.09; mix-blend-mode: multiply; }
.title-inner { max-width: 1120px; margin: 0 auto; padding: 8vh 32px 48px; }
.pillars { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-top: 7vh; max-width: 900px; }
.pillars div { padding: 4px 18px 14px; border-left: 1px solid var(--line-2); }
.pillars b { display: block; font-family: var(--serif); font-size: 15px; font-weight: 600; letter-spacing: 0.08em; margin-bottom: 6px; }
.pillars span { font-size: 12.5px; color: var(--ink-2); line-height: 1.8; }
.setup { max-width: 880px; }
.setup h2 { font-family: var(--serif); font-size: 32px; font-weight: 600; margin: 0 0 8px; letter-spacing: 0.16em; }
.setup .step { margin-top: 30px; }
.setup .step > label { display: block; font-size: 11px; letter-spacing: 0.3em; color: var(--ink-3); margin-bottom: 10px; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.opt { position: relative; text-align: left; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: rgba(255, 255, 255, 0.4); cursor: pointer; transition: border-color .2s, background .2s; }
.opt:hover { border-color: var(--ink-3); }
.opt.on { border-color: var(--ink); background: rgba(255, 255, 255, 0.75); box-shadow: inset 0 0 0 1px var(--ink); }
.opt.on::after { content: ''; position: absolute; top: 10px; right: 10px; width: 6px; height: 6px; background: var(--accent); }
.opt b { display: block; font-family: var(--serif); font-size: 15px; font-weight: 600; letter-spacing: 0.06em; margin-bottom: 5px; }
.opt span { display: block; font-size: 12px; color: var(--ink-2); line-height: 1.65; }
.setup .foot, .page .foot { display: flex; gap: 12px; margin-top: 34px; align-items: center; flex-wrap: wrap; }
.page h2 { font-family: var(--serif); font-size: 32px; font-weight: 600; margin: 0 0 8px; letter-spacing: 0.16em; }
.page .step { margin-top: 28px; }
.page .step > label { display: block; font-size: 11px; letter-spacing: 0.3em; color: var(--ink-3); margin-bottom: 10px; }
.slotlist { display: flex; flex-direction: column; gap: 8px; margin-top: 22px; }
.slotcard { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.45); }
.slotcard > div { min-width: 0; }
.slotcard b { display: block; font-family: var(--serif); font-size: 16px; font-weight: 600; letter-spacing: 0.08em; }
.slotcard span, .slotcard small { display: block; margin-top: 3px; color: var(--ink-3); font-size: 12.5px; }
.slotcard small { font-family: var(--latin); letter-spacing: 0.04em; }
.slotcard .row, .slotcard > .btn { flex: none; }
.seed-no { font-family: var(--latin); font-size: 16px; font-weight: 500; letter-spacing: 0.06em; }

/* ---------- studio intro / loading ---------- */
#boot { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; overflow: hidden; cursor: pointer; user-select: none; background: var(--paper); }
.studio { position: relative; display: flex; flex-direction: column; align-items: center; margin-top: -3vh; }
.studio-mark { width: clamp(84px, 10vw, 118px); height: auto; overflow: visible; }
.mark-line { fill: none; stroke: #000; stroke-width: 1; stroke-linejoin: miter; vector-effect: non-scaling-stroke;
  stroke-dasharray: 1; stroke-dashoffset: 1; animation: mark-draw 1.4s cubic-bezier(.65, 0, .35, 1) .25s both, fade-out .5s ease 1.75s forwards; }
.mark-fill { fill: #000; clip-path: inset(100% 0 0 0); animation: mark-ink 1s cubic-bezier(.7, 0, .2, 1) 1.15s both; }
.studio-name { display: flex; margin-top: 34px; font-family: var(--latin); font-size: clamp(12px, 1.2vw, 14px); font-weight: 500; letter-spacing: 0.62em; padding-left: 0.62em; color: #000; }
.studio-name span { display: inline-block; opacity: 0; animation: letter-in 1s var(--ease) both; animation-delay: calc(1.55s + var(--i) * 0.035s); }
.studio-name .gap { width: 0.9em; }
.studio-rule { width: 36px; height: 1px; margin-top: 22px; background: #000; transform: scaleX(0); animation: rule-in 1s var(--ease) 2.05s both; }
.studio-sub { margin-top: 14px; font-size: 11px; letter-spacing: 1em; padding-left: 1em; color: var(--ink-3); opacity: 0; animation: fade-in 1s ease 2.25s both; }
.boot-progress { position: absolute; left: 50%; bottom: 10vh; width: min(220px, 60vw); transform: translateX(-50%); text-align: center; opacity: 0; animation: fade-in .8s ease 2.4s both; }
.boot-bar { height: 1px; background: var(--line); overflow: hidden; }
.boot-bar i { display: block; height: 100%; background: #000; transform-origin: 0 50%; transform: scaleX(0.03); transition: transform .6s var(--ease); }
#boot-status { margin: 14px 0 0; font-size: 11px; letter-spacing: 0.3em; color: var(--ink-3); }
.boot-skip { position: absolute; right: 30px; bottom: 26px; font-size: 10.5px; letter-spacing: 0.3em; color: var(--ink-4); opacity: 0; animation: fade-in .8s ease 1.2s both; }
#boot.ready .boot-skip { opacity: 0 !important; }
#boot.skip *, #boot.skip *::before, #boot.skip *::after { animation-delay: 0s !important; animation-duration: 0s !important; }
#boot.skip .boot-skip { display: none; }
#boot.done { cursor: default; animation: boot-out 1.1s ease .45s forwards; }
#boot.done .studio { animation: studio-out .8s var(--ease) forwards; }
#boot.done .boot-progress, #boot.done .boot-skip { animation: fade-out .3s ease forwards; }
#boot.error { cursor: default; }
#boot.error .boot-bar { display: none; }
#boot.error #boot-status { color: var(--neg); letter-spacing: 0.08em; line-height: 1.8; }
#boot.gone { display: none; }

@keyframes mark-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes mark-ink { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes letter-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes rule-in { to { transform: scaleX(1); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes studio-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes boot-out { to { opacity: 0; visibility: hidden; } }

@media (prefers-reduced-motion: reduce) {
  #boot *, #boot *::before, #boot *::after { animation-delay: 0s !important; animation-duration: 0s !important; }
}

/* ---------- main menu ---------- */
.menu { position: relative; min-height: 100%; display: grid; grid-template-columns: minmax(300px, 440px) 1fr; grid-template-rows: auto 1fr auto; column-gap: 40px; padding: 0 clamp(24px, 5vw, 76px); }
.menu-top { grid-column: 1 / -1; grid-row: 1; display: flex; align-items: center; gap: 14px; padding: 30px 0 0; font-family: var(--latin); font-size: 10.5px; font-weight: 500; letter-spacing: 0.42em; color: #000; }
.menu-top svg { width: 17px; height: 15px; fill: #000; }
.menu-top .sp { flex: 1; }
.menu-top .ed { font-weight: 400; letter-spacing: 0.3em; color: var(--ink-3); }
.menu-main { grid-column: 1; grid-row: 2; align-self: center; padding: 6vh 0; }
.gm-kicker { display: flex; align-items: center; gap: 14px; font-family: var(--latin); font-size: 10.5px; letter-spacing: 0.5em; color: var(--ink-3); }
.gm-kicker.place { font-family: var(--serif); font-size: 15px; letter-spacing: 0.34em; color: var(--ink-2); }
.gm-kicker::before { content: ''; width: 32px; height: 1px; background: var(--ink); }
.menu h1 { margin: 18px 0 0; font-family: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, serif; font-size: clamp(52px, 6.2vw, 84px); line-height: 0.95; letter-spacing: 0.04em; font-weight: 500; color: var(--ink); }
.gm-en { margin-top: 16px; font-family: var(--latin); font-size: 10.5px; letter-spacing: 0.42em; color: var(--ink-3); }
.menu-tag { max-width: 380px; margin: 26px 0 32px; font-family: var(--serif); font-size: 14.5px; line-height: 1.9; color: var(--ink-2); }
.menu-tag em { font-style: normal; color: var(--ink); font-weight: 600; }
.menu-list { display: flex; flex-direction: column; max-width: 400px; border-top: 1px solid var(--line-2); }
.mi { position: relative; display: grid; grid-template-columns: 44px 1fr auto; align-items: baseline; width: 100%; padding: 15px 4px 15px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  background: transparent; text-align: left; cursor: pointer; }
.mi .k { font-family: Georgia, "Times New Roman", serif; font-size: 12px; font-style: italic; color: var(--ink-4); transition: color .3s; }
.mi .t { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: 0.16em; color: var(--ink); transition: transform .45s var(--ease); display: inline-block; }
.mi .d { grid-column: 2; margin-top: 4px; font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .3s, transform .45s var(--ease); }
.mi::after { content: ''; grid-column: 3; grid-row: 1; align-self: center; width: 0; height: 1px; background: var(--ink); transition: width .45s var(--ease); }
.mi:hover, .mi:focus-visible { outline: none; }
.mi:hover .t, .mi:focus-visible .t, .mi:hover .d, .mi:focus-visible .d { transform: translateX(8px); }
.mi:hover .d, .mi:focus-visible .d { color: var(--ink-2); }
.mi:hover .k, .mi:focus-visible .k { color: var(--accent); }
.mi:hover::after, .mi:focus-visible::after { width: 28px; }
.mi.lead .k { color: var(--accent); }
.mi-sep { display: none; }

.menu-dispatch { grid-column: 1 / -1; grid-row: 3; display: flex; align-items: center; gap: 22px; padding: 18px 0 calc(22px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line-2); font-size: 12px; color: var(--ink-3); }
.dp-label { flex: none; font-family: var(--serif); font-size: 12.5px; font-weight: 600; letter-spacing: 0.3em; color: var(--ink); }
.dp-text { position: relative; flex: 1; min-width: 0; height: 20px; overflow: hidden; }
.dp-text span { position: absolute; inset: 0; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); opacity: 0; transform: translateY(8px); transition: opacity .8s ease, transform .8s var(--ease); }
.dp-text span.on { opacity: 1; transform: none; }
.dp-text span.off { opacity: 0; transform: translateY(-8px); }
.dp-text b { font-weight: 600; color: var(--ink); }
.mf-keys { flex: none; font-size: 11px; letter-spacing: 0.08em; }
.mf-keys kbd { display: inline-block; min-width: 18px; margin: 0 2px; padding: 0 4px; border: 1px solid var(--line-2); border-radius: 2px; font: 10.5px var(--latin); color: var(--ink-2); text-align: center; }

.rise { animation: rise 1.1s var(--ease) both; animation-delay: calc(0.35s + var(--d, 0) * 0.07s); }
.menu.static .rise { animation: none; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.at-title .labels { display: none; }

.credits { text-align: center; padding: 14px 0 4px; }
.credits svg { width: 56px; height: 50px; fill: #000; }
.credits .cr-name { margin-top: 22px; font-family: var(--latin); font-size: 12.5px; font-weight: 500; letter-spacing: 0.6em; padding-left: 0.6em; color: #000; }
.credits .cr-sub { margin: 10px 0 26px; font-size: 11px; letter-spacing: 0.8em; padding-left: 0.8em; color: var(--ink-3); }
.credits .kv { text-align: left; }
.guide .pillars { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 0; margin: 2px 0 8px; max-width: none; }
.ending { text-align: center; padding: 14px 0 6px; }
.ending h2 { font-family: var(--serif); font-size: 30px; font-weight: 600; letter-spacing: 0.16em; margin: 0 0 12px; color: var(--ink); }

/* ---------- 终局：画像与遗物 ---------- */
.portrait { margin: 2px 0 8px; padding: 18px 22px 16px; border: 1px solid var(--line); background: var(--paper-2); text-align: center; }
.portrait .p-label { font-family: var(--latin); font-size: 10px; letter-spacing: 0.52em; padding-left: 0.52em; color: var(--ink-4); text-transform: uppercase; }
.portrait .p-name { font-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: 0.34em; padding-left: 0.34em; margin: 10px 0 10px; }
.portrait .p-line { font-family: var(--serif); font-size: 15px; line-height: 1.95; color: var(--ink-2); margin: 0 0 14px; }
.portrait .p-body { font-size: 12.5px; line-height: 2.1; color: var(--ink-3); text-align: left; text-indent: 2em; margin: 0; }
.relics { margin: 2px 0 4px; }
.relic { display: flex; gap: 10px; padding: 10px 2px; border-bottom: 1px dashed var(--line); }
.relic:last-child { border-bottom: 0; }
.relic .r-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-3); margin-top: 8px; flex: none; }
.relic.scar .r-dot { background: var(--neg); }
.relic b { font-weight: 600; font-size: 13px; }
.relic .r-d { font-size: 12px; line-height: 1.7; color: var(--ink-3); margin-top: 3px; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  #maptools { left: calc(var(--rail-w) + 28px); transform: none; max-width: calc(100vw - 430px); }
  .map-legend { left: calc(var(--rail-w) + 28px); transform: none; }
}
@media (min-width: 821px) {
  body.drawer-open #maptools { left: calc(var(--rail-w) + 28px + var(--drawer-w) + 12px); right: 328px; transform: none; max-width: none; }
  body.drawer-open .map-legend { left: calc(var(--rail-w) + 28px + var(--drawer-w) + 12px); right: auto; transform: none; }
}
@media (max-width: 1100px) {
  :root { --drawer-w: 440px; }
  .pillars { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 0; }
}
@media (max-width: 820px) {
  :root { --hud-h: 52px; --rail-h: 60px; --edge: 8px; --float-top: 70px; }
  #hud { gap: 6px; }
  .brand { padding: 6px 10px; min-width: 0; }
  .brand .who b { max-width: 96px; font-size: 13px; }
  .brand .who span { display: none; }
  .hud-date { padding: 6px 10px; }
  .stat { min-width: 62px; padding: 4px 7px; }
  .stat .bar { width: 52px; }
  #hud .icon-btn { width: 40px; }
  #rail { top: auto; bottom: 0; left: 0; right: 0; width: auto; flex-direction: row; overflow-x: auto; border-radius: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); gap: 0; border-width: 1px 0 0; }
  #rail button { min-width: 58px; flex: 1; padding: 7px 2px 6px; font-size: 10.5px; }
  #rail button svg { width: 19px; height: 19px; }
  #rail button.on::before { left: 30%; right: 30%; top: -4px; bottom: auto; width: auto; height: 2px; }
  #drawer { left: 0; right: 0; width: auto; top: var(--float-top); bottom: calc(var(--rail-h) + env(safe-area-inset-bottom)); border-radius: 0; border-width: 0; z-index: 22; }
  #drawer-body { padding: 14px 16px 22px; }
  #inspector { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(var(--rail-h) + 74px); max-height: 46vh; }
  #maptools { left: 8px; right: 8px; bottom: calc(var(--rail-h) + 10px); transform: none; max-width: none; overflow-x: auto; }
  .map-legend { display: none; }
  #endcard { left: auto; right: 8px; bottom: calc(var(--rail-h) + 62px); width: auto; padding: 8px; }
  #endcard .wk, #endcard .todo, #endcard .fc { display: none; }
  #planbar { left: 8px; right: 8px; width: auto; transform: none; bottom: calc(var(--rail-h) + 10px); max-height: 52vh; }
  #planbar .pb-power, #planbar .pb-hint, #planbar .pb-shelf-head .muted { display: none; }
  #planbar .pb-items { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); max-height: 138px; }
  #planbar .pb-thumb { height: 42px; }
  #planconfirm { bottom: calc(var(--rail-h) + 190px); }
  .plan-tools { grid-template-columns: repeat(3, 1fr); }
  .end-btn { padding: 11px 18px; font-size: 13px; letter-spacing: 0.2em; }
  #toasts { bottom: calc(var(--rail-h) + 120px); }
  .week-grid { grid-template-columns: 20px repeat(7, 1fr); gap: 3px; }
  .slot { min-height: 54px; padding: 4px 3px 4px 5px; font-size: 10.5px; }
  .slot .nm { font-size: 11px; }
  .slot .tg { display: none; }
  .title-inner { padding: 5vh 20px 34px; }
  .menu { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; column-gap: 0; padding: 0 22px; }
  .menu-top { padding-top: 18px; }
  .menu-top .ed { display: none; }
  .menu-main { grid-column: 1; grid-row: 2; padding: 4vh 0 16px; align-self: center; }
  .menu h1 { font-size: 48px; letter-spacing: 0.02em; }
  #title.is-menu { background: linear-gradient(180deg, rgba(239, 236, 230, 0.94) 0%, rgba(239, 236, 230, 0.72) 42%, rgba(239, 236, 230, 0.88) 100%); }
  .gm-en { letter-spacing: 0.28em; }
  .menu-tag { margin: 16px 0 18px; font-size: 13.5px; }
  .mi { padding: 12px 0; }
  .mi .t { font-size: 18px; }
  .menu-dispatch { grid-row: 3; flex-wrap: wrap; gap: 8px 16px; }
  .mf-keys { display: none; }
  .boot-skip { right: 50%; transform: translateX(50%); bottom: 4vh; }
  .pillars { grid-template-columns: 1fr; margin-top: 4vh; }
  .slotcard { flex-direction: column; align-items: flex-start; }
  .page h2, .setup h2 { font-size: 26px; }
  .modal-head { padding: 18px 18px 14px; }
  .modal-body { padding: 16px 18px; }
  .modal-foot { padding: 12px 18px 16px; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}
#planconfirm .kv b span { flex-shrink: 1; }
#planconfirm .kv b .pos { color: var(--pos); }
#planconfirm .kv b .neg { color: var(--neg); }
#planconfirm .kv b .warn { color: var(--warn); font-weight: 600; }
#planconfirm .btn.primary kbd { color: var(--paper-3); border-color: rgba(255,255,255,0.35); background: transparent; }

/* ---------- 议会牌局 ---------- */
.cg { display: flex; flex-direction: column; gap: 10px; }
.cg-need { font-size: 13px; }
.cg-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: #e5e2da; }
.cg-bar i { display: block; height: 100%; }
.cg-bar .y { background: #3f7a5c; }
.cg-bar .u { background: #cfccc4; }
.cg-bar .n { background: #a8432f; }
.cg-nums { display: flex; justify-content: space-between; gap: 12px; font-size: 11.5px; margin-top: 2px; }
.cg-log { min-height: 38px; font-size: 12px; color: #4b5563; line-height: 1.6; border-left: 2px solid #e5e2da; padding-left: 8px; }
/* 手牌：按扑克牌来做。左上 / 右下双角标（右下的旋转 180°），中央是花色图腾与牌名，
   底边一行代价。四门花色沿用扑克的红黑两色。 */
.cg-hand { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 12px 9px; padding: 12px 2px 4px; }

.pcard {
  --w: 116px; --h: 162px;
  --suit: #26241f; --tilt: 0deg; --lift: 0px;
  position: relative; flex: 0 0 auto;
  width: var(--w); height: var(--h); margin-left: 0; padding: 0;
  border: 1px solid #d5cfc0; border-radius: 7px;
  background: linear-gradient(158deg, #fffefa 0%, #fdfaf2 52%, #f8f4e9 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.95), 0 1px 1px rgba(40,32,20,.10), 0 4px 9px -7px rgba(40,32,20,.4);
  cursor: pointer; text-align: center; font: inherit; color: var(--ink);
  transform: rotate(var(--tilt)) translateY(var(--lift));
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), opacity .18s;
  -webkit-tap-highlight-color: transparent;
}
.cg-hand > .pcard:first-child { margin-left: 0; }
.pcard::before {
  content: ""; position: absolute; inset: 3px; border-radius: 5px;
  border: 1px solid rgba(22,22,22,.055); pointer-events: none;
}
.pcard.red { --suit: #b23a24; }
.pcard.basic { border-color: #c9bb96; background: linear-gradient(158deg, #fffdf6 0%, #fdf9ec 60%, #faf3e2 100%); }
.pcard.basic::before { border-color: rgba(150,124,64,.16); }
.pcard:hover:not(:disabled) { --lift: -12px; z-index: 5; box-shadow: inset 0 1px 0 rgba(255,255,255,.95), 0 2px 4px rgba(40,32,20,.10), 0 20px 30px -16px rgba(40,32,20,.5); }
.pcard:active:not(:disabled) { --lift: -7px; }
.pcard:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.pcard:disabled, .pcard.off { opacity: .38; cursor: not-allowed; filter: grayscale(.5); --suit: var(--ink-4); }

.pcard .wm { position: absolute; top: 24px; right: 5px; width: 40px; height: 40px; pointer-events: none; }
.pcard .wm svg { width: 40px; height: 40px; fill: currentColor; color: var(--suit); opacity: .07; }
.pcard.red .wm svg { opacity: .045; }

/* 角标 */
.pcard .idx { position: absolute; top: 7px; left: 8px; display: flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1; color: var(--suit); }
.pcard .idx.br { top: auto; left: auto; right: 8px; bottom: 8px; transform: rotate(180deg); opacity: .4; }
.pcard .idx.br svg { width: 9px; height: 9px; }
.pcard .idx .n { font-family: var(--latin); font-size: 16px; font-weight: 600; letter-spacing: -.03em; }
.pcard .idx svg { width: 11px; height: 11px; display: block; fill: currentColor; }

/* 中央 */
.pcard .face { position: absolute; inset: 26px 9px 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; }
.pcard .face svg { width: 36px; height: 36px; color: var(--suit); opacity: .92; }
.pcard .face .nm { font-family: var(--serif); font-size: 15px; font-weight: 600; letter-spacing: .08em; line-height: 1.2; }
.pcard .face .tag { font-style: normal; display: block; border: 0; padding: 0; font-size: 9px; letter-spacing: .08em; color: var(--ink-3); }
.pcard .face .tag.cost { color: var(--ink-2); letter-spacing: .01em; }
.pcard .face .tag.cost.aff { color: var(--neg); }
.pcard.basic .face .tag { color: #9c8552; }

/* 底边代价 */

/* 扇形：一手牌微微张开，悬停时归正 */
.cg-hand.fan > .pcard:nth-child(1) { --tilt: -2deg; }
.cg-hand.fan > .pcard:nth-child(2) { --tilt: -1deg; }
.cg-hand > .pcard:nth-child(3) { --tilt: 0deg; }
.cg-hand.fan > .pcard:nth-child(4) { --tilt: 1deg; }
.cg-hand.fan > .pcard:nth-child(5) { --tilt: 2deg; }
.cg-hand.fan > .pcard:hover:not(:disabled) { --tilt: 0deg; }

@media (max-width: 720px) {
  .pcard { --w: 88px; --h: 126px; }
  .pcard .face svg { width: 28px; height: 28px; }
  .pcard .face .nm { font-size: 12px; }
}
.cg-head { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.cg-foot { display: flex; align-items: center; gap: 8px; }

/* ---------- 日程小游戏 ---------- */
.mg { display: flex; flex-direction: column; gap: 14px; align-items: center; padding: 8px 0; }
.mg-hint { font-size: 12.5px; color: #4b5563; }
.mg-track { position: relative; width: 100%; height: 18px; background: #ece9e1; border-radius: 9px; overflow: hidden; }
.mg-zone { position: absolute; left: 62%; width: 20%; top: 0; bottom: 0; background: #cfe3d4; }
.mg-needle { position: absolute; top: -3px; bottom: -3px; width: 3px; background: #1f2937; transform: translateX(-50%); }
.mg-big { width: 150px; height: 150px; border-radius: 50%; border: 2px solid #c9bfa4; background: #fbf7ec; font-size: 15px; cursor: pointer; user-select: none; }
.mg-big.pop { animation: mgpop .12s ease-out; }
@keyframes mgpop { from { transform: scale(.94); } to { transform: scale(1); } }
.mg-count { font-size: 13px; font-variant-numeric: tabular-nums; }
.mg-picks { display: flex; gap: 10px; }
.mg-pick { width: 110px; min-height: 96px; border: 1px solid #d8d4cb; border-radius: 8px; background: #fffdf8; display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center; cursor: pointer; }
.mg-pick small { font-size: 11px; color: #6b7280; }
.mg-pick.yes { border-color: #9dc3ab; }
.mg-pick.no { border-color: #d8b4ac; }

/* ---------- 政坛：报纸头版 / 集团诉求 / 民调 ---------- */
.paper { background: #f8f4e9; border: 1px solid #ded5c0; padding: 14px 16px 10px; box-shadow: inset 0 0 40px rgba(160, 140, 100, .07); }
.paper-head { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 2px solid var(--ink); padding-bottom: 5px; }
.paper-name { font-family: var(--serif); font-size: 21px; font-weight: 700; letter-spacing: 3px; }
.paper-meta { font-size: 10.5px; color: var(--ink-3); letter-spacing: .04em; }
.paper-title { font-family: var(--serif); font-size: 19px; line-height: 1.4; font-weight: 700; margin: 10px 0 6px; letter-spacing: .5px; }
.paper-sub { font-size: 12.5px; line-height: 1.75; color: var(--ink-2); }
.paper-foot { text-align: right; font-size: 10.5px; color: var(--ink-3); margin-top: 8px; }
.demand { margin-top: 8px; padding: 8px 10px; background: rgba(22, 22, 22, .025); border-left: 2px solid var(--ink-4); }
.ultimatum { margin-top: 8px; padding: 8px 10px; background: rgba(168, 67, 47, .075); border-left: 3px solid var(--neg); }
.card.alert { border-color: rgba(168, 67, 47, .55); }
.devbar { position: relative; height: 5px; margin: 7px 0 2px; background: var(--line); }
.devbar::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--ink-4); }
.devbar i { position: absolute; top: 0; bottom: 0; }
.poll-big { display: flex; align-items: baseline; gap: 12px; margin-top: 2px; }
.poll-big b { font-size: 34px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.poll-big span { font-size: 12px; }
.headline-row { display: flex; gap: 8px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.headline-row .w { flex: none; width: 48px; color: var(--ink-3); font-size: 10.5px; }
.headline-row .t { flex: 1; line-height: 1.55; }
.headline-row .tag { flex: none; }

/* 纪事 · 时间轴 */
.tl { display: flex; margin: 12px 0 2px; }
.tl-step { flex: 1; text-align: center; position: relative; }
.tl-step::before { content: ""; position: absolute; left: 0; right: 0; top: 4px; height: 1px; background: var(--line-2); }
.tl-step:first-child::before { left: 50%; }
.tl-step:last-child::before { right: 50%; }
.tl-step i { position: relative; display: block; width: 9px; height: 9px; margin: 0 auto 7px; border-radius: 50%; background: var(--bg); border: 1px solid var(--ink-4); }
.tl-step.past i { background: var(--ink-3); border-color: var(--ink-3); }
.tl-step.now i { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.tl-step span { display: block; font-size: 10.5px; line-height: 1.25; color: var(--ink-4); }
.tl-step.past span { color: var(--ink-3); }
.tl-step.now span { color: var(--ink); font-weight: 600; }

/* v4.1 · 条款工作台 / 承诺对账 / 判例 */
.clause-line { margin-top: 7px; padding: 5px 8px; font-size: 12px; line-height: 1.55; color: var(--ink-2); background: rgba(22, 22, 22, .028); border-left: 2px solid var(--ink-4); }
.clause-line.ok { border-left-color: #3f7a5c; }
.clause-line.warn { border-left-color: #b08a3c; }
.clause-line.bad { border-left-color: var(--neg); color: var(--neg); }
.clauses { margin-top: 8px; padding: 8px 10px; background: rgba(22, 22, 22, .022); border: 1px solid var(--line); }
.clause-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 12.5px; }
.clause-row .cl-label { flex: 1; }
.clause-row b { min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; }
.clause-row.edited b { color: var(--accent); }
.clause-row .seg-btns button { width: 26px; height: 24px; padding: 0; line-height: 1; }
.cl-desc { font-size: 11px; line-height: 1.5; color: var(--ink-3); margin: -2px 0 6px; }
