:root {
  --bg: #f2f3f1;
  --surface: #ffffff;
  --surface-2: #e9ebe7;
  --text: #101210;
  --muted: #6c716a;
  --line: #dfe2dc;

  /* Два акцента: чёрный — действия, салатовый — состояние и выделение */
  --accent: #101210;
  --on-accent: #ffffff;
  --lime: #b6f000;
  --lime-strong: #4f7a00;
  --lime-soft: #edfbc9;
  --on-lime: #101210;

  /* Инверсия — для «Выполнен» и других сильных меток */
  --invert-bg: #101210;
  --invert-fg: #ffffff;

  --danger: #101210;
  --danger-soft: #e9ebe7;
  --ok: var(--lime-strong);
  --ok-soft: var(--lime-soft);
  --work: var(--lime-strong);
  --work-soft: var(--lime-soft);
  --queue: #6c716a;
  --queue-soft: #e9ebe7;

  /* «В печати» — тёмная заливка акцентом, чтобы не сливаться со светлым «Надо отправить» */
  --print-bg: #4f7a00;
  --print-fg: #ffffff;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 18, 16, .05), 0 8px 24px -18px rgba(16, 18, 16, .4);
  --tap: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e100d;
    --surface: #181a16;
    --surface-2: #23261f;
    --text: #eef0ec;
    --muted: #969b91;
    --line: #2b2f27;

    --accent: #b6f000;
    --on-accent: #101210;
    --lime: #b6f000;
    --lime-strong: #b6f000;
    --lime-soft: #26330b;

    --invert-bg: #eef0ec;
    --invert-fg: #101210;

    --danger: #eef0ec;
    --danger-soft: #23261f;
    --queue: #969b91;
    --queue-soft: #23261f;

    --print-bg: #6f9c14;
    --print-fg: #0e100d;

    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -18px rgba(0, 0, 0, .9);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }

a { color: inherit; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--line); }
a:hover { text-decoration-color: var(--lime-strong); }

.app { min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- Шапка ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}

.topbar h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -.01em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .sub {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  min-width: var(--tap);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

main {
  flex: 1;
  padding: 14px 14px calc(96px + var(--safe-b));
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- Нижняя навигация (мобильная) ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 6px 8px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--line);
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
  text-decoration: none;
}

.tabbar a.on { color: var(--text); background: var(--lime-soft); }
.tabbar svg { width: 22px; height: 22px; }

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(72px + var(--safe-b));
  z-index: 31;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 18px;
  background: var(--lime);
  color: var(--on-lime);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 20px -6px color-mix(in srgb, var(--lime) 70%, transparent);
  cursor: pointer;
}

.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(.96); }

/* ---------- Блоки ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}

.card.pad0 { padding: 0; overflow: hidden; }
.scroll-x { overflow-x: auto; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 18px 2px 8px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.flex { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Чипы и статусы ---------- */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 14px 10px;
  margin: 0 -14px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip:hover { border-color: var(--text); color: var(--text); }

.chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.chip .n { font-size: 12px; opacity: .7; font-variant-numeric: tabular-nums; }

.st {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.st::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.st-queued { background: var(--surface-2); color: var(--muted); }
.st-need_model { background: transparent; color: var(--text); border-color: var(--text); border-style: dashed; }
.st-in_work { background: var(--lime); color: var(--on-lime); }
.st-printing { background: var(--print-bg); color: var(--print-fg); }
.st-to_ship { background: var(--lime-soft); color: var(--lime-strong); border-color: var(--lime-strong); }
.st-done { background: var(--invert-bg); color: var(--invert-fg); }
.st-canceled { background: transparent; color: var(--muted); border-color: var(--line); }

/* ---------- Карточка заказа ---------- */
.order {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 14px;
  margin-bottom: 10px;
  color: inherit;
  cursor: pointer;
}

.order:active { background: var(--surface-2); }
.order .num { font-size: 12.5px; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; }
.order .name { font-size: 16.5px; font-weight: 620; letter-spacing: -.01em; margin-top: 2px; }
.order .items { font-size: 13.5px; color: var(--muted); margin-top: 3px; }
.order .money { display: flex; align-items: baseline; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.order .total { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }

.due-badge {
  font-size: 12.5px;
  font-weight: 650;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  white-space: nowrap;
}

.due-badge.paid { background: var(--lime); color: var(--on-lime); }

.bar {
  height: 4px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 9px;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--lime);
  transition: width .3s ease;
}

.bar i.full { background: var(--lime); }

/* ---------- Таблицы (десктоп) ---------- */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 900px;
}

.tbl th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 13px 14px;
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.tbl td { padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover { background: var(--lime-soft); }
.tbl .r { text-align: right; }
/* Числовые колонки узкие — освободившаяся ширина уходит составу заказа. */
.tbl th.r, .tbl td.r { padding-left: 9px; padding-right: 9px; }
.tbl .r.mono { font-variant-numeric: tabular-nums; }
.tbl .cut { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

/* Номер и состав в одной ячейке: составу отдана вся ширина колонки, до трёх строк. */
.tbl .cell-order { width: 40%; min-width: 320px; vertical-align: top; }
.tbl .cell-client { white-space: nowrap; }

.tbl .cell-order .items {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  overflow: hidden;
  line-height: 1.35;
  color: var(--text);
  margin-top: 2px;
}

/* ---------- Строки-списки ---------- */
.list { display: flex; flex-direction: column; }

.list .item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: none;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  width: 100%;
  text-align: left;
  color: inherit;
  cursor: pointer;
  min-height: var(--tap);
}

.list .item:last-child { border-bottom: 0; }
.list .item:active { background: var(--surface-2); }

.avatar {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 12px;
  background: var(--lime-soft);
  color: var(--lime-strong);
  display: grid;
  place-items: center;
  font-weight: 650;
  font-size: 15px;
}

/* ---------- Суммы ---------- */
.sums { display: grid; gap: 9px; }
.sums .line { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.sums .line b { font-variant-numeric: tabular-nums; font-weight: 600; }
.sums .total { border-top: 1px dashed var(--line); padding-top: 9px; font-size: 17px; }
.sums .total b { font-weight: 700; }
.sums .due b { color: var(--text); font-weight: 700; }
.sums .due.zero b { color: var(--lime-strong); }

/* ---------- Формы ---------- */
.field { margin-bottom: 12px; }

.field > label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 5px 2px;
}

.input, select.input, textarea.input {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  appearance: none;
  outline: none;
}

.input:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--lime) 45%, transparent);
}

textarea.input { min-height: 84px; resize: vertical; line-height: 1.4; }

select.input {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  padding-right: 36px;
}

.input.money { font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 600; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: var(--tap);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { border-color: var(--text); }
.btn:active { transform: scale(.985); }
.btn svg { width: 18px; height: 18px; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 86%, var(--lime)); }
.btn.lime { background: var(--lime); border-color: var(--lime); color: var(--on-lime); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--text); border-color: var(--text); background: transparent; }
.btn.danger:hover { background: var(--invert-bg); color: var(--invert-fg); }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
/* Нечётное число статусов: последний не должен висеть половинкой. */
.seg button:last-child:nth-child(odd) { grid-column: 1 / -1; }

.seg button {
  min-height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.seg button:hover { border-color: var(--text); color: var(--text); }
.seg button.on { border-color: transparent; color: var(--on-accent); background: var(--accent); }
.seg button.on.st-queued { background: var(--surface-2); color: var(--text); border-color: var(--text); }
.seg button.on.st-need_model { background: var(--surface); color: var(--text); border-color: var(--text); border-style: dashed; }
.seg button.on.st-in_work { background: var(--lime); color: var(--on-lime); }
.seg button.on.st-printing { background: var(--print-bg); color: var(--print-fg); }
.seg button.on.st-to_ship { background: var(--lime-soft); color: var(--lime-strong); border-color: var(--lime-strong); }
.seg button.on.st-done { background: var(--invert-bg); color: var(--invert-fg); }
.seg button.on.st-canceled { background: var(--surface-2); color: var(--muted); border-color: var(--line); }

/* ---------- Позиции заказа ---------- */
.item-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.item-row .input { min-height: 42px; }
.item-row .qty { width: 78px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- Файлы ---------- */
.photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.photos figure {
  position: relative;
  margin: 0;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}

.photos a { display: block; width: 100%; height: 100%; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }

.photos .x {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: rgba(16, 18, 16, .6);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.file-row { display: flex; align-items: center; gap: 11px; padding: 10px 0; }
.file-row + .file-row { border-top: 1px solid var(--line); }
.file-row a { display: flex; align-items: baseline; gap: 8px; }

.file-thumb {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
  background: var(--surface-2);
  cursor: zoom-in;
}

.drop {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.drop:hover, .drop.hot { border-color: var(--lime-strong); color: var(--text); background: var(--lime-soft); }

.only-drag { display: none; }

@media (hover: hover) and (pointer: fine) {
  .only-drag { display: inline; }
}

.card[data-drop].hot {
  border-color: var(--lime-strong);
  background: var(--lime-soft);
  outline: 2px dashed var(--lime-strong);
  outline-offset: -6px;
}

.progress-line { height: 3px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress-line i { display: block; height: 100%; background: var(--lime); width: 0; transition: width .2s; }

/* ---------- Экран входа ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login .box { width: 100%; max-width: 320px; text-align: center; }
.login-logo { border-radius: 16px; margin-bottom: 14px; }
.login h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.02em; }

@media (min-width: 760px) {
  .login .box {
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 34px 32px 32px;
  }
}
.login p { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

.dots { display: flex; justify-content: center; gap: 12px; margin-bottom: 26px; }

.dots i {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: transparent;
  transition: all .15s;
}

.dots i.on { background: var(--lime); border-color: var(--lime); transform: scale(1.08); }
.dots.err i { border-color: var(--text); background: transparent; animation: shake .35s; }

@keyframes shake {
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.keys button {
  min-height: 62px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 23px;
  font-weight: 550;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.keys button:hover { border-color: var(--text); }
.keys button:active { background: var(--lime-soft); border-color: var(--lime-strong); }
.keys button.flat { background: transparent; border-color: transparent; font-size: 15px; font-weight: 600; }

/* ---------- Шторка ---------- */
.sheet-bg {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(16, 18, 16, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade .18s;
}

@keyframes fade { from { opacity: 0; } }

.sheet {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(20px + var(--safe-b));
  max-height: 92dvh;
  overflow-y: auto;
  animation: up .22s cubic-bezier(.2, .8, .3, 1);
}

@keyframes up { from { transform: translateY(24px); opacity: .6; } }

.sheet .grab { width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: 6px auto 14px; }
.sheet h2 { margin: 0 0 14px; font-size: 18px; letter-spacing: -.01em; }

@media (min-width: 640px) {
  .sheet-bg { align-items: center; }
  .sheet { border-radius: 18px; margin: 20px; padding: 20px 22px; }
  .sheet .grab { display: none; }
}

/* ---------- Тост ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 60;
  background: var(--invert-bg);
  color: var(--invert-fg);
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 550;
  max-width: min(92vw, 420px);
  box-shadow: 0 10px 30px -10px rgba(16, 18, 16, .5);
  animation: up .2s;
}

.toast.err { border-left: 4px solid var(--lime); }

/* ---------- Пусто / загрузка ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; opacity: .4; margin-bottom: 10px; }
.empty p { margin: 0 0 16px; font-size: 15px; }

.skeleton {
  height: 92px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 300% 100%;
  animation: sk 1.2s infinite;
  margin-bottom: 10px;
}

@keyframes sk { to { background-position: -150% 0; } }

/* ---------- Галерея ---------- */
html.gal-open, html.gal-open body { overflow: hidden; }

.gal {
  position: fixed;
  inset: 0;
  z-index: 70;
  overflow: hidden;
  background: rgba(16, 18, 16, .95);
  animation: fade .15s;
  user-select: none;
  -webkit-user-select: none;
}

.gal-track { display: flex; height: 100%; touch-action: none; will-change: transform; }
.gal-track.slide { transition: transform .28s cubic-bezier(.22, .61, .36, 1); }

.gal-slide {
  flex: 0 0 100%;
  height: 100%;
  /* Именно flex, а не grid: auto-строка грида растягивается под натуральную высоту картинки,
     и max-height:100% начинает считаться от неё — вертикальные фото уезжают за экран. */
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: calc(56px + env(safe-area-inset-top, 0px)) 12px calc(48px + env(safe-area-inset-bottom, 0px));
  /* Пока грузится оригинал, показываем превью строго в тех же границах, что и картинку */
  background: no-repeat center / contain content-box;
}

.gal-slide img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  min-width: 0;
  object-fit: contain;
  -webkit-user-drag: none;
}

.gal-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 22px;
  color: #fff;
  background: linear-gradient(rgba(16, 18, 16, .5), transparent);
  pointer-events: none;
}

.gal-count { font-size: 14px; font-variant-numeric: tabular-nums; opacity: .85; }
.gal-tools { display: flex; gap: 8px; pointer-events: auto; }

.gal-btn, .gal-nav {
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.gal-btn { width: 40px; height: 40px; }
.gal-btn:hover, .gal-nav:hover { background: rgba(255, 255, 255, .28); }

.gal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
}

.gal-nav.prev { left: 12px; }
.gal-nav.next { right: 12px; }
.gal-nav[hidden] { display: none; }

.gal-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 22px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  color: rgba(255, 255, 255, .82);
  font-size: 13px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: linear-gradient(transparent, rgba(16, 18, 16, .5));
  pointer-events: none;
}

@media (max-width: 759px) {
  .gal-nav { display: none; }
}

/* ---------- Планшет ---------- */
@media (min-width: 760px) and (max-width: 1099px) {
  main { padding-bottom: 40px; }
  .tabbar {
    position: sticky;
    top: 56px;
    bottom: auto;
    max-width: 780px;
    margin: 0 auto;
    border-top: 0;
    border-bottom: 1px solid var(--line);
    padding-bottom: 6px;
  }
  .tabbar a { flex-direction: row; gap: 7px; font-size: 14px; }
  .fab { bottom: 24px; right: 24px; }
}

/* ---------- Десктоп ---------- */
@media (min-width: 1100px) {
  .layout { display: flex; min-height: 100dvh; }

  .side {
    position: sticky;
    top: 0;
    height: 100dvh;
    width: 244px;
    min-width: 244px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 18px 14px;
    background: var(--surface);
    border-right: 1px solid var(--line);
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -.02em;
  }

  .brand img { border-radius: 8px; }

  .side-nav { display: flex; flex-direction: column; gap: 3px; }

  .side-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 14.5px;
    font-weight: 600;
    text-decoration: none;
  }

  .side-nav a:hover { background: var(--surface-2); color: var(--text); }
  .side-nav a.on { background: var(--accent); color: var(--on-accent); }
  .side-nav svg { width: 19px; height: 19px; }

  .side-new { width: 100%; }

  .side-stats {
    margin-top: auto;
    padding: 14px;
    border-radius: var(--radius);
    background: var(--surface-2);
    font-size: 13px;
    color: var(--muted);
    display: grid;
    gap: 7px;
  }

  .side-stats hr { border: 0; border-top: 1px solid var(--line); margin: 3px 0; }
  .side-stats b { display: block; color: var(--text); font-size: 16px; font-weight: 650; margin-top: 1px; }
  .side-stats .row-between b { display: inline; font-size: 14px; }

  .work { flex: 1; min-width: 0; display: flex; flex-direction: column; }

  .topbar { padding: 12px 26px; min-height: 66px; }
  .topbar h1 { font-size: 21px; flex: 0 0 auto; }
  .topbar .sub { font-size: 12.5px; }

  .topbar-search { flex: 1; display: flex; justify-content: center; }
  .topbar-search .input { max-width: 460px; min-height: 40px; }

  main { max-width: 1240px; padding: 22px 26px 60px; }

  .chips { padding: 0 0 16px; margin: 0; }

  .cols { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 24px; align-items: start; }
  .col > .section-title:first-child { margin-top: 0; }
  .col > .seg:first-child { margin-bottom: 18px !important; }

  .row-desktop { flex-direction: row; }
  .row-desktop .btn { width: auto; flex: 1; }

  .photos { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }

  .empty { padding: 70px 20px; }
}

/* Тонкие полосы прокрутки на десктопе */
@media (hover: hover) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 3px solid var(--bg); }
  ::-webkit-scrollbar-thumb:hover { background: var(--muted); }
  ::-webkit-scrollbar-track { background: transparent; }
}
