/* =====================================================================
   BakeCost — стили
   Мобильный экран в приоритете. Крупные кнопки и поля: руки в муке.
   ===================================================================== */

:root {
  color-scheme: light;

  --bg:        #FBF8F4;
  --card:      #FFFFFF;
  --card-soft: #F5F1EA;
  --text:      #1C1917;
  --text-2:    #6F675E;
  --text-3:    #9C938A;
  --line:      #E7E1D8;
  --line-2:    #D6CEC2;

  --accent:    #C2410C;
  --accent-hi: #E2572A;
  --accent-bg: #FDF0E8;
  --ok:        #15803D;
  --ok-bg:     #ECFAF0;
  --bad:       #B91C1C;
  --bad-bg:    #FDEDED;

  --r:   14px;
  --r-s: 10px;

  --nav-h: 66px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body.locked { overflow: hidden; }

h1, h2, h3 { font-weight: 600; margin: 0; }

/* ---------- Каркас ---------- */

.app { display: none; }
.app.on { display: block; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 14px) 16px 10px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; min-height: 56px;
}
.topbar h1 { font-size: 21px; flex: 1; }
.topbar .back {
  border: none; background: none; color: var(--accent);
  font-size: 17px; padding: 8px 4px 8px 0; cursor: pointer;
}

main {
  padding: 16px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
  max-width: 720px; margin: 0 auto;
}

.screen { display: none; }
.screen.on { display: block; }

/* ---------- Нижнее меню ---------- */

nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs button {
  border: none; background: none; cursor: pointer;
  height: var(--nav-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 12px; color: var(--text-3); font-family: inherit;
}
nav.tabs button .ico { font-size: 22px; line-height: 1; }
nav.tabs button.on { color: var(--accent); font-weight: 600; }

/* ---------- Карточки и списки ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 14px;
}
.card.soft { background: var(--card-soft); border-color: transparent; }

.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.list .item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; min-height: 66px;
  border-bottom: 1px solid var(--line);
  cursor: pointer; background: none; border-left: none; border-right: none; border-top: none;
  width: 100%; text-align: left; font: inherit; color: inherit;
}
.list .item:last-child { border-bottom: none; }
.list .item:active { background: var(--card-soft); }
.list .item .grow { flex: 1; min-width: 0; }
.list .item .t { font-size: 17px; }
.list .item .s { font-size: 14px; color: var(--text-2); margin-top: 2px; }
.list .item .price { font-size: 16px; white-space: nowrap; text-align: right; }
.list .item .price small { display: block; font-size: 12px; color: var(--text-3); }
.list .item .chev { color: var(--text-3); font-size: 20px; }

.empty { text-align: center; color: var(--text-2); padding: 34px 16px; font-size: 16px; }

/* ---------- Формы ---------- */

label.lb { display: block; font-size: 15px; color: var(--text-2); margin: 18px 0 7px; }
label.lb:first-child { margin-top: 0; }

input, select, textarea {
  width: 100%; font-family: inherit; font-size: 17px; color: var(--text);
  background: var(--card);
  border: 1px solid var(--line-2); border-radius: var(--r-s);
  padding: 0 14px; height: 52px;
}
textarea { height: auto; min-height: 84px; padding: 12px 14px; resize: vertical; }
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='9'><path d='M1 1l6 6 6-6' stroke='%236F675E' stroke-width='2' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 40px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; }
.field-row > .narrow { flex: 0 0 120px; }
.field-row > .wide { flex: 2; }

.prefix { display: flex; align-items: center; gap: 8px; }
.prefix > span { font-size: 20px; color: var(--text-2); }
.prefix > input { flex: 1; }

.hint { font-size: 13px; color: var(--text-3); margin-top: 7px; line-height: 1.5; }
.err  { font-size: 14px; color: var(--bad); margin-top: 8px; display: none; }
.err.on { display: block; }

/* ---------- Кнопки ---------- */

button.btn {
  width: 100%; height: 54px; font-family: inherit; font-size: 17px; font-weight: 600;
  border-radius: var(--r-s); cursor: pointer;
  border: 1px solid var(--line-2); background: var(--card); color: var(--text);
}
button.btn:active { transform: scale(.985); }
button.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.btn.danger  { background: none; border-color: transparent; color: var(--bad); font-weight: 500; }
button.btn.ghost   { background: none; }
button.btn[disabled] { opacity: .5; cursor: default; }
button.btn + button.btn { margin-top: 10px; }

.seg { display: grid; grid-auto-flow: column; gap: 6px; background: var(--card-soft); padding: 5px; border-radius: var(--r-s); margin-bottom: 16px; }
.seg button {
  border: none; background: none; font-family: inherit; font-size: 15px; color: var(--text-2);
  height: 40px; border-radius: 7px; cursor: pointer;
}
.seg button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

/* ---------- Окно поверх (форма) ---------- */

.sheet-bg {
  position: fixed; inset: 0; z-index: 50; background: rgba(28,25,23,.4);
  display: none; align-items: flex-end; justify-content: center;
}
.sheet-bg.on { display: flex; }
.sheet {
  background: var(--bg); width: 100%; max-width: 720px;
  max-height: 92vh; overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 0 16px calc(env(safe-area-inset-bottom) + 20px);
  -webkit-overflow-scrolling: touch;
}
.sheet-head {
  position: sticky; top: 0; background: var(--bg); z-index: 2;
  padding: 16px 0 12px; margin-bottom: 4px;
  display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line);
}
.sheet-head h2 { font-size: 19px; flex: 1; }
.sheet-head button {
  border: none; background: none; font-family: inherit; font-size: 17px;
  color: var(--accent); cursor: pointer; padding: 6px 2px;
}
.sheet-body { padding: 16px 0 0; }
.sheet-foot { padding-top: 22px; }

/* ---------- Вход ---------- */

.login { display: none; min-height: 100vh; align-items: center; justify-content: center; padding: 24px; }
.login.on { display: flex; }
.login .box { width: 100%; max-width: 380px; }
.login .logo { text-align: center; margin-bottom: 26px; }
.login .logo .big { font-size: 46px; }
.login .logo h1 { font-size: 24px; margin-top: 10px; }
.login .logo p { color: var(--text-2); font-size: 15px; margin: 6px 0 0; }

/* ---------- Счётчик количества ---------- */

.stepper { display: flex; align-items: center; gap: 14px; }
.stepper button {
  width: 62px; height: 62px; flex: none; border-radius: 50%;
  border: 1px solid var(--line-2); background: var(--card);
  font-size: 30px; line-height: 1; color: var(--text); cursor: pointer; font-family: inherit;
}
.stepper button:active { background: var(--card-soft); }
.stepper button[disabled] { opacity: .35; }
.stepper .n { flex: 1; text-align: center; }
.stepper .n b { display: block; font-size: 44px; font-weight: 600; line-height: 1.1; }
.stepper .n span { font-size: 14px; color: var(--text-2); }

input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 34px; padding: 0; border: none; background: none; margin-top: 6px;
}
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--line-2); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25);
  margin-top: -13px;
}
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line-2); }
input[type=range]::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25);
}

/* ---------- Разбивка цены ---------- */

.rows .row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 16px; }
.rows .row span { color: var(--text-2); }
.rows .row b { font-weight: 500; white-space: nowrap; }
.rows .row.total { border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 11px; font-size: 17px; }
.rows .row.total span { color: var(--text); font-weight: 600; }
.rows .row.total b { font-weight: 700; }
.rows .row.big { font-size: 19px; }
.rows .row.big b { font-weight: 700; }
.rows .row.good b { color: var(--ok); }
.rows .row.bad  b { color: var(--bad); }
.rows .gap { height: 12px; }

.rate {
  border-radius: var(--r); padding: 18px; text-align: center; margin-bottom: 14px;
  background: var(--ok-bg); color: var(--ok);
}
.rate.bad { background: var(--bad-bg); color: var(--bad); }
.rate .cap { font-size: 14px; opacity: .9; }
.rate .val { font-size: 38px; font-weight: 700; line-height: 1.15; margin: 4px 0; }

.tag {
  display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 99px;
  background: var(--accent-bg); color: var(--accent); margin-left: 6px; vertical-align: 1px;
}

.part-head {
  font-size: 13px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--accent); margin: 22px 0 8px; font-weight: 600;
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px);
  background: var(--text); color: #fff; padding: 13px 20px; border-radius: 99px;
  font-size: 15px; z-index: 80; max-width: 88vw; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.on { opacity: 1; }

.spin { text-align: center; padding: 48px 0; color: var(--text-3); }

/* ---------- Подпись автора ----------
   Наведение мышкой: линия выезжает слева направо,
   текст светлеет и чуть приподнимается.
   На планшете и телефоне мышки нет, поэтому эффекты
   включаются только там, где наведение вообще бывает —
   иначе на касании подсветка залипала бы.
------------------------------------- */

.madeby {
  text-align: center; font-size: 13px;
  margin: 30px 0 4px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.login .madeby { border-top: none; padding-top: 0; margin-top: 22px; }
.madeby a {
  position: relative; display: inline-block;
  color: var(--accent); text-decoration: none;
  transition: color .2s ease, transform .2s ease, text-shadow .2s ease;
}
.madeby a::after {
  content: ''; position: absolute; left: 0; bottom: -3px;
  width: 100%; height: 1.5px; background: currentColor;
  transform: scaleX(0); transform-origin: left center;
  transition: transform .34s cubic-bezier(.2, .7, .3, 1);
}

@media (hover: hover) {
  .madeby a:hover {
    color: var(--accent-hi);
    transform: translateY(-1.5px);
    text-shadow: 0 2px 12px rgba(194, 65, 12, .30);
  }
  .madeby a:hover::after { transform: scaleX(1); }
}

/* то же самое при выборе с клавиатуры */
.madeby a:focus-visible {
  outline: none; color: var(--accent-hi);
}
.madeby a:focus-visible::after { transform: scaleX(1); }

@media (min-width: 640px) {
  .sheet-bg { align-items: center; }
  .sheet { border-radius: 20px; max-height: 88vh; }
}
