@import url('../theme.css');

:root { --topbar-h: 64px; font-size: 15px; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 18px; font-weight: 600; letter-spacing: -.4px; }
.topbar { height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px; border-bottom: 1px solid var(--line); background: var(--bg); }
.edition { color: var(--muted); font-size: 13px; font-weight: 400; letter-spacing: 0; margin-left: 8px; }
.header-actions { display: flex; gap: 8px; }
.icon-button, .close-button, .strip-pager button, .pose-pager button { display: grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0; background: var(--raised); border: 1px solid var(--line); border-radius: 8px; font-size: 22px; line-height: 1; transition: background-color 160ms, border-color 160ms; }
.icon-button:hover, .close-button:hover, .strip-pager button:hover, .pose-pager button:hover { background: var(--hover); border-color: var(--control-line); }
button:disabled { opacity: .4; cursor: default; }
.text-button { border: 0; padding: 4px; background: none; color: var(--accent); font-size: 14px; }
.text-button:hover { color: var(--accent-hover); }
.studio { height: calc(100dvh - var(--topbar-h)); min-height: 0; overflow: hidden; }
.workbench { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(0,1fr) auto; grid-template-areas: "stage" "library"; height: 100%; min-height: 0; }
.workbench:has(.pose-section.open) { grid-template-columns: 280px minmax(0,1fr); grid-template-areas: "poses stage" "library library"; }
.workbench:has(.inspector.open) { grid-template-columns: minmax(0,1fr) 300px; grid-template-areas: "stage inspector" "library library"; }
.workbench:has(.pose-section.open):has(.inspector.open) { grid-template-columns: 280px minmax(0,1fr) 300px; grid-template-areas: "poses stage inspector" "library library library"; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 16px; }
.heading-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.count, .mini-label { color: var(--muted); font-size: 12px; }
.stage-panel { grid-area: stage; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); overflow: hidden; }
.stage-toolbar, .stage-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none; height: 52px; padding: 0 16px; }
.stage-tools { display: flex; align-items: center; gap: 6px; }
.stage-tools .button[aria-expanded=true] { border-color: var(--accent); background: var(--selection); }
.live-label { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 14px; font-weight: 600; }
.live-label i { width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--muted); }
.live-label span { font-size: 12px; font-weight: 400; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background-color: var(--stage-clay); background-image: radial-gradient(var(--grid-dark) .8px, transparent .8px); background-size: 24px 24px; color: var(--stage-clay-ink); }
.stage[data-surface=lilac] { background-color: var(--stage-lilac); color: var(--stage-lilac-ink); }
.stage[data-surface=night] { background-color: var(--stage-night); background-image: radial-gradient(var(--grid-light) .8px, transparent .8px); color: var(--stage-night-ink); }
.stage[data-surface=alpha] { background-color: var(--stage-alpha); background-image: conic-gradient(var(--stage-alpha-tile) 25%,transparent 0 50%,var(--stage-alpha-tile) 0 75%,transparent 0); background-size: 24px 24px; color: var(--stage-alpha-ink); }
.stage-top { position: absolute; top: 20px; left: 24px; font-size: 14px; font-weight: 550; }
.stage-watermark, .stage-corner { display: none; }
#mascot-position { position: absolute; left: 50%; top: 53%; touch-action: none; }
.stage-hint { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; font-size: 13px; pointer-events: none; }
.surfaces { display: flex; gap: 4px; }
.swatch { width: 32px; height: 32px; border: 6px solid var(--panel); outline: 1px solid transparent; outline-offset: -2px; border-radius: 50%; padding: 0; }
.swatch:hover { outline-color: var(--control-line); }
.swatch.active { outline-color: var(--accent); }
.paper { background: var(--stage-clay); }
.lilac { background: var(--stage-lilac); }
.night { background: var(--stage-night); }
.alpha { background: conic-gradient(var(--stage-alpha-tile) 25%,var(--stage-alpha) 0 50%,var(--stage-alpha-tile) 0 75%,var(--stage-alpha) 0); background-size: 8px 8px; }
#frame-status { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
#export-png { flex: none; white-space: nowrap; }

.library { grid-area: library; display: flex; flex-direction: column; gap: 6px; min-width: 0; background: var(--bg); border-top: 1px solid var(--line); padding: 10px 16px 6px; }
.library .panel-heading { margin: 0; min-height: 32px; }
.library h2 { font-size: 16px; }
.collection-search { width: 180px; min-width: 0; height: 32px; border: 1px solid var(--control-line); border-radius: 8px; background: var(--panel); padding: 5px 10px; font-size: 13px; }
.collection-search::placeholder { color: var(--muted); }
.strip-pager { display: flex; gap: 4px; }
.strip-pager button { width: 30px; height: 30px; font-size: 18px; }
.collection { display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; overscroll-behavior: contain; padding: 3px 3px 6px; scrollbar-width: thin; scrollbar-color: var(--control-line) transparent; }
.collection-card { width: 112px; flex: none; min-width: 0; padding: 4px 5px 6px; background: var(--panel); border: 1px solid transparent; border-radius: 10px; text-align: center; scroll-margin-inline: 12px; transition: background-color 160ms, border-color 160ms; }
.collection-card:hover { background: var(--raised); border-color: var(--line); }
.collection-card.active { border-color: var(--accent); background: var(--selection); }
.collection-art { height: 64px; display: grid; place-items: center; }
.collection-art img, .collection-art canvas { width: 64px; height: 64px; object-fit: contain; }
.collection-meta strong { display: block; margin-top: 4px; font-size: 13px; font-weight: 500; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.collection-meta small, .collection-meta > span { display: none; }
.collection-empty { padding: 18px 0; color: var(--muted); font-size: 14px; }

.pose-section, .inspector { display: none; min-width: 0; min-height: 0; padding: 16px; background: var(--panel); }
.pose-section.open { grid-area: poses; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.inspector.open { grid-area: inspector; display: flex; flex-direction: column; border-left: 1px solid var(--line); overflow: hidden; }
.pose-tabs, .inspector-tabs { display: flex; gap: 18px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.inspector-tabs { justify-content: space-between; gap: 6px; }
.pose-tabs button, .inspector-tabs button { padding: 0 0 10px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-size: 14px; }
.pose-tabs button:hover, .inspector-tabs button:hover { color: var(--text); }
.pose-tabs button.active, .inspector-tabs button.active { color: var(--accent); border-color: var(--accent); }
.pose-tabs button span { margin-left: 4px; font-size: 11px; }
.pose-gallery { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 5px; align-content: start; flex: 1; min-height: 0; overflow: auto; padding: 3px; }
.gaze-grid { grid-template-columns: repeat(var(--gaze-cols,5),minmax(0,1fr)); }
.pose-card { min-width: 0; border: 1px solid var(--line); border-radius: 7px; padding: 0; background: var(--raised); aspect-ratio: 1; transition: background-color 160ms, border-color 160ms; }
.pose-card:hover { background: var(--hover); }
.pose-card.active { background: var(--selection); border-color: var(--accent); }
.pose-card canvas { width: 100%; height: auto; aspect-ratio: 1; display: block; object-fit: contain; }
.pose-card span { display: none; }
.pose-gallery:not(.gaze-grid) .pose-card { aspect-ratio: auto; }
.pose-gallery:not(.gaze-grid) .pose-card span { display: block; font-size: 11px; padding: 0 2px 6px; text-overflow: ellipsis; overflow: hidden; }
.pose-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; flex: none; color: var(--muted); font-size: 13px; }
.inspector-content:not([hidden]) { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 3px; }
.control-section { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 12px; }
.control-section:last-child { border: 0; }
.label-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.label-row output { color: var(--muted); font-size: 12px; white-space: nowrap; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 18px; cursor: pointer; margin: 0; }
select { width: 100%; padding: 8px; border: 1px solid var(--control-line); background: var(--raised); border-radius: 7px; font-size: 14px; }
.coordinates { display: flex; gap: 14px; margin-top: 8px; }
.coordinates label { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: 12px; }
.coordinates input { min-width: 0; }
.switches { display: flex; flex-direction: column; gap: 12px; }
.switches label { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; }
input[role=switch] { appearance: none; width: 34px; height: 20px; background: var(--control-line); border-radius: 20px; position: relative; margin: 0; cursor: pointer; flex: none; }
input[role=switch]::after { content: ''; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--text); transition: transform 160ms; }
input[role=switch]:checked { background: var(--accent); }
input[role=switch]:checked::after { transform: translateX(14px); background: var(--accent-ink); }
#layer-controls { flex-direction: row; gap: 16px; }
#layer-controls label { flex: 1; }
.preview-reaction { display: flex; gap: 8px; }
.preview-reaction select { min-width: 0; }
#export-settings { flex: none; margin-top: 12px; width: 100%; }
.motion-note { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.motion-preview { width: 100%; margin: 4px 0 8px; }

#neutral-overlay { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .28; pointer-events: none; mix-blend-mode: multiply; }
#anchor-guides { position: absolute; inset: 0; pointer-events: none; }
#anchor-guides::before { content: ''; position: absolute; top: 0; bottom: 0; left: var(--pivot-x); border-left: 1px dashed currentColor; }
#anchor-guides::after { content: ''; position: absolute; left: 0; right: 0; top: var(--pivot-y); border-top: 1px dashed currentColor; }
.loader { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.loader img { grid-area: 1/1; width: min(240px,46vw); height: auto; }
#loader-ghost { opacity: .28; filter: grayscale(.4); }
#loader-fill { clip-path: inset(calc(100% - var(--load,0%)) 0 0 0); transition: clip-path 120ms linear; }
#loader-readout { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 6px 12px; border-radius: 999px; background: var(--bg); color: var(--text); font-size: 13px; white-space: nowrap; }
.stage[data-loading] #mascot-position, .stage[data-loading] .stage-hint { visibility: hidden; }
#notice { position: fixed; top: calc(var(--topbar-h) + 12px); left: 50%; transform: translateX(-50%); z-index: 10; max-width: 80vw; padding: 12px 20px; background: var(--raised); border: 1px solid var(--control-line); border-radius: 9px; font-size: 14px; box-shadow: 0 4px 24px var(--shadow); pointer-events: none; }
#notice:empty { display: none; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; }
dialog:not([open]) { display: none; }
dialog[open] { display: flex; flex-direction: column; width: min(640px,calc(100vw - 32px)); max-height: min(760px,calc(100dvh - 48px)); overflow: hidden; padding: 0; box-shadow: 0 24px 80px var(--shadow); }
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(4px); }
dialog .panel-heading { flex: none; margin: 0; padding: 20px; }
dialog h2 { font-size: 24px; }
dialog .dialog-body { min-height: 0; overflow: auto; padding: 0 20px 20px; }
dialog p { color: var(--muted); font-size: 15px; line-height: 1.5; }
.code-card pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.7; background: var(--bg); padding: 18px; border-radius: 10px; margin: 20px 0; }
.code-card .button { width: 100%; }
.workflow-steps { padding-left: 24px; margin: 12px 0 20px; }
.workflow-steps li { padding: 0 0 17px 8px; }
.workflow-steps strong, .workflow-steps span { display: block; }
.workflow-steps strong { font-size: 18px; margin-bottom: 4px; }
.workflow-steps span { color: var(--muted); line-height: 1.4; }
.workflow-links, .review-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }
.workflow-links a { color: var(--accent); }
.review-check { display: grid; grid-template-columns: 155px 1fr; gap: 12px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.review-check span { color: var(--muted); line-height: 1.4; }
.review-check[data-pass=false] strong { text-decoration: underline dotted; text-underline-offset: 4px; }
#review-results { margin-bottom: 20px; }
#review-results:empty { display: none; }

@media (max-width: 1080px) {
  .studio { height: auto; overflow: visible; }
  .workbench, .workbench:has(.pose-section.open), .workbench:has(.inspector.open), .workbench:has(.pose-section.open):has(.inspector.open) { height: auto; grid-template-columns: minmax(0,1fr); grid-template-rows: auto auto auto auto; grid-template-areas: "stage" "library" "poses" "inspector"; }
  .stage-panel { height: min(58dvh,560px); min-height: 320px; }
  .pose-section.open, .inspector.open { border: 0; border-top: 1px solid var(--line); max-height: min(46dvh,520px); }
  .edition { display: none; }
}
@media (max-width: 540px) {
  .topbar { padding-inline: 12px; gap: 8px; }
  .brand { font-size: 0; gap: 0; }
  .header-actions { gap: 4px; }
  .header-actions .button { padding-inline: 8px; font-size: 12px; }
  .stage-toolbar, .stage-footer { padding-inline: 10px; gap: 6px; }
  .live-label span { display: none; }
  .stage-tools .button { padding-inline: 10px; }
  .collection-search { width: 125px; }
  .heading-actions { gap: 6px; }
  .review-check { grid-template-columns: 1fr; gap: 5px; }
}
@media (prefers-reduced-transparency: reduce) {
  dialog::backdrop { background: var(--bg); backdrop-filter: none; }
}
