/* ============================================================
   Світлосхеми · UI 2.0 — «Преміум студія»
   Підключається після основного <style>, щоб зміни були оборотними.
   ============================================================ */

:root {
  --bg: #0b0c0f;
  --p1: #14161b;
  --p2: #1b1e25;
  --p3: #252932;
  --ln: rgba(255, 255, 255, .075);
  --ln2: rgba(255, 255, 255, .14);
  --tx: #f3f4f7;
  --mu: #9aa1b1;
  --ac: #ffb547;
  --ac2: #7cc4ff;
  --dn: #ff7373;
  --ac-soft: rgba(255, 181, 71, .14);
  --amber-1: #ffd08a;
  --amber-2: #ff9f1c;
  --r: 18px;
  --sh: 0 12px 34px rgba(0, 0, 0, .42);
}

html[data-theme="light"] {
  --bg: #f3f4f7;
  --p1: #ffffff;
  --p2: #eef0f4;
  --p3: #e0e4eb;
  --ln: rgba(18, 22, 30, .09);
  --ln2: rgba(18, 22, 30, .17);
  --tx: #15181e;
  --mu: #6d7584;
  --ac: #c77700;
  --ac2: #2f7bc9;
  --dn: #d64545;
  --ac-soft: rgba(199, 119, 0, .12);
  --amber-1: #e8a13c;
  --amber-2: #b86900;
  --sh: 0 12px 30px rgba(20, 26, 38, .14);
}

html, body { background: var(--bg); }
body {
  background-image: radial-gradient(1100px 560px at 50% -12%, rgba(255, 181, 71, .07), transparent 62%);
  background-attachment: fixed;
}
html[data-theme="light"] body {
  background-image: none;
}

:focus-visible { outline: 2px solid var(--ac); outline-offset: 2px; }

/* ---------- header ---------- */
.bar {
  position: relative;
  min-height: 56px;
  padding: calc(var(--sat) + 8px) clamp(12px, 3.6vw, 18px) 8px;
  gap: clamp(6px, 1.8vw, 9px);
  background: var(--p1);
  border-bottom: 1px solid var(--ln);
}
/* Status-bar strip follows the active theme (the meta tag switches the iOS icons) */
.bar::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: var(--sat);
  background: var(--p1);
  pointer-events: none;
}
.bar > * { position: relative; z-index: 1; }
.lib-h {
  min-width: 0; flex-direction: column; align-items: flex-start; justify-content: center;
  gap: 1px; overflow: hidden; line-height: 1.15;
}
.lib-h h1 {
  font-size: clamp(17px, 4.6vw, 19px);
  font-weight: 750;
  letter-spacing: -.025em;
  white-space: nowrap;
}
.lib-h h1::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber-1), var(--amber-2));
  vertical-align: 1px;
}
#libCount { font-size: 11px; letter-spacing: .01em; white-space: nowrap; }
.bar .btn-ac { min-height: 44px; padding: 0 14px; display: inline-flex; align-items: center; }
#ttl { font-size: clamp(15px, 4.4vw, 17px); }

@media (max-width: 360px) {
  #libCount { display: none; }
  .bar { gap: 6px; }
}

/* ---------- buttons ---------- */
.btn, .btn-ac, .chip, .ib, .fab, .cat-it, .card, .tabs button, .as-i {
  transition: transform .13s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease, color .18s ease;
}
.btn:active, .btn-ac:active, .chip:active, .ib:active, .fab:active,
.cat-it:active, .card:active, .tabs button:active, .as-i:active {
  transform: scale(.96);
  opacity: 1;
}
.btn { border-radius: 12px; background: var(--p3); }
.btn.ac, .btn-ac {
  border-radius: 13px;
  background: linear-gradient(135deg, var(--amber-1), var(--amber-2));
  color: #241705;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
  font-weight: 750;
}
html[data-theme="light"] .btn.ac, html[data-theme="light"] .btn-ac { color: #241705; }
.btn.dn { color: var(--dn); }
.ib {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--p2);
  border: 1px solid var(--ln);
  display: grid; place-items: center;
  font-size: 22px;
  line-height: 1;
}
html[data-theme="light"] .ib { background: var(--p1); border-color: var(--ln2); }
.lib-icon { font-size: 19px; }
.lib-icon.on { color: var(--ac); background: var(--ac-soft); border-color: var(--ac); }
@media (max-width: 360px) { .lib-icon { width: 40px; height: 40px; } }
.fab {
  width: 44px; height: 44px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--p2) 94%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--ln2);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
}

/* ---------- search & chips ---------- */
.lib-tools { padding: 12px 14px 4px; background: transparent; }
.lib-search { display: flex; align-items: center; gap: 8px; }
.lib-search #q { flex: 1; min-width: 0; }
.lib-search .ib { width: 44px; height: 44px; flex: none; }
#q {
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--p2);
  border: 1px solid var(--ln);
}
#q::placeholder { color: var(--mu); }
#q:focus {
  border-color: var(--ac);
  box-shadow: 0 0 0 3px var(--ac-soft);
  outline: none;
}
.chip {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--p2);
  border: 1px solid var(--ln);
}
.chip.on {
  background: linear-gradient(135deg, var(--amber-1), var(--amber-2));
  border-color: transparent;
  color: #241705;
}
html[data-theme="light"] .chip.on { color: #241705; }
.chip { min-height: 44px; display: inline-flex; align-items: center; }

/* ---------- library cards ---------- */
.grid { gap: 14px; padding: 14px 14px calc(var(--sab) + 28px); }
.card {
  position: relative;
  border-radius: 20px;
  border: 1px solid var(--ln);
  background: var(--p1);
  box-shadow: var(--sh);
}
.card:hover { transform: translateY(-2px); border-color: var(--ln2); }
.th {
  background: linear-gradient(160deg, #191c22, #0e1014);
  border-radius: 19px 19px 0 0;
  border-bottom: 1px solid var(--ln);
}
html[data-theme="light"] .th { background: linear-gradient(160deg, #22262e, #101216); }
.inset { border-radius: 10px; box-shadow: 0 4px 14px rgba(0, 0, 0, .45); }
.chips:not(.wrap) { -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 36px), transparent 100%); mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 36px), transparent 100%); }
.ct {
  padding: 9px 12px 0; font-size: 14.5px; font-weight: 650; letter-spacing: -.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; white-space: normal; line-height: 1.25; min-height: 2.5em;
}
.cs { padding: 2px 12px 12px; font-size: 11.5px; }
.empty { padding: 54px 20px; }
.empty b { font-size: 20px; letter-spacing: -.025em; }
.empty .btn-ac { padding: 12px 18px; border-radius: 14px; }

/* ---------- editor canvas ---------- */
#stage { background: #0e1014 !important; }
#cv { background: radial-gradient(circle at 50% 45%, #151820 0%, #0e1014 70%); }
#undoBtn:disabled, #redoBtn:disabled { opacity: .35; pointer-events: none; }
#scale { background: rgba(13, 14, 17, .7); border-radius: 8px; padding: 3px 7px; }
#selChip {
  border-radius: 999px;
  background: color-mix(in srgb, var(--p2) 96%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--ln2);
  box-shadow: var(--sh);
  padding: 7px 7px 7px 15px;
}
#selChip button { border-radius: 999px; background: linear-gradient(135deg, var(--amber-1), var(--amber-2)); color: #241705; }
.hint {
  border-radius: 18px;
  background: rgba(20, 22, 27, .96);
  border: 1px solid var(--ln2);
  box-shadow: var(--sh);
  animation: pop .2s ease both;
}
html[data-theme="light"] .hint { background: rgba(255, 255, 255, .97); }

/* ---------- bottom sheet & tabs ---------- */
#sheet {
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--ln2);
  background: color-mix(in srgb, var(--p1) 97%, transparent);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  box-shadow: 0 -16px 42px rgba(0, 0, 0, .38);
  transition: height .22s cubic-bezier(.22, .8, .25, 1);
}
html[data-theme="light"] #sheet { box-shadow: 0 -12px 34px rgba(20, 26, 38, .12); }
.grab { width: 46px; height: 5px; background: var(--ln2); border-radius: 4px; }
.fh {
  font-size: 11px;
  letter-spacing: .1em;
  font-weight: 750;
  color: var(--mu);
}
.f { border-bottom: 1px solid var(--ln); }
.f select, .f input[type=text], .f textarea, .full, .fld input, .addtag input {
  border-radius: 12px;
  border: 1px solid var(--ln);
  background: var(--p2);
}
.f select:focus, .f input:focus, .f textarea:focus, .full:focus {
  border-color: var(--ac);
  box-shadow: 0 0 0 3px var(--ac-soft);
  outline: none;
}
input[type=range]::-webkit-slider-thumb {
  width: 26px; height: 26px;
  background: linear-gradient(135deg, var(--amber-1), var(--amber-2));
  border: 3px solid var(--p1);
  box-shadow: 0 0 0 1px var(--ac), 0 3px 10px rgba(0, 0, 0, .4);
}
.tabs {
  min-height: 64px;
  padding-bottom: calc(var(--sab) + 5px);
  background: color-mix(in srgb, var(--p1) 94%, transparent);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.tabs button {
  margin: 0 4px;
  border-radius: 13px;
  padding: 9px 0 7px;
  color: var(--mu);
}
.tabs button.on {
  color: var(--ac);
  background: var(--ac-soft);
}
.tabs svg { width: 24px; height: 24px; }

/* ---------- overlays ---------- */
.ov {
  background: rgba(4, 5, 7, .66);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}
.as {
  border-radius: 24px 24px 0 0;
  background: color-mix(in srgb, var(--p1) 97%, transparent);
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
  border: 1px solid var(--ln2);
  border-bottom: 0;
  box-shadow: 0 -18px 60px rgba(0, 0, 0, .55);
  padding: 10px 12px calc(var(--sab) + 14px);
  animation: sheetIn .24s cubic-bezier(.2, .8, .25, 1) both;
}
.as-t { font-weight: 700; color: var(--tx); font-size: 14px; }
.as-i { border-radius: 15px; padding: 14px 16px; background: var(--p2); border: 1px solid var(--ln); }
.as-i:active { background: var(--p3); }
.as-c { background: transparent; text-align: center; color: var(--mu); border-color: transparent; }
.imgov { background: rgba(4, 5, 7, .95); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.imgov img { border-radius: 14px; box-shadow: var(--sh); }
.imgov .acts .btn { flex: 1; padding: 10px 8px; font-size: 13px; }
.imgov .ph-info { color: var(--mu); font-size: 12px; }

/* ---------- toast ---------- */
#toast {
  border-radius: 999px;
  background: rgba(24, 27, 33, .96);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--ln2);
  box-shadow: var(--sh);
  padding: 11px 18px;
}
html[data-theme="light"] #toast { background: rgba(255, 255, 255, .97); }
#toast.on { animation: toastIn .22s ease both; }

/* ---------- micro animations ---------- */
@keyframes pop { from { opacity: 0; transform: translate(-50%, -47%) scale(.96); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes sheetIn { from { transform: translateY(18px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastIn { from { transform: translate(-50%, 8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ---------- library filters & favourites ---------- */
.lib-filters { display: flex; align-items: center; gap: 8px; padding: 2px 0 6px; }
.lib-filters .chip { font-size: 12.5px; padding: 7px 12px; }
.lib-filters .chip.on { background: linear-gradient(135deg, var(--amber-1), var(--amber-2)); color: #241705; border-color: transparent; }
html[data-theme="light"] .lib-filters .chip.on { color: #241705; }
#sortSel {
  margin-left: auto;
  border-radius: 999px;
  border: 1px solid var(--ln);
  background: var(--p2);
  color: var(--mu);
  font-size: 12.5px;
  padding: 7px 10px;
  max-width: 46%;
}
.card .fav {
  position: absolute;
  top: 8px; right: 8px;
  z-index: 2;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(10, 11, 14, .62);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: rgba(255, 255, 255, .6);
  font-size: 16px;
  line-height: 1;
}
.card .fav.on { color: var(--amber-1); background: rgba(10, 11, 14, .82); }
.card .th { position: relative; }

/* ---------- collapsible details ---------- */
details.fold { border-top: 1px solid var(--ln); margin-top: 12px; padding-top: 8px; }
details.fold > summary {
  list-style: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .06em;
  color: var(--mu);
  padding: 6px 0;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: " ›"; float: right; transition: transform .18s ease; }
details.fold[open] > summary::after { transform: rotate(90deg); }
details.fold .desc { white-space: pre-wrap; word-break: break-word; }

/* ---------- draggable sheet ---------- */
#sheet .grab {
  position: relative;
  width: 100%; height: 44px;
  background: transparent;
  touch-action: none;
  cursor: ns-resize;
}
#sheet .grab::after {
  content: "";
  position: absolute; left: 50%; top: 50%;
  width: 46px; height: 5px;
  transform: translate(-50%, -50%);
  background: var(--ln2);
  border-radius: 4px;
}
#sheetBody { height: calc(100% - 44px); }
#sheetBody::-webkit-scrollbar { width: 0; }

/* ---------- onboarding & checklist ---------- */
.onb {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--sat) + 20px) 20px calc(var(--sab) + 20px);
  background: rgba(4, 5, 7, .84);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  animation: fadeIn .2s ease both;
}
.onb-card {
  width: 100%; max-width: 380px;
  border-radius: 26px;
  padding: 26px 22px calc(22px + var(--sab));
  background: var(--p1);
  border: 1px solid var(--ln2);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
  text-align: center;
  animation: sheetIn .26s cubic-bezier(.2, .8, .25, 1) both;
}
.onb-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.onb-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--ln2); }
.onb-dots i.on { width: 18px; border-radius: 999px; background: var(--ac); }
.onb-ic { font-size: 46px; line-height: 1; margin-bottom: 12px; }
.onb-card h2 { margin: 0 0 8px; font-size: 21px; letter-spacing: -.02em; }
.onb-card p { margin: 0 0 20px; color: var(--mu); font-size: 14px; line-height: 1.5; min-height: 64px; }
.onb-actions { display: flex; gap: 8px; }
.onb-actions button { flex: 1; min-height: 44px; border-radius: 14px; }
.check-pre {
  max-width: 560px;
  max-height: 68vh;
  overflow: auto;
  -webkit-user-select: text;
  user-select: text;
  margin: 0;
  padding: 16px;
  border-radius: 16px;
  background: var(--p1);
  border: 1px solid var(--ln2);
  color: var(--tx);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- result mode: keep the interactive plan visible by default ---------- */
/* план займає третину, прев’ю — решту висоти; меню знизу завжди лишається на екрані */
#ed.result-mode #stage { flex: 0 0 32%; min-height: 150px; }
#ed.result-mode #sheet { flex: 1 1 0; min-height: 0; height: auto !important; }
#ed.result-mode.plan-hidden #stage { display: none; }
#ed.result-mode.plan-hidden #sheet {
  flex: 1 1 auto; height: auto !important; min-height: 0;
  border-radius: 0; border-top: 0; box-shadow: none;
}
#ed.result-mode #sheet .grab { display: none; }
#ed.result-mode #sheetBody { height: 100%; padding-bottom: calc(var(--sab) + 16px); }
.plan-toggle { display: none; }
#ed.result-mode .plan-toggle {
  display: block; position: absolute; left: 10px; top: 10px; z-index: 3;
  min-height: 36px; padding: 0 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--p1) 88%, transparent);
  border: 1px solid var(--ln2); color: var(--tx);
  font-size: 12.5px; font-weight: 700;
}
.pv { display: flex; flex-direction: column; gap: 10px; }
.pv-img {
  align-self: center; width: max-content; max-width: 100%;
  position: relative; display: grid; place-items: center;
  max-height: 40vh; cursor: zoom-in;
  border-radius: 12px; overflow: hidden; background: #000;
  border: 1px solid var(--ln);
}
#pvCv { display: block; max-width: 100%; }
.pv-zoom {
  position: absolute; right: 10px; bottom: 10px;
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(8, 9, 12, .62); color: #fff; font-size: 17px;
  pointer-events: none;
}
.pv-ctl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-items: end; }
.pv-camrow { grid-column: 1/-1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.pv-camrow button {
  min-height: 54px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; padding: 7px 4px;
  border-radius: 12px; background: var(--p2); border: 1px solid var(--ln);
}
.pv-camrow button:active { transform: scale(.97); }
.pv-camrow small { font-size: 10px; color: var(--mu); text-transform: uppercase; letter-spacing: .06em; }
.pv-camrow b { font-size: 14px; font-variant-numeric: tabular-nums; }
.pv-mode { grid-column: 1/-1; }
.pv-mode button { min-height: 44px; }
.pv-ev { grid-column: 1/-1; }
.pv-ev > span { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--mu); }
.pv-ev input { width: 100%; }
.pv-row { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pv-row label { font-size: 10.5px; color: var(--mu); text-transform: uppercase; letter-spacing: .06em; }
.pv-row select {
  width: 100%; min-height: 44px; padding: 8px 10px;
  border-radius: 12px; background: var(--p2); border: 1px solid var(--ln);
  color: var(--tx); font-size: 14px;
}
.pv-zebra { grid-column: 1/-1; display: flex; align-items: center; justify-content: space-between; grid-template-columns: 1fr auto; padding: 4px 0; }
.pv-actions { grid-column: 1/-1; display: flex; gap: 8px; }
.pv-actions .btn { flex: 1; min-height: 44px; }
.pv-meter {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 2px;
  border-radius: 12px; background: var(--p2); border: 1px solid var(--ln);
  padding: 8px 12px; font-size: 12.5px; line-height: 1.35; color: var(--mu);
}
.pv-meter span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-meter button { min-height: 36px; padding: 3px 9px; color: var(--ac); font-size: 12.5px; }
.pv-meter #pvMeterAll { flex-basis: 100%; white-space: normal; color: var(--tx); padding-top: 6px; border-top: 1px solid var(--ln); }
.pv-photos .fi { margin-bottom: 4px; }
.ph-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ph-cell { min-width: 0; padding: 6px; border-radius: 14px; background: var(--p2); }
.ph-cell .fh { margin: 2px 0 6px; font-size: 10px; }
.ph-grid .ph-row { flex-wrap: wrap; gap: 6px; }
.ph-grid .ph { width: 100%; height: auto; aspect-ratio: 4/5; }
.ph-grid .ph.add { min-height: 72px; }

/* ---------- quick adjust above tabs ---------- */
.quick {
  flex: none; display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: var(--p1); border-top: 1px solid var(--ln);
}
.quick.hidden { display: none; }
.quick button {
  min-height: 40px; border-radius: 10px; padding: 0 8px;
  background: var(--p2); border: 1px solid var(--ln);
  font-variant-numeric: tabular-nums;
}
.qb-name { font-weight: 750; color: var(--ac); min-width: 34px; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qb-val { min-width: 66px; font-weight: 650; font-size: 13px; }
.qb-pair { display: flex; gap: 4px; }
.qb-pair button { width: 40px; font-size: 18px; }
.qb-profile { margin-left: auto; color: var(--ac); font-size: 12.5px; font-weight: 700; }
@media (max-width: 360px) {
  .qb-val { min-width: 54px; padding: 0 5px; font-size: 12px; }
  .qb-pair button { width: 36px; }
  .qb-profile { padding: 0 6px; }
}
.objmode { margin-bottom: 8px; }
.objmode button { min-height: 40px; }
.stp { width: 44px; height: 44px; }
input[type=range] { height: 44px; }
.card .fav { top: 6px; right: 6px; width: 44px; height: 44px; font-size: 19px; }
html[data-theme="light"] .card .fav { background: rgba(255,255,255,.72); color: var(--mu); }
html[data-theme="light"] .card .fav.on { color: #c77700; }

/* ---------- fullscreen preview & numeric input ---------- */
.pvov { position: fixed; inset: 0; z-index: 90; background: #000; display: grid; place-items: center; padding: 16px; animation: fadeIn .18s ease both; }
.pvov canvas { max-width: 100%; max-height: 90vh; }
.pvov-close { position: absolute; top: calc(var(--sat) + 12px); right: 14px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; font-size: 20px; }
.pvov-cap { position: absolute; bottom: calc(var(--sab) + 16px); color: rgba(255,255,255,.5); font-size: 12px; }
.qnum input { width: 100%; margin: 10px 0 14px; border: 1px solid var(--ln); background: var(--p2); border-radius: 12px; padding: 12px 14px; font-size: 18px; color: var(--tx); }
.qnum .acts .btn { min-height: 44px; }

/* ---------- light-theme contrast fix for hard-coded dark grays ---------- */
html[data-theme="light"] .cn { color: var(--tx); }
html[data-theme="light"] .f > label, html[data-theme="light"] .fl label { color: var(--tx); }
html[data-theme="light"] .seg button { color: var(--mu); }
html[data-theme="light"] .desc { color: var(--tx); }
html[data-theme="light"] .fi { color: var(--tx); }
html[data-theme="light"] .pv-tg { color: var(--tx); }

/* ---------- disabled undo/redo stay in place ---------- */
#undoBtn:disabled, #redoBtn:disabled { display: grid !important; opacity: .35; pointer-events: none; }

/* ---------- touch targets ---------- */
.stp { min-width: 40px; min-height: 40px; }
.card .fav { width: 36px; height: 36px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- без зуму сторінки; прокрутка лише там, де вона потрібна ---------- */
html, body { touch-action: pan-x pan-y; overscroll-behavior: none; }
.screen { height: 100dvh; bottom: auto; }
#ed.result-mode #scale { display: none; }

/* ---------- прев’ю: перемикач плану живе на кадрі, тож план завжди можна повернути ---------- */
#ed.result-mode .plan-toggle { display: none; }
.pv { align-items: stretch; }
.pv-plan {
  position: absolute; left: 10px; bottom: 10px; z-index: 2;
  min-height: 34px; padding: 0 10px; border-radius: 10px;
  background: rgba(8, 9, 12, .62); color: #fff; font-size: 12px; font-weight: 650;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
#ed.result-mode.plan-hidden .pv-img { max-height: 62vh; }

/* рядки з перемикачем: підпис займає всю вільну ширину */
.f:has(> .sw) { grid-template-columns: 1fr auto; }
.f:has(> .sw) > .sw { justify-self: end; }

/* ---------- адаптивність ---------- */
/* застосунок з домашнього екрана: dvh там коротший на висоту статус-бара, тож тягнемо екран по краях */
@media (display-mode: standalone) { .screen { height: var(--apph, auto); bottom: 0; } }
html.standalone .screen { height: var(--apph, auto); bottom: 0; }
html.standalone, html.standalone body { min-height: var(--apph, 100%); }
html.standalone .ov, html.standalone .imgov { height: var(--apph, auto); }
/* кнопка плану: на вузькому кадрі лишається тільки значок, щоб не налазити на ⤢ */
.pv-plan { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; max-width: calc(100% - 64px); }
.pv-plan span { flex: none; }
.pv-img.narrow .pv-plan { width: 34px; padding: 0; justify-content: center; font-size: 15px; }
.pv-img.narrow .pv-plan span { display: none; }
/* низькі екрани: план у прев’ю менший, щоб кадр лишався читабельним */
@media (max-height: 700px) { #ed.result-mode #stage { flex-basis: 26%; min-height: 120px; } }
#quickBar button, #quickBar span { white-space: nowrap; }
.obj-strip { padding: 10px 0 2px; }
.obj-strip .chip { min-height: 36px; font-size: 12.5px; }
.pv-wide { grid-column: 1/-1; }
#toast.act { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; }
.toast-act { background: var(--ac); color: #1b1306; font-weight: 700; border-radius: 999px; padding: 8px 14px; font-size: 13.5px; flex: none; }
.bk { flex: none; display: flex; align-items: center; gap: 10px; margin: 0 14px 4px; padding: 10px 10px 10px 14px; border-radius: 16px; background: rgba(255, 181, 71, .10); border: 1px solid rgba(255, 181, 71, .35); }
.bk > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bk b { font-size: 13.5px; } .bk small { font-size: 12px; color: var(--mu); line-height: 1.3; }
.bk .btn-ac { padding: 9px 12px; font-size: 13px; white-space: nowrap; }
.bk .ib { width: 36px; height: 36px; flex: none; }
