:root {
  --bg: #141519;
  --bg-elev: #1e2128;
  --bg-card: #22262f;
  --bg-card-hi: #272c36;
  --line: #2e333d;
  --line-hi: #3a4049;
  --text: #ecedf0;
  --text-dim: #969ca7;
  --text-faint: #6b7280;
  --gold: #e0b36a;         /* 暖金点缀 */
  --gold-hi: #f0c782;
  --gold-soft: rgba(224,179,106,.14);
  --wood: #b98a5e;
  --p0: #e8726a;           /* 必做 红 */
  --p1: #e3bc63;           /* 重要 黄 */
  --p2: #8b93a0;           /* 可延后 灰 */
  --radius: 15px;
  --radius-sm: 9px;
  --shadow: 0 8px 28px rgba(0,0,0,.4);
  --shadow-sm: 0 2px 10px rgba(0,0,0,.25);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(224,179,106,.07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC",
    "HarmonyOS Sans SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: calc(96px + var(--safe-b));
  max-width: 640px;
  margin: 0 auto;
}
:where(button, [tabindex], summary, .check):focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 6px;
}

/* 顶部概况 */
.hero {
  padding: 26px 20px 10px;
  position: relative;
}
.hero::before {
  content: ""; position: absolute; left: 20px; top: 22px;
  width: 34px; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, var(--gold), transparent);
}
.hero h1 {
  font-size: 27px; font-weight: 800; margin: 14px 0 8px;
  letter-spacing: -.5px; line-height: 1.15;
}
.hero .sub {
  color: var(--text-dim); font-size: 12.5px;
  display: inline-flex; flex-wrap: wrap; gap: 6px 8px;
}
.hero .sub span {
  background: var(--bg-card); border: 1px solid var(--line);
  padding: 3px 9px; border-radius: 20px; font-variant-numeric: tabular-nums;
}

/* 户型图(吸顶) */
.floorplan-wrap {
  position: sticky; top: 0; z-index: 40;
  padding: 10px 16px 8px;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(20,21,25,0));
  transition: padding .3s var(--ease);
}
.floorplan-wrap.compact {
  padding: 8px 16px;
  background: rgba(22,24,29,.9);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  border-bottom: 1px solid var(--line-hi);
  box-shadow: 0 6px 22px rgba(0,0,0,.4);
}
/* 展开/收缩共用横向布局:收缩时图在左、说明在右 */
.floorplan-wrap { display: flex; flex-direction: column; }
.fp-svg-box {
  display: flex; justify-content: center;
  transition: max-height .36s var(--ease);
  max-height: 70vh; overflow: hidden;
}
.floorplan-wrap svg {
  width: 100%; height: auto; max-height: 68vh; display: block;
  filter: drop-shadow(0 10px 24px rgba(0,0,0,.35));
  transition: max-height .36s var(--ease), filter .3s var(--ease);
}

/* 收缩态:整体变成一条横向薄条 */
.floorplan-wrap.compact { flex-direction: row; align-items: center; gap: 12px; }
.floorplan-wrap.compact .fp-svg-box { max-height: 72px; flex: 0 0 auto; }
.floorplan-wrap.compact svg { width: auto; max-height: 72px; filter: none; }

/* 当前房间说明条 */
.fp-caption {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--text-dim);
  opacity: 0; max-height: 0; overflow: hidden;
  transition: opacity .3s var(--ease), max-height .3s var(--ease);
}
.floorplan-wrap.compact .fp-caption { opacity: 1; max-height: 40px; flex: 1; }
.fp-caption .dot {
  width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto;
  background: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft);
}
.fp-caption .fp-room { color: var(--gold); }
.room-shape {
  fill: var(--bg-card); stroke: var(--line-hi); stroke-width: 1.5;
  transition: fill .28s var(--ease), stroke .28s var(--ease); cursor: pointer;
}
.room-shape.active { fill: var(--gold); stroke: var(--gold-hi); }
.room-shape.pulse { animation: roomPulse .5s var(--ease); }
@keyframes roomPulse {
  0% { stroke-width: 1.5; }
  40% { stroke-width: 4; stroke: var(--gold-hi); }
  100% { stroke-width: 1.5; }
}
.room-label { fill: var(--text-dim); font-size: 5px; font-weight: 500; pointer-events: none; transition: fill .28s var(--ease); }
.room-label.area { font-size: 4.2px; fill: var(--text-faint); }
.room-shape.active + .room-label, .room-label.active { fill: #1a1510; }
.room-shape.active ~ .room-label.area, .room-label.area.active { fill: #4a3c22; }
.room-badge { fill: var(--gold); }
.room-badge-text { fill: #1a1510; font-size: 4px; font-weight: 700; pointer-events: none; font-variant-numeric: tabular-nums; }

/* 区块标题 */
.section-title {
  padding: 22px 20px 2px; font-size: 12px; font-weight: 700;
  color: var(--text-faint); letter-spacing: 2px; text-transform: uppercase;
  display: flex; align-items: center; gap: 9px;
}
.section-title::before {
  content: ""; width: 14px; height: 2px; border-radius: 2px;
  background: var(--gold); flex: 0 0 auto;
}

/* 房间分组 */
.room-group { scroll-margin-top: 170px; padding: 4px 16px; }
.room-group > h2 {
  font-size: 18px; font-weight: 700; margin: 16px 2px 8px;
  display: flex; align-items: center; gap: 8px; letter-spacing: -.2px;
  transition: color .25s var(--ease);
}
.room-group.hl > h2 { color: var(--gold); }
.room-group.hl > h2::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--gold-soft), transparent);
}

/* 卡片 */
.card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 15px; margin: 9px 0;
  box-shadow: var(--shadow-sm); display: flex; gap: 13px; align-items: flex-start;
  transition: border-color .2s var(--ease), background .2s var(--ease), transform .2s var(--ease);
}
.card:hover { border-color: var(--line-hi); background: var(--bg-card-hi); }
.card:active { transform: scale(.992); }
.card.enter { animation: cardIn .4s var(--ease) both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.card:has(.check.on) { border-color: rgba(224,179,106,.35); }
.card .check {
  width: 25px; height: 25px; flex: 0 0 25px; margin-top: 1px;
  border: 2px solid var(--line-hi); border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s var(--ease); background: var(--bg-elev);
}
.card .check:hover { border-color: var(--gold); }
.card .check.on { background: linear-gradient(145deg, var(--gold-hi), var(--gold)); border-color: var(--gold); }
.card .check.on::after { content: "✓"; color: #1a1510; font-weight: 800; font-size: 15px; }
.card .body { flex: 1; min-width: 0; }
.card .name { font-weight: 650; font-size: 15px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; letter-spacing: -.1px; }
.card .desc { color: var(--text-dim); font-size: 12.5px; margin-top: 4px; line-height: 1.5; }
.card .price {
  margin-top: 10px; font-variant-numeric: tabular-nums; color: var(--gold);
  font-weight: 700; font-size: 14.5px; display: flex; align-items: center; flex-wrap: wrap; gap: 7px;
}
.card .price > span:first-child { margin-right: auto; }
.card .price .edit-btn, .card .price .reset-btn {
  background: none; border: 1px solid var(--line-hi); color: var(--text-dim);
  font-size: 12px; font-weight: 600; border-radius: var(--radius-sm); padding: 4px 10px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  transition: all .18s var(--ease);
}
.card .price .edit-btn:hover { border-color: var(--gold); color: var(--gold); }
.card .price .reset-btn:hover { border-color: var(--p0); color: var(--p0); }
.card .price svg { width: 13px; height: 13px; }

/* 优先级标签 */
.tag {
  font-size: 10.5px; padding: 2px 8px; border-radius: 7px; font-weight: 700;
  letter-spacing: .3px; line-height: 1.4;
}
.tag.P0 { background: rgba(232,114,106,.16); color: var(--p0); }
.tag.P1 { background: rgba(227,188,99,.16); color: var(--p1); }
.tag.P2 { background: rgba(139,147,160,.16); color: var(--p2); }
.tag.added { background: var(--gold-soft); color: var(--gold); }

/* 编辑弹层 */
.editor {
  margin-top: 10px; padding: 13px; background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 12px;
  animation: slideDown .22s var(--ease);
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.editor label { display: block; font-size: 11.5px; color: var(--text-dim); margin: 8px 0 3px; font-weight: 600; }
.editor label:first-child { margin-top: 0; }
.editor input, .editor select {
  width: 100%; background: var(--bg); border: 1px solid var(--line-hi); color: var(--text);
  border-radius: var(--radius-sm); padding: 9px 10px; font-size: 15px; transition: border-color .18s;
}
.editor input:focus, .editor select:focus { outline: none; border-color: var(--gold); }
.editor .row { display: flex; gap: 10px; }
.editor .row > div { flex: 1; }
.editor .save {
  margin-top: 12px; background: linear-gradient(145deg, var(--gold-hi), var(--gold)); color: #1a1510;
  border: none; border-radius: var(--radius-sm); padding: 11px 14px; font-weight: 800;
  cursor: pointer; width: 100%; font-size: 14.5px; transition: filter .18s, transform .1s;
}
.editor .save:hover { filter: brightness(1.06); }
.editor .save:active { transform: scale(.985); }

/* 房间内新增条目按钮 */
.add-item-btn {
  width: 100%; margin: 8px 0 2px; padding: 11px; background: transparent;
  border: 1px dashed var(--line-hi); color: var(--text-dim); border-radius: 12px;
  font-size: 13.5px; font-weight: 600; cursor: pointer; transition: all .18s var(--ease);
}
.add-item-btn:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }
.add-item-btn:active { transform: scale(.99); }

/* 决策 / 附录 折叠 */
details.block {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); margin: 9px 16px; padding: 2px 16px; box-shadow: var(--shadow-sm);
  transition: border-color .2s var(--ease);
}
details.block[open] { border-color: var(--line-hi); }
details.block > summary {
  cursor: pointer; padding: 13px 0; font-weight: 650; font-size: 14.5px; list-style: none;
  display: flex; align-items: center; gap: 8px;
}
details.block > summary::-webkit-details-marker { display: none; }
details.block > summary::before {
  content: ""; width: 0; height: 0; border-left: 6px solid var(--gold);
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  transition: transform .2s var(--ease); flex: 0 0 auto;
}
details.block[open] > summary::before { transform: rotate(90deg); }
details.block .decision-body, details.block .appendix-body {
  white-space: pre-wrap; color: var(--text-dim); font-size: 13.5px; line-height: 1.65; padding: 0 0 14px;
}
details.block b { color: var(--text); }

/* 悬浮合计条 */
.totalbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-width: 640px; margin: 0 auto;
  background: rgba(24,27,33,.8); backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border-top: 1px solid var(--line-hi);
  box-shadow: 0 -8px 30px rgba(0,0,0,.35);
  padding: 13px 20px calc(13px + var(--safe-b)); cursor: pointer;
  transition: background .2s;
}
.totalbar .main { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.totalbar .count { color: var(--text-dim); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.totalbar .count::after {
  content: "▾"; color: var(--text-faint); font-size: 11px; transition: transform .22s var(--ease);
}
.totalbar.open .count::after { transform: rotate(180deg); }
.totalbar .amount {
  font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.3px;
  background: linear-gradient(135deg, var(--gold-hi), var(--gold));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.totalbar .breakdown {
  max-height: 0; overflow: hidden; margin-top: 0; font-size: 13px; color: var(--text-dim);
  transition: max-height .26s var(--ease), margin-top .26s var(--ease);
}
.totalbar.open .breakdown { max-height: 140px; margin-top: 10px; }
.totalbar .breakdown div {
  display: flex; justify-content: space-between; padding: 4px 0;
  font-variant-numeric: tabular-nums; border-top: 1px solid var(--line);
}
.totalbar .breakdown div:first-child { border-top: none; }

.toast {
  position: fixed; bottom: calc(108px + var(--safe-b)); left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--bg-elev); color: var(--text); border: 1px solid var(--line-hi);
  padding: 9px 18px; border-radius: 22px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0; transition: opacity .3s, transform .3s var(--ease);
  pointer-events: none; z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto !important; }
}
