:root {
  color-scheme: dark;
  --bg: #090d13;
  --panel: rgba(18, 24, 33, 0.93);
  --panel-alt: #171f2b;
  --input: #0d141d;
  --text: #f5f7fb;
  --muted: #909bab;
  --subtle: #667184;
  --border: #283448;
  --border-bright: #3a4961;
  --accent: #7c5cff;
  --accent-bright: #a18eff;
  --success: #57d39b;
  --danger: #ff7085;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, rgba(124, 92, 255, 0.12), transparent 32rem),
    radial-gradient(circle at 100% 95%, rgba(42, 126, 255, 0.07), transparent 32rem),
    var(--bg);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: hidden;
}

button, select, textarea, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.ambient { position: fixed; width: 28rem; height: 28rem; border-radius: 50%; filter: blur(100px); opacity: 0.07; pointer-events: none; }
.ambient-one { top: -14rem; left: 12%; background: var(--accent); }
.ambient-two { right: -16rem; bottom: -16rem; background: #247fff; }

.app-shell { position: relative; width: min(1540px, calc(100% - 48px)); margin: 0 auto; padding: 28px 0 38px; }

.topbar { min-height: 60px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; margin-bottom: 34px; }

.brand { display: inline-flex; width: fit-content; flex-direction: column; gap: 2px; padding: 0; border: 0; background: transparent; color: var(--text); text-align: left; }
.brand:hover .brand-name { color: #fff; }
.brand-name { font-size: 1.55rem; font-weight: 670; letter-spacing: -0.04em; transition: color 150ms ease; }

.eyebrow, .label { color: #aeb8c8; font-size: 0.7rem; font-weight: 720; letter-spacing: 0.09em; text-transform: uppercase; }
.eyebrow { color: var(--accent-bright); }

.main-nav { display: inline-flex; padding: 4px; border: 1px solid var(--border); background: rgba(18, 24, 33, 0.75); }
.nav-button { min-width: 88px; min-height: 34px; border: 0; background: transparent; color: var(--muted); font-size: 0.82rem; font-weight: 670; }
.nav-button:hover { color: var(--text); }
.nav-button.active { background: var(--panel-alt); color: var(--text); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16); }

.topbar-status { position: relative; justify-self: end; display: inline-flex; align-items: center; gap: 8px; }
.worker-switcher { display: inline-flex; min-height: 42px; max-width: 210px; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--border); background: rgba(18, 24, 33, 0.76); }
.worker-switcher select { min-width: 0; max-width: 164px; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: .74rem; cursor: pointer; text-overflow: ellipsis; }
.worker-switcher select option { background: #151d28; color: var(--text); }
.worker-switcher.offline .status-dot { background: var(--danger); box-shadow: 0 0 14px rgba(255, 112, 133, .42); }
.worker-switcher.remote .status-dot { background: #7c5cff; box-shadow: 0 0 14px rgba(124, 92, 255, .42); }
.account-button { min-height: 42px; padding: 0 12px; border: 1px solid var(--border); background: rgba(18, 24, 33, .76); color: var(--muted); font-size: .74rem; font-weight: 700; }
.account-button:hover { border-color: var(--border-bright); color: var(--text); }
.hardware-pill { display: inline-flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 15px; border: 1px solid var(--border); background: rgba(18, 24, 33, 0.76); color: var(--muted); font-size: 0.78rem; box-shadow: 0 10px 32px rgba(0, 0, 0, 0.16); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 14px rgba(87, 211, 155, 0.55); }
.hardware-pill.error .status-dot { background: var(--danger); box-shadow: 0 0 14px rgba(255, 112, 133, 0.45); }
.connection-notice { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin: -12px 0 30px; padding: 24px 26px; border: 1px solid rgba(255, 183, 86, .42); background: linear-gradient(120deg, rgba(109, 70, 24, .22), rgba(18, 24, 33, .9)); box-shadow: var(--shadow); }
.connection-notice h2 { margin: 5px 0 7px; font-size: 1.15rem; }
.connection-notice p { max-width: 760px; margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.connection-notice > div:last-child { display: flex; flex: 0 0 auto; gap: 8px; }
.generation-queue { position: relative; }
.queue-button { display: inline-flex; min-height: 42px; align-items: center; gap: 8px; padding: 0 13px; border: 1px solid var(--border); background: rgba(18, 24, 33, 0.76); color: var(--muted); font-size: .78rem; font-weight: 700; }
.queue-button:hover, .queue-button[aria-expanded="true"] { border-color: var(--border-bright); background: var(--panel-alt); color: var(--text); }
.queue-badge { display: grid; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; place-items: center; background: #2d927a; color: #effffb; font-size: .68rem; }
.queue-panel { position: absolute; z-index: 42; top: calc(100% + 8px); right: 0; width: min(480px, calc(100vw - 28px)); max-height: min(640px, calc(100vh - 100px)); overflow: auto; border: 1px solid var(--border-bright); background: #131b27; box-shadow: var(--shadow); }
.queue-panel > header { position: sticky; z-index: 1; top: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px; border-bottom: 1px solid var(--border); background: #131b27; }
.queue-panel > header strong, .queue-panel > header span { display: block; }
.queue-panel > header strong { font-size: .84rem; }
.queue-panel > header span { margin-top: 4px; color: var(--subtle); font-size: .7rem; }
.queue-panel > header .queue-total { margin-top: 0; color: #a7ead9; text-align: right; white-space: nowrap; }
.queue-list:empty::after { display: block; padding: 22px 14px; color: var(--subtle); content: "The generator is ready for a new job."; font-size: .78rem; }
.queue-item { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; padding: 13px 14px; border-bottom: 1px solid rgba(58, 73, 97, .7); }
.queue-item:last-child { border-bottom: 0; }
.queue-position { display: grid; width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 50%; place-items: center; color: var(--subtle); font-size: .7rem; font-weight: 750; }
.queue-item.is-current .queue-position { border-color: rgba(87, 211, 155, .5); background: rgba(45, 146, 122, .16); color: #a7ead9; }
.queue-item-copy { min-width: 0; }
.queue-item-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.queue-item-heading strong { overflow: hidden; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.queue-item-state { color: #a7ead9; font-size: .64rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.queue-item-detail, .queue-item-eta { overflow: hidden; margin: 4px 0 0; color: var(--muted); font-size: .7rem; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.queue-item-eta { color: #bcc7d7; }
.queue-progress { height: 3px; margin-top: 9px; overflow: hidden; background: var(--input); }
.queue-progress span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #3eb392, #8edbc8); transition: width 220ms ease; }
.queue-cancel { align-self: center; width: 30px; height: 30px; padding: 0; border: 1px solid rgba(255, 112, 133, .38); border-radius: 50%; background: rgba(135, 38, 59, .12); color: #ff9cad; font-size: 1rem; line-height: 1; }
.queue-cancel:hover:not(:disabled) { border-color: var(--danger); background: rgba(135, 38, 59, .3); color: #ffe2e7; }
.queue-cancel:disabled { opacity: .4; cursor: wait; }
.job-inbox { position: relative; }
.inbox-button { display: inline-flex; min-height: 42px; align-items: center; gap: 8px; padding: 0 13px; border: 1px solid var(--border); background: rgba(18, 24, 33, 0.76); color: var(--muted); font-size: .78rem; font-weight: 700; }
.inbox-button:hover, .inbox-button[aria-expanded="true"] { border-color: var(--border-bright); background: var(--panel-alt); color: var(--text); }
.inbox-badge { display: grid; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; place-items: center; background: var(--accent); color: #fff; font-size: .68rem; }
.inbox-panel { position: absolute; z-index: 40; top: calc(100% + 8px); right: 0; width: min(420px, calc(100vw - 28px)); max-height: min(600px, calc(100vh - 100px)); overflow: auto; border: 1px solid var(--border-bright); background: #131b27; box-shadow: var(--shadow); }
.inbox-panel header { display: flex; justify-content: space-between; gap: 14px; padding: 13px 14px; border-bottom: 1px solid var(--border); color: var(--text); font-size: .82rem; }
.inbox-panel header span { color: var(--subtle); font-size: .72rem; }
.inbox-empty { margin: 0; padding: 18px 14px; color: var(--subtle); font-size: .78rem; }
.inbox-item { display: grid; width: 100%; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 12px 14px; border: 0; border-bottom: 1px solid rgba(58, 73, 97, .7); background: transparent; color: var(--text); text-align: left; }
.inbox-item:hover { background: rgba(124, 92, 255, .09); }
.inbox-item:last-child { border-bottom: 0; }
.inbox-item strong, .inbox-item span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-item strong { font-size: .78rem; }
.inbox-item span { margin-top: 4px; color: var(--muted); font-size: .7rem; }
.inbox-state { align-self: center; color: #b6a8ff; font-size: .68rem; font-weight: 750; text-transform: uppercase; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(2rem, 4vw, 3.25rem); font-weight: 660; letter-spacing: -0.055em; }
.library-hero p, .create-heading p { margin: 0; color: var(--muted); font-size: 0.92rem; }

.library-hero, .create-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.library-actions, .model-actions, .output-actions { display: flex; align-items: center; gap: 8px; }

.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border: 1px solid transparent; color: var(--text); font-weight: 690; text-decoration: none; transition: transform 150ms ease, background 150ms ease, border-color 150ms ease, opacity 150ms ease; }
.button:hover:not(:disabled):not(.disabled) { transform: translateY(-1px); }
.button:active:not(:disabled):not(.disabled) { transform: translateY(0); }
.button.primary { background: linear-gradient(120deg, #6e4cf3, #8968ff); box-shadow: 0 12px 28px rgba(92, 63, 224, 0.25); }
.button.primary:hover:not(:disabled) { background: linear-gradient(120deg, #7959fb, #9578ff); }
.button.secondary { background: var(--panel-alt); }
.button.secondary:hover:not(:disabled):not(.disabled) { border-color: var(--border-bright); background: #1b2533; }
.button.small { min-height: 36px; padding: 0 12px; font-size: 0.79rem; }
.button:disabled, .button.disabled { opacity: 0.4; pointer-events: none; }
.compact-primary { min-width: 152px; }

.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 14px; }
.library-card { position: relative; min-width: 0; padding: 0; overflow: hidden; border: 1px solid var(--border); background: var(--panel); color: var(--text); text-align: left; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16); transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease; }
.library-card:hover { z-index: 1; border-color: #6f5cbd; transform: translateY(-4px); box-shadow: 0 18px 42px rgba(0, 0, 0, 0.3); }
.library-card:focus-visible { outline: 3px solid rgba(161, 142, 255, 0.5); outline-offset: 2px; }
.library-group-preview { position: relative; display: grid; width: 100%; aspect-ratio: 1 / 1; overflow: hidden; gap: 2px; background: var(--input); }
.library-group-preview.image-count-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.library-group-preview.image-count-3, .library-group-preview.image-count-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.library-group-preview.image-count-3 .library-thumb:first-child { grid-row: span 2; }
.library-thumb { display: block; width: 100%; height: 100%; min-height: 0; object-fit: cover; background: var(--input); }
.library-group-count { position: absolute; right: 9px; bottom: 9px; padding: 5px 8px; border: 1px solid rgba(255, 255, 255, .18); border-radius: 999px; background: rgba(7, 10, 16, .82); color: #fff; font-size: .67rem; font-weight: 760; box-shadow: 0 5px 16px rgba(0, 0, 0, .28); }
.library-card-meta { display: grid; gap: 4px; padding: 11px 12px 12px; }
.library-card-size { color: var(--text); font-size: 0.79rem; font-weight: 700; }
.library-card-date { overflow: hidden; color: var(--subtle); font-size: 0.72rem; text-overflow: ellipsis; white-space: nowrap; }
.library-card-prompt { display: -webkit-box; overflow: hidden; margin-top: 3px; color: var(--muted); font-size: 0.72rem; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.library-card-open { display: block; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; }
.library-card-open:focus-visible { outline: 3px solid rgba(161, 142, 255, 0.5); outline-offset: -3px; }
.library-card-actions { position: absolute; z-index: 2; top: 0; left: 0; width: 100%; aspect-ratio: 1 / 1; pointer-events: none; }
.favorite-toggle, .library-delete-toggle { position: absolute; display: grid; width: 34px; height: 34px; padding: 0; border-radius: 50%; place-items: center; background: rgba(9, 13, 19, .78); font-size: 1rem; pointer-events: auto; }
.favorite-toggle { top: 9px; right: 9px; border: 1px solid rgba(245, 211, 104, .42); color: #f4df8a; }
.favorite-toggle:hover { border-color: #ffe78e; background: rgba(91, 73, 20, .78); }
.favorite-toggle.is-favorite { background: rgba(105, 80, 19, .92); color: #fff0a2; }
.library-delete-toggle { bottom: 9px; left: 9px; border: 1px solid rgba(255, 112, 133, .46); color: #ff9eac; font-size: .92rem; }
.library-delete-toggle:hover { border-color: var(--danger); background: rgba(135, 38, 59, .72); color: #fff; }
.favorites-filter-active { border-color: rgba(245, 211, 104, .7) !important; color: #ffe99b !important; }

.scaffold-group-gallery { display: grid; gap: 9px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.scaffold-group-gallery-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.scaffold-group-gallery-heading strong { font-size: .78rem; }
.scaffold-group-gallery-heading span { color: var(--subtle); font-size: .7rem; }
.scaffold-group-strip { display: flex; gap: 7px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: thin; }
.scaffold-group-image { flex: 0 0 62px; width: 62px; height: 62px; overflow: hidden; padding: 0; border: 2px solid transparent; border-radius: 8px; background: var(--input); }
.scaffold-group-image:hover { border-color: var(--border-bright); }
.scaffold-group-image.is-selected { border-color: var(--accent-bright); box-shadow: 0 0 0 2px rgba(139, 113, 255, .18); }
.scaffold-group-image img { display: block; width: 100%; height: 100%; object-fit: cover; }

.library-empty { display: grid; max-width: 480px; justify-items: center; margin: 11vh auto 0; padding: 52px 28px; border: 1px dashed var(--border-bright); background: rgba(18, 24, 33, 0.54); text-align: center; }
.sparkle { color: var(--accent-bright); font-size: 1.2rem; }
.library-empty h2 { margin: 18px 0 7px; font-size: 1.24rem; }
.library-empty p { max-width: 370px; margin-bottom: 22px; color: var(--muted); font-size: 0.86rem; line-height: 1.55; }


.create-heading { margin-bottom: 19px; }
.create-heading h1 { margin-bottom: 4px; font-size: clamp(1.75rem, 3vw, 2.35rem); }
.workspace { display: grid; grid-template-columns: minmax(380px, 450px) minmax(0, 1fr); gap: 18px; min-height: calc(100vh - 202px); }
.control-card, .output-card { border: 1px solid var(--border); background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.control-card { display: flex; min-height: 720px; flex-direction: column; padding: 24px; }
.generator-worker-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(170px, .72fr); gap: 14px; align-items: center; margin-bottom: 18px; padding: 13px 14px; border: 1px solid rgba(124, 92, 255, .34); background: rgba(71, 52, 145, .1); }
.generator-worker-card h2 { margin: 3px 0 4px; font-size: .94rem; }
.generator-worker-card p { margin: 0; color: var(--subtle); font-size: .7rem; line-height: 1.4; }
.generator-worker-card .worker-switcher { width: 100%; max-width: none; }
.generator-worker-card .worker-switcher select { width: 100%; max-width: none; }
.tile-repair-worker-setting { display: grid; gap: 6px; margin: 12px 0; }
.section-heading, .output-heading, .steps-heading, .batch-heading, .quick-row, .output-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.section-heading p, .output-heading p, .steps-heading p, .batch-heading p { margin: 4px 0 0; color: var(--subtle); font-size: 0.76rem; }
.icon-button { width: 36px; height: 36px; padding: 0; border: 0; background: transparent; color: var(--subtle); font-size: 1.35rem; }
.icon-button:hover { background: var(--panel-alt); color: var(--text); }

.field { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 0; outline: none; background: var(--input); color: var(--text); transition: border-color 150ms ease, box-shadow 150ms ease; }
.field:focus { border-color: #7059cf; box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.12); }
select.field { cursor: pointer; }
textarea.field { resize: vertical; padding: 12px; line-height: 1.5; }
.full-width { margin-top: 10px; }
.model-recommendation { min-height: 18px; margin: 8px 0 0; color: var(--accent-bright); font-size: 0.72rem; line-height: 1.4; }
.model-prompting-guide { margin-top: 10px; border: 1px solid rgba(124, 92, 255, .26); background: rgba(54, 40, 111, .1); }
.model-prompting-guide summary { padding: 10px 12px; color: #c9bcff; font-size: .72rem; font-weight: 700; cursor: pointer; }
.model-prompting-guide p { margin: 0; padding: 0 12px 12px; color: var(--muted); font-size: .73rem; line-height: 1.55; white-space: pre-wrap; }
.lora-module { margin-top: 12px; padding: 10px 11px; border: 1px solid rgba(73, 196, 171, .32); background: linear-gradient(120deg, rgba(41, 131, 114, .09), rgba(13, 20, 29, .64)); }
.lora-module-heading { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 10px; }
.lora-module-heading h2, .lora-module-heading h4 { margin: 2px 0 0; font-size: .86rem; }
.lora-add-button { flex: 0 0 auto; min-height: 32px; padding: 0 10px; color: #a7ead9; }
.lora-active-list { display: grid; min-width: 0; gap: 6px; margin-top: 8px; }
.lora-active-empty { margin: 0; color: var(--subtle); font-size: .7rem; line-height: 1.35; }
.lora-active-row { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 7px 8px; border: 1px solid rgba(73, 196, 171, .28); background: rgba(8, 13, 20, .5); }
.lora-active-row.is-incompatible { border-color: rgba(220, 191, 114, .3); }
.lora-active-copy { min-width: 0; }
.lora-active-copy strong { display: block; overflow: hidden; color: var(--text); font-size: .73rem; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.lora-active-copy span { display: block; margin-top: 2px; color: #a7ead9; font-size: .64rem; line-height: 1.35; overflow-wrap: anywhere; }
.lora-active-copy .lora-compatibility { color: #dcbf72; }
.lora-remove-button { display: grid; width: 28px; height: 28px; padding: 0; border: 1px solid rgba(255, 112, 133, .28); place-items: center; background: rgba(150, 42, 66, .1); color: #ffabb9; font-size: .86rem; line-height: 1; }
.lora-remove-button:hover { border-color: var(--danger); background: rgba(150, 42, 66, .3); color: #ffe2e7; }
.lora-source-link { display: inline-block; color: #a7ead9; font-size: .66rem; font-weight: 680; text-decoration: none; }
.lora-source-link:hover { color: var(--text); }
.scaffold-refinement-view { width: min(960px, 100%); margin: 0 auto; border: 1px solid rgba(73, 196, 171, 0.46); background: linear-gradient(145deg, rgba(20, 43, 43, 0.86), var(--panel)); box-shadow: var(--shadow); }
.scaffold-refinement-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 24px; border-bottom: 1px solid rgba(73, 196, 171, 0.24); }
.scaffold-refinement-header h2 { margin: 4px 0 5px; font-size: clamp(1.4rem, 2.6vw, 1.9rem); }
.scaffold-refinement-header p { max-width: 620px; margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.scaffold-refinement-summary { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 16px; align-items: center; margin: 20px 24px 0; padding: 12px; border: 1px solid rgba(73, 196, 171, 0.26); background: rgba(7, 19, 20, 0.5); }
.scaffold-refinement-summary img { display: block; width: 112px; aspect-ratio: 1; object-fit: cover; background: var(--input); }
.scaffold-refinement-summary .label { color: #a7ead9; font-size: .66rem; }
.scaffold-refinement-summary strong { display: block; margin-top: 5px; color: var(--text); font-size: .95rem; }
.scaffold-refinement-summary p { margin: 5px 0 0; color: var(--muted); font-size: .77rem; line-height: 1.45; }
.scaffold-live-viewer { margin: 14px 24px 0; overflow: hidden; border: 1px solid rgba(87, 180, 255, .38); background: #080d12; }
.scaffold-live-viewer > header { display: flex; min-height: 48px; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: rgba(13, 24, 32, .94); }
.scaffold-live-viewer > header strong { overflow: hidden; color: var(--muted); font-size: .73rem; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }
.live-preview-badge { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 7px; color: #b9e5ff; font-size: .68rem; font-weight: 760; letter-spacing: .045em; text-transform: uppercase; }
.live-preview-badge i { width: 7px; height: 7px; border-radius: 50%; background: #58d6aa; box-shadow: 0 0 0 4px rgba(88, 214, 170, .12), 0 0 14px rgba(88, 214, 170, .65); animation: live-pulse 1.5s ease-in-out infinite; }
.scaffold-live-viewer > div { position: relative; display: grid; height: min(62vh, 680px); min-height: 340px; place-items: center; overflow: hidden; }
.scaffold-live-viewer img { display: block; width: 100%; height: 100%; object-fit: contain; }
.scaffold-live-viewer p { position: absolute; inset: auto 16px 14px; margin: 0; padding: 8px 10px; border: 1px solid rgba(112, 128, 151, .3); background: rgba(7, 11, 16, .8); color: #d9e0e9; font-size: .72rem; line-height: 1.4; text-align: center; }
.scaffold-refinement-settings { display: flex; min-width: 0; flex-direction: column; gap: 10px; padding: 20px 24px; }
.scaffold-setting-card, .scaffold-batch-card, .scaffold-tiled-settings { min-width: 0; padding: 15px; border: 1px solid var(--border); background: rgba(9, 15, 21, 0.52); }
.scaffold-setting-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, .72fr); gap: 16px; align-items: center; }
.scaffold-lora-module { grid-template-columns: 1fr; border-color: rgba(73, 196, 171, .32); }
.scaffold-lora-module .lora-active-list { margin-top: 2px; }
.scaffold-lora-module .lora-active-empty { margin: 0; }
.scaffold-setting-card p, .scaffold-batch-card > div > p { margin: 5px 0 0; color: var(--subtle); font-size: .73rem; line-height: 1.42; }
.scaffold-base-step-setting { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr); gap: 9px; }
.scaffold-base-step-setting output { color: var(--accent-bright); font-size: .77rem; font-weight: 720; }
.scaffold-base-step-setting .range { margin: 0; }
.scaffold-tiled-settings { display: grid; grid-template-columns: minmax(180px, .75fr) minmax(0, 1.25fr); gap: 15px; align-items: end; border-color: rgba(255, 193, 94, 0.3); background: linear-gradient(120deg, rgba(171, 111, 35, 0.12), rgba(13, 20, 29, 0.52)); }
.scaffold-tiled-settings .tiled-redraw-setting, .scaffold-tiled-settings .tiled-overlap-setting, .scaffold-tiled-settings .tiled-detail-estimate { grid-column: 1 / -1; }
.scaffold-face-module { grid-template-columns: 1fr; align-items: start; }
.scaffold-face-steps { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; }
.scaffold-face-steps .range { grid-column: 1 / -1; margin-top: 0; }
.scaffold-face-steps output { color: var(--accent-bright); font-size: .77rem; font-weight: 720; }
.scaffold-face-strength { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px 12px; padding-top: 10px; border-top: 1px solid rgba(143, 119, 255, 0.2); }
.scaffold-face-strength .range { grid-column: 1 / -1; }
.scaffold-manual-face-toggle { grid-column: 1 / -1; margin-top: 4px; color: #a7ead9; }
.scaffold-manual-face-help { grid-column: 1 / -1; margin: -2px 0 0; color: var(--subtle); font-size: .72rem; line-height: 1.42; }
.scaffold-face-marker-stage { grid-column: 1 / -1; display: grid; gap: 9px; }
.scaffold-face-marker-canvas { position: relative; width: fit-content; max-width: 100%; line-height: 0; border: 1px solid rgba(73, 196, 171, .42); background: #080d12; }
.scaffold-face-marker-canvas img { display: block; max-width: min(100%, 520px); max-height: 380px; width: auto; height: auto; }
.scaffold-face-marker-overlay { position: absolute; inset: 0; cursor: crosshair; touch-action: none; }
.scaffold-face-marker-selection { position: absolute; z-index: 1; border: 2px solid #a7ead9; background: rgba(73, 196, 171, .15); box-shadow: 0 0 0 1px rgba(7, 19, 20, .8) inset; pointer-events: none; }
.scaffold-face-marker-stage .button { justify-self: start; }
.scaffold-batch-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; border-color: rgba(124, 92, 255, 0.36); background: linear-gradient(120deg, rgba(124, 92, 255, 0.09), rgba(13, 20, 29, 0.66)); }
.scaffold-batch-card .batch-summary { grid-column: 1 / -1; margin: 0; }
.scaffold-seed-card { grid-template-columns: 1fr; }
.scaffold-refinement-actions { padding: 0 24px 24px; }
.scaffold-refinement-actions .primary { width: 100%; min-height: 52px; }
.prompt-block { margin-top: 22px; }
.prompt-block .label, .setting .label { display: block; margin-bottom: 8px; }
.prompt { min-height: 142px; }
.reference-card { margin-top: 16px; padding: 14px 15px; border: 1px solid rgba(124, 92, 255, 0.4); background: linear-gradient(120deg, rgba(124, 92, 255, 0.1), rgba(13, 20, 29, 0.68)); }
.reference-card.unsupported { border-color: var(--border); background: rgba(13, 20, 29, 0.5); }
.reference-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.reference-heading h2 { margin: 4px 0 0; font-size: 0.95rem; letter-spacing: -0.02em; }
.reference-count { padding: 4px 7px; border: 1px solid var(--border); background: var(--input); color: var(--accent-bright); font-size: 0.72rem; font-weight: 720; }
.reference-help { margin: 8px 0 12px; color: var(--muted); font-size: 0.76rem; line-height: 1.45; }
.reference-card.unsupported .reference-help { color: var(--subtle); }
.reference-selected { display: flex; min-height: 42px; flex-wrap: wrap; gap: 8px; }
.reference-empty { align-self: center; margin: 0; color: var(--subtle); font-size: 0.74rem; }
.reference-image-chip { position: relative; width: 72px; height: 72px; overflow: hidden; border: 1px solid var(--border-bright); background: var(--input); }
.reference-image-chip img { display: block; width: 100%; height: 100%; object-fit: cover; }
.reference-source { position: absolute; right: 0; bottom: 0; left: 0; padding: 3px 4px; background: rgba(7, 11, 16, 0.82); color: #d9d1ff; font-size: 0.58rem; font-weight: 700; line-height: 1.1; text-align: center; }
.reference-remove { position: absolute; top: 3px; right: 3px; display: grid; width: 20px; height: 20px; padding: 0; border: 1px solid rgba(255, 190, 199, 0.72); border-radius: 50%; place-items: center; background: rgba(74, 20, 32, 0.9); color: #fff1f3; font-size: 1rem; line-height: 1; }
.reference-remove:hover:not(:disabled) { background: rgba(156, 43, 67, 0.95); }
.reference-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; align-items: start; margin-top: 12px; }
.reference-library-picker { min-width: 0; border: 1px solid var(--border); background: rgba(11, 17, 25, 0.58); }
.reference-library-picker summary { padding: 9px 10px; color: var(--muted); cursor: pointer; font-size: 0.75rem; font-weight: 650; }
.reference-library-picker.disabled { opacity: 0.48; }
.reference-library-picker.disabled summary { cursor: not-allowed; pointer-events: none; }
.reference-library-grid { display: grid; max-height: 210px; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; padding: 0 9px 9px; overflow: auto; }
.reference-library-image { min-width: 0; aspect-ratio: 1; padding: 0; overflow: hidden; border: 1px solid var(--border); background: var(--input); }
.reference-library-image:hover:not(:disabled) { border-color: var(--accent-bright); transform: translateY(-1px); }
.reference-library-image:disabled { opacity: 0.42; }
.reference-library-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.reference-library-empty { grid-column: 1 / -1; margin: 4px 0; color: var(--subtle); font-size: 0.74rem; }
.reference-upload-label { white-space: nowrap; cursor: pointer; }
.reference-upload-label.disabled { cursor: not-allowed; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.setting { min-width: 0; }

.steps-card, .batch-card { margin-top: 16px; padding: 14px 15px 12px; border: 1px solid var(--border); background: rgba(13, 20, 29, 0.6); }
.steps-heading, .batch-heading { align-items: flex-start; }
.stepper { display: grid; grid-template-columns: 34px 50px 34px; border: 1px solid var(--border); background: var(--input); }
.stepper button { height: 34px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 1rem; }
.stepper button:hover { background: var(--panel-alt); color: var(--text); }
.stepper input { width: 50px; height: 34px; border: 0; border-right: 1px solid var(--border); border-left: 1px solid var(--border); outline: 0; background: transparent; color: var(--text); text-align: center; font-weight: 700; appearance: textfield; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { margin: 0; appearance: none; }
.range { width: 100%; height: 4px; margin: 15px 0 2px; appearance: none; border-radius: 4px; outline: none; background: linear-gradient(90deg, var(--accent) var(--range-progress, 39%), var(--border) var(--range-progress, 39%)); }
.range::-webkit-slider-thumb { width: 16px; height: 16px; appearance: none; border: 3px solid var(--accent); border-radius: 50%; background: var(--text); cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); }
.range::-moz-range-thumb { width: 12px; height: 12px; border: 3px solid var(--accent); border-radius: 50%; background: var(--text); cursor: pointer; }
.batch-card { border-color: rgba(124, 92, 255, 0.36); background: linear-gradient(120deg, rgba(124, 92, 255, 0.09), rgba(13, 20, 29, 0.66)); }
.batch-summary { margin: 12px 0 0; color: var(--accent-bright); font-size: 0.76rem; font-weight: 650; }
.generation-time-estimate { margin: 8px 0 0; color: #a9ccee; font-size: .73rem; line-height: 1.42; }
.generation-time-estimate.is-learning { color: var(--subtle); }
.tile-repair-time-estimate { max-width: 260px; margin: 2px 0 0 auto; text-align: right; }
.quick-row { margin-top: 14px; color: var(--subtle); font-size: 0.77rem; }
.check-control { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--muted); }
.check-control input { width: 15px; height: 15px; accent-color: var(--accent); }
.face-detail-control { color: var(--accent-bright); }
.face-detail-control.unsupported { opacity: 0.46; cursor: not-allowed; }
.face-detail-control.unsupported input { pointer-events: none; }
.face-step-control { margin-top: 12px; padding: 13px 14px 10px; border: 1px solid rgba(143, 119, 255, 0.35); background: linear-gradient(120deg, rgba(124, 92, 255, 0.1), rgba(13, 20, 29, 0.52)); }
.face-step-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.face-step-heading p { margin: 4px 0 0; color: var(--subtle); font-size: 0.74rem; }
.face-step-heading output { flex: 0 0 auto; color: var(--accent-bright); font-size: 0.77rem; font-weight: 720; }
.face-step-control .range { margin-top: 14px; }
.face-strength-setting { margin-top: 14px; padding-top: 13px; border-top: 1px solid rgba(143, 119, 255, 0.2); }
.face-prompt-setting { margin-top: 14px; padding-top: 13px; border-top: 1px solid rgba(255, 193, 94, 0.28); }
.face-prompt-setting .label { color: #f3d497; }
.face-prompt-setting textarea { margin-top: 7px; }
.face-prompt-setting p { margin: 7px 0 0; color: var(--subtle); font-size: .72rem; line-height: 1.42; }
.scaffold-face-prompt-setting { grid-column: 1 / -1; padding-top: 10px; border-top: 1px solid rgba(255, 193, 94, 0.28); }
.scaffold-face-prompt-setting .label { color: #f3d497; }
.scaffold-face-prompt-setting textarea { min-height: 148px; margin-top: 7px; resize: vertical; line-height: 1.55; }
.scaffold-face-prompt-setting p { margin: 7px 0 0; color: var(--subtle); font-size: .72rem; line-height: 1.42; }
.experimental-detail-card { margin-top: 12px; padding: 13px 14px; border: 1px solid rgba(255, 193, 94, 0.28); background: linear-gradient(120deg, rgba(171, 111, 35, 0.12), rgba(13, 20, 29, 0.52)); }
.experimental-detail-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.experimental-detail-control { color: #ffdda0; }
.experimental-detail-control.unsupported { opacity: 0.46; cursor: not-allowed; }
.experimental-detail-control.unsupported input { pointer-events: none; }
.experimental-badge { padding: 3px 6px; border: 1px solid rgba(255, 193, 94, 0.36); color: #f5cb79; font-size: 0.61rem; font-weight: 750; letter-spacing: .08em; }
.experimental-detail-card > p { margin: 8px 0 0; color: var(--subtle); font-size: 0.74rem; line-height: 1.45; }
.tiled-detail-settings { display: grid; grid-template-columns: minmax(130px, .82fr) minmax(0, 1.18fr); gap: 14px; align-items: end; margin-top: 13px; }
.tiled-step-setting .range { margin: 14px 0 2px; }
.tiled-redraw-setting { grid-column: 1 / -1; }
.tiled-redraw-setting .range { margin: 14px 0 2px; }
.tiled-redraw-setting p { margin: 6px 0 0; color: var(--subtle); font-size: .71rem; }
.tiled-overlap-setting { grid-column: 1 / -1; }
.tiled-overlap-setting .range { margin: 14px 0 2px; }
.tiled-overlap-setting p { margin: 6px 0 0; color: var(--subtle); font-size: 0.71rem; }
.scene-aware-setting { grid-column: 1 / -1; padding: 11px 12px; border: 1px solid rgba(87, 180, 255, .26); background: rgba(36, 103, 156, .10); }
.scene-aware-control { color: #b9e2ff; font-weight: 700; }
.scene-aware-setting p { margin: 6px 0 0; color: var(--subtle); font-size: .71rem; line-height: 1.42; }
.tiled-detail-estimate { grid-column: 1 / -1; margin: -2px 0 0; padding: 10px 11px; border: 1px solid rgba(255, 193, 94, 0.22); background: rgba(89, 58, 16, 0.15); color: #f3d497; font-size: 0.73rem; font-weight: 650; line-height: 1.4; }
.advanced { margin-top: 14px; border-top: 1px solid var(--border); }
.advanced summary { padding: 13px 0 5px; color: var(--muted); cursor: pointer; font-size: 0.8rem; font-weight: 650; list-style: none; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::after { float: right; color: var(--subtle); content: "＋"; }
.advanced[open] summary::after { content: "−"; }
.advanced-content { padding: 8px 0 2px; }
.advanced-row { display: block; margin-top: 12px; }
.compact-prompt { min-height: 82px; }
.generation-actions { margin-top: auto; padding-top: 18px; }
.generation-actions .primary { width: 100%; min-height: 52px; }
.abort-button { width: 100%; min-height: 42px; margin-top: 8px; border-color: rgba(255, 112, 133, 0.62); background: rgba(135, 38, 59, 0.3); color: #ffb6c1; font-size: 0.82rem; font-weight: 700; }
.abort-button:hover:not(:disabled) { border-color: var(--danger); background: rgba(150, 42, 66, 0.46); color: #ffe2e7; }
.progress-track { height: 5px; margin-top: 12px; overflow: hidden; background: var(--input); }
.progress-fill { width: 0; height: 100%; background: linear-gradient(90deg, var(--accent), #9d86ff); transition: width 220ms ease; }
.status-message { min-height: 18px; margin: 7px 0 0; color: var(--subtle); font-size: 0.77rem; }
.status-message.error { color: var(--danger); }
.status-message.success { color: var(--success); }

.output-card { display: grid; min-width: 0; grid-template-rows: auto minmax(520px, 1fr) auto; }
.output-heading { min-height: 77px; padding: 16px 20px; }
.image-stage { position: relative; display: grid; min-height: 520px; place-items: center; margin: 0 20px; overflow: hidden; border: 1px solid var(--border); background: linear-gradient(rgba(255, 255, 255, 0.012), rgba(255, 255, 255, 0.012)), var(--input); }
.image-stage::before { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, transparent 49.8%, rgba(255,255,255,.015) 50%, transparent 50.2%), linear-gradient(transparent 49.8%, rgba(255,255,255,.015) 50%, transparent 50.2%); content: ""; }
.empty-state { max-width: 340px; padding: 40px 20px; color: var(--subtle); text-align: center; }
.empty-state h2 { margin: 18px 0 6px; color: #a8b3c3; font-size: 1.05rem; font-weight: 580; }
.empty-state p { margin: 0; font-size: 0.82rem; line-height: 1.55; }
#resultImage, .live-preview-image { position: relative; z-index: 1; width: 100%; height: 100%; max-height: calc(100vh - 280px); object-fit: contain; background: var(--input); }
.live-preview-image { image-rendering: auto; }
.loading-state { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; color: var(--muted); }
.loading-state strong { margin-top: 24px; color: #cbd3df; font-size: 0.95rem; }
.loading-state > span { margin-top: 7px; font-size: 0.78rem; }
.loading-state.has-preview { position: absolute; right: 14px; bottom: 14px; left: 14px; display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 1px 10px; align-items: center; padding: 10px 12px; border: 1px solid rgba(112, 128, 151, .34); background: rgba(7, 11, 16, .82); backdrop-filter: blur(12px); }
.loading-state.has-preview .loader-orbit { width: 22px; height: 22px; grid-row: 1 / span 2; }
.loading-state.has-preview .loader-orbit span { width: 5px; height: 5px; margin-top: -3px; }
.loading-state.has-preview strong { min-width: 0; margin: 0; overflow: hidden; font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.loading-state.has-preview > span { min-width: 0; margin: 1px 0 0; overflow: hidden; font-size: .67rem; text-overflow: ellipsis; white-space: nowrap; }
.loader-orbit { width: 48px; height: 48px; border: 1px solid var(--border-bright); border-radius: 50%; animation: spin 1.5s linear infinite; }
.loader-orbit span { display: block; width: 8px; height: 8px; margin: -4px auto 0; border-radius: 50%; background: var(--accent-bright); box-shadow: 0 0 16px rgba(154, 132, 255, 0.8); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes live-pulse { 50% { opacity: .48; transform: scale(.82); } }
.output-footer { min-height: 54px; padding: 0 20px; color: var(--subtle); font-size: 0.75rem; }
.text-button { padding: 6px 0; border: 0; background: transparent; color: var(--subtle); font-size: 0.75rem; }
.text-button:hover { color: var(--muted); }

.image-modal { position: fixed; z-index: 50; inset: 0; padding: 0; background: #070b10; }
.modal-backdrop { position: absolute; inset: 0; border: 0; background: rgba(4, 7, 11, 0.86); }
.modal-card { position: relative; z-index: 1; display: grid; width: 100vw; height: 100vh; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; border: 0; background: #111821; }
.modal-header { display: flex; min-height: 72px; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 20px; border-bottom: 1px solid var(--border); background: rgba(17, 24, 33, 0.96); }
.modal-header h2 { margin: 3px 0 0; font-size: 1.25rem; letter-spacing: -0.025em; }
.modal-actions, .zoom-controls { display: inline-flex; align-items: center; gap: 7px; }
.modal-actions { margin-left: auto; }
.viewer-button, .zoom-label { min-height: 34px; border: 1px solid var(--border); background: var(--input); color: var(--muted); font-size: 0.76rem; font-weight: 680; }
.viewer-button { min-width: 34px; padding: 0 10px; }
.viewer-button:hover, .zoom-label:hover { border-color: var(--border-bright); background: var(--panel-alt); color: var(--text); }
.zoom-label { min-width: 56px; padding: 0 8px; }
.rerun-image-button { min-width: 92px; border-color: rgba(143, 119, 255, 0.56); color: #d8d0ff; }
.rerun-image-button:hover:not(:disabled) { border-color: var(--accent-bright); background: rgba(102, 77, 206, 0.26); color: #f1efff; }
.scaffold-refine-button { min-width: 108px; border-color: rgba(73, 196, 171, 0.52); color: #a7ead9; }
.scaffold-refine-button:hover:not(:disabled) { border-color: #57d9bc; background: rgba(31, 126, 108, 0.24); color: #e2fff7; }
.scaffold-inspect-button { min-width: 116px; border-color: rgba(246, 186, 87, 0.52); color: #ffe1a3; }
.scaffold-inspect-button:hover:not(:disabled) { border-color: #ffd36f; background: rgba(137, 94, 24, 0.25); color: #fff4d8; }
.tile-repair-button { min-width: 112px; border-color: rgba(87, 180, 255, 0.52); color: #b7e1ff; }
.tile-repair-button:hover:not(:disabled) { border-color: #71bfff; background: rgba(42, 108, 164, 0.25); color: #eaf7ff; }
.delete-image-button { min-width: 92px; border-color: rgba(255, 112, 133, 0.52); color: #ffabb9; }
.delete-image-button:hover { border-color: var(--danger); background: rgba(150, 42, 66, 0.3); color: #ffe2e7; }
.modal-content { display: grid; min-height: 0; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); }
.modal-image-wrap { position: relative; display: grid; min-width: 0; min-height: 0; place-items: center; overflow: hidden; background: #090d13; touch-action: none; user-select: none; }
.modal-image-wrap.is-pannable { cursor: grab; }
.modal-image-wrap.is-pannable:active { cursor: grabbing; }
.modal-image-wrap img { position: relative; z-index: 1; display: block; max-width: none; max-height: none; min-width: 0; min-height: 0; transform-origin: center; transition: transform 140ms ease; will-change: transform; }
.modal-image-wrap.is-panning img { transition: none; }
.image-nav-button { position: absolute; z-index: 10; top: 50%; display: grid; width: 44px; height: 64px; padding: 0; border: 1px solid rgba(188, 177, 245, 0.32); place-items: center; background: rgba(9, 13, 19, 0.68); color: #ebe7ff; font-size: 2.3rem; line-height: 1; pointer-events: auto; transform: translateY(-50%); transition: opacity 150ms ease, background 150ms ease, border-color 150ms ease; }
.image-nav-button:hover:not(:disabled) { border-color: var(--accent-bright); background: rgba(59, 43, 119, 0.84); }
.image-nav-button:disabled { opacity: 0.22; cursor: not-allowed; }
.image-nav-previous { left: 18px; }
.image-nav-next { right: 18px; }
.zoom-help { position: absolute; z-index: 10; right: 18px; bottom: 16px; margin: 0; padding: 8px 10px; border: 1px solid rgba(112, 128, 151, 0.25); background: rgba(7, 11, 16, 0.74); color: #c2cad6; font-size: 0.72rem; pointer-events: none; }
.modal-image-wrap.is-pannable .zoom-help { opacity: 0; }
.image-details { display: grid; min-height: 0; align-content: start; gap: 0; padding: 18px 20px; overflow: auto; background: #111821; }
.detail-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border-bottom: 0; }
.detail-label { display: block; margin-bottom: 5px; color: var(--subtle); font-size: 0.68rem; font-weight: 720; letter-spacing: .08em; text-transform: uppercase; }
.detail-value { color: var(--text); font-size: 0.82rem; line-height: 1.55; overflow-wrap: anywhere; white-space: pre-wrap; }
.detail-prompt { max-height: 170px; overflow: auto; }
.scaffold-inspector-intro { margin-bottom: 14px; color: var(--muted); font-size: .8rem; line-height: 1.45; }
.scaffold-inspector-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.scaffold-inspector-card { display: grid; gap: 7px; min-width: 0; padding: 7px; border: 1px solid var(--border); border-radius: 8px; background: var(--input); color: var(--muted); text-align: left; font-size: .72rem; line-height: 1.35; }
.scaffold-inspector-card:hover { border-color: var(--border-bright); background: var(--panel-alt); color: var(--text); }
.scaffold-inspector-card.is-selected { border-color: #f3bd58; box-shadow: 0 0 0 1px rgba(243, 189, 88, 0.18); color: #fff1cf; }
.scaffold-inspector-card img { display: block; width: 100%; aspect-ratio: 1; border-radius: 5px; background: #080c12; object-fit: cover; }
.tile-repair-panel { min-height: 0; overflow: hidden; }
.tile-repair-workspace { display: grid; height: 100%; min-height: 0; grid-template-columns: minmax(380px, 450px) minmax(0, 1fr); }
.tile-repair-sidebar { display: grid; min-width: 0; min-height: 0; grid-template-rows: minmax(0, 1fr) auto auto; padding: 18px 20px; overflow: hidden; border-right: 1px solid var(--border); background: var(--panel); }
.tile-repair-heading { min-height: 0; padding: 0 6px 16px 0; overflow-y: auto; }
.tile-repair-heading h3 { margin: 3px 0 5px; font-size: 1.08rem; }
.tile-repair-heading p { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.45; }
.tile-repair-prompt-setting { width: 100%; margin-top: 12px; padding: 12px 13px; border: 1px solid rgba(87, 180, 255, .28); background: rgba(34, 78, 112, .11); }
.tile-repair-prompt-setting textarea { margin-top: 7px; }
.tile-repair-prompt-setting > small { display: block; margin-top: 5px; color: var(--subtle); font-size: .71rem; line-height: 1.4; }
.tile-repair-prompt-strength { margin-top: 12px; padding-top: 11px; border-top: 1px solid rgba(87, 180, 255, .2); }
.tile-repair-prompt-strength .range { margin: 14px 0 2px; }
.tile-repair-prompt-strength p { margin: 6px 0 0; color: var(--subtle); font-size: .71rem; line-height: 1.4; }
.tile-repair-lora-module { width: 100%; margin-top: 12px; padding: 12px 13px; }
.tile-repair-step-setting { width: 100%; margin-top: 12px; }
.tile-repair-step-setting small { display: block; margin-top: 5px; color: var(--subtle); font-size: .71rem; }
.tile-repair-face-setting { width: 100%; margin-top: 12px; padding: 12px 13px; border: 1px solid rgba(143, 119, 255, .32); background: linear-gradient(120deg, rgba(124, 92, 255, .1), rgba(13, 20, 29, .42)); }
.tile-repair-face-controls { display: flex; align-items: center; gap: 18px; }
.tile-repair-face-setting > p { margin: 7px 0 0; color: var(--subtle); font-size: .72rem; line-height: 1.42; }
.tile-repair-face-steps { margin-top: 11px; background: rgba(8, 13, 20, .42); }
.tile-repair-face-marker-help { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 13px; padding-top: 12px; border-top: 1px solid rgba(143, 119, 255, .2); }
.tile-repair-face-marker-help p { margin: 0; color: var(--subtle); font-size: .72rem; line-height: 1.42; }
.tile-repair-clear-face { flex: 0 0 auto; }
.tile-repair-status { padding: 12px 0; border-top: 1px solid var(--border); }
.tile-repair-count { display: inline-block; padding: 7px 10px; border: 1px solid rgba(87, 180, 255, .42); background: rgba(43, 114, 173, .16); color: #b9e2ff; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.tile-repair-time-estimate { max-width: none; margin: 7px 0 0; text-align: left; }
.tile-repair-stage { display: grid; min-width: 0; min-height: 0; padding: 16px; place-items: center; overflow: auto; background: #090d13; }
.tile-repair-canvas { position: relative; max-width: 100%; max-height: 100%; line-height: 0; }
.tile-repair-canvas img { display: block; max-width: 100%; max-height: calc(100vh - 104px); width: auto; height: auto; }
.tile-repair-canvas svg { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.tile-repair-canvas.is-face-selector svg { cursor: cell; }
.tile-repair-hit-area { fill: transparent; pointer-events: all; }
.tile-repair-area { fill: rgba(117, 179, 255, .08); stroke: rgba(164, 205, 255, .58); stroke-width: 7; vector-effect: non-scaling-stroke; pointer-events: none; transition: fill 90ms ease, stroke 90ms ease; }
.tile-repair-area.is-preview { fill: rgba(255, 201, 96, .2); stroke: #ffd176; stroke-dasharray: 10 8; }
.tile-repair-area.is-selected { fill: rgba(118, 88, 235, .35); stroke: #bba6ff; }
.tile-repair-marker { fill: #f5eeff; stroke: #6247c6; stroke-width: 7; vector-effect: non-scaling-stroke; pointer-events: none; }
.tile-repair-face-area { fill: rgba(91, 226, 188, .12); stroke: #69e5c2; stroke-width: 7; stroke-dasharray: 8 6; vector-effect: non-scaling-stroke; pointer-events: none; }
.tile-repair-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.tile-repair-actions .button { width: 100%; }
.tile-repair-actions #tileRepairRun { grid-column: 1 / -1; }
.lora-picker-modal { position: fixed; z-index: 75; inset: 0; display: grid; padding: min(5vh, 40px) min(4vw, 48px); place-items: center; }
.lora-picker-card { position: relative; z-index: 1; display: grid; width: min(720px, 100%); max-height: min(760px, calc(100vh - 40px)); grid-template-rows: auto minmax(0, 1fr) auto auto; overflow: hidden; border: 1px solid rgba(73, 196, 171, .48); background: #111821; box-shadow: var(--shadow); }
.lora-picker-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--border); background: linear-gradient(120deg, rgba(41, 131, 114, .12), rgba(17, 24, 33, .96)); }
.lora-picker-header h2 { margin: 4px 0 4px; font-size: 1.2rem; }
.lora-picker-header p { margin: 0; color: var(--muted); font-size: .76rem; }
.lora-picker-body { display: grid; min-height: 0; grid-template-rows: auto minmax(0, 1fr); gap: 12px; padding: 16px 20px; overflow: hidden; }
.lora-picker-search { display: block; }
.lora-picker-list { display: grid; min-height: 0; align-content: start; gap: 8px; overflow-y: auto; }
.lora-picker-empty { margin: 0; padding: 18px; border: 1px dashed var(--border); color: var(--muted); font-size: .78rem; text-align: center; }
.lora-picker-option { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border: 1px solid var(--border); background: rgba(8, 13, 20, .55); }
.lora-picker-option:hover { border-color: rgba(73, 196, 171, .42); }
.lora-picker-option.is-selected { border-color: #49c4ab; background: rgba(24, 78, 68, .22); box-shadow: 0 0 0 1px rgba(73, 196, 171, .16); }
.lora-picker-option.is-active { opacity: .62; }
.lora-picker-select { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 11px 12px; border: 0; background: transparent; color: var(--text); text-align: left; }
.lora-picker-select:disabled { cursor: default; }
.lora-picker-option-copy { min-width: 0; }
.lora-picker-option-copy strong { display: block; color: var(--text); font-size: .79rem; line-height: 1.3; }
.lora-picker-option-copy span { display: block; margin-top: 3px; color: var(--subtle); font-size: .68rem; line-height: 1.4; overflow-wrap: anywhere; }
.lora-picker-option-status { color: #a7ead9; font-size: .68rem; font-weight: 720; white-space: nowrap; }
.lora-picker-option > .lora-source-link { margin-right: 12px; white-space: nowrap; }
.lora-picker-strength { padding: 14px 20px; border-top: 1px solid rgba(73, 196, 171, .24); background: rgba(25, 82, 73, .1); }
.lora-picker-strength-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lora-picker-strength output { color: #a7ead9; font-size: .76rem; font-weight: 720; }
.lora-picker-strength .range { margin: 12px 0 0; }
.lora-picker-strength p { margin: 8px 0 0; color: var(--subtle); font-size: .7rem; line-height: 1.4; }
.lora-picker-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 20px; border-top: 1px solid var(--border); }
.model-import-modal { position: fixed; z-index: 82; inset: 0; display: grid; padding: min(4vh, 32px) min(4vw, 48px); place-items: center; }
.model-import-card { position: relative; z-index: 1; display: grid; width: min(980px, 100%); max-height: min(900px, calc(100vh - 32px)); grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; border: 1px solid rgba(124, 92, 255, .52); background: #111821; box-shadow: var(--shadow); }
.model-import-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 18px 22px; border-bottom: 1px solid var(--border); background: linear-gradient(120deg, rgba(89, 67, 177, .17), rgba(17, 24, 33, .98)); }
.model-import-header h2 { margin: 4px 0 5px; font-size: 1.25rem; }
.model-import-header p { margin: 0; color: var(--muted); font-size: .76rem; }
.model-import-body { display: grid; align-content: start; gap: 14px; padding: 18px 22px; overflow-y: auto; }
.model-import-section { border: 1px solid var(--border); background: rgba(8, 13, 20, .38); }
.model-import-section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; padding: 13px 15px; border-bottom: 1px solid var(--border); }
.model-import-section-heading h3 { margin: 4px 0 0; font-size: .92rem; }
.model-import-section-heading > p { max-width: 430px; margin: 0; color: var(--subtle); font-size: .7rem; line-height: 1.45; text-align: right; }
.model-import-grid, .model-import-prompt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 15px; }
.model-import-prompt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.model-import-wide { grid-column: 1 / -1; }
.model-import-base-help { display: block; margin-top: 7px; color: var(--subtle); font-size: .7rem; line-height: 1.45; }
.model-import-toggle-row { display: flex; flex-wrap: wrap; gap: 18px; padding: 15px; }
.model-import-subsection { margin: 0 15px 15px; border: 1px solid rgba(124, 92, 255, .24); background: rgba(60, 45, 122, .08); }
.model-import-subsection .model-import-grid { padding: 13px; }
.field-with-suffix { position: relative; }
.field-with-suffix .field { width: 100%; padding-right: 36px; }
.field-with-suffix > span { position: absolute; top: 50%; right: 12px; color: var(--subtle); font-size: .72rem; transform: translateY(-50%); pointer-events: none; }
.model-import-actions { display: flex; min-height: 66px; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 22px; border-top: 1px solid var(--border); background: #111821; }
.model-import-actions > p { margin: 0; color: var(--danger); font-size: .73rem; line-height: 1.4; }
.model-import-actions > div { display: flex; flex: 0 0 auto; gap: 8px; }
.batch-review-modal { position: fixed; z-index: 55; inset: 0; display: grid; padding: min(5vh, 44px) min(4vw, 56px); place-items: center; }
.batch-review-card { position: relative; z-index: 1; display: grid; width: min(1180px, 100%); max-height: 100%; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; border: 1px solid var(--border-bright); background: #111821; box-shadow: var(--shadow); }
.batch-review-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.batch-review-header h2 { margin: 4px 0 5px; font-size: 1.2rem; }
.batch-review-header p { margin: 0; color: var(--muted); font-size: .8rem; }
.batch-review-content { display: grid; min-height: 0; grid-template-rows: minmax(156px, .4fr) minmax(250px, .6fr); overflow: hidden; }
.batch-review-grid { display: grid; min-height: 0; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); align-content: start; gap: 8px; padding: 10px 16px; overflow: auto; }
.batch-review-image { position: relative; min-width: 0; padding: 0; overflow: hidden; border: 2px solid var(--border); background: var(--input); color: var(--text); text-align: left; }
.batch-review-image:hover, .batch-review-image:focus-visible { border-color: var(--accent-bright); }
.batch-review-image.is-selected { border-color: #f4dc7e; box-shadow: 0 0 0 2px rgba(244, 220, 126, .18); }
.batch-review-image img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
.batch-review-image span { display: block; padding: 5px 7px; color: var(--muted); font-size: .64rem; }
.batch-review-check { position: absolute; top: 8px; right: 8px; display: grid; min-width: 25px; height: 25px; border: 1px solid rgba(255, 255, 255, .42); border-radius: 50%; place-items: center; background: rgba(7, 11, 16, .78); color: transparent; font-size: .82rem; }
.batch-review-image.is-selected .batch-review-check { border-color: #ffe789; background: #816817; color: #fff9cd; }
.batch-review-preview { position: relative; display: grid; min-height: 0; overflow: hidden; border-top: 1px solid var(--border); place-items: center; background: #080d12; }
.batch-review-preview img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.batch-review-preview-meta { position: absolute; top: 12px; left: 14px; max-width: calc(100% - 28px); margin: 0; padding: 7px 9px; border: 1px solid rgba(112, 128, 151, .3); background: rgba(7, 11, 16, .8); color: #d9e0e9; font-size: .72rem; line-height: 1.35; pointer-events: none; }
.batch-review-preview:not(.has-image) img { display: none; }
.mobile-review-viewer { display: none; }
.mobile-review-stage { position: relative; min-height: 0; overflow: hidden; background: #070b10; }
.mobile-review-stage > img { display: block; width: 100%; height: 100%; object-fit: contain; transition: opacity .14s ease, transform .14s ease; }
.mobile-review-nav { position: absolute; z-index: 2; top: 50%; display: grid; width: 44px; height: 58px; padding: 0; border: 1px solid rgba(255, 255, 255, .2); border-radius: 5px; place-items: center; background: rgba(7, 11, 16, .72); color: #fff; font-size: 2rem; transform: translateY(-50%); }
.mobile-review-nav:disabled { visibility: hidden; }
.mobile-review-previous { left: 7px; }
.mobile-review-next { right: 7px; }
.mobile-review-image-meta { position: absolute; z-index: 2; top: 9px; left: 10px; display: flex; max-width: calc(100% - 20px); gap: 8px; margin: 0; padding: 6px 8px; border: 1px solid rgba(112, 128, 151, .3); background: rgba(7, 11, 16, .78); color: #d9e0e9; font-size: .68rem; line-height: 1.2; pointer-events: none; }
.mobile-review-image-meta strong { color: #fff; }
.mobile-review-strip { display: flex; gap: 7px; min-height: 0; padding: 7px 10px; overflow-x: auto; overscroll-behavior-x: contain; background: #0d131a; scrollbar-width: thin; }
.mobile-review-thumb { position: relative; flex: 0 0 58px; height: 58px; padding: 0; overflow: hidden; border: 2px solid var(--border); background: #080d12; }
.mobile-review-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.mobile-review-thumb.is-current { border-color: var(--accent-bright); box-shadow: 0 0 0 1px rgba(87, 180, 255, .24); }
.mobile-review-thumb::after { position: absolute; right: 3px; bottom: 3px; display: none; min-width: 19px; height: 19px; border-radius: 50%; place-items: center; color: #fff; font-size: .65rem; font-weight: 800; }
.mobile-review-thumb.is-kept::after { display: grid; background: #2b8a57; content: "\2713"; }
.mobile-review-thumb.is-discarded::after { display: grid; background: #9c3e46; content: "\00d7"; }
.mobile-review-decisions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 8px 10px 3px; background: #111821; }
.mobile-review-discard-this { border-color: rgba(235, 105, 116, .5); color: #ffc7cc; }
.mobile-review-discard-this.is-active { border-color: #ed6d78; background: rgba(156, 62, 70, .3); }
.mobile-review-keep-this.is-active { border-color: #83d4a8; background: #276946; color: #fff; }
.mobile-review-progress { margin: 0; padding: 4px 10px 8px; background: #111821; color: var(--subtle); font-size: .67rem; text-align: center; }
.batch-review-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 20px; border-top: 1px solid var(--border); }
.batch-review-actions > div { display: flex; gap: 8px; }
.review-select-all { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .78rem; }
.modal-open { overflow: hidden; }
.account-modal { position: fixed; z-index: 90; inset: 0; display: grid; padding: min(7vh, 56px) min(4vw, 48px); place-items: center; }
.account-card { position: relative; z-index: 1; width: min(680px, 100%); max-height: calc(100vh - 48px); overflow: auto; border: 1px solid rgba(124, 92, 255, .48); background: #111821; box-shadow: var(--shadow); }
.account-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 20px 22px; border-bottom: 1px solid var(--border); background: linear-gradient(120deg, rgba(83, 62, 158, .16), rgba(17, 24, 33, .98)); }
.account-header h2 { margin: 4px 0 5px; font-size: 1.2rem; }
.account-header p { margin: 0; color: var(--muted); font-size: .76rem; }
.account-body { padding: 20px 22px 22px; }
#accountSignedOut { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 18px; }
.account-option { display: flex; min-width: 0; flex-direction: column; align-items: stretch; }
.account-option h3, .link-worker-card h3, .account-worker-heading h3, .access-code-reveal h3 { margin: 0 0 7px; font-size: .95rem; }
.account-option p, .link-worker-card p, .access-code-reveal p { margin: 0 0 15px; color: var(--muted); font-size: .74rem; line-height: 1.5; }
.account-option .button { margin-top: 12px; }
.account-divider { display: grid; width: 1px; place-items: center; background: var(--border); }
.account-divider span { padding: 6px 0; background: #111821; color: var(--subtle); font-size: .68rem; transform: translateX(-50%); }
.account-code-input { font-family: "Cascadia Mono", Consolas, monospace; letter-spacing: .08em; text-transform: uppercase; }
.access-code-reveal { text-align: center; }
.access-code-reveal output { display: block; margin: 18px 0 14px; padding: 16px; border: 1px solid rgba(73, 196, 171, .55); background: #0a1219; color: #b8f5e5; font: 700 1.08rem/1.4 "Cascadia Mono", Consolas, monospace; letter-spacing: .13em; overflow-wrap: anywhere; user-select: all; }
.access-code-reveal .button { margin: 4px; }
.signed-in-summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.signed-in-summary strong { display: block; margin-top: 5px; font-size: 1.05rem; }
.link-worker-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 18px 0; padding: 16px; border: 1px solid rgba(73, 196, 171, .3); background: rgba(23, 73, 65, .12); }
.link-worker-card p { margin-bottom: 0; }
.link-worker-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.account-worker-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 20px 0 10px; }
.account-worker-heading h3 { margin: 4px 0 0; }
.account-worker-list { display: grid; gap: 8px; }
.account-worker-empty { padding: 18px; border: 1px dashed var(--border); color: var(--muted); font-size: .76rem; text-align: center; }
.account-worker-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--border); background: rgba(8, 13, 20, .48); }
.account-worker-row .status-dot.offline { background: var(--danger); box-shadow: none; }
.account-worker-copy strong { display: block; font-size: .78rem; }
.account-worker-copy span { display: block; margin-top: 3px; color: var(--subtle); font-size: .67rem; }
.account-worker-actions { display: flex; align-items: center; gap: 6px; }
.account-worker-rename { min-height: 32px; padding: 0 10px; border: 1px solid var(--border); background: transparent; color: var(--muted); font-size: .68rem; font-weight: 700; }
.account-worker-rename:hover { border-color: var(--border-bright); color: var(--text); }
.account-worker-remove { width: 32px; height: 32px; border: 1px solid var(--border); background: transparent; color: var(--muted); }
.account-worker-remove:hover { border-color: rgba(255, 112, 133, .55); color: var(--danger); }
.account-message { min-height: 1.2em; margin: 14px 0 0; color: var(--muted); font-size: .74rem; }
.account-message.error { color: var(--danger); }

.mobile-dock, .tile-repair-mobile-tabs { display: none; }

.toast { position: fixed; z-index: 60; right: 24px; bottom: 24px; max-width: min(380px, calc(100vw - 48px)); padding: 13px 16px; border: 1px solid var(--border-bright); background: #182130; color: var(--text); font-size: 0.82rem; box-shadow: 0 18px 48px rgba(0, 0, 0, 0.42); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255, 112, 133, 0.55); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 1050px) {
  .topbar { grid-template-columns: 1fr auto; }
  .main-nav { grid-row: 2; grid-column: 1 / -1; justify-self: start; }
  .topbar-status { grid-column: 2; }
  .worker-switcher { max-width: 180px; }
  .hardware-pill { display: none; }
  .workspace { grid-template-columns: 1fr; min-height: 0; }
  .control-card { min-height: 0; }
  .output-card { min-height: 680px; }
  #resultImage { max-height: 680px; }
  .tile-repair-workspace { grid-template-columns: minmax(340px, 400px) minmax(0, 1fr); }
}

@media (max-width: 760px) {
  html { scroll-padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  button, .button, .icon-button, .viewer-button, .zoom-label { min-height: 44px; }
  .field { min-height: 48px; font-size: 16px; }
  textarea.field { line-height: 1.5; }
  .check-control { min-height: 44px; }
  .check-control input { width: 19px; height: 19px; flex: 0 0 auto; }
  .range { height: 8px; margin-top: 20px; margin-bottom: 10px; }
  .range::-webkit-slider-thumb { width: 24px; height: 24px; }
  .range::-moz-range-thumb { width: 20px; height: 20px; }

  .app-shell { width: min(100% - 24px, 620px); padding: 12px 0 24px; }
  .topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; gap: 10px 12px; margin-bottom: 20px; }
  .brand { grid-column: 1; grid-row: 1; align-self: center; }
  .brand-name { font-size: 1.22rem; }
  .brand .eyebrow { font-size: .58rem; }
  .main-nav { display: none; }
  .topbar-status { display: contents; }
  .worker-switcher { grid-column: 1 / -1; grid-row: 2; width: 100%; max-width: none; min-height: 46px; }
  .worker-switcher select { width: 100%; max-width: none; flex: 1; font-size: .78rem; }
  .account-button { grid-column: 2; grid-row: 1; min-height: 44px; max-width: 42vw; overflow: hidden; padding: 0 12px; text-overflow: ellipsis; white-space: nowrap; }
  .hardware-pill, .queue-button, .inbox-button { display: none; }
  .generation-queue, .job-inbox { display: contents; }

  .mobile-dock { position: fixed; z-index: 45; right: 0; bottom: 0; left: 0; display: grid; height: calc(66px + env(safe-area-inset-bottom)); grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 5px 8px env(safe-area-inset-bottom); border-top: 1px solid rgba(83, 98, 120, .72); background: rgba(12, 18, 26, .96); box-shadow: 0 -12px 34px rgba(0, 0, 0, .36); backdrop-filter: blur(18px); }
  .mobile-dock-button { position: relative; display: grid; min-width: 0; min-height: 56px; grid-template-rows: 23px auto; align-content: center; place-items: center; gap: 2px; padding: 3px 2px; border: 0; border-radius: 8px; background: transparent; color: var(--subtle); font-size: .65rem; font-weight: 720; }
  .mobile-dock-button.is-active, .mobile-dock-button[aria-expanded="true"] { background: rgba(124, 92, 255, .14); color: #ddd6ff; }
  .mobile-dock-icon { font-size: 1.2rem; line-height: 1; }
  .mobile-dock-badge { position: absolute; top: 4px; left: calc(50% + 8px); display: grid; min-width: 18px; height: 18px; padding: 0 4px; border: 2px solid #0c121a; border-radius: 999px; place-items: center; background: var(--accent); color: #fff; font-size: .58rem; }

  .queue-panel, .inbox-panel { position: fixed; z-index: 46; top: auto; right: 8px; bottom: calc(72px + env(safe-area-inset-bottom)); left: 8px; width: auto; max-height: calc(100dvh - 92px - env(safe-area-inset-bottom)); overscroll-behavior: contain; border-color: var(--border-bright); box-shadow: 0 -18px 50px rgba(0, 0, 0, .48); }
  .queue-panel > header, .inbox-panel header { align-items: flex-start; padding: 14px; }
  .queue-item { grid-template-columns: 30px minmax(0, 1fr) 44px; padding: 13px 12px; }
  .queue-cancel { width: 44px; height: 44px; }
  .queue-item-heading { align-items: flex-start; flex-direction: column; gap: 3px; }
  .queue-item-detail, .queue-item-eta { white-space: normal; }
  .inbox-item { min-height: 64px; }

  .connection-notice { align-items: stretch; flex-direction: column; gap: 16px; margin: 0 0 22px; padding: 16px; }
  .connection-notice > div:last-child { display: grid; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .connection-notice #noticeAccountButton { grid-column: 1 / -1; }
  .connection-notice .button { width: 100%; padding: 0 10px; }

  h1 { font-size: clamp(1.75rem, 10vw, 2.35rem); }
  .library-hero { align-items: flex-start; flex-direction: column; gap: 16px; margin-bottom: 18px; }
  .library-hero p { font-size: .8rem; }
  .library-actions { display: grid; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .library-actions .button { width: 100%; min-width: 0; padding: 0 9px; }
  .library-actions .compact-primary { grid-column: 1 / -1; }
  .library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .library-card:hover { transform: none; }
  .library-card-meta { padding: 9px 10px 10px; }
  .library-card-prompt { -webkit-line-clamp: 2; }
  .favorite-toggle { top: 6px; right: 6px; }
  .library-delete-toggle { bottom: 6px; left: 6px; }
  .favorite-toggle, .library-delete-toggle { width: 44px; height: 44px; }
  .library-empty { margin-top: 7vh; padding: 38px 20px; }

  .create-heading { align-items: center; flex-direction: row; gap: 12px; margin-bottom: 12px; }
  .create-heading h1 { margin: 0; font-size: 1.55rem; }
  .create-heading > div > p, .create-heading .eyebrow { display: none; }
  .create-heading .button { flex: 0 0 auto; min-height: 42px; padding: 0 11px; font-size: .74rem; }
  .workspace { display: flex; min-height: 0; flex-direction: column; gap: 12px; }
  .workspace > .output-card { order: -1; }
  .control-card, .output-card { box-shadow: 0 14px 40px rgba(0, 0, 0, .22); }
  .control-card { min-height: 0; padding: 14px; }
  .generator-worker-card { grid-template-columns: 1fr; gap: 9px; margin-bottom: 14px; padding: 11px; }
  .output-card { min-height: 0; grid-template-rows: auto minmax(300px, 50svh) auto; }
  .output-heading { min-height: 0; align-items: flex-start; flex-direction: column; padding: 13px 14px; }
  .output-actions { display: grid; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .output-actions .button { width: 100%; min-width: 0; }
  .image-stage { min-height: 300px; height: 50svh; max-height: 520px; margin: 0 10px; }
  #resultImage, .live-preview-image { max-height: 50svh; }
  .output-footer { min-height: 48px; padding: 0 12px; font-size: .66rem; }
  .output-footer > span { max-width: 60%; }

  .section-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
  .model-actions { display: grid; width: 100%; grid-template-columns: minmax(0, 1fr) 44px; }
  .model-actions .button { width: 100%; }
  .model-actions .icon-button { width: 44px; height: 44px; }
  .model-recommendation { font-size: .68rem; }
  .lora-module-heading { align-items: flex-start; }
  .lora-add-button { min-height: 40px; }
  .lora-remove-button { width: 40px; height: 40px; }
  .prompt-block { margin-top: 18px; }
  .prompt { min-height: 176px; }
  .reference-actions { grid-template-columns: 1fr; }
  .reference-upload-label { width: 100%; }
  .reference-image-chip { width: 78px; height: 78px; }
  .reference-remove { width: 32px; height: 32px; }
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .steps-card, .batch-card { padding: 12px; }
  .steps-heading, .batch-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 10px; }
  .steps-heading p, .batch-heading p { font-size: .69rem; line-height: 1.35; }
  .stepper { grid-template-columns: 44px 52px 44px; }
  .stepper button, .stepper input { height: 44px; }
  .stepper input { width: 52px; font-size: 16px; }
  .quick-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: 6px; }
  .quick-row .check-control { padding: 7px 9px; border: 1px solid var(--border); background: rgba(8, 13, 20, .42); }
  .quick-row #sizePreview { grid-column: 1 / -1; margin: 2px 0 0; text-align: right; }
  .face-step-heading { align-items: flex-start; }
  .face-step-heading p { font-size: .69rem; line-height: 1.4; }
  .tiled-detail-settings { grid-template-columns: 1fr; }
  .tiled-step-setting, .tiled-redraw-setting, .tiled-overlap-setting, .tiled-detail-estimate { grid-column: auto; }
  .advanced summary { min-height: 44px; padding-top: 14px; }
  .generation-actions { position: sticky; z-index: 8; bottom: calc(72px + env(safe-area-inset-bottom)); margin: 16px -6px -6px; padding: 10px 6px 6px; border-top: 1px solid rgba(71, 84, 105, .8); background: linear-gradient(180deg, rgba(17, 24, 33, .88), #111821 24%); }
  .loading-state.has-preview { position: fixed; z-index: 44; right: 8px; bottom: calc(66px + env(safe-area-inset-bottom)); left: 8px; }
  .scaffold-live-viewer:not([hidden]) p { position: fixed; z-index: 44; right: 8px; bottom: calc(66px + env(safe-area-inset-bottom)); left: 8px; }

  .scaffold-refinement-view { width: 100%; }
  .scaffold-refinement-header { align-items: stretch; flex-direction: column; gap: 14px; padding: 16px; }
  .scaffold-refinement-header .button { width: 100%; }
  .scaffold-refinement-summary { grid-template-columns: 72px minmax(0, 1fr); gap: 11px; margin: 12px 14px 0; padding: 9px; }
  .scaffold-refinement-summary img { width: 72px; }
  .scaffold-refinement-summary strong { font-size: .82rem; }
  .scaffold-refinement-summary p { font-size: .68rem; }
  .scaffold-live-viewer { margin: 10px 14px 0; }
  .scaffold-live-viewer > header { align-items: flex-start; flex-direction: column; gap: 4px; padding: 9px 11px; }
  .scaffold-live-viewer > header strong { width: 100%; font-size: .68rem; }
  .scaffold-live-viewer > div { height: 56svh; min-height: 300px; }
  .scaffold-live-viewer p { right: 8px; bottom: 8px; left: 8px; padding: 7px 8px; font-size: .66rem; }
  .scaffold-refinement-settings { gap: 8px; padding: 14px; }
  .scaffold-setting-card, .scaffold-batch-card, .scaffold-tiled-settings { grid-template-columns: 1fr; gap: 12px; padding: 12px; }
  .scaffold-tiled-settings .tiled-redraw-setting, .scaffold-tiled-settings .tiled-overlap-setting, .scaffold-tiled-settings .tiled-detail-estimate { grid-column: auto; }
  .scaffold-face-marker-canvas img { max-height: 58svh; }
  .scaffold-batch-card .batch-summary { grid-column: auto; }
  .scaffold-refinement-actions { position: sticky; z-index: 8; bottom: calc(72px + env(safe-area-inset-bottom)); padding: 10px 14px 14px; border-top: 1px solid var(--border); background: rgba(17, 24, 33, .96); }

  .image-modal, .modal-card { width: 100vw; height: 100dvh; }
  .modal-header { display: grid; min-height: 0; grid-template-columns: minmax(0, 1fr) 44px; gap: 8px 10px; padding: 9px 10px; }
  .modal-header > div:first-child { min-width: 0; }
  .modal-header .eyebrow { font-size: .57rem; }
  .modal-header h2 { overflow: hidden; margin: 2px 0 0; font-size: .95rem; text-overflow: ellipsis; white-space: nowrap; }
  .modal-close { grid-column: 2; grid-row: 1; width: 44px; height: 44px; }
  .modal-actions { grid-column: 1 / -1; grid-row: 2; width: 100%; margin: 0; padding: 1px 0 3px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
  .zoom-controls { flex: 0 0 auto; }
  .viewer-button, .zoom-label { flex: 0 0 auto; min-height: 44px; }
  .scaffold-inspect-button, .rerun-image-button, .scaffold-refine-button, .tile-repair-button, .delete-image-button { min-width: max-content; padding: 0 11px; }
  .modal-content { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(128px, 31dvh); }
  .modal-image-wrap { min-height: 0; }
  .image-nav-button { width: 44px; height: 58px; font-size: 2rem; }
  .image-nav-previous { left: 6px; }
  .image-nav-next { right: 6px; }
  .zoom-help { display: none; }
  .image-details { max-height: none; padding: 8px 14px calc(14px + env(safe-area-inset-bottom)); }
  .detail-row { padding: 9px 0; }
  .detail-value { font-size: .76rem; }
  .image-modal.is-image-focused .modal-card { grid-template-rows: minmax(0, 1fr); }
  .image-modal.is-image-focused .modal-header,
  .image-modal.is-image-focused .image-details,
  .image-modal.is-image-focused .image-nav-button,
  .image-modal.is-image-focused .zoom-help { display: none; }
  .image-modal.is-image-focused .modal-content { grid-template-rows: minmax(0, 1fr); }

  .tile-repair-panel { display: grid; min-height: 0; grid-template-rows: auto minmax(0, 1fr); }
  .tile-repair-mobile-tabs { display: grid; min-height: 50px; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 5px; border-bottom: 1px solid var(--border); background: #111821; }
  .tile-repair-mobile-tabs button { min-height: 40px; border: 0; background: transparent; color: var(--subtle); font-size: .73rem; font-weight: 720; }
  .tile-repair-mobile-tabs button.is-active { background: rgba(87, 180, 255, .14); color: #c9eaff; }
  .tile-repair-mobile-tabs span { display: inline-grid; min-width: 18px; height: 18px; margin-left: 4px; border-radius: 999px; place-items: center; background: #386f9a; color: #fff; font-size: .6rem; }
  .tile-repair-workspace { display: grid; height: 100%; grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); overflow: hidden; }
  .tile-repair-sidebar, .tile-repair-stage { grid-column: 1; grid-row: 1; min-height: 0; }
  .tile-repair-panel[data-mobile-view="canvas"] .tile-repair-sidebar { display: none; }
  .tile-repair-panel[data-mobile-view="tools"] .tile-repair-stage { display: none; }
  .tile-repair-sidebar { grid-template-rows: minmax(0, 1fr) auto auto; padding: 12px; border: 0; }
  .tile-repair-heading { padding: 0 2px 12px 0; }
  .tile-repair-heading h3 { font-size: .98rem; }
  .tile-repair-heading > p { font-size: .72rem; }
  .tile-repair-stage { padding: 6px; }
  .tile-repair-canvas { max-width: 100%; max-height: 100%; }
  .tile-repair-canvas img { max-width: 100%; max-height: calc(100dvh - 122px); }
  .tile-repair-face-controls { align-items: flex-start; flex-direction: column; gap: 4px; }
  .tile-repair-face-marker-help { align-items: stretch; flex-direction: column; }
  .tile-repair-actions { padding-bottom: env(safe-area-inset-bottom); }

  .lora-picker-modal, .model-import-modal, .batch-review-modal, .account-modal { padding: 0; }
  .lora-picker-card, .model-import-card, .batch-review-card, .account-card { width: 100vw; height: 100dvh; max-height: 100dvh; border: 0; }
  .lora-picker-header, .model-import-header, .batch-review-header, .account-header { padding: 13px 14px; }
  .lora-picker-header h2, .model-import-header h2, .batch-review-header h2, .account-header h2 { font-size: 1.05rem; }
  .lora-picker-body { padding: 12px 14px; }
  .lora-picker-option { grid-template-columns: 1fr; }
  .lora-picker-select { min-height: 58px; gap: 8px; padding: 10px; }
  .lora-picker-option > .lora-source-link { margin: 0 10px 10px; min-height: 36px; line-height: 36px; }
  .lora-picker-strength { padding: 12px 14px; }
  .lora-picker-actions { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .lora-picker-actions .button { flex: 1; }

  .model-import-body { gap: 10px; padding: 12px; }
  .model-import-section-heading { align-items: flex-start; flex-direction: column; gap: 7px; padding: 12px; }
  .model-import-section-heading > p { max-width: none; text-align: left; }
  .model-import-grid, .model-import-prompt-grid { grid-template-columns: 1fr; padding: 12px; }
  .model-import-wide { grid-column: auto; }
  .model-import-toggle-row { align-items: flex-start; flex-direction: column; gap: 2px; padding: 12px; }
  .model-import-actions { min-height: 0; align-items: stretch; flex-direction: column; gap: 7px; padding: 9px 14px calc(9px + env(safe-area-inset-bottom)); }
  .model-import-actions > div { width: 100%; }
  .model-import-actions .button { flex: 1; }

  .account-card { overflow-y: auto; }
  .account-header { position: sticky; z-index: 2; top: 0; background: #111821; }
  .account-body { padding: 14px 14px calc(18px + env(safe-area-inset-bottom)); }
  #accountSignedOut { grid-template-columns: 1fr; }
  .account-divider { width: 100%; height: 1px; }
  .account-divider span { padding: 0 7px; transform: none; }
  .link-worker-card { align-items: stretch; flex-direction: column; padding: 13px; }
  .link-worker-actions { display: grid; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .link-worker-card .button { width: 100%; padding: 0 8px; }
  .signed-in-summary { align-items: flex-start; }
  .account-worker-heading { align-items: center; }
  .account-worker-remove { width: 44px; height: 44px; }

  .batch-review-card { grid-template-rows: auto minmax(0, 1fr) auto; }
  .batch-review-header { min-height: 68px; align-items: center; }
  .batch-review-header .eyebrow { display: none; }
  .batch-review-header h2 { margin: 0 0 3px; }
  .batch-review-header p { overflow: hidden; max-width: calc(100vw - 78px); text-overflow: ellipsis; white-space: nowrap; }
  .batch-review-content { display: block; min-height: 0; }
  .batch-review-grid, .batch-review-preview { display: none; }
  .mobile-review-viewer:not([hidden]) { display: grid; height: 100%; min-height: 0; grid-template-rows: minmax(0, 1fr) 72px auto auto; overflow: hidden; }
  .mobile-review-stage { touch-action: none; }
  .mobile-review-decisions .button { min-height: 48px; }
  .batch-review-actions { align-items: stretch; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .review-select-all { display: none; }
  .batch-review-actions > div { display: grid; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .batch-review-actions .button { width: 100%; padding: 0 8px; }

  .toast { right: 12px; bottom: calc(78px + env(safe-area-inset-bottom)); left: 12px; max-width: none; }
}

@media (max-width: 380px) {
  .settings-grid, .quick-row { grid-template-columns: 1fr; }
  .quick-row #sizePreview { grid-column: auto; }
  .library-card-date { display: none; }
  .link-worker-actions { grid-template-columns: 1fr; }
}

@media (max-width: 900px) and (max-height: 540px) {
  .image-stage { height: 68svh; }
  #resultImage, .live-preview-image { max-height: 68svh; }
  .modal-content { grid-template-rows: minmax(0, 1fr) minmax(100px, 36dvh); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
