/* Color tokens live in theme.css (loaded before this file). This file uses
   var(--token) only - no hardcoded colors - so the theme is swappable there. */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

a {
    color: var(--accent);
    text-decoration: none;
}

/* Readable pixel-art display font, used for the left menu labels only. */
@font-face {
    font-family: "Pixelify Sans";
    src: url("/fonts/pixelify-sans-latin.woff2") format("woff2");
    font-weight: 400 700;
    font-style: normal;
    font-display: swap;
}

/* App shell: persistent left sidebar + an iframe that holds the active view, so
   navigating swaps only the iframe and the menu never reloads. */
body.shell {
    height: 100vh;
    overflow: hidden;
}

/* Persistent left sidebar, always expanded, docked beside the view (no overlay). */
.view-frame {
    position: fixed;
    left: 208px;
    top: 0;
    height: 100vh;
    width: calc(100vw - 208px);
    border: 0;
    background: var(--bg);
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    width: 208px;
    height: 100vh;
    background: var(--panel);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 8px 7px;
    gap: 3px;
}

/* Home + search + filters stay pinned while the mobble list scrolls under them.
   The negative margin / matching padding cancels the sidebar's own 8px/7px padding
   so the stuck header sits flush and no list rows peek through above or beside it. */
.sb-top {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--panel);
    margin: -8px -7px 0;
    padding: 8px 7px 0;
}

.sb-search {
    display: block;
}

.sb-filter {
    display: flex;
}

.sb-home {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border-radius: 7px;
    font-family: "Pixelify Sans", sans-serif;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.3px;
    color: var(--text);
    margin-bottom: 4px;
}

.sb-home-icon {
    font-size: 16px;
    line-height: 1;
}

.sb-home:hover,
.sb-item:hover {
    background: var(--panel2);
}

.sb-home.active,
.sb-item.active {
    background: var(--accent);
    color: var(--on-accent);
}

.sb-search {
    width: 100%;
    box-sizing: border-box;
    margin: 2px 0 6px;
    padding: 6px 9px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel2);
    color: inherit;
    font-size: 13px;
}

.sb-search:focus {
    outline: none;
    border-color: var(--accent);
}

.sb-filter {
    display: flex;
    gap: 4px;
    padding: 2px 2px 6px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.sb-filter-btn {
    flex: 1 1 0;
    background: var(--panel2);
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 6px;
    padding: 4px 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    cursor: pointer;
}

.sb-filter-btn.active {
    background: var(--accent);
    color: var(--on-accent);
    border-color: var(--accent);
}

.sb-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.sb-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 3px 8px;
    border-radius: 7px;
    color: var(--text);
}

.sb-thumb {
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sb-thumb img {
    max-width: 24px;
    max-height: 24px;
    image-rendering: pixelated;
}

.sb-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: "Pixelify Sans", sans-serif;
    font-weight: 500;
    font-size: 15px;
    letter-spacing: 0.2px;
}

.sb-tag {
    flex: 0 0 auto;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 1px 4px;
    border-radius: 3px;
}

.sb-tag.gen1 {
    background: var(--tag-png-bg);
    color: var(--tag-png-fg);
}

.sb-tag.gen2 {
    background: var(--tag-spine-bg);
    color: var(--tag-spine-fg);
}

.sb-id {
    flex: 0 0 auto;
    font-size: 10px;
    color: var(--muted);
    opacity: 0.8;
}

.sb-item.active .sb-id {
    color: var(--on-accent);
    opacity: 0.7;
}

/* Per-mobble completeness badge: green check = complete, neutral checked box =
   all posings present but still missing sounds/portraits/etc, empty box = a posing
   is missing. Hovering a non-complete badge shows what's missing. */
.sb-status {
    flex: 0 0 auto;
    font-size: 14px;
    line-height: 1;
}

.sb-status::before {
    content: "";
}

.sb-status-complete::before {
    content: "✅";
}

.sb-status-partial::before {
    content: "☑";
    color: var(--muted);
}

.sb-status-empty::before {
    content: "☐";
    color: var(--muted);
}

.sb-status-partial,
.sb-status-empty {
    cursor: help;
}

.sb-missing-pop {
    position: fixed;
    z-index: 1000;
    max-width: 240px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.18);
    padding: 8px 10px;
    font-size: 12px;
    pointer-events: none;
}

.sb-missing-pop .smp-title {
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 10px;
}

.sb-missing-pop ul {
    margin: 0;
    padding-left: 14px;
}

.sb-missing-pop li {
    margin: 1px 0;
}

.sb-count {
    flex: 0 0 auto;
    font-size: 10px;
    font-weight: 700;
    color: var(--muted);
    padding: 1px 6px;
    border-radius: 99px;
    background: var(--panel2);
}

.sb-item.active .sb-count {
    background: rgba(255, 255, 255, 0.25);
    color: var(--on-accent);
}

.sb-count.complete {
    background: var(--green);
    color: var(--on-green);
}

/* simple dashboard */
.dash {
    padding: 24px;
}

.dash-cards {
    display: flex;
    gap: 16px;
    margin: 16px 0;
    flex-wrap: wrap;
}

.dash-card {
    display: block;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 24px;
    min-width: 120px;
    text-decoration: none;
    color: inherit;
}

.dash-card .num {
    font-size: 30px;
    font-weight: 800;
}

.dash-card .lbl {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.dash-card.clickable {
    cursor: pointer;
    transition: border-color 0.15s;
}

.dash-card.clickable:hover {
    border-color: var(--accent);
}

/* Homepage: pixel-art display font on the title + card labels, matching the left menu. */
body.home .topbar h1,
body.home .dash h2,
body.home .dash-card .lbl {
    font-family: "Pixelify Sans", sans-serif;
}

/* Numbers are unreadable in the pixel font - keep the stat counts on a clean sans. */
body.home .dash-card .num {
    font-family: Roboto, -apple-system, "Segoe UI", sans-serif;
}

/* Fred haunting the bottom-right corner like a ghost, gazing across toward the left
   menu. Decorative only - very faint, never intercepts clicks, sits under the content. */
.home-fred {
    position: fixed;
    right: 0;
    bottom: 0;
    height: 330px;
    width: auto;
    z-index: 0;
    opacity: 0.18;
    pointer-events: none;
    user-select: none;
}

/* "needs grid art" drilldown list */
.gridneed-h {
    margin: 20px 0 8px;
}

.gridneed-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 720px;
}

.gridneed-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
}

.gridneed-item:hover {
    border-color: var(--accent);
}

.gridneed-thumb {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gridneed-thumb img {
    max-width: 32px;
    max-height: 32px;
    image-rendering: pixelated;
}

.gridneed-name {
    flex: 1 1 auto;
    font-weight: 600;
}

.gridneed-id {
    color: var(--muted);
    font-weight: 400;
    font-size: 12px;
}

.gridneed-tag {
    flex: 0 0 auto;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
}

.gridneed-tag.gen1 {
    background: var(--tag-png-bg);
    color: var(--tag-png-fg);
}

.gridneed-tag.gen2 {
    background: var(--tag-spine-bg);
    color: var(--tag-spine-fg);
}

.gridneed-missing {
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--red);
}

.gridneed-count {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
}

/* "missing elements" page list */
.miss-wrap {
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-width: 480px;
}

.miss-group-h {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 6px;
}

.miss-row {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    margin-bottom: 4px;
    overflow: hidden;
}

.miss-row-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 5px 10px;
    cursor: pointer;
}

.miss-row-head:hover {
    background: var(--panel2);
}

.miss-chevron {
    flex: 0 0 auto;
    font-size: 11px;
    color: var(--muted);
    transition: transform 0.12s;
}

.miss-row.open .miss-chevron {
    transform: rotate(90deg);
}

.miss-mobbles {
    display: flex;
    flex-direction: column;
    padding: 2px 0 4px;
    border-top: 1px solid var(--border);
}

.miss-mob {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 5px 12px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--border);
}

.miss-mob:last-child {
    border-bottom: none;
}

.miss-mob:hover {
    background: var(--panel2);
}

.miss-mid {
    margin-left: auto;
    color: var(--muted);
    font-size: 11px;
}

.miss-row.optional {
    opacity: 0.6;
}

.miss-count {
    flex: 0 0 auto;
    min-width: 34px;
    text-align: right;
    font-weight: 800;
    font-size: 16px;
    color: var(--red);
}

.miss-row.optional .miss-count {
    color: var(--muted);
}

.miss-label {
    flex: 1 1 auto;
}

.miss-total {
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--muted);
}

header.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

header.topbar h1 {
    font-size: 18px;
    margin: 0;
}

.spacer {
    flex: 1;
}

.role-badge {
    background: var(--panel2);
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 4px 12px;
    font-size: 12px;
    color: var(--muted);
}

button,
.btn {
    background: var(--accent);
    color: var(--on-accent);
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
}

button.secondary {
    background: var(--panel2);
    border: 1px solid var(--border);
    color: var(--text);
}

button.green {
    background: var(--green);
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

input,
select {
    background: var(--panel2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 7px 9px;
    font-size: 13px;
}

input[type="number"] {
    width: 72px;
}

label {
    color: var(--muted);
    font-size: 12px;
    display: block;
    margin-bottom: 4px;
}

/* login */
.login-body {
    min-height: 100vh;
    overflow: hidden;
}

.login-bg {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

.login-wrap {
    position: relative;
    z-index: 1;
    max-width: 340px;
    margin: 12vh auto;
    background: color-mix(in srgb, var(--panel) 82%, transparent);
    backdrop-filter: blur(6px);
    padding: 28px;
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.login-logo {
    display: block;
    width: 200px;
    max-width: 80%;
    height: auto;
    margin: 0 auto 6px;
}

.login-sub {
    margin: 0 0 20px;
    text-align: center;
    font-size: 13px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--muted);
}

.login-wrap input {
    width: 100%;
    margin-bottom: 12px;
}

.login-wrap button {
    width: 100%;
}

.err {
    color: var(--red);
    font-size: 13px;
    min-height: 18px;
}

/* grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    padding: 24px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s;
}

.card:hover {
    border-color: var(--accent);
}

.card .thumb {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.card .thumb img {
    max-height: 120px;
    max-width: 100%;
}

.card .name {
    font-weight: 600;
}

.card .meta {
    color: var(--muted);
    font-size: 12px;
}

.tag {
    display: inline-block;
    font-size: 10px;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--panel2);
    color: var(--muted);
    letter-spacing: 0.5px;
}

.tag.gen2 {
    background: var(--tag-spine-bg);
    color: var(--tag-spine-fg);
}

.tag.gen1 {
    background: var(--tag-png-bg);
    color: var(--tag-png-fg);
}

/* detail layout */
.tabbar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 16px 20px 0;
    align-items: center;
    justify-content: center;
}

.tabbar .sep {
    width: 1px;
    height: 22px;
    background: var(--border);
    margin: 0 4px;
}

.tabbar button {
    background: var(--panel2);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 500;
    text-transform: capitalize;
}

.tabbar button.active {
    background: var(--accent);
    border-color: var(--accent);
}

.content-host {
    padding: 16px 20px 40px;
    max-width: 720px;
    margin: 0 auto;
}

.content-host .tab-panel {
    display: none;
}

.content-host .tab-panel.active {
    display: block;
}

.section-back {
    display: inline-block;
    margin-bottom: 14px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 18px;
}

.panel h3 {
    margin: 0 0 12px;
    font-size: 14px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.stage {
    position: relative;
    width: 420px;
    height: 420px;
    margin: 0 auto;
    background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 28px 28px;
    border-radius: 10px;
    overflow: hidden;
}

.stage canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.stage-pause {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 5;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 12px;
    line-height: 1;
    border-radius: 8px;
    opacity: 0.85;
}

.stage-pause:hover {
    opacity: 1;
}

/* stage + side control column */
.stage-wrap {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    justify-content: center;
}

.stage-wrap .stage {
    margin: 0;
}

/* control column beside the frame (fps / loops / pause / play-once / mute) */
.stage-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    min-width: 132px;
    background: var(--panel2);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 11px;
}

.stage-controls label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin: 0;
    color: var(--muted);
    font-size: 11px;
}

.stage-controls input {
    width: 48px;
    padding: 3px 5px;
    font-size: 12px;
}

.stage-controls .sc-buttons {
    display: flex;
    gap: 5px;
}

.stage-controls .sc-buttons button {
    flex: 1;
    padding: 4px 6px;
    font-size: 11px;
}


.overlay {
    position: absolute;
    inset: 0;
}

.marker {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: grab;
    user-select: none;
}

.marker .dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--on-accent);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5);
}

.marker .lbl {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    white-space: nowrap;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    padding: 1px 5px;
    border-radius: 4px;
}

.marker.mouth .dot {
    background: var(--orange);
}

.bubble-sprite {
    display: block;
    pointer-events: none;
}

.shadow-ellipse {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: ew-resize;
    outline: 1px dashed rgba(78, 201, 122, 0.45);
}

.shadow-sprite {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.floor-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 12px;
    transform: translateY(-50%);
    cursor: ns-resize;
}

.floor-line::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    border-top: 2px dashed var(--floor);
}

.floor-line .floor-lbl {
    position: absolute;
    left: 8px;
    top: -16px;
    font-size: 10px;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    padding: 1px 5px;
    border-radius: 4px;
}

.shadow-handle {
    position: absolute;
    right: -6px;
    bottom: -6px;
    width: 12px;
    height: 12px;
    background: var(--green);
    border-radius: 50%;
    cursor: nwse-resize;
}

.row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.posing-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.posing-tabs button {
    background: var(--panel2);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 500;
    text-transform: capitalize;
}

.posing-tabs button.active {
    background: var(--accent);
    border-color: var(--accent);
}

.sound-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}

.hint {
    color: var(--muted);
    font-size: 12px;
    margin: 4px 0 10px;
}

.crop-sources {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.crop-sources button {
    background: var(--panel2);
    border: 1px solid var(--border);
    color: var(--text);
}

.crop-sources button.active {
    border-color: var(--accent);
}

.crop-stage {
    position: relative;
    width: 360px;
    max-width: 100%;
    margin: 0 auto;
    background: var(--checker-b);
    border-radius: 8px;
    overflow: hidden;
}

.crop-stage img {
    display: block;
    width: 100%;
}

.crop-box {
    position: absolute;
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
    cursor: move;
}

.crop-box .ch {
    position: absolute;
    right: -7px;
    bottom: -7px;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 3px;
    cursor: nwse-resize;
}

.portrait-previews {
    display: flex;
    gap: 14px;
    margin: 0 0 14px;
    justify-content: center;
}

.portrait-previews .pv {
    text-align: center;
    cursor: pointer;
}

.portrait-previews .pv img {
    transition: border-color 0.15s;
}

.portrait-previews .pv.active img {
    border-color: var(--accent);
}

.portrait-previews .pv.active .meta {
    color: var(--accent);
}

.portrait-previews img {
    width: 90px;
    height: 90px;
    object-fit: contain;
    background: var(--panel2);
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* ---- dressed outfit portrait previews (same crop, live) ---- */
.portrait-outfit-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin: 6px 0 14px;
}

.portrait-outfit-row .pof-lbl {
    width: 100%;
    font-size: 12px;
    color: var(--muted);
}

.pof-tile {
    position: relative;
    text-align: center;
}

.pof-tile canvas {
    width: 80px;
    height: 80px;
    background: var(--panel2);
    border-radius: 8px;
    border: 1px solid var(--border);
    display: block;
}

.pof-tile.pof-empty canvas {
    opacity: 0.25;
}

.pof-tile .pof-name {
    margin-top: 3px;
    font-size: 11px;
    max-width: 82px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pof-tile .pof-check {
    position: absolute;
    top: 3px;
    right: 4px;
    font-size: 9px;
    font-weight: 800;
    color: var(--accent);
}

.seq-input {
    width: 100%;
    min-height: 56px;
    resize: vertical;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: 0.5px;
}

/* visual frame-sequence builder */
.fb-row {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 6px;
    margin-bottom: 12px;
    background: var(--panel2);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.fb-row.fb-seq {
    min-height: 92px;
}

.fb-row.fb-seq:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent);
}

.fb-seq:empty::after {
    content: "Drag reference frames here, or click one above";
    color: var(--muted);
    font-size: 12px;
    margin: auto;
}

.fb-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.fb-toolbar-btns {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

.fb-tile {
    position: relative;
    flex: 0 0 auto;
    width: 76px;
    height: 76px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 10px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
}

.fb-tile img {
    max-width: 100%;
    max-height: 100%;
    pointer-events: none;
}

.fb-tile .fb-num {
    position: absolute;
    bottom: 0;
    right: 2px;
    font-size: 9px;
    color: var(--text);
    background: var(--panel);
    padding: 0 2px;
    border-radius: 3px;
    opacity: 0.85;
    pointer-events: none;
}

.fb-tile.fb-over {
    box-shadow: inset 3px 0 0 var(--accent);
}

.fb-endzone {
    flex: 0 0 auto;
    width: 28px;
    align-self: stretch;
    min-height: 76px;
    border: 2px dashed var(--border);
    border-radius: 6px;
}

.fb-endzone.fb-over {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 2px var(--accent);
}

.fb-seqtile.fb-sel {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
}

.fb-seqtile .fb-rm,
.fb-seqtile .fb-dup {
    position: absolute;
    top: 2px;
    width: 18px;
    height: 18px;
    padding: 0;
    font-size: 10px;
    line-height: 1;
    border-radius: 4px;
    display: none;
}

.fb-seqtile .fb-rm {
    right: 2px;
    background: var(--red);
    color: var(--on-accent);
}

.fb-seqtile .fb-dup {
    left: 2px;
    background: var(--accent);
    color: var(--on-accent);
}

.fb-seqtile:hover .fb-rm,
.fb-seqtile:hover .fb-dup {
    display: block;
}

/* per-step sound badge */
.fb-snd-badge {
    position: absolute;
    bottom: 1px;
    left: 2px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
    line-height: 16px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--on-accent);
    border: none;
    cursor: pointer;
}

/* spine event boxes */
.fb-event {
    position: relative;
    flex: 0 0 auto;
    min-width: 86px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel2);
    text-align: center;
    cursor: pointer;
}

.fb-event-name {
    font-weight: 600;
    font-size: 13px;
    text-transform: capitalize;
}

.fb-event-time {
    font-size: 10px;
    color: var(--muted);
    margin-top: 2px;
}

.fb-event-snd {
    font-size: 10px;
    color: var(--accent);
    margin-top: 5px;
}

.fb-event-nomatch {
    opacity: 0.6;
    cursor: default;
}

.fb-event-nomatch .fb-event-snd {
    color: var(--muted);
}

/* sound pool chips */
.fb-pool {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 6px 0 4px;
}

.fb-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px 4px 4px;
    background: var(--panel2);
    border: 1px solid var(--border);
    border-radius: 99px;
    font-size: 12px;
    cursor: grab;
    user-select: none;
}

.fb-chip span {
    color: var(--text);
}

.fb-chip-play {
    width: 22px;
    height: 22px;
    padding: 0;
    border-radius: 50%;
    font-size: 9px;
}

.fb-chip-upload {
    cursor: pointer;
    color: var(--muted);
    border-style: dashed;
    padding: 6px 12px;
}

/* per-step sound popover */
.fb-sound-pop {
    position: fixed;
    z-index: 50;
    min-width: 190px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    padding: 8px;
}

.fb-pop-title {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 6px;
}

.fb-pop-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.fb-pop-row span {
    flex: 1;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fb-pop-row button {
    width: 26px;
    height: 24px;
    padding: 0;
    font-size: 10px;
}

.filmstrip {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 12px;
}

.filmstrip .frame {
    width: 54px;
}

.filmstrip .thumb {
    width: 54px;
    height: 54px;
    background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 12px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.filmstrip .thumb img {
    max-width: 100%;
    max-height: 100%;
}

.filmstrip .frame .n {
    text-align: center;
    font-size: 10px;
    color: var(--muted);
    margin-top: 2px;
}

.locked {
    opacity: 0.55;
    pointer-events: none;
}

/* resource summary page */
.summary {
    padding: 18px 20px 56px;
    max-width: 1160px;
    margin: 0 auto;
}

.summary-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 6px;
}

.summary-head img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    background: var(--panel2);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.summary-head h2 {
    margin: 0;
    font-size: 20px;
}

/* arcade-style mobble name */
.mob-name {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 26px;
    font-weight: 800;
    color: var(--text);
    text-shadow: 2px 2px 0 var(--shadow), 3px 3px 0 var(--accent);
}

.mob-id {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 12px;
    color: var(--muted);
    background: var(--panel2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    vertical-align: middle;
    margin-left: 6px;
}

.summary-bar {
    margin-top: 8px;
}

.summary-frac {
    font-size: 22px;
    font-weight: 700;
}

.summary-frac.complete {
    color: var(--green);
}

.summary-frac.partial {
    color: var(--orange);
}

/* labeled summary rows: title on the left, tiles flowing on the right */
.summary-row {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    padding: 16px 0;
    border-top: 1px solid var(--border);
}

.summary-row:first-of-type {
    border-top: none;
}

.row-label {
    flex: 0 0 96px;
    padding-top: 8px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
    font-weight: 600;
    font-size: 14px;
}

.row-count {
    padding: 3px 11px;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 700;
    background: var(--panel2);
    border: 1px solid var(--border);
    color: var(--muted);
}

.row-count.complete {
    background: var(--green);
    border-color: var(--green);
    color: var(--on-green);
}

.row-items {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    gap: 12px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    align-items: flex-start;
}

.tile-opt {
    color: var(--muted);
    font-size: 10px;
}

.resource-section {
    margin-top: 24px;
}

.resource-section h3 {
    margin: 0 0 12px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.resource-section .grp-count {
    color: var(--muted);
    font-weight: 500;
    font-size: 12px;
}

.resource-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.resource-tile {
    width: 112px;
    height: 132px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--panel);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    position: relative;
}

.resource-tile .thumb {
    width: 84px;
    height: 84px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* outfit "try-on": dressed frame overlaid on the base posing; dim poses w/o an outfit */
.posing-outfit-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
    pointer-events: none;
}

.resource-tile.dimmed {
    opacity: 0.3;
}

.sum-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: zoom-out;
}

.sum-lightbox-inner {
    padding: 10px;
    border-radius: 12px;
}

.sum-lightbox-inner.checker {
    background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 22px 22px;
}

.sum-lightbox img {
    max-width: 70vw;
    max-height: 80vh;
    display: block;
}

.sum-lightbox-cap {
    text-align: center;
    color: #fff;
    font-size: 12px;
    margin-top: 8px;
    text-shadow: 0 1px 3px #000;
}

.outfit-tryon {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 6px 0 14px;
}

.outfit-tryon-lbl {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    margin-right: 2px;
}

.outfit-tryon-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px 4px 5px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
}

.outfit-tryon-btn img {
    width: 30px;
    height: 30px;
    object-fit: contain;
    border-radius: 6px;
    background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 8px 8px;
}

.outfit-tryon-btn:hover {
    border-color: var(--accent);
}

.outfit-tryon-btn.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent) inset;
}

/* transparency checkerboard behind posing/portrait/facebook thumbnails */
.resource-tile .thumb.checker {
    background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 12px 12px;
    border-radius: 8px;
}

.resource-tile .thumb canvas,
.resource-tile .thumb img {
    max-width: 100%;
    max-height: 100%;
}

.stage.checker {
    background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 22px 22px;
}

/* ---- AI back-posing popup ---- */
.ai-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 16px;
    z-index: 1000;
    overflow-y: auto;
}

.ai-modal {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 1040px;
    max-width: 96vw;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.ai-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.ai-head h3 {
    margin: 0;
    font-size: 16px;
}

.ai-x {
    background: none;
    border: 0;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
}

.ai-body {
    padding: 16px 18px;
}

.ai-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin: 14px 0 6px;
}

.ai-select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
}

.ai-castrow {
    display: flex;
    gap: 10px;
    align-items: center;
}

.ai-cast-custom {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
}

.ai-refs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.ai-ref {
    width: 110px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    text-align: center;
    background: var(--panel2);
}

.ai-ref.draft {
    border-color: var(--accent);
}

.ai-ref-thumb {
    height: 84px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 12px 12px;
    border-radius: 6px;
    overflow: hidden;
}

.ai-ref-thumb img {
    max-width: 100%;
    max-height: 84px;
}

.ai-ref-label {
    font-size: 10px;
    color: var(--muted);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-mini-btn {
    margin-top: 5px;
    font-size: 11px;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel);
    cursor: pointer;
    color: var(--text);
}

.ai-prompt {
    width: 100%;
    min-height: 130px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    font-family: ui-monospace, Menlo, monospace;
    font-size: 12px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
}

.ai-genrow {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.ai-improve-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0 2px;
}

.ai-results {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 14px;
}

.ai-cand {
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 4px;
    cursor: pointer;
    background: var(--panel2);
}

.ai-cand.selected {
    border-color: var(--accent);
}

.ai-cand-img {
    position: relative;
}

.ai-cand-tag {
    position: absolute;
    bottom: 4px;
    left: 4px;
    font-size: 9px;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 99px;
    background: rgba(70, 180, 90, 0.92);
    color: #fff;
}

.ai-cand.err {
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

.ai-cand-err {
    font-size: 11px;
    color: var(--red, #c0392b);
    text-align: center;
    padding: 8px;
}

.ai-cand-img {
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-cand-img.checker {
    background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 14px 14px;
}

.ai-cand-img img {
    width: 100%;
    display: block;
}

.ai-foot {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
}

/* outfit studio - selector */
.outfit-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 8px 0 14px;
}

.outfit-chip {
    position: relative;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 9px 5px 5px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    background: var(--panel);
}

.outfit-chip:hover {
    border-color: var(--accent);
}

.outfit-chip.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent) inset;
}

.outfit-chip img {
    width: 34px;
    height: 30px;
    object-fit: contain;
    border-radius: 6px;
    background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 8px 8px;
}

.outfit-chip-name {
    font-size: 13px;
    font-weight: 600;
}

.outfit-chip-badge {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1px 5px;
    border-radius: 4px;
    font-weight: 700;
}

.outfit-chip-badge.imported {
    background: var(--tag-png-bg);
    color: var(--tag-png-fg);
}

.outfit-chip-badge.ai {
    background: var(--tag-spine-bg);
    color: var(--tag-spine-fg);
}

.outfit-chip-del {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 15px;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
}

.outfit-chip-del:hover {
    color: var(--red);
}

.outfit-newchip {
    background: var(--panel2);
    border: 1px dashed var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: 6px 12px;
    font-weight: 600;
    cursor: pointer;
}

/* imported outfit - read-only dressed posings */
.outfit-impgrid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.outfit-imptile {
    position: relative;
    width: 120px;
    height: 140px;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overflow: hidden;
}

.outfit-imptile.checker {
    background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 12px 12px;
}

.outfit-imptile img {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

.outfit-impname {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 10px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    padding: 2px 0;
}

/* outfit studio */
.outfit-sheetwrap {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin: 6px 0 14px;
}

.outfit-sheetctl {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.outfit-brief {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

.outfit-sheet {
    flex: 0 0 260px;
    width: 260px;
    height: 260px;
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.outfit-sheet.checker {
    background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 14px 14px;
}

.outfit-sheet img {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

.outfit-refbox {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 6px 0 10px;
    padding: 10px 12px;
    border: 1px dashed var(--border);
    border-radius: 10px;
    color: var(--muted);
}

.outfit-refbox.on {
    border-style: solid;
    border-color: var(--green);
    background: color-mix(in srgb, var(--green) 8%, transparent);
    color: var(--text);
}

.outfit-refbox img {
    width: 56px;
    height: 64px;
    object-fit: contain;
    border-radius: 8px;
    background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 10px 10px;
}

.outfit-reftext {
    flex: 1 1 auto;
    font-size: 13px;
    line-height: 1.4;
}

.outfit-apwrap {
    margin: 6px 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    background: var(--panel);
}

.outfit-apwrap > summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
}

.outfit-apprompt {
    width: 100%;
    margin-top: 8px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 12px;
    line-height: 1.5;
    resize: vertical;
    opacity: 0.85;
}

.outfit-frames {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.outfit-frow {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.outfit-fthumb {
    flex: 0 0 96px;
    width: 96px;
    height: 110px;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overflow: hidden;
}

.outfit-fthumb.applied {
    border-color: var(--ok, #3ba55d);
    box-shadow: 0 0 0 2px var(--ok, #3ba55d) inset;
}

.outfit-fthumb img {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

.outfit-fmid {
    flex: 0 0 130px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.outfit-flabel {
    font-size: 12px;
    font-weight: 700;
    text-transform: capitalize;
    color: var(--muted);
}

.outfit-cands {
    flex: 1 1 auto;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.outfit-cand {
    position: relative;
    width: 96px;
    height: 110px;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
}

.outfit-cand.checker {
    background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 12px 12px;
}

.outfit-cand:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent) inset;
}

.outfit-cand img {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

.outfit-cand.err {
    align-items: center;
    font-size: 11px;
    color: var(--danger, #d9534f);
    cursor: default;
    padding: 4px;
    text-align: center;
}

.outfit-cand.saving {
    opacity: 0.5;
}

.outfit-regen {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 22px;
    height: 22px;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 13px;
    line-height: 22px;
    cursor: pointer;
}

.outfit-regen:hover {
    background: var(--accent);
}

/* facebook icon generator */
.fb-stage {
    position: relative;
    margin: 10px auto;
    border-radius: 10px;
    overflow: hidden;
    background: var(--panel2);
}

.fb-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.fb-pose {
    position: absolute;
    cursor: move;
    outline: 1px dashed rgba(255, 255, 255, 0.75);
}

.fb-pose img,
.fb-pose canvas {
    display: block;
    width: 100%;
    pointer-events: none;
}

.fb-handle {
    position: absolute;
    right: -7px;
    bottom: -7px;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 3px;
    cursor: nwse-resize;
}

.fb-ctrl {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px auto 2px;
    max-width: 460px;
}

.fb-ctrl input[type="range"] {
    flex: 1;
}

.fb-ctrl .hint {
    min-width: 38px;
    text-align: right;
}

/* ---- Tools hub page ---- */
.tools {
    padding: 16px 20px;
}

.tool-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 12px;
}

.tool-card {
    display: block;
    width: 280px;
    padding: 18px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--panel);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, transform 0.1s;
}

.tool-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.tool-card .tool-icon {
    font-size: 30px;
}

.tool-card .tool-name {
    font-weight: 800;
    font-size: 16px;
    margin: 6px 0 4px;
}

.tool-card .tool-desc {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.45;
}

/* ---- Back-stand AI batch page ---- */
.bb-controls {
    margin: 6px 16px 10px;
}

.bb-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
}

.bb-progress {
    font-weight: 700;
    color: var(--accent);
}

.bb-list {
    margin: 8px 16px 60px;
}

.bb-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

.bb-row.bb-saved {
    background: rgba(70, 180, 90, 0.08);
}

.bb-thumb {
    width: 56px;
    height: 56px;
    flex: 0 0 56px;
    border-radius: 8px;
    overflow: hidden;
    display: block;
}

.bb-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.bb-name {
    flex: 0 0 180px;
    font-weight: 700;
}

.bb-name .bb-id {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

.bb-gen {
    flex: 0 0 auto;
}

.bb-cands {
    display: flex;
    gap: 8px;
    flex: 1 1 auto;
    flex-wrap: wrap;
}

.bb-cand {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
}

.bb-cand img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.bb-cand:hover {
    border-color: var(--muted);
}

.bb-cand.bb-sel {
    border-color: var(--accent);
}

.bb-status {
    flex: 0 0 150px;
    text-align: right;
}

.bb-done {
    max-width: 520px;
    margin: 80px auto;
    text-align: center;
}

.bb-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.bb-modal-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    max-width: 92vw;
}

.bb-modal-inner img {
    max-width: 88vw;
    max-height: 78vh;
    border-radius: 10px;
}

.bb-modal-foot {
    display: flex;
    gap: 12px;
}

/* ---- Facebook batch page ---- */
.fbb {
    max-width: 520px;
    margin: 16px auto;
    text-align: center;
}

.fbb-progress {
    font-weight: 700;
    color: var(--accent);
}

.fbb-current {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 18px;
    margin-bottom: 4px;
}

.fbb-name {
    font-weight: 800;
}

.fbb-id {
    color: var(--muted);
    font-size: 13px;
}

.fbb-foot {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 10px 0;
}

.fbb-remaining {
    color: var(--muted);
    font-size: 13px;
}

.fbb .kbd {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.25);
    font-size: 11px;
    font-weight: 700;
}

.fbb-done {
    max-width: 520px;
    margin: 80px auto;
    text-align: center;
}

/* tile markers */
.ai-spark {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
}

.ai-pill {
    position: absolute;
    top: 5px;
    left: 6px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.5px;
    padding: 1px 5px;
    border-radius: 99px;
    background: var(--accent);
    color: var(--on-accent);
}

/* small ✕ to remove an AI-validated posing (top-right of a resource tile) */
.tile-cancel {
    position: absolute;
    top: 4px;
    right: 5px;
    width: 18px;
    height: 18px;
    padding: 0;
    line-height: 16px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    border-radius: 99px;
    border: none;
    cursor: pointer;
    background: rgba(200, 60, 60, 0.9);
    color: #fff;
    z-index: 3;
}

.tile-cancel:hover {
    background: rgba(210, 40, 40, 1);
}

.ai-badge {
    margin-left: 10px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 99px;
    background: var(--accent);
    color: var(--on-accent);
}

/* wallpaper background picker grid */
.wp-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    max-height: 560px;
    overflow-y: auto;
    padding: 8px 2px;
}

.wp-tile {
    width: 96px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 4px;
    background: var(--panel2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.wp-tile img {
    width: 84px;
    height: 140px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

.wp-tile .wp-none {
    width: 84px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    border: 1px dashed var(--border);
    border-radius: 6px;
}

.wp-tile .wp-name {
    font-size: 10px;
    text-align: center;
    color: var(--muted);
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wp-tile.selected {
    border-color: var(--accent);
}

.wp-tile.selected .wp-name {
    color: var(--text);
}

.resource-tile .thumb.hint-thumb {
    position: relative;
}

.hint-bubble {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.resource-tile .tlabel {
    font-size: 12px;
    text-transform: capitalize;
    color: var(--text);
}

.resource-tile .check {
    position: absolute;
    top: 5px;
    right: 6px;
    font-size: 14px;
    line-height: 1;
}

.resource-tile.clickable {
    cursor: pointer;
    transition: border-color 0.12s, transform 0.12s;
}

.resource-tile.clickable:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.resource-tile.present.playable {
    cursor: pointer;
}

.resource-tile.present.playable::after {
    content: "\25B6";
    position: absolute;
    bottom: 8px;
    right: 9px;
    font-size: 9px;
    color: var(--muted);
}

.resource-tile.missing {
    border: 2px dashed var(--border);
    background: transparent;
}

.resource-tile.missing .tlabel {
    color: var(--muted);
}

.resource-tile.missing .thumb::after {
    content: "\2014";
    color: var(--muted);
    font-size: 24px;
}

.resource-tile .sound-icon {
    font-size: 30px;
}

.resource-tile.optional .tlabel span {
    color: var(--muted);
    font-size: 10px;
}

/* Exercise sounds: GEN2 maps a set of sounds to the clicker's named events. Shown as a
   compact card (same height as a tile) with a header + a wrap of playable event chips. */
.exercise-group {
    min-width: 132px;
    max-width: 260px;
    height: 132px;
    border-radius: 14px;
    border: 1px dashed var(--border);
    background: var(--panel);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    box-sizing: border-box;
}

.exercise-head {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.exercise-head .ex-icon {
    font-size: 16px;
}

.exercise-head .ex-count {
    margin-left: auto;
    background: var(--accent, #4a90d9);
    color: #fff;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 11px;
}

.exercise-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    overflow-y: auto;
    align-content: flex-start;
}

.snd-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--border);
    background: var(--bg, #f5f6f8);
    color: var(--text, #222);
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}

.snd-chip:hover {
    background: var(--accent, #4a90d9);
    border-color: var(--accent, #4a90d9);
    color: #fff;
}

.snd-chip .chip-play {
    font-size: 8px;
    opacity: 0.6;
}

.snd-chip:hover .chip-play {
    opacity: 1;
}

/* pixel-art completeness bar */
.pixbar {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.pixbar-track {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--bar-bg);
    border: 2px solid var(--shadow);
    box-shadow: 0 0 0 2px var(--bar-frame);
    image-rendering: pixelated;
}

.pixbar .seg {
    width: 5px;
    height: 13px;
    background: var(--bar-empty);
}

/* on homepage cards, stack the count under the bar so it never clips */
.card .pixbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.pixbar.partial .seg.on {
    background: var(--orange);
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), inset 0 -2px 0 rgba(0, 0, 0, 0.35);
}

.pixbar.complete .seg.on {
    background: var(--green);
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45), inset 0 -2px 0 rgba(0, 0, 0, 0.35);
}

.pixbar-num {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
}

.pixbar.partial .pixbar-num {
    color: var(--orange);
}

.pixbar.complete .pixbar-num {
    color: var(--green);
}

/* large variant for the summary header */
.pixbar.lg .seg {
    width: 11px;
    height: 22px;
}

.pixbar.lg .pixbar-track {
    padding: 4px;
    gap: 3px;
}

.pixbar.lg .pixbar-num {
    font-size: 18px;
}

/* homepage completeness badge (links to summary) */
.card .completeness {
    display: inline-block;
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--green);
    color: var(--on-green);
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
}
