﻿:root {
  --bg: #0a0a0a;
  --panel: #171717;
  --panel-2: #222222;
  --line: rgba(255,255,255,.1);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --primary: #4f8cff;
  --primary-2: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 14px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button, input { font: inherit; }
button { cursor: pointer; }

#app {
  width: 100vw;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-left: 1px solid rgba(255,255,255,.06);
  border-right: 1px solid rgba(255,255,255,.06);
}

.topbar {
  display: flex;
  gap: 4px;
  padding: 6px;
  background: rgba(23,23,23,.96);
  border-bottom: 1px solid var(--line);
}
.nav-btn {
  flex: 1;
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  color: var(--muted);
  background: transparent;
  font-weight: 650;
}
.nav-btn.active { color: #fff; background: #2563eb; }

.page-wrap { flex: 1; position: relative; overflow: hidden; }
.page { position: absolute; inset: 0; display: none; overflow-y: auto; padding-bottom: calc(22px + var(--safe-bottom)); }
.page.active { display: block; }

.builder { padding: 18px 14px 28px; }
.header { margin-bottom: 18px; }
.header h1 { margin: 0 0 6px; font-size: 28px; line-height: 1.1; letter-spacing: 0; }
.header p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.panel-title { display: block; color: #e5e5e5; font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.budget-row { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 4px 0 10px; }
.currency { color: var(--muted); font-size: 28px; }
#budget-input {
  width: min(72vw, 230px);
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  text-align: center;
  font-size: 44px;
  font-weight: 800;
}
.quick-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.chip, .option, .seg-btn, .ghost-btn, .primary-btn, .icon-btn {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}
.chip { min-height: 34px; color: #bfdbfe; font-size: 13px; font-weight: 700; }
.chip.active { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }

.usage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.option { min-height: 56px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 9px 10px; text-align: left; }
.option strong { font-size: 15px; }
.option span { font-size: 12px; color: var(--muted); margin-top: 2px; }
.option.active { border-color: var(--primary); background: rgba(79,140,255,.16); }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg-btn { min-height: 40px; color: var(--muted); font-weight: 700; }
.seg-btn.active { color: #fff; background: #2563eb; border-color: #2563eb; }

.primary-btn {
  width: 100%;
  min-height: 52px;
  border: 0;
  background: #2563eb;
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  margin: 8px 0 14px;
}
.primary-btn:disabled { opacity: .55; }
.ghost-btn { min-height: 40px; padding: 0 12px; color: #bfdbfe; font-weight: 700; }
.hidden { display: none !important; }

.results-title { font-size: 18px; margin: 18px 0 10px; }
.config-card {
  background: #151515;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  margin-bottom: 10px;
}
.config-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.config-name { font-weight: 800; line-height: 1.35; }
.tag { display: inline-block; margin-top: 4px; color: #93c5fd; font-size: 12px; }
.price { white-space: nowrap; font-size: 19px; font-weight: 850; }
.over { color: var(--warning); font-size: 12px; text-align: right; }
.parts { display: grid; gap: 6px; margin: 10px 0; }
.part-row { color: #d4d4d8; font-size: 13px; line-height: 1.4; }
.reason { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 8px 0; }
.compat-ok { color: var(--primary-2); font-size: 13px; font-weight: 700; }
.warn { color: var(--warning); font-size: 13px; line-height: 1.45; }
.score-grid { display: grid; gap: 6px; margin-top: 10px; }
.score { display: grid; grid-template-columns: 44px 1fr 30px; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.bar { height: 5px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.fill { height: 100%; background: #22c55e; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }

.scene-page { height: 100%; overflow: hidden; padding: 0; }
.scene-shell { position: relative; height: 100%; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.scene-top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}
.scene-title, .hint {
  pointer-events: auto;
  background: rgba(0,0,0,.65);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  padding: 9px 10px;
  backdrop-filter: blur(12px);
}
.scene-title strong { display: block; font-size: 14px; }
.scene-title span, .hint { color: #d4d4d8; font-size: 12px; line-height: 1.4; }
.scene-actions { display: flex; flex-direction: column; gap: 8px; pointer-events: auto; }
.icon-btn { width: 42px; height: 42px; font-weight: 800; background: rgba(23,23,23,.82); }
.parts-tray {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: rgba(10,10,10,.88);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.parts-list { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.parts-list::-webkit-scrollbar { display: none; }
.part-btn { flex: 0 0 auto; min-width: 72px; height: 54px; padding: 7px; font-size: 12px; color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); }
.part-btn.installed { border-color: #22c55e; background: rgba(34,197,94,.18); }

.showcase-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 42px 14px calc(14px + var(--safe-bottom));
  background: linear-gradient(transparent, rgba(0,0,0,.88));
}
.showcase-info { text-align: center; margin-bottom: 12px; }
.showcase-info strong { display: block; font-size: 17px; }
.showcase-info span { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.showcase-controls { display: flex; justify-content: center; gap: 10px; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-body {
  width: 100%;
  max-width: 480px;
  max-height: 82dvh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  padding: 18px 14px calc(18px + var(--safe-bottom));
}
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 19px; }
.close-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2); color: #fff; font-size: 20px; }
.detail-grid { display: grid; gap: 8px; }
.detail-item { background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); border-radius: var(--radius); padding: 10px; font-size: 13px; line-height: 1.45; }
.detail-item strong { display: block; color: #fff; margin-bottom: 3px; }
.share-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.toast { position: fixed; left: 50%; bottom: 82px; transform: translateX(-50%); z-index: 80; max-width: 88vw; background: rgba(0,0,0,.88); color: #fff; padding: 10px 14px; border-radius: 999px; font-size: 13px; }

@media (min-width: 481px) {
  body { background: #050505; }
}
