:root {
  --bg: #f4f5f7; --panel: #ffffff; --ink: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --accent: #1f6feb; --accent-ink: #fff; --danger: #c93c37; --stage: #2a2e36; --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
h2 { font-size: 20px; margin: 0; } h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .center { text-align: center; } .spacer { flex: 1; }
.error { color: var(--danger); min-height: 1.2em; margin: 4px 0 0; }
input, select { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: inherit; }
input[type=range] { padding: 0; border: 0; accent-color: var(--accent); }
input[type=color] { padding: 2px; height: 34px; width: 60px; }
label { display: flex; flex-direction: column; gap: 4px; }
label.row, .row { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.row.gap { gap: 8px; flex-wrap: wrap; margin-top: 8px; }
label.row input[type=range] { flex: 1; }
.col { display: flex; flex-direction: column; gap: 8px; }
label.check { flex-direction: row; align-items: center; gap: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #c9ced6; } .btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); } .btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; } .btn.wide { width: 100%; margin-top: 8px; }
.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }

.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; letter-spacing: -.01em; }
.brand.big { font-size: 26px; justify-content: center; }
.brand .dim { color: var(--muted); font-weight: 500; margin-left: -8px; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent) url(/static/favicon.svg) center/cover; }

.topbar { height: 54px; display: flex; align-items: center; gap: 24px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
#nav { display: flex; gap: 2px; overflow-x: auto; }
#nav a { padding: 7px 12px; border-radius: 7px; color: var(--ink); text-decoration: none; white-space: nowrap; }
#nav a:hover { background: var(--bg); } #nav a.on { background: #e8f0fe; color: var(--accent); font-weight: 600; }
.user { margin-left: auto; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
body:not(.is-admin) .admin-only { display: none; }

.view { display: none; padding: 20px; max-width: 1400px; margin: 0 auto; }
.view.on { display: block; }
.view-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-left: auto; }

/* nalaganje */
.drop { border: 2px dashed #c4cad4; border-radius: 16px; background: var(--panel); min-height: 360px; display: grid; place-items: center; text-align: center; padding: 24px; transition: .15s; }
.drop.over { border-color: var(--accent); background: #f0f6ff; }
.drop h2 { margin: 12px 0 6px; }
.drop-icon { width: 64px; height: 64px; margin: 0 auto; border-radius: 16px; background: #e8f0fe url(/static/favicon.svg) center/44px no-repeat; }
.spinner { width: 42px; height: 42px; margin: 0 auto; border: 4px solid #dbe4f3; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.small { width: 26px; height: 26px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* urejevalnik */
.view.editor.on { display: grid; grid-template-columns: 1fr 300px; gap: 16px; max-width: none; height: calc(100vh - 54px - 34px); padding: 12px; }
.view.editor.on .panel { max-height: 100%; }
.stage-wrap { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.stage { position: relative; flex: 1; background: var(--stage); border-radius: var(--radius); overflow: hidden; touch-action: none; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage #result-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--stage); }
.stage-hint { position: absolute; left: 12px; bottom: 10px; color: #cfd5df; font-size: 12px; pointer-events: none; text-shadow: 0 1px 2px #000; }
.stage-bar { display: flex; align-items: center; gap: 8px; padding-top: 8px; }
.zoom { display: flex; align-items: center; gap: 4px; }
.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; overflow-y: auto; }
.group { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: 0; margin-bottom: 0; }
.group label.row { margin-top: 10px; }
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.tools button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font: inherit; font-size: 12px; color: var(--ink); }
.tools button.on { border-color: var(--accent); background: #e8f0fe; color: var(--accent); font-weight: 600; }
.ic { width: 20px; height: 20px; display: block; background: currentColor; -webkit-mask: var(--m) center/contain no-repeat; mask: var(--m) center/contain no-repeat; }
.ic-erase { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M16.2 3.6l4.2 4.2a2 2 0 010 2.8L11 20H6.5l-3-3a2 2 0 010-2.8L13.4 3.6a2 2 0 012.8 0zM12 18l-5-5-2.1 2.1L7.8 18zM20 20v-2h-6l-2 2z'/%3E%3C/svg%3E"); }
.ic-restore { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 14c-1.7 0-3 1.3-3 3 0 1.3-1.2 2-2 2 .9 1.2 2.5 2 4 2 2.2 0 4-1.8 4-4 0-1.7-1.3-3-3-3zm13.7-9.4l-1.3-1.3a1 1 0 00-1.4 0L9 12.3 11.7 15l9-9a1 1 0 000-1.4z'/%3E%3C/svg%3E"); }
.ic-plate { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 7h18v10H3zM5 9v6h14V9zm2 1h2v4H7zm3 0h2v4h-2zm4 0h3v4h-3z'/%3E%3C/svg%3E"); }
.ic-pan { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l3 3h-2v4h4V7l3 3-3 3v-2h-4v4h2l-3 3-3-3h2v-4H7v2l-3-3 3-3v2h4V5H9z'/%3E%3C/svg%3E"); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 5px 12px; font: inherit; cursor: pointer; color: var(--ink); }
.seg button.on { background: var(--accent); color: #fff; } .seg button:disabled { opacity: .4; cursor: default; }
.seg.small button { padding: 3px 9px; font-size: 12px; }
.plates { list-style: none; padding: 0; margin: 6px 0; }
.plates li { display: flex; justify-content: space-between; align-items: center; padding: 3px 8px; background: #fff8db; border-radius: 6px; margin-bottom: 4px; font-size: 13px; }
.plates li button { border: 0; background: none; cursor: pointer; color: var(--danger); font-size: 16px; line-height: 1; }
.bg-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.bg-grid button { padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; background: #eee; position: relative; aspect-ratio: 3/2; }
.bg-grid button.on { border-color: var(--accent); }
.bg-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bg-grid span { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.65)); padding: 8px 6px 3px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bg-studio { background: radial-gradient(ellipse at center, #fff 0%, #dcdfe4 100%) !important; }
details.adj { margin-top: 10px; } details.adj summary { cursor: pointer; color: var(--muted); font-size: 13px; }

/* galerija */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card { background: var(--panel); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); cursor: pointer; border: 0; padding: 0; text-align: left; font: inherit; color: inherit; }
.card img { width: 100%; aspect-ratio: 3/2; object-fit: cover; display: block; background: #e5e7eb; }
.card .meta { padding: 8px 10px; } .card .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#g-q { min-width: 240px; }
#g-more { margin-top: 18px; }

/* dialogi */
dialog { border: 0; border-radius: 14px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3); max-width: min(94vw, 420px); }
dialog::backdrop { background: rgba(15,18,25,.6); }
dialog.dlg-img { max-width: 96vw; max-height: 96vh; padding: 0; overflow: hidden; display: none; flex-direction: column; background: #111; }
dialog.dlg-img[open] { display: flex; }
dialog.dlg-img img { max-width: 96vw; max-height: calc(96vh - 64px); object-fit: contain; display: block; margin: 0 auto; }
.dlg-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: #fff; }
.toast { position: fixed; left: 50%; top: 66px; transform: translateX(-50%) translateY(-12px); background: #1d2330; color: #fff; padding: 10px 16px; border-radius: 9px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: 90vw; }
.toast.on { opacity: 1; transform: translateX(-50%); } .toast.err { background: var(--danger); }

/* admin */
.bg-admin { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.bg-list { display: flex; flex-direction: column; gap: 8px; }
.bg-item { display: flex; gap: 10px; align-items: center; padding: 6px; border-radius: 9px; background: var(--panel); box-shadow: var(--shadow); cursor: pointer; border: 2px solid transparent; font: inherit; text-align: left; color: inherit; }
.bg-item.on { border-color: var(--accent); }
.bg-item img { width: 96px; height: 64px; object-fit: cover; border-radius: 6px; }
.bg-item .off { color: var(--danger); font-size: 12px; }
.bg-edit, .settings > .form-grid { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.preview-box { position: relative; background: var(--stage); border-radius: 8px; overflow: hidden; aspect-ratio: 3/2; margin-bottom: 14px; }
.bg-edit .preview-box { aspect-ratio: auto; height: min(46vh, 520px); }
.preview-box img { width: 100%; height: 100%; object-fit: contain; display: block; }
.preview-box .spinner { position: absolute; right: 12px; top: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.form-grid label:has(input[type=range]) { display: grid; grid-template-columns: 1fr auto; }
.form-grid label:has(input[type=range]) input { grid-column: 1; } .form-grid .v { grid-column: 2; grid-row: 2; font-size: 12px; color: var(--muted); min-width: 44px; text-align: right; }
fieldset { border: 1px solid var(--line); border-radius: 8px; display: flex; gap: 14px; flex-wrap: wrap; }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.logo-box { display: flex; gap: 12px; align-items: center; }
.logo-prev { width: 140px; height: 80px; border-radius: 8px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); }
.logo-prev img { max-width: 90%; max-height: 90%; }
.checker { background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 50%/16px 16px; }
.tbl { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.tbl th, .tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.tbl tr:last-child td { border-bottom: 0; }

/* prijava */
.login-body { display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); padding: 32px; border-radius: 16px; box-shadow: var(--shadow); width: min(380px, 100%); text-align: center; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; text-align: left; }

@media (max-width: 900px) {
  .view.editor.on { grid-template-columns: 1fr; height: auto; }
  .stage { height: 56vh; flex: none; }
  .stage-hint { display: none; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; row-gap: 6px; }
  #nav { order: 3; width: 100%; }
  .toast { top: 100px; }
  .bg-admin, .settings, .form-grid { grid-template-columns: 1fr; }
  .topbar { gap: 10px; } .brand .dim { display: none; }
  .user #me-name { display: none; }
}

/* izdelal Visteh */
.credit { display: flex; justify-content: flex-end; align-items: flex-end; gap: 6px; height: 34px; padding: 0 12px 8px; font-size: 10px; color: #a3a8b0; }
.credit img { height: 18px; width: auto; display: block; }
.credit.fixed { position: fixed; right: 0; bottom: 0; }
body:not(.login-body) { display: flex; flex-direction: column; min-height: 100vh; }
body:not(.login-body) > .credit { margin-top: auto; }
.view { width: 100%; }

/* trgovci */
body:not(.is-super) .super-only { display: none !important; }
.visteh-top { height: 16px; width: auto; margin-right: 10px; opacity: .9; }
.brand img.dealer-logo { height: 34px; width: auto; display: block; }
.brand .dealer-name { font-weight: 700; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #eef1f5; color: var(--muted); margin-left: 4px; }
.badge.own { background: #e8f0fe; color: var(--accent); }
.dealer-ctx { font-weight: 600; }
.logo-box[data-kind=header] .logo-prev { background: #fff; }
@media (max-width: 900px) { .visteh-top { display: none; } }

/* raziskovalec galerije */
.explorer { display: grid; grid-template-columns: 250px 1fr; gap: 16px; align-items: start; }
.tree { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; position: sticky; top: 66px; max-height: calc(100vh - 90px); overflow: auto; }
.tree ul { list-style: none; margin: 0; padding-left: 14px; }
.tree > ul { padding-left: 0; }
.tn { display: flex; align-items: center; gap: 4px; padding: 4px 6px; border-radius: 6px; cursor: pointer; white-space: nowrap; font-size: 13px; }
.tn:hover { background: var(--bg); } .tn.on { background: #e8f0fe; color: var(--accent); font-weight: 600; }
.tn.drop { outline: 2px dashed var(--accent); background: #f0f6ff; }
.tn .tw { width: 14px; text-align: center; color: var(--muted); font-size: 10px; flex: none; }
.tn .nm { overflow: hidden; text-overflow: ellipsis; } .tn .ct { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 400; }
.ic-folder { width: 16px; height: 13px; flex: none; border-radius: 2px 3px 3px 3px; background: #e0b84f; position: relative; }
.ic-folder::before { content: ""; position: absolute; left: 0; top: -3px; width: 7px; height: 4px; background: #e0b84f; border-radius: 2px 2px 0 0; }
.ex-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 15px; }
.crumbs a { color: var(--accent); text-decoration: none; cursor: pointer; } .crumbs a:hover { text-decoration: underline; }
.crumbs .sep { color: var(--muted); } .crumbs b { font-weight: 600; }
.card.folder { display: flex; flex-direction: column; align-items: center; justify-content: center; aspect-ratio: auto; padding: 18px 10px; gap: 8px; background: #fffaf0; }
.card.folder .big-folder { width: 64px; height: 48px; border-radius: 4px 6px 6px 6px; background: #e0b84f; position: relative; box-shadow: inset 0 -10px 0 #d3a93f; }
.card.folder .big-folder::before { content: ""; position: absolute; left: 0; top: -8px; width: 26px; height: 10px; background: #e0b84f; border-radius: 4px 4px 0 0; }
.card.folder.drop { outline: 3px dashed var(--accent); }
.card { position: relative; }
.card .sel { position: absolute; top: 8px; left: 8px; width: 22px; height: 22px; border-radius: 6px; background: rgba(255,255,255,.9); border: 1px solid #c4cad4; display: grid; place-items: center; opacity: 0; transition: .1s; }
.card:hover .sel, .card.picked .sel, .gallery.picking .sel { opacity: 1; }
.card.picked { outline: 3px solid var(--accent); } .card.picked .sel { background: var(--accent); border-color: var(--accent); }
.card.picked .sel::after { content: "✓"; color: #fff; font-size: 14px; font-weight: 700; }
.card .path { color: var(--muted); font-size: 11px; }
@media (max-width: 900px) { .explorer { grid-template-columns: 1fr; } .tree { position: static; max-height: 220px; } }
