:root {
  --bg: #14161a; --bg2: #1c1f25; --glass: rgba(24, 27, 33, .72); --line: rgba(255, 255, 255, .09);
  --text: #eef0f3; --muted: #9aa3ae; --accent: #d9873f; --accent2: #f0b27a; --ok: #3ccf7a; --warn: #f0b429;
  --r: 14px; --font: Nunito, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
#app { position: fixed; inset: 0; background: radial-gradient(120% 90% at 60% 35%, #2a2e36 0%, #181a1f 55%, #111316 100%); }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
button, select, input { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255,255,255,.04); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s; }
.btn:hover { background: rgba(255,255,255,.09); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; font-weight: 650; }
.btn.primary:hover { background: var(--accent2); }
.btn.icon { width: 38px; padding: 0; justify-content: center; }
.btn.round { border-radius: 50%; width: 46px; height: 46px; }
.btn.round svg { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.active { border-color: var(--accent); color: var(--accent2); }
.muted { color: var(--muted); font-weight: 400; }

/* top bar */
.topbar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; pointer-events: none; z-index: 5; }
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 17px; letter-spacing: .2px; }
.brand-logo { display: flex; align-items: center; height: 44px; padding: 4px 10px; border-radius: 12px; background: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.brand-logo img { height: 36px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; font-weight: 800; font-size: 19px; }
.brand-text small { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .3px; }
.top-actions { display: flex; gap: 8px; }

/* status chips */
.status { position: absolute; top: 74px; left: 18px; display: flex; flex-wrap: wrap; gap: 8px; z-index: 4; max-width: calc(100% - 400px); }
.chip { display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 13px; }
.chip .k { color: var(--muted); }
.chip b { font-variant-numeric: tabular-nums; font-weight: 600; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.state.printing .dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(60,207,122,.18); animation: pulse 1.6s infinite; }
.state.paused .dot { background: var(--warn); }
.state.done .dot { background: var(--accent); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(60,207,122,.05); } }

/* side panel */
.panel { position: absolute; top: 74px; right: 18px; bottom: 104px; width: 340px; z-index: 5; display: flex; flex-direction: column;
  background: var(--glass); border: 1px solid var(--line); border-radius: 18px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.panel-handle { display: none; }
.panel-body { overflow-y: auto; padding: 6px 18px 18px; scrollbar-width: thin; }
.panel section { padding: 12px 0; border-bottom: 1px solid var(--line); }
.panel section:last-child { border-bottom: 0; }
.panel h2 { font-size: 16px; margin: 4px 0 12px; }
.panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 4px 0 10px; font-weight: 600; }
.panel h3 + .swatches { margin-bottom: 14px; }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; padding: 4px; background: rgba(0,0,0,.25); border-radius: 12px; }
.seg button { height: 40px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); }
.seg button.on { background: rgba(255,255,255,.1); color: var(--text); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.seg svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(30px, 1fr)); gap: 7px; }
.sw { position: relative; aspect-ratio: 1; border-radius: 50%; border: 2px solid rgba(255,255,255,.12); cursor: pointer; padding: 0; background: var(--c);
  box-shadow: inset 0 -6px 10px rgba(0,0,0,.22), inset 0 4px 8px rgba(255,255,255,.18); transition: transform .12s; }
.sw:hover { transform: scale(1.08); }
.sw.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(224,164,88,.35), inset 0 -6px 10px rgba(0,0,0,.22); }
.sw.out { opacity: .32; cursor: not-allowed; }
.sw.out::after { content: ""; position: absolute; left: 50%; top: 8%; bottom: 8%; width: 2px; background: #ff6b6b; transform: rotate(45deg); }
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.chips button { height: 50px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.03); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.chips button b { font-size: 15px; }
.chips button small { font-size: 10.5px; color: var(--ok); }
.chips button.na small { color: #ff8a8a; }
.chips button.na { opacity: .55; cursor: not-allowed; }
.chips button.on { border-color: var(--accent); background: rgba(224,164,88,.12); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.facts span { display: block; font-size: 12px; color: var(--muted); }
.facts b { font-size: 16px; font-variant-numeric: tabular-nums; }
.file-name { font-weight: 600; word-break: break-all; margin-bottom: 10px; }
.view-opts { display: grid; gap: 10px; }
.tog { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.tog input { display: none; }
.tog span { width: 36px; height: 20px; border-radius: 10px; background: rgba(255,255,255,.14); position: relative; transition: background .15s; flex: none; }
.tog span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.tog input:checked + span { background: var(--accent); }
.tog input:checked + span::after { transform: translateX(16px); }
.panel-foot { flex: none; padding: 14px 18px; border-top: 1px solid var(--line); background: rgba(0,0,0,.18); border-radius: 0 0 18px 18px; }
.cta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cta-name { font-weight: 650; }
.cta-price { color: var(--accent2); font-size: 18px; font-weight: 700; }

/* transport */
.transport { position: absolute; left: 18px; right: 376px; bottom: 18px; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 18px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 20px 50px rgba(0,0,0,.3); }
#btnPlay .i-pause { display: none; }
#app.playing #btnPlay .i-pause { display: block; }
#app.playing #btnPlay .i-play { display: none; }
.timeline { flex: 1; min-width: 120px; }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent) var(--p, 0%), rgba(255,255,255,.14) var(--p, 0%)); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent) var(--p, 0%), rgba(255,255,255,.14) var(--p, 0%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; margin-top: -5px; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: #fff; }
.speed { display: flex; align-items: center; gap: 6px; }
.speed .k { color: var(--muted); font-size: 12px; }
select { height: 32px; border-radius: 8px; border: 1px solid var(--line); background: rgba(0,0,0,.3); padding: 0 8px; }
.views { display: flex; gap: 4px; }

/* overlays */
.loader { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--bg); transition: opacity .5s; }
#app:not(.is-loading) .loader { opacity: 0; pointer-events: none; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.12); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader .bar { width: 200px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.1); overflow: hidden; }
.loader .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.drop { position: absolute; inset: 12px; z-index: 30; border: 2px dashed var(--accent); border-radius: 20px; background: rgba(20,22,26,.82); display: none; align-items: center; justify-content: center; font-size: 18px; }
#app.dragging .drop { display: flex; }
.toast { position: absolute; left: 50%; top: 18px; transform: translate(-50%, -80px); z-index: 40; max-width: min(560px, 90vw); padding: 12px 16px; border-radius: 12px; background: #2a2e36; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.4); transition: transform .3s; }
.toast.show { transform: translate(-50%, 0); }
.toast.err { border-color: #ff6b6b; }

/* exhibition / kiosk */
.kiosk-cta { display: none; }
#app.kiosk .panel, #app.kiosk .transport, #app.kiosk .top-actions { display: none; }
#app.kiosk .status { max-width: none; }
#app.kiosk .kiosk-cta { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; position: absolute; left: 28px; bottom: 28px; z-index: 6; padding: 18px 22px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 18px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.kc-title { font-size: 22px; font-weight: 700; }
.kc-url { font-size: 26px; font-weight: 800; color: var(--accent2); letter-spacing: .3px; }
#btnKioskExit { margin-top: 6px; opacity: .55; }

/* tablet / phone: panel becomes a bottom sheet */
@media (max-width: 900px) {
  .brand-logo { height: 36px; padding: 3px 8px; } .brand-logo img { height: 29px; } .brand-text { font-size: 16px; }
  .status { top: 60px; left: 12px; max-width: calc(100% - 24px); gap: 6px; }
  .chip { height: 28px; padding: 0 10px; font-size: 12px; }
  .hide-sm { display: none; }
  .topbar { padding: 10px 12px; }
  .top-actions .btn span { display: none; }
  .top-actions .btn { width: 38px; padding: 0; justify-content: center; }
  .transport { left: 12px; right: 12px; bottom: calc(12px + var(--sheet, 64px)); flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .timeline { order: 5; flex-basis: 100%; }
  .views { display: none; }
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; border-radius: 18px 18px 0 0; max-height: 64px; transition: max-height .3s; }
  .panel.open { max-height: 72vh; }
  .panel-handle { display: flex; justify-content: center; align-items: center; height: 28px; border: 0; background: transparent; cursor: pointer; flex: none; }
  .panel-handle span { width: 44px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.3); }
  .panel-body { padding-top: 0; }
  .panel-foot { border-radius: 0; padding: 10px 14px; }
  .panel:not(.open) .panel-foot { display: none; }
  #app.kiosk .kiosk-cta { left: 12px; right: 12px; bottom: 12px; }
  .kc-url { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
