:root {
  color-scheme: dark;
  --panel: rgba(15, 20, 26, .92);
  --border: rgba(197, 214, 228, .15);
  --text: #e8edf2;
  --muted: #97a7b7;
  --accent: #92d8e4;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: #1c2630; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: var(--text); }
canvas#viewport {
  display: block; width: 100vw; height: 100vh; touch-action: none;
  cursor: grab; outline: none;
}
canvas#viewport.dragging { cursor: grabbing; }
canvas#viewport.action-ready, canvas#viewport.acting { cursor: crosshair; }
canvas#viewport { background: linear-gradient(155deg, #414b56, #252e38); }
[hidden] { display: none !important; }
#controlPanel {
  position: fixed; top: 17px; left: 17px; bottom: 17px;
  width: min(308px, calc(100vw - 34px)); z-index: 3;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 15px; backdrop-filter: blur(16px);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 68px rgba(0,0,0,.32);
  transition: transform .23s ease, opacity .23s ease;
}
.panel-hidden #controlPanel { transform: translateX(calc(-100% - 35px)); opacity: 0; pointer-events: none; }
#panelHeader { padding: 20px 19px 15px; border-bottom: 1px solid var(--border); }
.eyebrow { font-size: 10px; text-transform: uppercase; letter-spacing: .16em; color: var(--accent); font-weight: 700; }
h1 { font-size: 20px; letter-spacing: -.035em; font-weight: 650; margin: 8px 0 7px; }
.description { color: #a7b5c3; font-size: 12px; line-height: 1.52; margin: 0; }
#panelContent { flex: 1; min-height: 0; padding: 2px 19px 16px; overflow-y: auto; overscroll-behavior: contain; }
#panelContent::-webkit-scrollbar { width: 7px; }
#panelContent::-webkit-scrollbar-thumb { background: #4b5660; border-radius: 5px; }
section { padding: 16px 0; border-bottom: 1px solid var(--border); }
#panelContent > div:last-child > section:last-child { border-bottom: none; }
h2 { font-size: 10px; font-weight: 750; letter-spacing: .15em; text-transform: uppercase; color: #aab8c3; margin: 0 0 13px; }
.control { margin-bottom: 13px; }
.control:last-child { margin-bottom: 0; }
.controlHead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 12px; margin-bottom: 7px; }
.controlHead span { color: #d4dfe7; }
.controlHead label { min-width: 0; overflow-wrap: anywhere; }
.controlHead output { flex-shrink: 0; white-space: nowrap; font-variant-numeric: tabular-nums; color: #a9d9e3; font-size: 11px; }
input[type=range] { width: 100%; height: 4px; margin: 0; appearance: none; background: #475563; border-radius: 8px; cursor: pointer; display: block; }
input[type=range]::-webkit-slider-thumb { appearance: none; width: 13px; height: 13px; background: #b6e3ec; border: 2px solid #1f343c; border-radius: 100%; }
input[type=range]::-moz-range-thumb { width: 11px; height: 11px; background: #b6e3ec; border: 2px solid #1f343c; border-radius: 100%; }
select { display: block; width: 100%; appearance: none; color: var(--text); background: #25313b; border: 1px solid #47545d; padding: 10px 30px 10px 10px; border-radius: 7px; font-family: inherit; font-size: 12px; }
.check { display: flex; align-items: flex-start; gap: 9px; min-height: 20px; font-size: 12px; line-height: 1.5; margin: 0; cursor: pointer; color: #d4dfe7; }
.check input { flex: 0 0 15px; accent-color: #76bdce; width: 15px; height: 15px; margin: 2px 0 0; }
.rowButtons { display: flex; flex-wrap: wrap; gap: 8px; }
#panelContent .control > .rowButtons, #panelContent section > .rowButtons { margin-top: 10px; }
#panelContent .workbenchSection > .presetControl { margin-bottom: 12px; }
#panelContent .workbenchSection > .rowButtons { margin-top: 0; }
#panelContent .workbenchSection > .rowButtons + .rowButtons { margin-top: 12px; }
.workbenchActions { flex-direction: column; align-items: stretch; }
button, .uploadButton { padding: 9px 11px; border-radius: 7px; border: 1px solid #4b5c68; background: #2b3944; color: #e5edf2; font-family: inherit; font-size: 11px; font-weight: 600; cursor: pointer; text-align: center; }
button:not(:disabled):hover, .uploadButton:hover { background: #39505d; border-color: #8aa7b7; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid #a9e5f0; outline-offset: 2px; }
.secondaryHint { font-size: 11px; line-height: 1.5; color: #9badbb; margin: 9px 0 0; }
#panelHeader, #panelFooter { flex-shrink: 0; }
#panelFooter { margin-top: auto; padding: 12px 19px; border-top: 1px solid var(--border); font-size: 10px; color: #8f9ca9; line-height: 1.4; overflow-wrap: anywhere; }
#status { max-height: 70px; overflow-y: auto; }
#topBar { position: fixed; top: 22px; right: 24px; z-index: 2; display: flex; align-items: center; gap: 9px; }
.topChip { font-size: 11px; padding: 7px 10px; border-radius: 999px; border: 1px solid rgba(240,250,255,.2); color: #e6eff7; background: rgba(18,28,36,.66); backdrop-filter: blur(10px); font-variant-numeric: tabular-nums; }
#hidePanel { min-width: 100px; }
#performancePanel { position: fixed; z-index: 5; top: 68px; right: 24px; width: min(350px, calc(100vw - 24px)); max-height: calc(100vh - 90px); overflow: auto; overflow-wrap: anywhere; padding: 16px; background: #10171e; border: 1px solid var(--border); border-radius: 12px; font-size: 11px; }
.performanceHeader { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.performanceHeader h2 { margin: 0; }
.performanceMetrics { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 12px; }
.performanceMetrics dt { color: var(--muted); }
.performanceMetrics dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.frameGraph { display: block; width: 100%; height: 68px; margin-top: 14px; background: #1b252e; border-radius: 5px; }
.frameGraph polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; }
@media (max-width: 1100px) { #topBar .timingChip { display: none; } }
@media (max-width: 900px) { #runtimeLabel { display: none; } }
#bottomBar { position: fixed; right: 25px; bottom: 22px; color: #e4edf5; background: rgba(13,20,26,.66); border-radius: 9px; font-size: 11px; line-height: 1.55; padding: 10px 13px; z-index: 2; pointer-events: none; }
#errorOverlay { position: fixed; inset: 0; background: #151c24; z-index: 10; display: grid; place-items: center; padding: 30px; color: #f0c3bd; font-size: 16px; text-align: center; }
#errorOverlay[hidden] { display: none; }
#errorOverlay pre { white-space: pre-wrap; max-width: 850px; font-family: inherit; font-size: 13px; line-height: 1.6; text-align: left; }
.panel-hidden #controlPanel { visibility: hidden; }
.searchLabel { display: block; margin-top: 22px; font-size: 12px; color: var(--muted); }
input[type=search] { width: min(500px, 100%); padding: 10px; margin: 8px 0 18px; background: #25313b; color: var(--text); border: 1px solid #47545d; border-radius: 7px; }
#gallery { position: fixed; inset: 17px; z-index: 4; overflow: auto; padding: 32px; border: 1px solid var(--border); border-radius: 15px; background: var(--panel); backdrop-filter: blur(16px); }
#gallery h1 { font-size: 24px; }
#effectList { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 18px; margin-top: 18px; }
.effectCard { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #1b252e; }
.effectCard img { width: 100%; height: 180px; object-fit: contain; display: block; }
.effectCard .cardBody { padding: 18px; }
.effectCard h2 { text-transform: none; font-size: 16px; letter-spacing: -.02em; color: var(--text); line-height: 1.4; margin-bottom: 8px; }
.effectCard .rowButtons { margin-top: 15px; }
.effectCard .topChip { display: inline-block; margin-top: 10px; }
#catalogStatus, #status { margin-top: 7px; }
details { font-size: 12px; line-height: 1.6; }
summary { color: var(--accent); cursor: pointer; }
.projectDocument { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; color: #bdcbd5; }
.control input[type=file] { width: 100%; margin-top: 9px; color: var(--muted); font-size: 11px; }
.control select { margin-bottom: 0; }
#bottomBar { max-width: 42vw; }
@media (max-width: 760px) {
  #topBar .topChip { display: none; }
}
@media (max-width: 680px) {
  #performancePanel { top: 60px; right: 12px; max-height: calc(100vh - 80px); }
  #gallery { padding: 20px; inset: 12px; }
  #controlPanel { top: 60px; left: 12px; bottom: 82px; width: min(292px, calc(100vw - 24px)); }
  #topBar { right: 12px; top: 12px; gap: 8px; }
  #bottomBar { left: 12px; right: 12px; bottom: 11px; max-width: none; font-size: 10px; }
  #panelHeader { padding: 15px; }
  #panelContent { padding: 0 15px 12px; }
}
@media (max-width: 680px) and (max-height: 520px) {
  #panelHeader { padding: 10px 15px; }
  #panelHeader .description { display: none; }
  #status { max-height: 56px; }
}
