/* ============================================================
   帝国时代4 · 开局速查  —  样式
   纯静态、无依赖。配色走"羊皮纸 + 鎏金"的中世纪手稿感。
   ============================================================ */

:root {
  --bg:            #12100d;
  --bg-2:          #1a1713;
  --panel:         #201c17;
  --panel-2:       #272219;
  --line:          #3a3125;
  --line-soft:     #2b2519;
  --text:          #e8dfd0;
  --text-dim:      #a3998a;
  --text-faint:    #6f6659;
  --gold:          #c9a227;
  --gold-bright:   #e8c65a;
  --gold-soft:     rgba(201, 162, 39, .13);

  --c-def:   #6fa8dc;   /* 防御 */
  --c-eco:   #7cc47f;   /* 经济 */
  --c-mil:   #d97b6c;   /* 军事 */
  --c-skill: #b28ddb;   /* 技能 */
  --c-cost:  #c9a06a;   /* 代价 */
  --c-relic: #e8c65a;   /* 圣物 */
  --c-spec:  #7fc7c4;   /* 特殊 */
  --c-hero:  #e08fb0;   /* 英雄 */

  --radius: 10px;
  --shadow: 0 4px 18px rgba(0, 0, 0, .45);
  --mono: "Cascadia Mono", "Consolas", "SF Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

/* 重要：.list 上的 display:grid 会盖掉浏览器默认的 [hidden]{display:none}
   （类选择器优先于 UA 样式表的属性选择器），导致 list.hidden = true 失效。
   这里显式兜底，保证 hidden 属性永远能生效。 */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse 900px 500px at 50% -220px, rgba(201, 162, 39, .10), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  padding-bottom: 64px;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 18px; }

/* ---------------- 头部 ---------------- */
header {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(201, 162, 39, .07), transparent);
  padding: 26px 0 20px;
}
.brand { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
h1 {
  font-size: 25px; margin: 0; letter-spacing: .5px; font-weight: 700;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand .sub { color: var(--text-faint); font-size: 13px; letter-spacing: 1px; }

.stats { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 7px 13px; font-size: 12.5px;
  color: var(--text-dim); display: flex; align-items: baseline; gap: 7px;
}
.stat b { color: var(--gold-bright); font-size: 16px; font-family: var(--mono); }

/* ---------------- 控件区 ---------------- */
.controls {
  position: sticky; top: 0; z-index: 40;
  background: rgba(18, 16, 13, .93);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 0 0;
}
.searchrow { display: flex; gap: 10px; align-items: center; }
.searchbox { position: relative; flex: 1; }
.searchbox svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); opacity: .45; }
#search {
  width: 100%; padding: 11px 38px 11px 38px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); font-size: 14.5px; font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#search:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
#search::placeholder { color: var(--text-faint); }
#clearSearch {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--text-faint); cursor: pointer;
  font-size: 19px; line-height: 1; padding: 4px 7px; border-radius: 5px; display: none;
}
#clearSearch:hover { color: var(--gold); background: var(--gold-soft); }
body.has-query #clearSearch { display: block; }

/* 标签页 */
.tabs { display: flex; gap: 4px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-faint); font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 14px; cursor: pointer; white-space: nowrap;
  display: flex; align-items: center; gap: 7px; transition: color .15s;
}
.tab:hover { color: var(--text-dim); }
.tab.active { color: var(--gold-bright); border-bottom-color: var(--gold); }
.tab .cnt {
  background: var(--panel-2); border-radius: 20px; padding: 1px 7px;
  font-size: 11px; font-family: var(--mono); color: var(--text-faint);
}
.tab.active .cnt { background: var(--gold-soft); color: var(--gold-bright); }

/* ---------------- 工具条 ---------------- */
.toolbar {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  padding: 16px 0 4px; font-size: 13px; color: var(--text-faint);
}
.toolbar .group { display: flex; align-items: center; gap: 7px; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
  background: var(--panel); border: 1px solid var(--line-soft); color: var(--text-dim);
  border-radius: 20px; padding: 4px 11px; font-size: 12.5px; cursor: pointer;
  font-family: inherit; transition: all .14s;
}
.chip:hover { border-color: var(--line); color: var(--text); }
.chip.on { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-bright); }
select.mini {
  background: var(--panel); border: 1px solid var(--line-soft); color: var(--text-dim);
  border-radius: 7px; padding: 5px 9px; font-family: inherit; font-size: 12.5px; cursor: pointer; outline: none;
}
select.mini:focus { border-color: var(--gold); }
.result-count { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--text-faint); }

/* ---------------- 卡片列表 ---------------- */
main { padding-top: 6px; }
.list { display: grid; gap: 9px; margin-top: 14px; }

.card {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-left: 3px solid var(--line); border-radius: var(--radius);
  padding: 13px 16px; transition: border-color .15s, background .15s, transform .1s;
}
.card:hover { background: var(--panel-2); border-color: var(--line); }
.card.t-def   { border-left-color: var(--c-def); }
.card.t-eco   { border-left-color: var(--c-eco); }
.card.t-mil   { border-left-color: var(--c-mil); }
.card.t-skill { border-left-color: var(--c-skill); }
.card.t-cost  { border-left-color: var(--c-cost); }
.card.t-relic { border-left-color: var(--c-relic); }
.card.t-spec  { border-left-color: var(--c-spec); }
.card.t-hero  { border-left-color: var(--c-hero); }
.card.t-elite { border-left-color: var(--c-spec); }

.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.name { font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: .3px; }
.card-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }

.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 20px;
  border: 1px solid currentColor; opacity: .85; white-space: nowrap;
}
.b-def   { color: var(--c-def); }
.b-eco   { color: var(--c-eco); }
.b-mil   { color: var(--c-mil); }
.b-skill { color: var(--c-skill); }
.b-cost  { color: var(--c-cost); }
.b-relic { color: var(--c-relic); }
.b-spec  { color: var(--c-spec); }
.b-hero  { color: var(--c-hero); }
.b-elite { color: var(--c-spec); }
.b-gold  { color: var(--gold); font-family: var(--mono); }

/* 分组标题（特殊单位：英雄 / 精锐） */
.section {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin: 22px 0 2px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.section:first-child { margin-top: 4px; }
.section h2 {
  margin: 0; font-size: 16px; font-weight: 700; letter-spacing: .5px;
  color: var(--c-spec); display: flex; align-items: baseline; gap: 8px;
}
.section.sec-hero h2 { color: var(--c-hero); }
.section h2 .sn {
  font-family: var(--mono); font-size: 11.5px; font-weight: 400;
  background: var(--panel-2); border-radius: 20px; padding: 1px 8px; color: var(--text-faint);
}
.section .sd { font-size: 12.5px; color: var(--text-faint); }

.card.unit-hero { border-left-width: 4px; }

.effect { color: var(--text); margin-top: 7px; font-size: 14px; }
.effect.dim { color: var(--text-dim); font-size: 13.5px; }

.note, .advice {
  margin-top: 9px; padding: 8px 11px; border-radius: 7px;
  font-size: 13px; line-height: 1.6;
}
.note { background: rgba(255, 255, 255, .028); color: var(--text-dim); border-left: 2px solid var(--line); }
.advice { background: var(--gold-soft); color: #d8c9a4; border-left: 2px solid var(--gold); }
.note::before, .advice::before { font-weight: 700; margin-right: 6px; letter-spacing: 1px; font-size: 11.5px; }
.note::before { content: "备注"; color: var(--text-faint); }
.advice::before { content: "建议"; color: var(--gold); }

/* 天赋等级表 */
.tiers { margin-top: 10px; display: grid; gap: 4px; }
.tier {
  display: grid; grid-template-columns: 46px 74px 1fr; gap: 10px; align-items: baseline;
  font-size: 13px; padding: 5px 9px; border-radius: 6px; background: rgba(255, 255, 255, .022);
}
.tier .lv { font-family: var(--mono); color: var(--text-faint); font-size: 12px; }
.tier .cost { font-family: var(--mono); color: var(--gold); font-weight: 600; }
.tier .desc { color: var(--text-dim); }
.tier.picked { background: var(--gold-soft); }
.tier.picked .desc { color: var(--text); }

mark { background: rgba(232, 198, 90, .3); color: var(--gold-bright); border-radius: 2px; padding: 0 1px; }

/* 加入按钮 */
.btn-add {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text-dim);
  border-radius: 7px; padding: 4px 11px; font-size: 12.5px; cursor: pointer;
  font-family: inherit; transition: all .14s; white-space: nowrap;
}
.btn-add:hover { border-color: var(--gold); color: var(--gold-bright); }
.btn-add.on { background: var(--gold); border-color: var(--gold); color: #1a1408; font-weight: 700; }
.btn-add.blocked {
  opacity: .5; cursor: not-allowed; border-style: dashed;
}
.btn-add.blocked:hover { border-color: var(--line); color: var(--text-faint); }

/* 只读标记（支线任务 / 特殊单位 不参与规划） */
.ro {
  margin-left: auto; font-size: 11.5px; color: var(--text-faint);
  border: 1px dashed var(--line); border-radius: 20px; padding: 2px 10px; white-space: nowrap;
}

/* 增益条数上限提示 */
.caprow {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  margin-top: 10px; font-size: 13px; color: var(--text-dim);
}
.caprow b { font-family: var(--mono); color: var(--gold-bright); font-size: 15px; }
.caprow b.over { color: #e0714f; }
.capnote { font-size: 12px; color: var(--text-faint); }
.capnote.on { color: var(--c-eco); }

/* 轻提示 */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 18px);
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--gold);
  color: var(--text); padding: 11px 18px; border-radius: 9px; font-size: 13.5px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s; z-index: 90; max-width: min(90vw, 620px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.warn { border-left-color: #e0714f; }

/* 下拉筛选槽 */
select.mini.slot { min-width: 118px; }
select.mini.slot + select.mini.slot { margin-left: 6px; }
select.mini.slot option:disabled { color: var(--text-faint); }

/* 「且」筛选提示 */
.filterhint {
  width: 100%; font-size: 12.5px; color: var(--text-faint); line-height: 1.7;
  padding: 3px 0 2px;
}
.filterhint b { color: var(--gold-bright); font-family: var(--mono); }
.filterhint code {
  background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 4px;
  padding: 1px 6px; font-family: var(--mono); font-size: 11.5px; color: var(--text-dim);
  white-space: nowrap;
}

/* 等级选择器 */
.lvsel { display: flex; gap: 3px; align-items: center; }
.lvsel button {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text-faint);
  width: 25px; height: 25px; border-radius: 5px; cursor: pointer; font-family: var(--mono);
  font-size: 12px; padding: 0; transition: all .12s;
}
.lvsel button:hover { border-color: var(--gold); color: var(--gold-bright); }
.lvsel button.on { background: var(--gold); border-color: var(--gold); color: #1a1408; font-weight: 700; }
.lvsel .costnow { font-family: var(--mono); color: var(--gold); font-size: 12.5px; margin-left: 4px; }

/* ---------------- 我的规划 ---------------- */
.plan-head {
  background: linear-gradient(180deg, var(--gold-soft), transparent);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-top: 16px;
}
.plan-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.plan-title h2 { margin: 0; font-size: 18px; color: var(--gold-bright); letter-spacing: .5px; }
.plan-total { font-family: var(--mono); font-size: 27px; color: var(--gold-bright); font-weight: 700; }
.plan-total small { font-size: 13px; color: var(--text-faint); font-weight: 400; margin-left: 4px; }

.budgetbar { margin-top: 12px; }
.budgetbar .track { height: 7px; background: var(--panel-2); border-radius: 20px; overflow: hidden; }
.budgetbar .fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-bright)); transition: width .3s; }
.budgetbar .fill.over { background: linear-gradient(90deg, #b4472f, #e0714f); }
.budgetbar .lbl { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-faint); margin-top: 6px; }

.plan-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 8px 15px; font-size: 13.5px; cursor: pointer;
  font-family: inherit; transition: all .14s;
}
.btn:hover { border-color: var(--gold); color: var(--gold-bright); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1a1408; font-weight: 700; }
.btn.primary:hover { background: var(--gold-bright); }
.btn.ghost { color: var(--text-faint); }
.btn.ghost:hover { color: #e0714f; border-color: #e0714f; }

.plan-group { margin-top: 18px; }
.plan-group > h3 {
  font-size: 13px; color: var(--text-faint); text-transform: uppercase;
  letter-spacing: 1.5px; margin: 0 0 8px; font-weight: 600;
}
.plan-item {
  display: flex; align-items: center; gap: 11px;
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 8px; padding: 9px 13px; margin-bottom: 6px; font-size: 13.5px;
}
.plan-item .pn { font-weight: 600; }
.plan-item .pl { font-family: var(--mono); font-size: 12px; color: var(--text-faint); }
.plan-item .pc { margin-left: auto; font-family: var(--mono); color: var(--gold); font-weight: 600; }
.plan-item .pr {
  background: none; border: 0; color: var(--text-faint); cursor: pointer;
  font-size: 17px; line-height: 1; padding: 2px 6px; border-radius: 5px;
}
.plan-item .pr:hover { color: #e0714f; background: rgba(224, 113, 79, .12); }

.empty { text-align: center; padding: 54px 20px; color: var(--text-faint); }
.empty .big { font-size: 38px; opacity: .35; margin-bottom: 10px; }
.empty p { margin: 6px 0; font-size: 14px; }
.empty .hint { font-size: 12.5px; color: var(--text-faint); opacity: .8; }

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .wrap { padding: 0 13px; }
  h1 { font-size: 21px; }
  .tier { grid-template-columns: 40px 66px 1fr; gap: 7px; font-size: 12.5px; }
  .result-count { margin-left: 0; width: 100%; }
  .plan-total { font-size: 23px; }
}

/* ---------------- 打印 ---------------- */
body.printing #list,
body.printing #toolbar,
body.printing .controls,
body.printing header { display: none !important; }

@media print {
  .controls, .card-actions, .plan-actions, .toolbar, .stats, header, #list { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
  .card, .plan-head, .plan-item { background: #fff; border-color: #bbb; break-inside: avoid; }
  .name, h1, .plan-title h2, .plan-total { color: #000 !important; -webkit-text-fill-color: #000; }
  .effect, .note, .advice, .tier .desc { color: #222 !important; }
  .advice, .note { background: #f4f4f4 !important; }
  .plan-head { border: 1px solid #bbb; }
  .plan-group > h3 { color: #000; }
  a { text-decoration: none; color: #000; }
}
