* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-cyan: #92f0ee;
    --bg-orange: #ffb46f;
    --panel: rgba(255, 253, 248, 0.88);
    --panel-strong: rgba(255, 255, 255, 0.94);
    --line: rgba(42, 66, 98, 0.12);
    --line-strong: rgba(33, 89, 156, 0.22);
    --text: #202838;
    --muted: #697386;
    --blue: #2f79ff;
    --teal: #14b8b1;
    --amber: #f59e0b;
    --danger: #e44f5f;
    --shadow: 0 24px 70px rgba(32, 43, 66, 0.16);
    --soft-shadow: 0 12px 34px rgba(35, 59, 88, 0.11);
}

body {
    min-height: 100vh;
    font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background:
        linear-gradient(120deg, rgba(103, 210, 255, 0.85), rgba(255, 178, 96, 0.8)),
        radial-gradient(circle at 18% 14%, rgba(255, 255, 255, 0.74), transparent 28%),
        radial-gradient(circle at 88% 78%, rgba(255, 229, 190, 0.72), transparent 32%),
        #d9f5ef;
    overflow: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.2) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.62), transparent 78%);
}

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

button {
    cursor: pointer;
}

.app-shell {
    position: relative;
    z-index: 1;
    height: 100vh;
    padding: 22px;
    display: grid;
    grid-template-rows: 1fr;
}

.sidebar,
.task-panel,
.canvas-panel,
.wide-page {
    border: 1px solid rgba(255, 255, 255, 0.74);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.91), rgba(250, 252, 255, 0.82));
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(20px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 260px;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 0;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    background: linear-gradient(135deg, var(--blue), var(--teal));
    box-shadow: 0 12px 24px rgba(47, 121, 255, 0.22);
}

.model-select,
.inline-options select,
.key-create-row select {
    min-height: 44px;
    border-radius: 10px;
    border: 1px solid var(--line);
    color: var(--text);
    background: rgba(255, 255, 255, 0.76);
    padding: 0 38px 0 14px;
    outline: none;
}

.model-select {
    width: 320px;
}

.ratio-native-select {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.ratio-picker {
    position: relative;
    width: 104px;
}

.ratio-picker-button {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.76);
    padding: 0 34px 0 14px;
    text-align: left;
    font-weight: 700;
    position: relative;
}

.ratio-picker-button::after {
    content: "";
    position: absolute;
    right: 14px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid #526078;
    border-bottom: 2px solid #526078;
    transform: translateY(-70%) rotate(45deg);
}

.ratio-picker-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 6px);
    z-index: 3000;
    display: none;
    width: 132px;
    max-height: 236px;
    overflow-y: auto;
    border: 1px solid rgba(42, 66, 98, 0.14);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 42px rgba(27, 43, 67, 0.18);
    padding: 6px;
    backdrop-filter: blur(16px);
}

.ratio-picker.is-open .ratio-picker-menu {
    display: grid;
    gap: 2px;
}

.ratio-picker-menu button {
    min-height: 34px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    padding: 0 10px;
    text-align: left;
    font-weight: 800;
}

.ratio-picker-menu button:hover,
.ratio-picker-menu button.is-active {
    background: rgba(47, 121, 255, 0.12);
    color: #2b66c8;
}

.status-chip,
.mode-badge,
.step-row span {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.68);
    color: var(--muted);
    min-height: 36px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.status-chip span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #21c987;
}

.icon-btn,
.circle-btn,
.canvas-tools button {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.66);
    color: #526078;
    min-height: 44px;
    padding: 0 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.login-btn {
    min-width: 58px;
    font-weight: 800;
}

.circle-btn {
    width: 44px;
    padding: 0;
    border-radius: 50%;
    font-weight: 800;
}

.workspace {
    min-height: 0;
    display: grid;
    grid-template-columns: 96px 392px minmax(0, 1fr);
    gap: 20px;
    transition: grid-template-columns 0.25s ease;
}

.workspace.sidebar-collapsed {
    grid-template-columns: 0 392px minmax(0, 1fr);
}

.sidebar {
    position: relative;
    border-radius: 24px;
    padding: 54px 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

.collapse-btn {
    position: absolute;
    top: 14px;
    right: 12px;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--muted);
    font-size: 26px;
    line-height: 1;
    z-index: 3;
}

.nav-item {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 16px;
    background: transparent;
    color: #59667a;
    min-height: 66px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: 0.2s ease;
}

.nav-item span {
    font-size: 19px;
}

.nav-item b {
    font-size: 13px;
    font-weight: 700;
}

.nav-item.active {
    color: var(--blue);
    border-color: rgba(47, 121, 255, 0.22);
    background: linear-gradient(180deg, rgba(47, 121, 255, 0.12), rgba(20, 184, 177, 0.07));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.workspace.sidebar-collapsed .sidebar {
    width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
}

.workspace.sidebar-collapsed .nav-item {
    opacity: 0;
    pointer-events: none;
}

.workspace.sidebar-collapsed .collapse-btn {
    top: 22px;
    left: 0;
    right: auto;
    transform: translateX(-50%);
    opacity: 1;
    pointer-events: auto;
    width: 34px;
    height: 44px;
    border-radius: 14px;
    color: var(--blue);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--soft-shadow);
}

.task-panel {
    border-radius: 24px;
    min-height: 0;
    overflow: hidden;
}

.function-card {
    height: 100%;
    display: none;
    padding: 26px;
    overflow-y: auto;
}

.function-card.active {
    display: block;
}

.panel-head,
.wide-head,
.key-card-head,
.canvas-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.wide-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.panel-head {
    margin-bottom: 16px;
}

.eyebrow {
    color: var(--teal);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 6px;
}

h2 {
    font-size: 24px;
    line-height: 1.2;
}

h3 {
    font-size: 18px;
}

.input-group {
    margin-bottom: 12px;
}

.input-group label,
.inline-options label,
.key-create-row label {
    display: block;
    color: #4e5b70;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
}

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

.group-head label {
    margin-bottom: 0;
}

.input-group input[type="text"],
.input-group textarea,
.key-card input[type="password"],
.key-card input[type="text"],
.quick-edit input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.74);
    color: var(--text);
    outline: none;
    padding: 12px 14px;
    transition: 0.2s ease;
}

.secret-input {
    -webkit-text-security: disc;
    text-security: disc;
}

.input-group textarea {
    min-height: 104px;
    resize: vertical;
}

.input-group input:focus,
.input-group textarea:focus,
select:focus {
    border-color: rgba(47, 121, 255, 0.58);
    box-shadow: 0 0 0 4px rgba(47, 121, 255, 0.08);
}

.preset-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.preset-btn {
    border: 1px solid rgba(47, 121, 255, 0.16);
    border-radius: 999px;
    background: rgba(47, 121, 255, 0.08);
    color: #2c67cd;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
}

.inline-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

#generate-banana-size-wrapper,
#clone-banana-size-wrapper {
    grid-column: 1 / -1;
}

.drop-zone {
    position: relative;
    min-height: 104px;
    border: 1.5px dashed rgba(47, 121, 255, 0.34);
    border-radius: 16px;
    display: grid;
    place-items: center;
    color: var(--muted);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(245, 251, 255, 0.42)),
        repeating-linear-gradient(90deg, transparent 0 18px, rgba(47, 121, 255, 0.04) 18px 19px);
    overflow: hidden;
    transition: 0.2s ease;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--blue);
    background-color: rgba(47, 121, 255, 0.06);
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.drop-zone-content {
    text-align: center;
    pointer-events: none;
}

.upload-icon {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    color: var(--blue);
    background: rgba(47, 121, 255, 0.1);
    font-size: 23px;
}

.image-preview-container {
    position: relative;
    margin-top: 14px;
    width: 100%;
}

.image-preview,
.multi-image-item img {
    display: block;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: var(--soft-shadow);
}

.image-preview {
    width: 100%;
    max-height: 230px;
}

.multi-image-preview {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 12px;
}

.multi-image-item {
    position: relative;
    aspect-ratio: 1;
}

.multi-image-item img {
    width: 100%;
    height: 100%;
}

.delete-image-btn {
    position: absolute;
    top: -7px;
    right: -7px;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 50%;
    color: white;
    background: var(--danger);
    box-shadow: 0 8px 18px rgba(228, 79, 95, 0.28);
}

.image-count {
    color: var(--muted);
    font-size: 12px;
    margin-top: 8px;
}

.step-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0 14px;
}

.step-row span:first-child {
    color: var(--blue);
}

.step-row span:last-child {
    color: var(--teal);
}

.mode-toggle {
    min-height: 34px;
    border: 1px solid rgba(47, 121, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.68);
    color: #526078;
    padding: 0 14px;
    font-weight: 800;
}

.mode-toggle.active {
    border-color: rgba(20, 184, 177, 0.34);
    background: rgba(20, 184, 177, 0.12);
    color: #087f78;
}

.tooltip-trigger {
    position: relative;
}

.tooltip-trigger::after {
    content: attr(data-tooltip);
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    z-index: 30;
    width: min(280px, 72vw);
    border: 1px solid rgba(42, 66, 98, 0.16);
    border-radius: 10px;
    background: rgba(32, 40, 56, 0.94);
    color: white;
    box-shadow: 0 14px 34px rgba(27, 43, 67, 0.22);
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.55;
    text-align: left;
    white-space: normal;
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.tooltip-trigger::before {
    content: "";
    position: absolute;
    right: 18px;
    bottom: calc(100% + 4px);
    z-index: 31;
    border: 6px solid transparent;
    border-top-color: rgba(32, 40, 56, 0.94);
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.tooltip-trigger:hover::after,
.tooltip-trigger:hover::before,
.tooltip-trigger:focus-visible::after,
.tooltip-trigger:focus-visible::before {
    opacity: 1;
    transform: translateY(0);
}

.btn {
    width: 100%;
    min-height: 52px;
    border: 0;
    border-radius: 14px;
    color: white;
    font-weight: 800;
    background: linear-gradient(135deg, #2f79ff, #12b7b1);
    box-shadow: 0 18px 34px rgba(47, 121, 255, 0.24);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-sm {
    border: 1px solid rgba(47, 121, 255, 0.2);
    border-radius: 10px;
    background: rgba(47, 121, 255, 0.1);
    color: #2b66c8;
    min-height: 38px;
    padding: 0 14px;
    font-weight: 800;
}

.loading,
.error,
.success,
.result {
    display: none;
}

.loading.show,
.error.show,
.success.show,
.result.show {
    display: block;
}

.loading {
    margin-top: 14px;
    text-align: center;
    color: var(--muted);
}

.spinner {
    width: 28px;
    height: 28px;
    margin: 0 auto 8px;
    border-radius: 50%;
    border: 3px solid rgba(47, 121, 255, 0.14);
    border-top-color: var(--blue);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error,
.success {
    margin-top: 12px;
    border-radius: 12px;
    padding: 12px;
    font-size: 13px;
}

.error {
    background: rgba(228, 79, 95, 0.1);
    color: #b4233a;
}

.success {
    background: rgba(20, 184, 177, 0.11);
    color: #087f78;
}

.result.show {
    margin-top: 14px;
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.58);
}

.result img {
    width: 100%;
    border-radius: 12px;
    cursor: zoom-in;
}

.canvas-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-radius: 24px;
    padding: 22px;
    overflow: hidden;
}

.canvas-head {
    margin-bottom: 16px;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    column-gap: 18px;
    row-gap: 10px;
}

.canvas-tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    flex: 0 1 auto;
}

.canvas-tools .model-select {
    width: clamp(240px, 28vw, 360px);
    min-height: 44px;
}

.background-jobs {
    display: none;
    align-items: flex-start;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 12px;
    overflow: visible;
    position: relative;
    z-index: 20;
}

.background-jobs.show {
    display: flex;
}

.background-job {
    height: 44px;
    min-width: 230px;
    max-width: min(330px, 28vw);
    display: inline-flex;
    align-items: center;
    gap: 9px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.84);
    padding: 0 8px 0 12px;
    box-shadow: 0 8px 22px rgba(35, 59, 88, 0.08);
    color: var(--text);
    white-space: nowrap;
}

.background-job-status {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    border-radius: 999px;
    display: grid;
    place-items: center;
}

.background-job-copy {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #344055;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.background-job-copy strong {
    font-size: 14px;
    font-weight: 900;
}

.background-job-copy span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.background-job-close {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #526078;
    font-size: 22px;
    line-height: 1;
    display: grid;
    place-items: center;
}

.background-job-close:hover {
    background: rgba(82, 96, 120, 0.1);
}

.background-job[data-status="running"] {
    border-color: rgba(47, 121, 255, 0.58);
    color: var(--blue);
}

.background-job[data-status="running"] .background-job-status {
    border: 3px dotted currentColor;
    animation: spin 1.2s linear infinite;
}

.background-job[data-status="running"] .background-job-copy strong {
    color: var(--blue);
}

.background-job[data-status="done"] {
    border-color: rgba(33, 169, 91, 0.52);
    color: #1fa85b;
}

.background-job[data-status="done"] .background-job-status {
    border: 2px solid currentColor;
}

.background-job[data-status="done"] .background-job-status::before {
    content: "✓";
    font-size: 13px;
    font-weight: 900;
    line-height: 1;
}

.background-job[data-status="done"] .background-job-copy strong {
    color: #1fa85b;
}

.background-job[data-status="error"] {
    border-color: rgba(228, 79, 95, 0.52);
    color: var(--danger);
}

.background-job[data-status="error"] .background-job-status {
    border: 2px solid currentColor;
}

.background-job[data-status="error"] .background-job-status::before {
    content: "!";
    font-size: 13px;
    font-weight: 900;
    line-height: 1;
}

.background-job[data-status="error"] .background-job-copy strong {
    color: var(--danger);
}

.background-job-more-wrap {
    position: relative;
    flex: 0 0 auto;
}

.background-job-more {
    height: 44px;
    min-width: 112px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1.5px solid rgba(47, 121, 255, 0.58);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.84);
    color: var(--blue);
    font-weight: 900;
    box-shadow: 0 8px 22px rgba(35, 59, 88, 0.08);
}

.background-job-chevron {
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
}

.background-job-popover {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(460px, calc(100vw - 72px));
    display: none;
    border: 1px solid rgba(42, 66, 98, 0.12);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 20px 48px rgba(35, 59, 88, 0.18);
    padding: 16px;
    backdrop-filter: blur(18px);
}

.background-jobs.menu-open .background-job-popover {
    display: block;
}

.background-job-popover h3 {
    margin-bottom: 12px;
    font-size: 18px;
}

.background-job-list {
    display: grid;
    gap: 10px;
}

.background-job-list .background-job {
    width: 100%;
    max-width: none;
    justify-content: flex-start;
}

.result-canvas {
    --canvas-scale: 1;
    --canvas-pan-x: 0px;
    --canvas-pan-y: 0px;
    position: relative;
    flex: 1;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    background:
        radial-gradient(circle at 20px 20px, rgba(35, 74, 122, 0.12) 1.2px, transparent 1.2px) 0 0 / 18px 18px,
        linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(245, 248, 251, 0.72));
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.result-canvas.panning {
    cursor: grabbing;
}

.result-canvas.box-selecting {
    cursor: crosshair;
}

.canvas-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    gap: 10px;
    text-align: center;
    color: var(--muted);
    pointer-events: none;
    z-index: 1;
}

.canvas-empty span {
    color: var(--blue);
    font-size: 38px;
}

.canvas-item {
    position: absolute;
    width: min(58%, 760px);
    border-radius: 14px;
    background: white;
    padding: 8px;
    box-shadow: 0 24px 58px rgba(27, 43, 67, 0.22);
    cursor: grab;
    user-select: none;
    transform: translate(var(--canvas-pan-x), var(--canvas-pan-y));
    transition: box-shadow 0.15s ease;
    z-index: 2;
}

.canvas-item.selected {
    outline: 1.5px solid rgba(47, 121, 255, 0.64);
    outline-offset: 1px;
    box-shadow:
        0 20px 54px rgba(27, 43, 67, 0.2),
        0 0 0 1px rgba(47, 121, 255, 0.12);
}

.canvas-item.dragging {
    cursor: grabbing;
    box-shadow: 0 32px 72px rgba(27, 43, 67, 0.35);
    transition: none;
}

.canvas-item img {
    width: 100%;
    display: block;
    border-radius: 10px;
}

.canvas-item::before,
.canvas-item::after {
    content: "";
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: var(--blue);
    border: 2px solid white;
    display: none;
}

.canvas-item.selected::before,
.canvas-item.selected::after {
    display: none;
}

.canvas-item::before {
    top: -8px;
    right: -8px;
}

.canvas-item::after {
    bottom: -8px;
    right: -8px;
}

.canvas-context-menu {
    position: fixed;
    z-index: 10000;
    min-width: 168px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 44px rgba(27, 43, 67, 0.2);
    padding: 6px;
    backdrop-filter: blur(12px);
}

.canvas-context-menu small {
    display: block;
    max-width: 220px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
    margin: 0 4px 5px;
    padding: 5px 6px 8px;
}

.canvas-context-menu button {
    width: 100%;
    min-height: 34px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    text-align: left;
    padding: 0 10px;
    font-weight: 800;
}

.canvas-context-menu button:hover {
    background: rgba(47, 121, 255, 0.1);
    color: #2b66c8;
}

.floating-toolbar,
.quick-edit,
.canvas-meta {
    display: none;
}

.canvas-item.selected .floating-toolbar {
    display: flex;
}

.canvas-item.selected .quick-edit {
    display: none;
}

.canvas-item.selected .canvas-meta {
    display: none;
}

.result-canvas.has-multi-selection .canvas-item.selected .floating-toolbar,
.result-canvas.has-multi-selection .canvas-item.selected .quick-edit,
.result-canvas.has-multi-selection .canvas-item.selected .canvas-meta,
.result-canvas.box-selecting .canvas-item.selected .floating-toolbar,
.result-canvas.box-selecting .canvas-item.selected .quick-edit,
.result-canvas.box-selecting .canvas-item.selected .canvas-meta {
    display: none;
}

.result-canvas.has-multi-selection .canvas-item.selected::before,
.result-canvas.has-multi-selection .canvas-item.selected::after {
    display: none;
}

.canvas-selection-box {
    position: absolute;
    z-index: 9000;
    transform: translate(var(--canvas-pan-x), var(--canvas-pan-y));
    border: 1.5px solid var(--blue);
    border-radius: 8px;
    background: rgba(47, 121, 255, 0.12);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.68);
    pointer-events: none;
}

.floating-toolbar {
    margin-top: 8px;
    gap: 8px;
    padding: 6px;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
}

.floating-toolbar button {
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #516079;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 800;
}

.quick-edit {
    grid-template-columns: minmax(0, 1fr) 76px 76px;
    gap: 8px;
    width: 100%;
    padding: 8px 0 0;
}

.quick-edit .quick-prompt {
    grid-column: 1 / 3;
}

.quick-edit select,
.quick-edit input {
    min-width: 0;
    min-height: 34px;
    border-radius: 10px;
    border: 1px solid var(--line);
    padding: 0 10px;
    background: white;
}

.quick-edit button {
    border: 0;
    border-radius: 10px;
    min-height: 34px;
    color: white;
    background: var(--blue);
    font-weight: 800;
}

.canvas-meta {
    margin-top: 8px;
    padding: 8px 2px 0;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

.wide-page {
    display: none;
    grid-column: 2 / 4;
    min-height: 0;
    border-radius: 24px;
    padding: 26px;
    overflow: auto;
}

.wide-page.active {
    display: block;
}

.wide-head {
    margin-bottom: 18px;
}

.wide-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-weight: 800;
}

.key-layout {
    display: grid;
    grid-template-columns: minmax(240px, 0.8fr) 1fr 1fr;
    gap: 18px;
}

.key-card,
.settings-placeholder {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.68);
    box-shadow: var(--soft-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.78);
    padding: 20px;
}

.key-card p,
.settings-placeholder p {
    color: var(--muted);
    font-size: 13px;
    margin: 6px 0 16px;
}

.key-create-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin: 14px 0;
}

.key-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.model-pool {
    margin-top: 16px;
    display: grid;
    gap: 10px;
}

.model-pool-head {
    display: grid;
    gap: 4px;
}

.model-pool-head small {
    color: var(--muted);
    font-size: 12px;
}

.model-add-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
}

.model-batch-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.model-pool textarea {
    min-height: 70px;
    resize: vertical;
    line-height: 1.45;
}

.model-pool-list {
    display: grid;
    gap: 8px;
    max-height: 260px;
    overflow: auto;
}

.model-pool-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.58);
    padding: 10px;
}

.model-pool-item strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-pool-name {
    min-width: 0;
}

.model-pool-name small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px;
}

.key-profile {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.62);
    padding: 12px;
}

.key-profile small {
    display: block;
    color: var(--muted);
    margin-top: 4px;
}

.key-profile strong {
    overflow-wrap: anywhere;
}

.key-profile-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.key-profile button,
.model-pool-item button {
    border: 0;
    border-radius: 9px;
    background: rgba(47, 121, 255, 0.1);
    color: var(--blue);
    padding: 8px 10px;
    font-weight: 800;
}

.key-profile button.icon-btn {
    width: 34px;
    padding: 8px 0;
}

.key-profile button.is-active {
    background: rgba(47, 121, 255, 0.16);
}

.key-profile button.danger-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.model-remove-btn {
    align-self: end;
    white-space: nowrap;
}

.model-remove-btn:disabled {
    opacity: 0.45;
}

.settings-placeholder {
    max-width: 620px;
}

.image-modal,
.group-modal,
.confirm-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
    background: rgba(11, 18, 30, 0.72);
}

.image-modal {
    overflow: hidden;
}

.image-modal.show,
.group-modal.show,
.confirm-modal.show {
    display: flex;
}

.image-modal img {
    max-width: 94vw;
    max-height: 92vh;
    border-radius: 14px;
    box-shadow: 0 34px 88px rgba(0, 0, 0, 0.38);
    cursor: zoom-out;
    transform: translate(0, 0) scale(1);
    transform-origin: center center;
    transition: transform 0.08s ease-out;
    will-change: transform;
}

.image-modal img.is-zoomed {
    cursor: grab;
}

.image-modal img.is-panning {
    cursor: grabbing;
    transition: none;
}

.image-modal-close {
    position: absolute;
    top: 22px;
    right: 32px;
    color: white;
    font-size: 42px;
}

.group-modal-content,
.confirm-modal-content {
    position: relative;
    width: min(92vw, 460px);
    max-height: calc(100vh - 48px);
    border-radius: 20px;
    background: var(--panel-strong);
    padding: 26px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.group-modal-content {
    display: flex;
    flex-direction: column;
}

.group-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: rgba(87, 98, 118, 0.12);
    color: var(--muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.group-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
    overflow: auto;
    padding-right: 4px;
}

.group-btn {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.7);
    padding: 12px;
    cursor: pointer;
    text-align: left;
}

.group-btn small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.confirm-modal-title {
    display: flex;
    gap: 10px;
    align-items: center;
    font-weight: 800;
    margin-bottom: 14px;
}

.confirm-modal-message {
    color: var(--muted);
    white-space: pre-line;
    line-height: 1.5;
}

.confirm-modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.confirm-modal-btn {
    border: 0;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 800;
}

.confirm-modal-btn-cancel {
    background: rgba(87, 98, 118, 0.12);
    color: var(--muted);
}

.confirm-modal-btn-confirm {
    background: var(--blue);
    color: white;
}

.key-modal-subtitle {
    color: var(--muted);
    margin: 8px 0 12px;
}

.key-value-block {
    display: block;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(20, 33, 50, 0.06);
    padding: 12px;
    overflow-wrap: anywhere;
    line-height: 1.5;
}

.key-edit-field {
    display: grid;
    gap: 6px;
    margin-top: 12px;
    font-weight: 800;
    color: var(--text);
}

.key-edit-field input {
    width: 100%;
}

.toast {
    position: fixed;
    top: 22px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2500;
    border-radius: 999px;
    background: rgba(20, 33, 50, 0.86);
    color: white;
    padding: 12px 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.toast.show {
    opacity: 1;
}

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

    .app-shell {
        height: auto;
        min-height: 100vh;
    }

    .workspace {
        grid-template-columns: 82px minmax(320px, 420px);
    }

    .canvas-panel,
    .wide-page {
        grid-column: 1 / -1;
        min-height: 720px;
    }
}
