:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: #eeedf5;
  background: #11111a;
  --panel: #191924;
  --edge: #2b2a3b;
  --muted: #aaa7bd;
  --accent: #c4adff;
  --accent-solid: #b79aed;
  --mono: ui-monospace, 'SF Mono', Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
h1, h2, h3, p, dl, dd { margin: 0; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .38; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[data-icon] { display: inline-grid; place-items: center; flex: none; }
[data-icon] svg, button svg { width: 17px; height: 17px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.topbar { border-bottom: 1px solid #282635; background: #15151f; }
.topbar-inner, .shell { max-width: 1464px; margin-inline: auto; padding-inline: clamp(18px, 4vw, 60px); }
.topbar-inner { height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; font: 600 23px/1 Georgia, serif; letter-spacing: -.01em; color: inherit; text-decoration: none; }
.brand-mark { width: 37px; height: 37px; color: #e3ca9c; background: #2b2538; border: 1px solid #493955; border-radius: 10px; }
.brand-mark svg { width: 21px; height: 21px; }
.topbar-nav { display: flex; align-items: center; gap: 12px; min-width: 0; }
.project { display: flex; align-items: center; gap: 8px; color: #c5bfd5; background: #1d1c29; border: 1px solid #353246; padding: 7px 11px; border-radius: 8px; font-size: .875rem; white-space: nowrap; text-decoration: none; }
.project:hover, .project[aria-current="page"] { border-color: #55446f; color: #ebddff; }
.current-collection { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .875rem; }
.project svg { width: 15px; height: 15px; color: var(--accent); }
.shell { padding-bottom: 48px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 16px; padding-block: 37px 28px; }
.page-heading h1 { font: 500 clamp(2.45rem, 4.1vw, 3.65rem)/1.04 Georgia, serif; letter-spacing: -.048em; }
.page-heading p { margin-top: 11px; color: var(--muted); line-height: 1.5; }
.sequence-button { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 7px 12px; border: 1px solid #514169; border-radius: 8px; color: #e9d8ff; background: #302640; font-size: .875rem; font-weight: 600; }
.sequence-button:hover { background: #423252; }
#load-status { color: var(--muted); }
.collection-catalog { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.collection-card { --light: 156 121 230; --line: 131 105 189; position: relative; display: flex; flex-direction: column; overflow: hidden; color: inherit; text-decoration: none; border: 1px solid var(--edge); border-radius: 16px; background: var(--panel); }
.collection-card[data-collection="mag"] { --light: 222 91 162; --line: 182 87 148; }
.collection-card[data-collection="ksiega"] { --light: 173 110 215; --line: 155 101 194; }
.collection-card[data-collection="skrzynia"] { --light: 215 158 98; --line: 178 124 81; }
.collection-card[data-collection="miedziany-elf"] { --light: 225 129 81; --line: 170 102 72; }
.collection-card[data-collection="titan"] { --light: 235 151 74; --line: 177 112 73; }
.collection-card:hover { border-color: rgb(var(--line) / .8); background: #211e2d; }
.collection-art { position: relative; display: grid; isolation: isolate; place-items: center; overflow: hidden; height: clamp(215px, 26vw, 356px); border-bottom: 1px solid var(--edge); background: radial-gradient(ellipse at 50% 54%, rgb(var(--light) / .23), transparent 66%), radial-gradient(circle, rgb(var(--line) / .27) 1px, transparent 1px) center / 21px 21px, #13131f; }
.collection-art::before { content: ''; position: absolute; z-index: -1; top: 79%; left: 50%; width: min(51%, 278px); aspect-ratio: 1; transform: translate(-50%, -50%) rotateX(61deg) rotateZ(45deg); border: 1px solid rgb(var(--line) / .51); background: repeating-linear-gradient(rgb(var(--line) / .22) 0 1px, transparent 1px 34px), repeating-linear-gradient(90deg, rgb(var(--line) / .22) 0 1px, transparent 1px 34px), rgb(var(--light) / .06); }
.collection-art canvas { display: block; position: absolute; left: 50%; bottom: 15%; width: min(62%, 327px); height: auto; transform: translateX(-50%); image-rendering: pixelated; }
.collection-card[data-collection="mag"] canvas { width: min(52%, 254px); bottom: 14%; }
.collection-card-body { padding: 19px 22px 21px; flex: 1; }
.collection-card-title { display: flex; align-items: baseline; flex-wrap: wrap; justify-content: space-between; gap: 8px 18px; }
.collection-card-title h2 { font: 500 clamp(1.55rem, 2.6vw, 2.1rem)/1.1 Georgia, serif; letter-spacing: -.02em; }
.collection-count { font: .75rem var(--mono); color: #d4c6ec; }
.collection-card-body p { margin-top: 8px; color: var(--muted); font-size: .875rem; line-height: 1.45; }
.collection-card[data-unavailable] { opacity: .7; }
@media (min-width: 1230px) {
  .collection-catalog { grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); gap: 16px; }
  .collection-art { height: 244px; }
  .collection-card-title h2 { font-size: 1.65rem; }
  .collection-card-body { padding-inline: 16px; }
}
.workspace { display: grid; grid-template-columns: minmax(225px, 266px) minmax(0, 1fr); align-items: start; gap: 18px; }
.panel { min-width: 0; border: 1px solid var(--edge); border-radius: 14px; background: var(--panel); }
.section-heading, .timeline-heading, .info-heading, .asset-heading { display: flex; align-items: center; gap: 10px; }
.library-header { padding: 16px 14px 13px; border-bottom: 1px solid var(--edge); }
.section-heading { padding-inline: 3px; margin-bottom: 13px; justify-content: space-between; }
.section-heading h2, .info-heading h2, .timeline-heading h2 { font-size: 1rem; font-weight: 650; }
.count { padding: 2px 7px; border-radius: 6px; color: #cbc3df; background: #292638; font: .75rem/1.5 var(--mono); }
.search { display: flex; align-items: center; gap: 8px; padding-inline: 10px; background: #14141e; border: 1px solid #302e40; border-radius: 8px; color: var(--muted); }
.search:focus-within { border-color: var(--accent); }
.search input { width: 100%; min-width: 0; height: 37px; background: transparent; border: 0; outline: none; color: #eeedf5; font-size: .875rem; }
.search input::placeholder { color: #a29eb6; }
.category-picker { display: block; position: relative; min-width: 0; margin-top: 8px; }
.category-picker select { width: 100%; height: 34px; padding: 0 29px 0 10px; appearance: none; border: 1px solid #302e40; border-radius: 8px; background: #171622; color: #dcd5e9; font-size: .8125rem; }
.category-picker [data-icon] { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.asset-list { padding: 4px 8px 10px; max-height: 601px; overflow: auto; scrollbar-width: thin; scrollbar-color: #403a51 transparent; }
.asset-group { padding: 13px 1px 0; }
.asset-group h3 { margin: 0 9px 6px; color: var(--muted); font-size: .75rem; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; }
.asset-row { width: 100%; min-width: 0; min-height: 49px; display: flex; align-items: center; gap: 10px; text-align: left; padding: 4px 8px; color: #e5e1ee; border: 1px solid transparent; border-radius: 8px; background: transparent; }
.asset-row:hover { background: #222131; }
.asset-row[aria-current="true"] { background: #302744; border-color: #51416c; color: #f3eaff; }
.asset-thumb { flex: 0 0 36px; height: 36px; border-radius: 6px; border: 1px solid #383245; background: #14131f; overflow: hidden; }
.asset-thumb :is(canvas, img), .frame-thumb :is(canvas, img) { display: block; width: 100%; height: 100%; object-fit: contain; }
.asset-thumb canvas, .frame-thumb canvas { image-rendering: pixelated; }
.asset-label { flex: 1; min-width: 0; font-size: .875rem; font-weight: 580; overflow-wrap: anywhere; }
.asset-number { flex: none; color: var(--muted); font: .75rem var(--mono); }
.asset-row[aria-current="true"] .asset-number { color: var(--accent); }
.empty { padding: 18px 10px; color: var(--muted); font-size: .875rem; }

.editor { min-width: 0; display: grid; gap: 16px; }
.inspect-layout { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) 233px; gap: 16px; align-items: stretch; }
.preview { overflow: hidden; }
.preview-header { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; min-height: 66px; padding: 12px 15px 12px 17px; }
.asset-heading { flex-wrap: wrap; gap: 7px 10px; }
.asset-heading h2 { font-size: 1.2rem; font-weight: 650; line-height: 1.2; }
.tag { color: #d4bdfc; font-size: .75rem; font-weight: 550; padding: 3px 7px; border-radius: 5px; background: #332844; }
.segmented { display: flex; padding: 3px; gap: 2px; border-radius: 8px; border: 1px solid #302d41; background: #14141e; }
.segmented button { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 5px; background: transparent; padding: 5px 8px; color: var(--muted); font-size: .875rem; white-space: nowrap; }
.segmented button[aria-pressed="true"] { background: #302940; color: #efe5ff; }
.segmented button:hover { color: #fff; }
.segmented svg { width: 14px; height: 14px; }

.stage { position: relative; display: grid; place-items: center; isolation: isolate; container-type: size; height: clamp(285px, 30vw, 401px); overflow: hidden; background: #13121e; border-block: 1px solid var(--edge); }
.stage[data-background="grid"] {
  background: radial-gradient(ellipse at 50% 52%, #57426b65, transparent 68%), radial-gradient(circle, #81739a47 1px, transparent 1px) 50% 50% / 20px 20px, #13121e;
}
.stage[data-background="checker"] {
  background: repeating-conic-gradient(#272637 0 25%, #1d1c2a 0 50%) 50% 50% / 24px 24px;
}
.floor { display: none; position: absolute; z-index: -1; top: 76%; left: 50%; width: min(43%, 270px); aspect-ratio: 1; transform: translate(-50%, -50%) rotateX(61deg) rotateZ(45deg); border: 1px solid #ab87e369; background: linear-gradient(#a580cf3d 1px, transparent 1px) 0 0 / 12.5% 12.5%, linear-gradient(90deg, #a580cf3d 1px, transparent 1px) 0 0 / 12.5% 12.5%, #45315d36; box-shadow: 0 0 38px #8465a02b, inset 0 0 36px #8465a03b; }
.stage[data-background="grid"][data-view="frame"] .floor { display: block; }
.stage-tools, .zoom-tools { position: absolute; z-index: 2; display: flex; align-items: center; gap: 5px; right: 11px; }
.stage-tools { top: 11px; }
.zoom-tools { bottom: 11px; gap: 0; }
.tool-button, .zoom-tools button { display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px; background: #1d1a2a; border: 1px solid #3a334d; border-radius: 7px; color: #c9c0dc; }
.tool-button[aria-pressed="true"], .tool-button:hover, .zoom-tools button:hover:not(:disabled) { background: #332744; color: #ede2ff; }
.motion-source { padding-inline: 8px; font-size: .8125rem; }
.zoom-tools button:first-child { border-radius: 7px 0 0 7px; }
.zoom-tools button:last-child { border-radius: 0 7px 7px 0; }
.zoom-tools #zoom-reset { min-width: 54px; border-inline: 0; border-radius: 0; font: .75rem var(--mono); }
.zoom-tools svg { width: 14px; height: 14px; }
.sprite { position: absolute; top: var(--anchor-y, 50%); left: 50%; width: min(91%, 385px); width: min(91cqw, calc(var(--frame-height-limit, 102cqh) * var(--frame-ratio, 1))); aspect-ratio: var(--frame-ratio, 1); transform: translate(var(--translate-x, -50%), var(--translate-y, -50%)) scale(var(--zoom, 1)); transform-origin: var(--origin-x, 50%) var(--origin-y, 50%); }
.workspace:is([data-collection="miedziany-elf"], [data-collection="titan"]) .sprite { --frame-height-limit: 79cqh; }
.stage[data-wide-motion] .sprite { width: min(62cqw, calc(102cqh * var(--frame-ratio, 1))); }
.sprite canvas { position: absolute; top: 0; left: -50%; width: 200%; height: 100%; display: block; image-rendering: pixelated; }
.sprite img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.pivot-marker { position: absolute; left: var(--origin-x); top: var(--origin-y); width: 13px; height: 13px; border: 1px solid #f2cef9; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 0 1px #191321, 0 0 8px #c59bea; }
.pivot-marker::before, .pivot-marker::after { content: ''; position: absolute; background: #f2cef9; inset: 50% -4px auto; height: 1px; }
.pivot-marker::after { inset: -4px auto -4px 50%; width: 1px; height: auto; }
.atlas { display: block; max-width: calc(100% - 24px); max-height: calc(100% - 55px); object-fit: contain; }
.atlas[src$=".png"] { image-rendering: pixelated; }
.preview-error { z-index: 1; padding: 12px; color: #f5d3da; background: #2b1f2c; border-radius: 8px; text-align: center; }

.playback { min-height: 65px; display: flex; align-items: center; gap: 12px; padding: 11px 14px; }
.transport, .playback-options { display: flex; align-items: center; gap: 4px; }
.play-button, .icon-button { display: grid; place-items: center; width: 32px; height: 34px; padding: 0; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #c7bfd9; }
.play-button { width: 37px; height: 36px; margin-right: 2px; background: var(--accent-solid); color: #20152f; }
.play-button:hover:not(:disabled) { background: #d3bcff; }
.icon-button:hover:not(:disabled) { background: #2b2639; }
.loop-button[aria-pressed="true"] { color: var(--accent); background: #342943; border-color: #503c67; }
.scrubber { min-width: 0; flex: 1; display: flex; align-items: center; gap: 10px; }
.scrubber input { min-width: 30px; width: 100%; margin: 0; accent-color: var(--accent-solid); cursor: pointer; }
.scrubber input:disabled { opacity: .4; cursor: default; }
.frame-counter { color: #d4cede; white-space: nowrap; font: .75rem var(--mono); }
.speed { position: relative; }
.speed select { display: block; height: 34px; width: 65px; padding: 0 15px 0 7px; appearance: none; border-radius: 7px; border: 1px solid #383447; background: #201f2c; color: #e3dbee; font-size: .875rem; }
.speed select:disabled { opacity: .42; }
.speed [data-icon] { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); pointer-events: none; color: var(--muted); }
.speed svg { width: 12px; height: 12px; }

.info { padding: 17px 14px; }
.info-heading { padding-inline: 3px; }
.info-heading [data-icon] { color: var(--accent); }
.metadata { padding-block: 8px 10px; margin-top: 8px; border-block: 1px solid var(--edge); }
.metadata > div { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; padding: 9px 3px; }
.metadata dt { color: var(--muted); font-size: .8125rem; }
.metadata dd { color: #eae3f1; font: .75rem var(--mono); white-space: nowrap; }
.info h3 { color: #ccc5da; font-size: .8125rem; font-weight: 600; }
.info-pivot, .source { padding: 16px 3px 0; }
.coordinates { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.coordinates span { padding: 5px 7px; border: 1px solid #383246; border-radius: 5px; color: #d9c7ee; background: #211e30; font: .75rem var(--mono); }
.source a { display: flex; align-items: center; gap: 7px; min-width: 0; border: 1px solid #3b344c; margin-top: 8px; padding: 8px 7px; border-radius: 7px; background: #201e2c; color: #e1cfff; text-decoration: none; font: .75rem var(--mono); }
.source a:hover { border-color: #aa87d6; }
.source a svg { width: 14px; height: 14px; }
#source-name { flex: 1; overflow-wrap: anywhere; }
.timeline { padding: 13px 15px 14px; }
.timeline-heading { justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.key-hint { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: .75rem; }
kbd { padding: 1px 5px; border: 1px solid #3a3549; border-radius: 4px; background: #242232; font: .75rem var(--mono); }
.timeline-frames { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: #403a51 transparent; padding: 3px; margin: -3px; }
.frame-button { flex: 0 0 clamp(61px, 6.2vw, 86px); display: grid; gap: 4px; padding: 4px 4px 5px; border: 1px solid #353145; border-radius: 8px; color: #bfb7d0; background: #171622; font: .75rem var(--mono); }
.frame-button:hover { border-color: #80699b; }
.frame-button[aria-current="true"] { color: #ebd9ff; border-color: #b393e8; background: #392c50; }
.frame-button[data-phase] { flex-basis: 108px; }
.frame-thumb { display: block; height: 52px; background: radial-gradient(ellipse at center, #37294073, transparent 80%), #13121d; border-radius: 5px; }

@media (max-width: 1110px) {
  .workspace { grid-template-columns: 214px minmax(0, 1fr); gap: 13px; }
  .inspect-layout, .editor { gap: 13px; }
  .inspect-layout { grid-template-columns: minmax(0, 1fr) 194px; }
  .playback { gap: 8px; padding-inline: 9px; }
}
@media (max-width: 940px) {
  .inspect-layout { display: contents; }
  .preview { grid-row: 1; }
  .timeline { grid-row: 2; }
  .info { grid-row: 3; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
  .info-heading, .metadata { grid-column: 1 / -1; }
  .metadata { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
}
@media (max-width: 640px) {
  .topbar-inner { height: 58px; }
  .page-heading { padding-block: 26px 20px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .collection-catalog { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .collection-art canvas { width: min(54%, 244px); }
  .collection-card[data-collection="mag"] canvas { width: min(44%, 195px); }
  .library-header { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; padding: 10px 12px; }
  .section-heading { grid-column: 1 / -1; justify-content: start; margin: 0; }
  .search { min-width: 0; }
  .category-picker { margin-top: 0; }
  .direction-picker { grid-column: 1 / -1; }
  .category-picker select { height: 39px; }
  .asset-list { display: flex; align-items: flex-start; gap: 12px; overflow: auto; max-height: none; }
  .asset-group { display: flex; flex-wrap: wrap; align-items: center; width: max-content; flex: 0 0 auto; gap: 4px; padding-top: 8px; }
  .asset-group h3 { flex-basis: 100%; margin-left: 3px; }
  .asset-row { width: auto; min-height: 33px; gap: 5px; padding: 3px 5px; }
  .asset-thumb { flex-basis: 24px; height: 24px; }
  .asset-number { display: none; }
  .stage { height: 320px; }
  .key-hint { display: none; }
}
@media (max-width: 400px) {
  .topbar-nav { gap: 6px; }
  .current-collection { display: none; }
  .preview-header { padding-inline: 10px; }
  .stage { height: 260px; }
  .playback { flex-wrap: wrap; }
  .scrubber { flex-basis: 100%; order: 1; }
  .playback-options { margin-left: auto; }
  .metadata { display: block; }
}
