:root {
    color-scheme: dark;
    --bg: #111225;
    --bg-deep: #0b0c1c;
    --panel: #17182d;
    --panel-2: #101126;
    --panel-3: #202238;
    --line: #292b46;
    --line-soft: #22243d;
    --text: #f8f6ff;
    --muted: #9a9db7;
    --faint: #6f728b;
    --cream: #fbfac0;
    --blue: #92a0c6;
    --accent: #f6f5b3;
    --danger: #ff6e87;
    --shadow: 0 18px 60px rgba(0, 0, 0, .34);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 12px;
    overflow: hidden;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    color: inherit;
}

svg {
    display: block;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-shell {
    display: grid;
    grid-template-columns: 332px minmax(420px, 1fr) 118px;
    grid-template-rows: 38px minmax(0, 1fr);
    min-height: 100vh;
    background:
        radial-gradient(circle at 56% 13%, rgba(255, 255, 255, .035), transparent 21%),
        linear-gradient(90deg, #17182c 0 332px, var(--bg-deep) 332px calc(100% - 118px), #121326 calc(100% - 118px));
}

.topbar {
    grid-column: 1 / 2;
    grid-row: 1;
    display: grid;
    grid-template-columns: 46px 1fr 42px 146px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: #17182e;
}

.topbar-title {
    display: flex;
    align-items: center;
    justify-content: center;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    color: #fff9c2;
    font-weight: 700;
    letter-spacing: .01em;
}

.mode-switch-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    padding: 0 12px;
    border: 0;
    border-left: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}

.mode-switch-button:hover {
    background: #20213a;
}

.mode-switch-button svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.global-import-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    height: 38px;
    padding: 0;
    border: 0;
    border-left: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    font-weight: 900;
    cursor: pointer;
    white-space: nowrap;
}

.global-import-button span {
    display: none;
}

.global-import-button:hover {
    background: #252744;
}

.global-import-button svg {
    width: 15px;
    height: 15px;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-left: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    min-width: 36px;
    height: 38px;
}

.icon-button:hover {
    background: #20213a;
}

.icon-button.small {
    min-width: 34px;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    background: #191a31;
}

.icon-button.ghost {
    border-color: transparent;
    background: transparent;
}

.left-panel {
    grid-column: 1;
    grid-row: 2;
    overflow-y: auto;
    padding: 16px 16px 18px;
    border-right: 1px solid var(--line);
    scrollbar-color: #333653 transparent;
}

.api-key-card {
    border: 1px solid var(--line);
    background: rgba(20, 21, 39, .86);
    padding: 12px;
    margin-bottom: 10px;
}

.api-key-card label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-weight: 800;
}

.api-key-input-wrap {
    display: grid;
    grid-template-columns: 28px 1fr;
    align-items: center;
    border: 1px solid var(--line);
    background: #111225;
}

.api-key-input-wrap svg {
    width: 16px;
    height: 16px;
    justify-self: center;
    color: var(--cream);
}

.api-key-input-wrap input {
    height: 34px;
    border: 0;
    background: transparent;
    padding: 0 10px 0 0;
    color: var(--text);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.model-card,
.panel-card,
.image-settings {
    border: 1px solid var(--line);
    background: rgba(20, 21, 39, .86);
}

.model-card {
    padding: 16px;
    margin-bottom: 34px;
}

.model-card select,
select,
input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #111225;
    color: var(--text);
}

.model-card select {
    padding: 0 22px 4px 0;
    border: 0;
    background: transparent;
    color: #fff;
    font-weight: 800;
    white-space: normal;
}

.model-card p {
    margin: 4px 0 0;
    color: #fff;
    font-weight: 700;
    line-height: 1.45;
}

.prompt-card {
    padding: 12px 12px 0;
    background: #0e0f22;
}

.prompt-tabs,
.mini-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 9px;
}

.prompt-tab,
.mini-tabs button,
.tool-button,
.choice-button,
.sample-tabs button {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-weight: 800;
    cursor: pointer;
}

.prompt-tab.active,
.mini-tabs button.active,
.choice-button.active,
.sample-tabs button.active {
    background: #252744;
    color: #fff;
}

.prompt-tab {
    padding: 4px 7px;
}

.prompt-tabs .icon-button {
    margin-left: auto;
}

.prompt-editor {
    position: relative;
    min-height: 118px;
}

.prompt-input,
.prompt-highlight {
    min-height: 118px;
    padding: 0;
    border: 0;
    background: transparent;
    font-weight: 800;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.prompt-input {
    position: relative;
    z-index: 1;
    color: #fff;
    resize: vertical;
}

.prompt-highlight {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: none;
    color: #fff;
    pointer-events: none;
    overflow: hidden;
}

.prompt-editor.highlight-enabled .prompt-highlight {
    display: block;
}

.prompt-editor.highlight-enabled .prompt-input {
    color: transparent;
    caret-color: #fff;
}

.prompt-emphasis {
    border-radius: 3px;
    padding: 0 2px;
}

.prompt-emphasis.up {
    color: #fff6a8;
    background: rgba(247, 240, 151, .16);
}

.prompt-emphasis.down {
    color: #8fc8ff;
    background: rgba(104, 164, 255, .16);
}

.hidden {
    display: none !important;
}

.quality-row {
    display: grid;
    grid-template-columns: 28px 1fr;
    align-items: center;
    gap: 8px;
    margin: 8px 0 4px;
}

input[type="range"] {
    height: 16px;
    border: 0;
    padding: 0;
    accent-color: var(--cream);
    background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 8px;
    background: #242741;
}

input[type="range"]::-webkit-slider-thumb {
    margin-top: -4px;
}

.mini-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    border: 0;
    background: transparent;
    color: #fff;
}

.check-line {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-weight: 700;
    margin: 0 0 12px;
}

.check-line.compact {
    color: #fff;
    margin-top: 10px;
}

.check-line input,
.toggle-row input {
    width: 14px;
    height: 14px;
    accent-color: var(--cream);
}

.base-image-slot {
    display: grid;
    grid-template-columns: 1fr 36px;
    align-items: center;
    gap: 6px;
    margin: 0 -12px;
    padding: 12px 12px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-weight: 800;
}

.base-image-active {
    position: relative;
    margin: 0 -12px;
    padding: 10px 14px 14px;
    background: #7f8795;
    overflow: hidden;
}

.base-image-active::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(16, 17, 34, .36);
}

.base-image-active > * {
    position: relative;
}

.base-image-active img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: .45;
}

.base-image-tools {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-bottom: 10px;
}

.tool-button.mask-ready {
    background: var(--cream);
    color: #101126;
}

.tool-button {
    padding: 8px 12px;
    background: #252744;
    color: #fff;
}

.base-image-active label,
.ai-settings label {
    display: block;
    margin: 8px 0 3px;
    font-weight: 800;
}

.section-heading,
.module-title,
.settings-header,
.global-position {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.section-heading {
    position: relative;
}

.character-add-menu {
    position: absolute;
    right: 0;
    top: 34px;
    z-index: 4;
    display: grid;
    min-width: 128px;
    border: 1px solid var(--line);
    background: #17182d;
    box-shadow: var(--shadow);
}

.character-add-menu button {
    height: 34px;
    border: 0;
    background: transparent;
    color: #fff;
    text-align: left;
    padding: 0 12px;
    font-weight: 900;
    cursor: pointer;
}

.character-add-menu button:hover {
    background: #252744;
}

.section-heading {
    margin: 18px 0 8px;
}

h2 {
    margin: 0;
    font-size: 12px;
    font-weight: 800;
}

p {
    margin: 0;
}

.section-heading p,
.module-title p {
    color: var(--muted);
    font-weight: 700;
}

.add-button {
    border: 0;
    background: #272945;
    color: #fff;
    padding: 8px 10px;
    font-weight: 900;
    cursor: pointer;
}

.character-card {
    border: 1px solid var(--line);
    background: #111225;
    margin-bottom: 10px;
}

.character-head {
    display: grid;
    grid-template-columns: 1fr 30px 30px 30px 30px;
    align-items: center;
    gap: 2px;
    background: #181a31;
}

.character-card.disabled-item,
.ref-item.disabled-item {
    opacity: .56;
    filter: grayscale(.45);
}

.character-card.disabled-item textarea,
.character-card.disabled-item .character-title,
.ref-item.disabled-item {
    color: var(--faint);
}

.character-title {
    padding: 8px;
    font-weight: 900;
}

.character-body {
    padding: 10px;
}

.character-body textarea {
    min-height: 76px;
    border: 0;
    padding: 0;
    background: transparent;
    color: #fff;
    font-weight: 800;
    resize: vertical;
}

.character-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 8px;
}

.position-grid {
    display: grid;
    grid-template-columns: repeat(5, 18px);
    gap: 4px;
    margin-right: auto;
}

.position-grid button {
    width: 18px;
    height: 18px;
    border: 1px solid var(--line);
    background: #15162b;
    cursor: pointer;
}

.position-grid button.active {
    background: var(--danger);
    border-color: var(--cream);
}

.choice-button {
    padding: 6px 9px;
    color: #fff;
    background: #252744;
}

.global-position {
    margin: 8px 0 22px;
    font-weight: 800;
}

.module-card {
    padding: 12px;
    margin-bottom: 10px;
}

.module-title {
    align-items: flex-start;
}

.module-title > svg {
    margin-top: 4px;
}

.ref-item {
    display: grid;
    grid-template-columns: 82px 1fr 32px 32px;
    gap: 10px;
    padding: 10px 0 0;
    border-top: 1px solid var(--line-soft);
    margin-top: 10px;
}

.ref-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ref-mode-select {
    width: 100%;
    height: 30px;
    padding: 0 8px;
    margin-bottom: 8px;
    border: 1px solid var(--line);
    background: #111225;
    color: var(--text);
    font-weight: 800;
}

.module-note {
    margin-top: 10px;
    color: var(--muted);
    font-weight: 700;
    line-height: 1.5;
}

.ref-item img {
    width: 82px;
    height: 82px;
    object-fit: cover;
    background: #050510;
}

.ref-item.disabled-item img {
    opacity: .42;
}

.ref-item label {
    display: block;
    margin-bottom: 6px;
    font-weight: 800;
}

.ref-hash {
    color: #fff;
    font-weight: 800;
    margin-bottom: 5px;
}

.image-settings {
    border: 0;
    background: transparent;
    margin: 18px 0;
}

.image-settings h2 {
    color: var(--muted);
    margin-bottom: 8px;
}

.size-grid {
    display: grid;
    grid-template-columns: 1fr 126px;
    gap: 8px;
}

.size-grid select,
.size-readout,
.sample-tabs {
    height: 36px;
    background: #111225;
    border: 1px solid var(--line);
}

.size-grid select {
    padding: 0 12px;
    font-weight: 800;
}

.size-readout {
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    color: #fff;
    font-weight: 800;
}

.sample-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin-top: 8px;
}

.sample-tabs button {
    color: #fff;
}

.ai-settings {
    padding: 14px;
    margin-top: min(22vh, 180px);
}

.settings-header {
    color: var(--muted);
    font-weight: 800;
    margin-bottom: 14px;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 8px;
}

.settings-grid input,
.settings-grid select,
.ai-settings select,
.floating-panel select,
.account-modal input {
    height: 38px;
    padding: 0 10px;
}

.ai-settings details {
    margin-top: 12px;
}

.ai-settings summary {
    font-weight: 800;
    cursor: pointer;
}

.generate-button {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 38px;
    border: 0;
    background: var(--cream);
    color: #070814;
    font-weight: 900;
    cursor: pointer;
}

.generate-button:disabled {
    opacity: .65;
    cursor: wait;
}

.gallery-area {
    grid-column: 2;
    grid-row: 1 / 3;
    overflow-y: auto;
    padding: 56px 40px 40px;
    background:
        radial-gradient(circle at 18% 17%, rgba(255, 255, 255, .05), transparent 7%),
        radial-gradient(circle at 83% 14%, rgba(255, 255, 255, .04), transparent 8%),
        var(--bg-deep);
}

.app-shell.director-mode {
    grid-template-columns: 72px minmax(620px, 1fr) 118px;
    background: linear-gradient(90deg, #17182c 0 72px, var(--bg-deep) 72px calc(100% - 118px), #121326 calc(100% - 118px));
}

.app-shell.director-mode .left-panel,
.app-shell.director-mode #generationPage {
    display: none;
}

.app-shell.director-mode .topbar {
    grid-column: 2;
    justify-self: center;
    grid-template-columns: 1fr 146px;
    width: 430px;
}

.app-shell.director-mode .mobile-menu {
    display: none;
}

.app-shell.director-mode .global-import-button {
    display: none;
}

.director-page {
    grid-column: 1 / 3;
    grid-row: 1 / 3;
    display: none;
    grid-template-columns: 72px minmax(620px, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 0;
    min-height: 100vh;
    padding: 70px 22px 16px 0;
    background: var(--bg-deep);
}

.app-shell.director-mode .director-page {
    display: grid;
}

.director-rail {
    grid-row: 1 / 3;
    display: flex;
    justify-content: center;
    padding-top: 18px;
    background: #17182c;
}

.director-upload-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 86px;
    max-width: calc(100% - 16px);
    height: 32px;
    border: 0;
    background: #252744;
    color: #fff;
    cursor: pointer;
}

.director-workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    min-height: 0;
}

.director-canvas {
    position: relative;
    min-height: 520px;
    border: 1px solid var(--line);
    background: #0c0d1f;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.director-canvas img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.director-placeholder {
    width: 88px;
    height: 60px;
    border-radius: 8px;
    background: #252744;
    color: #0c0d1f;
    display: flex;
    align-items: center;
    justify-content: center;
}

.director-placeholder svg {
    width: 54px;
    height: 38px;
    stroke-width: 2.4;
}

.director-controls {
    margin-top: 26px;
    border: 1px solid var(--line);
    background: rgba(23, 24, 45, .92);
}

.director-tool-options {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--line);
}

.director-help {
    margin-bottom: 12px;
    color: var(--muted);
    font-weight: 800;
}

.director-help strong {
    color: var(--cream);
    margin-left: 10px;
}

.director-option-grid {
    display: grid;
    grid-template-columns: 170px 1fr;
    gap: 10px;
    align-items: end;
}

.director-option-grid.three {
    grid-template-columns: 210px 1fr;
}

.director-option-grid label {
    display: block;
    color: #fff;
    font-weight: 900;
}

.director-option-grid label span {
    display: block;
    margin-bottom: 7px;
}

.director-option-grid select,
.director-option-grid input {
    height: 34px;
    padding: 0 10px;
    background: #101126;
    color: #fff;
    border: 1px solid var(--line);
}

.defry-buttons {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    height: 34px;
    border: 1px solid var(--line);
    background: #101126;
}

.defry-buttons button {
    border: 0;
    background: transparent;
    color: #fff;
    font-weight: 900;
    cursor: pointer;
}

.defry-buttons button.active {
    background: #252744;
    color: var(--cream);
}

.director-toolbar {
    display: grid;
    grid-template-columns: repeat(6, max-content) 1fr;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
}

.director-tool,
.director-transform {
    height: 34px;
    border: 0;
    padding: 0 12px;
    font-weight: 900;
}

.director-tool {
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.director-tool.active {
    background: #252744;
    color: var(--cream);
}

.director-transform {
    justify-self: end;
    background: #565b68;
    color: #101126;
    cursor: pointer;
}

.director-transform.ready {
    background: var(--cream);
}

.director-transform:disabled {
    background: #565b68;
    opacity: .55;
    cursor: not-allowed;
}

.starter {
    text-align: center;
    color: var(--muted);
    margin-bottom: 28px;
}

.starter .sparkles {
    color: var(--cream);
    font-size: 40px;
    letter-spacing: 24px;
}

.starter h1 {
    margin: 0 0 8px;
    color: var(--cream);
    font-size: 18px;
}

.starter p {
    margin-top: 22px;
    font-weight: 800;
}

.masonry {
    width: min(920px, 100%);
    margin: 0 auto;
    column-count: 4;
    column-gap: 12px;
}

.empty-gallery-message {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 140px);
    color: var(--muted);
    font-weight: 800;
    text-align: center;
}

.empty-gallery-message.hidden {
    display: none;
}

.gallery-card {
    display: block;
    width: 100%;
    margin: 0 0 12px;
    break-inside: avoid;
    border: 1px solid rgba(255, 255, 255, .09);
    padding: 0;
    background: #111225;
    cursor: pointer;
    overflow: hidden;
    border-radius: 7px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .24);
    text-align: left;
    transition: transform .14s ease, border-color .14s ease, background .14s ease;
}

.gallery-card:hover {
    transform: translateY(-2px);
    border-color: rgba(251, 250, 192, .5);
    background: #17182d;
}

.gallery-card img,
.gallery-card .starter-art {
    width: 100%;
    display: block;
}

.gallery-card img {
    height: auto;
}

.gallery-card-meta {
    display: grid;
    gap: 5px;
    padding: 9px 10px 10px;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.gallery-card-meta span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #f6f1ff;
    font-weight: 800;
}

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

.gallery-action-menu {
    position: fixed;
    z-index: 80;
    width: 224px;
    padding: 6px;
    border: 1px solid var(--line);
    background: #17182d;
    box-shadow: var(--shadow);
}

.gallery-action-menu button {
    width: 100%;
    min-height: 34px;
    padding: 0 10px;
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    font-weight: 800;
    cursor: pointer;
}

.gallery-action-menu button:hover {
    background: #252744;
}

.gallery-action-menu button.danger {
    color: var(--danger);
}

.starter-art {
    min-height: 170px;
    background:
        radial-gradient(circle at 34% 28%, rgba(255,255,255,.8) 0 3px, transparent 4px),
        linear-gradient(135deg, var(--c1), var(--c2));
}

.starter-art.tall {
    min-height: 250px;
}

.starter-art.short {
    min-height: 140px;
}

.history-panel {
    grid-column: 3;
    grid-row: 1 / 3;
    border-left: 1px solid var(--line);
    background: #111225;
    overflow-y: auto;
}

.history-toggle {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 40px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: #111225;
    color: #fff;
    font-weight: 900;
    cursor: pointer;
}

.history-list {
    padding: 8px;
}

.history-thumb {
    width: 100%;
    margin-bottom: 8px;
    border: 1px solid var(--line);
    background: #050510;
}

.history-thumb img {
    display: block;
    width: 100%;
}

.floating-panel {
    position: fixed;
    left: 332px;
    top: 54px;
    z-index: 30;
    width: 330px;
    padding: 18px;
    background: #191a2f;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.floating-panel label,
.account-modal label {
    display: block;
    margin-top: 18px;
    font-weight: 800;
}

.floating-panel label span,
    .account-modal label span {
    display: block;
    margin-bottom: 8px;
}

.toggle-row {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
}

.toggle-row span {
    margin: 0 !important;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 9, 20, .74);
}

.account-modal {
    width: min(420px, calc(100vw - 32px));
    padding: 22px;
    background: #191a2f;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.account-modal h2 {
    font-size: 16px;
}

.account-modal p {
    margin: 12px 0 18px;
    color: var(--muted);
    font-weight: 700;
}

.primary-modal-btn {
    width: 100%;
    height: 38px;
    border: 0;
    background: var(--cream);
    color: #080916;
    font-weight: 900;
    cursor: pointer;
}

.image-import-modal {
    position: relative;
    width: min(520px, calc(100vw - 28px));
    max-height: calc(100vh - 40px);
    overflow: auto;
    padding: 28px 28px 24px;
    border: 1px solid var(--line);
    background:
        radial-gradient(circle at 48% 38%, transparent 0 164px, rgba(146, 160, 198, .18) 165px 166px, transparent 167px),
        #17182d;
    box-shadow: var(--shadow);
}

.modal-close {
    position: absolute;
    top: 18px;
    right: 20px;
    width: 34px;
    height: 34px;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 34px;
    line-height: 1;
    cursor: pointer;
}

.image-import-modal h2 {
    max-width: 320px;
    color: var(--cream);
    font-size: 21px;
    line-height: 1.15;
    margin: 20px 0 18px;
    font-family: Georgia, "Times New Roman", serif;
}

.import-preview-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 218px;
    border: 1px solid var(--line);
    background: #0c0d1f;
    overflow: hidden;
}

.import-preview-frame img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.import-action-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin: 16px 0 22px;
}

.import-action-row button {
    height: 34px;
    padding: 0 14px;
    border: 0;
    background: var(--cream);
    color: #0d0e20;
    font-weight: 900;
    cursor: pointer;
}

.metadata-panel h3 {
    margin: 0 0 6px;
    font-size: 15px;
    color: #fff;
}

.metadata-panel p {
    margin: 0 0 12px;
    color: var(--muted);
    font-weight: 800;
}

.metadata-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 18px;
}

.metadata-grid label {
    display: grid;
    grid-template-columns: 18px max-content minmax(0, 1fr);
    align-items: start;
    gap: 8px;
    min-width: 0;
    color: #fff;
    font-weight: 900;
}

.metadata-grid strong {
    min-width: 0;
    color: var(--cream);
    font-weight: 800;
    overflow-wrap: anywhere;
}

.raw-metadata {
    margin: 16px 0;
    border-top: 1px solid var(--line);
}

.raw-metadata div {
    display: grid;
    grid-template-columns: 116px minmax(0, 1fr);
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line-soft);
}

.raw-metadata span {
    color: var(--muted);
    font-weight: 900;
}

.raw-metadata strong {
    color: #fff;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.mask-editor {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    background: #0b0c1c;
}

.mask-topbar {
    display: grid;
    grid-template-columns: repeat(3, max-content) 1fr;
    gap: 10px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    background: #111225;
}

.mask-tool-card {
    display: grid;
    grid-template-columns: 90px 150px;
    gap: 8px 12px;
    align-items: center;
    min-height: 74px;
    padding: 10px;
    border: 1px solid var(--line);
    background: #191a31;
}

.mask-tool-card label {
    font-weight: 900;
}

.mask-tool-card input[type="range"] {
    grid-column: 2;
}

.mask-tool {
    min-height: 34px;
    border: 1px solid var(--line);
    background: #111225;
    color: #fff;
    font-weight: 900;
    cursor: pointer;
}

.mask-tool.active {
    background: #252744;
    color: var(--cream);
}

.mask-editor-actions {
    justify-self: end;
    display: flex;
    align-items: start;
    gap: 8px;
}

.mask-editor-actions .primary-modal-btn {
    width: auto;
    padding: 0 18px;
}

.mask-stage-wrap {
    min-height: 0;
    overflow: auto;
    padding: 34px 24px 48px;
}

.mask-stage {
    position: relative;
    width: min(100%, 1180px);
    margin: 0 auto;
}

.mask-stage img,
.mask-stage canvas {
    display: block;
    width: 100%;
    max-height: calc(100vh - 180px);
    object-fit: contain;
}

.mask-stage img {
    opacity: .72;
}

.mask-stage canvas {
    position: absolute;
    inset: 0;
    cursor: crosshair;
    touch-action: none;
    mix-blend-mode: screen;
}

.toast-stack {
    position: fixed;
    top: 50px;
    right: 132px;
    z-index: 50;
    display: grid;
    gap: 8px;
    width: min(360px, calc(100vw - 32px));
}

.toast {
    padding: 12px 14px;
    border: 1px solid var(--line);
    background: #191a2f;
    color: #fff;
    box-shadow: var(--shadow);
    font-weight: 800;
}

.toast.error {
    border-color: var(--danger);
}

@media (max-width: 980px) {
    body {
        overflow: auto;
    }

    .app-shell {
        display: block;
        min-height: 100vh;
        background: var(--bg-deep);
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 20;
        grid-template-columns: 46px 1fr 42px 132px;
    }

    .left-panel {
        position: fixed;
        inset: 38px auto 0 0;
        z-index: 18;
        width: min(332px, 88vw);
        background: #17182c;
        transform: translateX(-100%);
        transition: transform .18s ease;
    }

    body.panel-open .left-panel {
        transform: translateX(0);
        box-shadow: var(--shadow);
    }

    .gallery-area {
        padding: 58px 12px 24px;
        min-height: calc(100vh - 38px);
    }

    .masonry {
        column-count: 2;
    }

    .history-panel {
        display: none;
    }

    .app-shell.director-mode {
        display: block;
    }

    .app-shell.director-mode .topbar {
        grid-template-columns: 1fr 132px;
        width: 100%;
    }

    .app-shell.director-mode .director-page {
        display: block;
        padding: 12px;
    }

    .director-rail {
        padding: 0 0 12px;
        background: transparent;
        justify-content: flex-start;
    }

    .director-workspace {
        grid-template-columns: 1fr;
    }

    .director-canvas {
        min-height: 360px;
    }

    .director-toolbar {
        grid-template-columns: repeat(2, 1fr);
    }

    .director-transform {
        justify-self: stretch;
    }

    .director-option-grid,
    .director-option-grid.three {
        grid-template-columns: 1fr;
    }

    .floating-panel {
        left: 16px;
        right: 16px;
        top: 54px;
        width: auto;
    }

    .toast-stack {
        right: 12px;
        top: 50px;
    }

    .global-import-button {
        height: 38px;
    }

    .metadata-grid,
    .raw-metadata div {
        grid-template-columns: 1fr;
    }

    .mask-topbar {
        grid-template-columns: 1fr;
    }

    .mask-tool-card {
        grid-template-columns: 88px 1fr;
    }

    .mask-editor-actions {
        justify-self: stretch;
    }
}

@media (max-width: 560px) {
    .masonry {
        column-count: 1;
    }
}
