:root {
  --bg: #0b0a09; --card: #17140f; --card2: #1f1b15; --line: rgba(227,184,113,.18); --line2: rgba(255,255,255,.08);
  --text: #f3ede4; --muted: #a39a8c; --gold: #e3b871; --gold2: #f6dba4;
  --grad: linear-gradient(135deg, #f6dba4 0%, #e3b871 45%, #b98a45 100%);
  --font: 'Manrope', system-ui, -apple-system, sans-serif; --font-h: 'Unbounded', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { overflow-x: hidden; margin: 0; background: var(--bg); color: var(--text); font: 500 15px/1.4 var(--font); }
body { padding-bottom: calc(118px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }

/* шапка */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(11,10,9,.95); border-bottom: 1px solid var(--line2); }
.top__brand { padding: 0; border: 0; background: none; display: flex; align-items: center; gap: 9px; font: 600 16px/1 var(--font-h); letter-spacing: -.02em; }

.wrap { padding: 14px 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; max-width: 640px; margin: 0 auto; }

/* карточки */
.card { background: var(--card); border: 1px solid var(--line2); border-radius: 20px; padding: 14px; }
.card h3 { margin: 0 0 10px; font: 600 16px/1.2 var(--font-h); }

/* комната */
.room { padding: 0; overflow: hidden; border-color: var(--line); }
.room__head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; }
.room__name { flex: 1; min-width: 0; background: none; border: 0; border-bottom: 1px dashed transparent; font: 600 16px/1.2 var(--font-h); padding: 4px 0; }
.room__name:focus { outline: none; border-bottom-color: var(--gold); }
.room__sum { font: 600 15px/1 var(--font-h); color: var(--gold2); white-space: nowrap; }
.room__toggle { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line2); background: rgba(255,255,255,.04); transition: transform .25s; }
.room.is-open .room__toggle { transform: rotate(180deg); }
.room__body { display: none; padding: 4px 14px 14px; gap: 12px; }
.room.is-open .room__body { display: grid; grid-template-columns: minmax(0, 1fr); }

/* поля */
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; color: var(--text); font-weight: 700; }
.auto { font-style: normal; font-size: 11px; color: var(--gold); border: 1px solid var(--line); border-radius: 999px; padding: 1px 6px; margin-left: 4px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; align-items: end; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; min-height: 40px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line2); background: rgba(255,255,255,.03); color: var(--muted); font-size: 13.5px; font-weight: 700; }
.seg button.is-on { border-color: var(--gold); color: var(--gold2); background: rgba(227,184,113,.1); }
.seg--mini button { flex: 0 0 auto; min-height: 30px; padding: 4px 10px; border-radius: 999px; font-size: 12px; }

.stepper { display: flex; align-items: center; height: 46px; border: 1px solid var(--line2); border-radius: 12px; background: rgba(255,255,255,.03); overflow: hidden; }
.stepper button { width: 46px; height: 100%; flex: none; border: 0; background: none; color: var(--gold2); font-size: 22px; font-weight: 600; }
.stepper button:active { background: rgba(227,184,113,.12); }
.stepper input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; text-align: center; font: 700 17px/1 var(--font); }
.stepper input:focus { outline: none; background: rgba(227,184,113,.06); }

.note { margin: -4px 0 0; padding: 8px 10px; border-radius: 10px; font-size: 13px; color: var(--gold2); background: rgba(227,184,113,.1); border: 1px solid var(--line); }
.note[hidden] { display: none; }
.hint { color: var(--muted); font-size: 12.5px; }

/* разбивка по ценам (для мастера) */
.break { list-style: none; margin: 4px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line2); display: grid; gap: 5px; font-size: 14px; }
.break li { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); }
.break b { color: var(--text); font-weight: 700; white-space: nowrap; }
.break__total { margin-top: 4px; padding-top: 6px; border-top: 1px dashed var(--line2); color: var(--text) !important; font-weight: 700; }
.break__total b { color: var(--gold2) !important; }
.link-del { justify-self: start; background: none; border: 0; color: #ff9a8a; font-size: 13.5px; font-weight: 700; padding: 4px 0; }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 12px 18px; border-radius: 16px; border: 1px solid transparent; font-weight: 800; font-size: 15px; }
.btn--add { width: 100%; border: 1.5px dashed rgba(227,184,113,.55); background: rgba(227,184,113,.06); color: var(--gold2); }
.btn--ghost { background: rgba(255,255,255,.04); border-color: var(--line2); color: var(--muted); }
.btn--block { width: 100%; }

/* итог внизу */
.totalbar { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(180deg, #221d16, #15120e); border-top: 1.5px solid rgba(227,184,113,.6); box-shadow: 0 -12px 30px rgba(0,0,0,.5); }
.totalbar__lines { display: grid; gap: 2px; font-size: 12.5px; color: var(--muted); }
.totalbar__sum { text-align: right; }
.totalbar__sum small { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.totalbar__sum b { font: 600 clamp(22px, 7vw, 30px)/1.1 var(--font-h); background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; white-space: nowrap; }

.toast { position: fixed; z-index: 40; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 10px 16px; border-radius: 999px; background: #2a241c; border: 1px solid var(--line); font-weight: 700; font-size: 14px; }
.toast[hidden] { display: none; }

/* ---------- план комнаты (рисование) ---------- */
.sketch { position: relative; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #100e0b; }
/* холст почти на весь экран: над ним шапка и строка комнаты, под ним статус и итог */
.sketch__cv { display: block; width: 100%; height: calc(100vh - 300px); height: calc(100svh - 300px); min-height: 340px; touch-action: none; cursor: crosshair; }
.sketch__bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--line2); min-height: 44px; }
.sketch__status { font-size: 12.5px; font-weight: 700; color: var(--gold2); }
.sketch__status.is-warn { color: #ffb3a6; }
.sketch__redraw { flex: none; padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line2); background: rgba(255,255,255,.04); color: var(--muted); font-size: 12.5px; font-weight: 700; }

/* название замера и кнопка «Замеры» */
.title-in { width: 100%; height: 48px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line2); background: var(--card); font-weight: 700; }
.title-in:focus { outline: none; border-color: var(--gold); }
.top__saved { margin-left: auto; margin-right: 8px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: rgba(227,184,113,.08); color: var(--gold2); font-size: 12.5px; font-weight: 800; }

.btn--gold { background: var(--grad); color: #1d1608; box-shadow: 0 10px 30px -12px rgba(227,184,113,.6); }

/* окна */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(6,5,4,.82); }
.modal[hidden] { display: none; }
.modal__card { width: min(420px, 100%); min-width: 0; grid-template-columns: minmax(0, 1fr); max-height: 86vh; overflow: auto; display: grid; gap: 14px; padding: 18px; border-radius: 22px; border: 1.5px solid rgba(227,184,113,.6); background: linear-gradient(180deg, #1f1b15, #13110d); }
.modal__card > b, .modal__head b { font: 600 17px/1.2 var(--font-h); }
.modal__head { display: flex; align-items: center; justify-content: space-between; }
.modal__btns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ask__row { display: flex; align-items: center; gap: 10px; }
.ask__row input { flex: 1; min-width: 0; height: 58px; border-radius: 14px; border: 1px solid var(--gold); background: rgba(0,0,0,.3); text-align: center; font: 600 26px/1 var(--font-h); }
.ask__row input:focus { outline: none; }
.ask__row span { color: var(--muted); font-weight: 700; }
.x { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.04); font-size: 22px; color: var(--gold2); }
.saved-item { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; padding: 12px; border-radius: 16px; border: 1px solid var(--line2); background: rgba(255,255,255,.02); }
.saved-item__info { display: grid; gap: 2px; min-width: 0; }
.saved-item__info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-item__info small { color: var(--muted); font-size: 12px; }
.saved-item__sum { color: var(--gold2); font: 600 14px/1.2 var(--font-h); white-space: nowrap; align-self: center; }
.saved-item__btns { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.saved-item__btns .btn { min-height: 40px; font-size: 13.5px; }
.client { display: grid; gap: 10px; }
.client .title-in { background: rgba(255,255,255,.03); }
.saved-item__tel { color: var(--gold2); font-weight: 700; font-size: 14px; text-decoration: none; }
.stepper.is-locked { opacity: .75; }
.stepper.is-locked input { color: var(--gold2); }
.auto--btn { cursor: pointer; background: rgba(227,184,113,.08); font: inherit; font-size: 11px; font-weight: 700; }
.ask__label { margin-bottom: -6px; color: var(--muted); font-weight: 700; font-size: 13px; }
.seg--col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg--col button:first-child { grid-column: 1 / -1; }

/* профиль — кнопка с всплывающим списком */
.picker { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 46px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--gold); background: rgba(227,184,113,.1); color: var(--gold2); font-weight: 800; font-size: 14.5px; text-align: left; }
.picker i { font-style: normal; color: var(--gold); }
.modal--sheet { align-items: end; padding: 0; }
.modal--sheet .modal__card { width: 100%; max-width: 640px; border-radius: 22px 22px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
.pick__list { display: grid; gap: 8px; }
.pick__opt { min-height: 54px; padding: 12px 16px; border-radius: 14px; border: 1px solid var(--line2); background: rgba(255,255,255,.03); color: var(--text); font-weight: 800; font-size: 16px; text-align: left; }
.pick__opt.is-on { border-color: var(--gold); color: var(--gold2); background: rgba(227,184,113,.12); }

/* свои светильники */
.check { display: flex; align-items: center; gap: 10px; margin-top: -4px; font-weight: 700; font-size: 14px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--gold); }

/* карнизы, LED, треки */
.item { display: grid; gap: 8px; padding: 10px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.02); }
.item__head { display: flex; align-items: center; justify-content: space-between; }
.item__head b { font-size: 14px; }
.x--sm { width: 30px; height: 30px; font-size: 18px; line-height: 1; }
.items__add { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.items__add .btn { min-height: 44px; padding: 8px; font-size: 14px; }

/* разбивка профиля по метрам под кнопкой профиля */
.psplit { display: grid; gap: 6px; }
.psplit:empty { display: none; }
.psplit__row { display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; border-radius: 12px; border: 1px solid var(--line2); background: rgba(255,255,255,.03); font-weight: 700; font-size: 14px; }
.psplit__row b { color: var(--gold2); }
.psplit__row.is-float { border-color: rgba(255,255,255,.7); }
.psplit__row.is-float b { color: #fff; }
.modal__card .hint { margin: -6px 0 0; font-size: 14px; }

/* копия в файл */
.backup { display: grid; gap: 8px; margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line2); }
.backup b { font-size: 15px; }
.backup .hint { margin: 0 0 4px; line-height: 1.4; }
.backup .btn { min-height: 46px; }
#savedList { display: grid; gap: 10px; }
.created { padding: 0 4px; color: var(--muted); font-size: 13px; font-weight: 700; }
