:root {
  --ink: #243040;
  --muted: #6d6458;
  --paper: #efe6d6;
  --card: #fffaf2;
  --line: #d9ccb6;
  --wood: #c4a06a;
  --accent: #d35400;
  --accent-2: #e67e22;
  --navy: #1f2a36;
  --ok: #2e8b57;
  --danger: #c0392b;
  --radius: 18px;
  --tap: 44px;
  --font: "Manrope", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  font-size: 16px;
  color: var(--ink);
  background: #161b20;
}

.stage {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(260px, 380px) auto;
  gap: 40px;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.stage-note {
  color: #d9d2c5;
  max-width: 360px;
}
.stage-kicker {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  color: #c4a06a;
  margin: 0 0 8px;
}
.stage-note h1 {
  font-size: 32px;
  line-height: 1.15;
  margin: 0 0 12px;
  color: #fffaf2;
}
.stage-note p, .stage-note li {
  color: #c9c0b2;
  line-height: 1.5;
}
.stage-note ul { padding-left: 18px; }

.phone {
  width: 390px;
  height: 844px;
  background: #0d1014;
  border-radius: 42px;
  padding: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.phone-bezel {
  height: 100%;
  background: var(--paper);
  border-radius: 32px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.status-bar {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 22px 0;
  font-size: 12px;
  font-weight: 700;
  color: #f4ebe0;
  background: var(--navy);
}
.notch {
  width: 92px;
  height: 10px;
  background: #0d1014;
  border-radius: 0 0 10px 10px;
}

.app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 280px at 50% -80px, rgba(196, 160, 106, 0.28), transparent 60%),
    var(--paper);
}

.app-header {
  background: var(--navy);
  color: #f7efe4;
  padding: 10px 16px 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #d7b483;
}
.app-header h2 {
  margin: 2px 0 0;
  font-size: 22px;
}

.ghost-btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: #f7efe4;
  border-radius: 999px;
  padding: 8px 12px;
  min-height: 36px;
  font: inherit;
  font-weight: 600;
}

.app-body {
  flex: 1;
  overflow: auto;
  padding: 14px 14px 8px;
  -webkit-overflow-scrolling: touch;
}

.screen { display: none; }
.screen.is-active { display: block; }
.screen[hidden] { display: none !important; }
.catalog { padding-bottom: 8px; }
.edge-pick-card { margin-top: 4px; }
.edge-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.edge-pick-card .field { margin-bottom: 0; }
.edge-pick-card select { min-height: 40px; padding: 8px; font-size: 13px; }

.material-card,
.card,
.card-link,
.part-card {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
}

.material-card,
.card-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.material-swatch {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, #c48a4a, #7a4d28);
  flex: none;
}
.material-copy { flex: 1; min-width: 0; display: grid; gap: 2px; }
.material-copy strong,
.part-card strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted, .hint, small { color: var(--muted); }
.hint { font-size: 12px; margin: 8px 0 12px; }
.chevron { font-size: 24px; color: #b7a48a; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 2px 10px;
}
.section-head h3, .card h3, .card-head h3 {
  margin: 0;
  font-size: 15px;
}
.count-pill {
  background: #e7d8bf;
  border-radius: 999px;
  padding: 2px 10px;
  font-weight: 700;
  font-size: 12px;
}

.parts-list { display: grid; gap: 10px; }
.part-card {
  padding: 12px;
  display: grid;
  gap: 6px;
  cursor: pointer;
}
.part-card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}
.part-meta { font-size: 13px; color: var(--muted); }
.edge-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11px;
  font-weight: 700;
  background: #efe1c8;
  border-radius: 999px;
  padding: 3px 8px;
}
.tag.on { background: #f3d0aa; color: #8a3b00; }
.icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: #f3e5d2;
  color: var(--danger);
  font-size: 18px;
  cursor: pointer;
}

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 242, 0.55);
}

.field, .field-grid .field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.field-qty { grid-column: 1 / -1; }

input, select, textarea {
  width: 100%;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  min-height: var(--tap);
}
textarea { min-height: 88px; resize: vertical; font-weight: 500; }
.search { margin-bottom: 10px; }

.stepper {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 8px;
}
.stepper button {
  border: 0;
  border-radius: 12px;
  background: #e8d7bb;
  font-size: 22px;
  cursor: pointer;
}

.card { padding: 12px; margin: 12px 0; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
}
.switch input, .consent input { width: 18px; height: 18px; accent-color: var(--ok); }
.texture-switch { margin-top: 12px; align-items: flex-start; }

.edge-board {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 8px 0 4px;
}
.edge-row {
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  gap: 8px;
  width: 100%;
  align-items: center;
}
.edge-side {
  min-height: 40px;
  border: 1px dashed #cbb898;
  background: #fff;
  border-radius: 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 6px;
}
.edge-side.top, .edge-side.bottom { width: 70%; }
.edge-side.on {
  border-style: solid;
  border-color: var(--accent);
  background: #fbe4cc;
  color: #8a3b00;
}
.edge-side:disabled { opacity: 0.4; }

.part-face {
  height: 108px;
  border-radius: 10px;
  background:
    repeating-linear-gradient(90deg, #c48a4a 0 8px, #a56b32 8px 10px),
    linear-gradient(#d7a66a, #b67a3d);
  color: #fff8ee;
  display: grid;
  place-items: center;
  text-align: center;
  box-shadow: inset 0 0 0 2px rgba(80, 40, 10, 0.25);
}
.part-face span { font-weight: 800; font-size: 16px; }
.part-face small { display: block; opacity: 0.8; }

.chips { display: flex; gap: 8px; overflow: auto; padding-bottom: 10px; }
.chip {
  flex: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.chip.is-on { background: var(--navy); color: #fff; border-color: var(--navy); }

.catalog { display: grid; gap: 8px; }
.catalog-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.catalog-item.is-on { border-color: var(--accent); background: #fff3e4; }
.swatch {
  width: 42px;
  height: 42px;
  border-radius: 10px;
}
.price { font-weight: 800; white-space: nowrap; }

.file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: 12px;
  background: #2c6ea5;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.file-btn input { display: none; }
.file-list { list-style: none; padding: 8px 0 0; margin: 0; }
.file-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.mill-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0;
}
.mill-grid label { display: grid; gap: 4px; font-size: 12px; }
.mill-row {
  display: grid;
  grid-template-columns: 1fr 90px 90px;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 700;
}

.result-hero {
  background: var(--navy);
  color: #f7efe4;
  border-radius: 20px;
  padding: 18px;
}
.result-hero .sum { font-size: 34px; font-weight: 800; margin: 8px 0 0; }
.breakdown { margin-top: 12px; }
.break-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.break-row b { white-space: nowrap; }
.warn {
  background: #fdebd0;
  color: #7a3e00;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 12px;
}

.consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.35;
  margin: 8px 0 16px;
}

.app-footer {
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(239, 230, 214, 0.94);
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
}
.app-footer .btn { flex: 1; }
.btn {
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ok { background: var(--ok); color: #fff; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  z-index: 20;
}

@media (max-width: 860px) {
  .stage {
    grid-template-columns: 1fr;
    padding: 0;
    gap: 0;
  }
  .stage-note { display: none; }
  .phone, .phone-bezel {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
  }
  .status-bar { display: none; }
}
