/* gaffer — plánovač světel */

.planner-body {
  --p-bg: #fbfaf7; --p-grid: #ebe8e0; --p-grid2: #d9d5ca;
  --p-wall: #16130f; --p-ink: #16130f; --p-line: #7a756b; --p-box: #e9e7e0;
  --p-fov: rgba(22,19,15,.05); --p-diff: #8d939a; --p-text: #3b372f; --p-accent: #3a7bd5;
  --tabbar-h: 0px;
  height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
}
:root[data-theme="dark"] .planner-body {
  --p-bg: #1a1814; --p-grid: #25221d; --p-grid2: #34312a;
  --p-wall: #ece9e1; --p-ink: #ece9e1; --p-line: #8c877c; --p-box: #2b2822;
  --p-fov: rgba(236,233,225,.06); --p-diff: #8a9096; --p-text: #cfcabf; --p-accent: #6aa2ff;
}

.planner-body .topbar { flex: none; position: relative; }
.topnav a.is-here { color: var(--ink); }
.auth-initial {
  width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: var(--paper);
  font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.auth-initial[hidden] { display: none; }
#authBtn.has-user .i-user { display: none; }

.pl {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 320px;
}

/* ---------- boční panely ---------- */
.pl-palette, .pl-side { background: var(--surface); overflow-y: auto; overscroll-behavior: contain; }
.pl-palette { border-right: 1px solid var(--line); padding: 14px 14px 22px; }
.pl-side { border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.sheet-grip { display: none; }

.pal-group { margin-bottom: 20px; }
.pal-group h4 {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-45); font-weight: 500; margin-bottom: 8px; display: flex; gap: 8px; align-items: baseline;
}
.pal-group h4 small { font-size: 9px; letter-spacing: .08em; text-transform: none; opacity: .8; }
.pal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.pal-grid button {
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 4px 8px;
  border: 1px solid var(--line); border-radius: var(--r-s); background: var(--paper);
  font-size: 11.5px; color: var(--ink-70); cursor: pointer; transition: border-color .14s, color .14s;
}
.pal-grid button:hover { border-color: var(--ink-45); color: var(--ink); }
.pal-grid svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.pal-grid svg .fill { fill: currentColor; stroke: none; opacity: .85; }
.pal-grid svg .ring { stroke: var(--paper); stroke-width: 1.4; fill: currentColor; }

.pal-search {
  width: 100%; margin-bottom: 8px; padding: 8px 11px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 999px; font: inherit; font-size: 13px; color: var(--ink);
}
.pal-search:focus { outline: none; border-color: var(--ink-45); }
.pal-list { display: grid; gap: 4px; }
.pal-item {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 8px; text-align: left;
  border: 1px solid transparent; border-radius: var(--r-s); cursor: pointer; background: none;
}
.pal-item:hover { background: var(--paper); border-color: var(--line); }
.pal-item .th { flex: none; width: 34px; height: 34px; border-radius: 6px; background: #f2f0ec; overflow: hidden; display: grid; place-items: center; }
.pal-item .th img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.pal-item .nm { flex: 1; min-width: 0; font-size: 12.5px; line-height: 1.3; color: var(--ink); }
.pal-item .pr { font-family: var(--mono); font-size: 10px; color: var(--ink-45); white-space: nowrap; }
.pal-empty { font-size: 12px; color: var(--ink-45); padding: 6px 2px; }

/* ---------- plátno ---------- */
.pl-stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.pl-bar {
  flex: none; display: flex; align-items: center; gap: 4px; padding: 7px 10px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: relative;
}
.bar-btn {
  height: 34px; min-width: 34px; padding: 0 10px; border: 1px solid transparent; border-radius: var(--r-s);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 12.5px; font-weight: 500; color: var(--ink-70); cursor: pointer; background: none; white-space: nowrap;
}
.bar-btn:hover:not(:disabled) { background: var(--paper); border-color: var(--line); color: var(--ink); }
.bar-btn:disabled { opacity: .35; cursor: default; }
.bar-btn[aria-pressed="true"] { color: var(--ink); background: var(--paper); border-color: var(--line); }
.bar-sep { width: 1px; height: 20px; background: var(--line); margin: 0 5px; flex: none; }
.proj-name {
  flex: 1; min-width: 120px; max-width: 320px; height: 34px; padding: 0 10px; border: 1px solid transparent;
  border-radius: var(--r-s); background: none; font: inherit; font-size: 14.5px; font-weight: 600;
  letter-spacing: -.02em; color: var(--ink);
}
.proj-name:hover { border-color: var(--line); }
.proj-name:focus { outline: none; border-color: var(--ink-45); background: var(--paper); }
.save-state { display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-45); white-space: nowrap; margin-right: auto; }
.save-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-45); flex: none; }
.save-state[data-s="saved"] i { background: #4caf7d; }
.save-state[data-s="pending"] i, .save-state[data-s="saving"] i { background: var(--k-warm); }
.save-state[data-s="error"] { color: var(--k-warm); font-weight: 600; }
.save-state[data-s="error"] i { background: var(--k-warm); }
.save-state span { display: none; }
@media (min-width: 1560px) { .save-state span { display: inline; } }
.only-m { display: none; }

.more-menu {
  position: absolute; right: 8px; top: 100%; z-index: 40; min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s); box-shadow: var(--shadow);
}
.more-menu[hidden] { display: none; }
.more-menu button { display: block; width: 100%; text-align: left; padding: 11px 12px; border-radius: 6px; font-size: 14px; color: var(--ink); }
.more-menu button:hover { background: var(--paper); }

.pl-canvas { flex: 1; min-height: 0; position: relative; background: var(--p-bg); overflow: hidden; }
#stage { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: default; }
#stage.panning { cursor: grabbing; }
#stage .it { cursor: grab; }
#stage .ph { cursor: pointer; }

.scale-bar { position: absolute; left: 14px; bottom: 12px; display: flex; flex-direction: column; gap: 3px; pointer-events: none; }
.scale-bar i { display: block; height: 6px; border: 1.5px solid var(--p-ink); border-top: none; opacity: .75; }
.scale-bar span { font-family: var(--mono); font-size: 10.5px; color: var(--p-text); }

.pl-hint {
  position: absolute; left: 50%; bottom: 46px; transform: translateX(-50%); max-width: min(440px, 88%);
  padding: 10px 15px; background: var(--ink); color: var(--paper); border-radius: 999px;
  font-size: 12.5px; text-align: center; pointer-events: none; box-shadow: var(--shadow);
}
.pl-hint[hidden] { display: none; }

.sel-bar {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: none; align-items: center; gap: 4px;
  padding: 5px 6px 5px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
  max-width: 94%;
}
.sel-name { font-size: 13px; font-weight: 600; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 4px; }
.sel-bar button { height: 36px; min-width: 36px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--paper); }
.sel-bar button.danger { color: var(--k-warm); }

/* ---------- SVG ---------- */
.pw { fill: none; stroke: var(--p-wall); }
.pcut { stroke: var(--p-bg); fill: none; }
.pwin { stroke: var(--p-line); fill: none; stroke-width: 1px; vector-effect: non-scaling-stroke; }
.pdoor { stroke: var(--p-line); fill: none; stroke-width: 1px; vector-effect: non-scaling-stroke; }
.pbox { fill: var(--p-box); stroke: var(--p-line); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.pact { fill: var(--p-ink); }
.pact-head { fill: var(--p-ink); stroke: var(--p-bg); stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.pcam { fill: var(--p-ink); }
.pfov { fill: var(--p-fov); stroke: var(--p-line); stroke-width: 1px; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.plabel { fill: var(--p-text); font-family: "DM Mono", ui-monospace, Menlo, monospace; font-size: var(--lbl, .14px); text-anchor: middle; pointer-events: none; }
.plabel.b { font-weight: 500; fill: var(--p-ink); }
.ptext { fill: var(--p-ink); font-family: "Schibsted Grotesk", system-ui, sans-serif; font-weight: 600; text-anchor: middle; }
.pdim { fill: var(--p-line); font-family: "DM Mono", ui-monospace, monospace; font-size: var(--lbl, .14px); text-anchor: middle; pointer-events: none; }
.pbeam-axis { fill: none; stroke-width: 1.4px; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.pbeam-edge { fill: none; stroke-width: 1.2px; vector-effect: non-scaling-stroke; opacity: .85; }
.pg-black { stroke: var(--p-ink); fill: none; }
.pg-diff { stroke: var(--p-diff); fill: none; stroke-dasharray: .14 .07; }
.pg-grid { stroke: var(--p-diff); fill: none; stroke-dasharray: .05 .05; }
.pg-mirror { stroke: #7fa9d6; fill: none; }
.psel { fill: none; stroke: var(--p-accent); stroke-width: 1.5px; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.pw.sel, .pw.sel-line { stroke: var(--p-accent); }
.ph { fill: var(--p-bg); stroke: var(--p-accent); stroke-width: 2px; vector-effect: non-scaling-stroke; }
.ph.rot { fill: var(--p-accent); }
.phline { stroke: var(--p-accent); stroke-width: 1px; vector-effect: non-scaling-stroke; stroke-dasharray: 3 3; pointer-events: none; }
.hit { fill: transparent; stroke: transparent; }

/* ---------- vlastnosti ---------- */
.side-tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.side-tabs button {
  flex: 1; padding: 13px 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-45);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.side-tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.side-tabs b { font-family: var(--mono); font-weight: 500; font-size: 10.5px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; margin-left: 4px; }
.side-pane { padding: 16px 16px 26px; flex: 1; }
.side-pane[hidden] { display: none; }

.pf { display: grid; gap: 5px; margin-bottom: 13px; }
.pf > label, .pf > .lab { font-family: var(--mono); font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-45); display: flex; justify-content: space-between; }
.pf > label b { font-weight: 500; color: var(--ink); letter-spacing: 0; text-transform: none; font-size: 11px; }
.pf input[type="text"], .pf input[type="number"], .pf select {
  width: 100%; min-width: 0; padding: 9px 11px; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-s); font: inherit; font-size: 14px; color: var(--ink);
}
.pf input:focus, .pf select:focus { outline: none; border-color: var(--ink-45); }
.pf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pf input[type="range"] { width: 100%; accent-color: var(--ink); height: 28px; }
.pf input[type="range"].kelvin {
  -webkit-appearance: none; appearance: none; height: 10px; border-radius: 99px; margin: 9px 0;
  background: linear-gradient(90deg, #e0762a 0%, #e8982f 22%, #f0c040 45%, #f4dc6a 62%, #a9c8e8 82%, #6f9fd6 100%);
}
.pf input[type="range"].kelvin::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink); }
.pf input[type="range"].kelvin::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink); }
.pf-actions { display: flex; gap: 8px; margin-top: 18px; }
.pf-actions .btn { flex: 1; }
.pf-title { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; }
.pf-title h3 { font-size: 16px; font-weight: 700; letter-spacing: -.025em; flex: 1; min-width: 0; }
.pf-title .tag { font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-45); }
.pf-empty p { font-size: 13px; color: var(--ink-70); line-height: 1.55; margin-bottom: 10px; }
.pf-empty ul { list-style: none; font-size: 12.5px; color: var(--ink-70); display: grid; gap: 7px; }
.pf-empty li { padding-left: 14px; position: relative; }
.pf-empty li::before { content: ""; position: absolute; left: 0; top: .6em; width: 5px; height: 5px; border-radius: 50%; background: var(--k-warm); }
.pf-empty kbd { font-family: var(--mono); font-size: 10.5px; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }

/* seznam techniky */
.gl-row { display: grid; grid-template-columns: 40px 1fr auto auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.gl-row .th { width: 40px; height: 40px; border-radius: 7px; background: #f2f0ec; display: grid; place-items: center; overflow: hidden; }
.gl-row .th img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.gl-row .n { min-width: 0; line-height: 1.3; }
.gl-row .n .ok { display: block; font-size: 11px; color: var(--ink-45); font-family: var(--mono); margin-top: 2px; }
.gl-row .n .w { display: block; font-size: 11.5px; color: var(--k-warm); font-weight: 600; margin-top: 2px; }
.gl-row .q { font-family: var(--mono); font-size: 12px; color: var(--ink-70); }
.gl-row .p { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }
.gl-total { display: flex; justify-content: space-between; align-items: baseline; padding: 13px 0 4px; }
.gl-total span { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-45); }
.gl-total strong { font-size: 19px; letter-spacing: -.02em; }
.gl-total.sub { padding-top: 2px; }
.gl-total.sub strong { font-size: 15px; color: var(--ink-70); }
.gl-term { padding: 12px; margin-bottom: 8px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-s); }
.gl-term-h { font-size: 12.5px; font-weight: 600; margin-bottom: 8px; }
.gl-term-h span { font-weight: 400; color: var(--ink-45); }
.gl-term label { display: grid; gap: 4px; font-family: var(--mono); font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-45); }
.gl-term input { width: 100%; min-width: 0; padding: 8px 9px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s); font: inherit; font-size: 14px; color: var(--ink); }
@media (max-width: 980px) { .gl-term input { font-size: 16px; } }
.gl-note { font-size: 11.5px; color: var(--ink-45); line-height: 1.5; margin: 6px 0 14px; }
.gl-empty { font-size: 13px; color: var(--ink-70); line-height: 1.55; }
.gl-actions { display: grid; gap: 8px; }

/* ---------- projekty ---------- */
.proj-card { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); overflow-y: auto; }
.proj-row { display: flex; align-items: center; gap: 8px; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--r-s); margin-bottom: 7px; background: var(--paper); }
.proj-row.cur { border-color: var(--ink); }
.proj-row .t { flex: 1; min-width: 0; text-align: left; cursor: pointer; }
.proj-row .t b { display: block; font-size: 14px; font-weight: 600; letter-spacing: -.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-row .t small { font-family: var(--mono); font-size: 10.5px; color: var(--ink-45); }
.proj-row button.ic { width: 36px; height: 36px; border-radius: 8px; color: var(--ink-70); font-size: 15px; }
.proj-row button.ic:hover { background: var(--surface); color: var(--ink); }
.proj-new { margin: 16px 0 6px; }
.proj-new h4 { font-family: var(--mono); font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-45); font-weight: 500; margin-bottom: 8px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.tpl { padding: 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); text-align: left; cursor: pointer; }
.tpl:hover { border-color: var(--ink-45); }
.tpl b { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 3px; }
.tpl span { font-size: 12px; color: var(--ink-70); line-height: 1.4; }
.proj-lock { padding: 16px; border: 1px dashed var(--line); border-radius: var(--r-s); font-size: 13px; color: var(--ink-70); line-height: 1.55; margin-bottom: 12px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + var(--tabbar-h)); transform: translateX(-50%); z-index: 200;
  background: var(--ink); color: var(--paper); padding: 11px 18px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow); max-width: 90vw; }
.toast[hidden] { display: none; }

#printSheet { display: none; }

/* ---------- mobil / tablet ---------- */
.pl-tabbar, .sheet-bg { display: none; }

@media (max-width: 980px) {
  .planner-body { --tabbar-h: 58px; }
  .pl { grid-template-columns: 1fr; padding-bottom: var(--tabbar-h); }
  .only-m { display: inline-flex; }
  .hide-m, .bar-btn .lbl { display: none; }
  .save-state { display: none; }
  .proj-name { max-width: none; }

  .pl-tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line);
  }
  .pl-tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--ink-45); }
  .pl-tabbar button.on { color: var(--ink); }
  .pl-tabbar b { font-family: var(--mono); font-weight: 500; font-size: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; margin-left: 2px; }

  .sheet-bg { display: block; position: fixed; inset: 0; z-index: 54; background: rgba(18,17,16,.4); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sheet-bg.on { opacity: 1; pointer-events: auto; }

  .pl-sheet {
    position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); z-index: 55;
    max-height: 58dvh; border: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0;
    transform: translateY(105%); transition: transform .24s cubic-bezier(.2,.8,.2,1); box-shadow: 0 -10px 30px rgba(0,0,0,.18);
  }
  .pl-sheet.open { transform: none; }
  .sheet-grip { display: block; width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: 8px auto 4px; flex: none; }
  .pl-palette { padding-top: 0; }
  .side-tabs { top: 0; }

  .sel-bar { display: flex; bottom: 12px; }
  .sel-bar[hidden] { display: none; }
  .pl-hint { bottom: 62px; border-radius: 14px; }
  .scale-bar { bottom: 62px; }
  .pal-grid { grid-template-columns: repeat(3, 1fr); }
  .pal-item { padding: 9px 8px; }
  .pf input[type="text"], .pf input[type="number"], .pf select { font-size: 16px; }
  .pal-search { font-size: 16px; }
  .proj-name { font-size: 16px; }
}

@media print {
  body.planner-body { display: block; height: auto; overflow: visible; }
  body.planner-body > *:not(#printSheet) { display: none !important; }
  #printSheet { display: block !important; }
  #printSheet svg { width: 100%; height: auto; }
  @page { size: A4 landscape; margin: 10mm; }
}
