:root {
    color-scheme: dark;
    --bg: #050b17;
    --bg-2: #091226;
    --panel: rgba(11, 24, 46, 0.86);
    --panel-2: rgba(15, 32, 60, 0.82);
    --line: rgba(97, 154, 255, 0.22);
    --line-strong: rgba(110, 184, 255, 0.45);
    --text: #eaf4ff;
    --muted: #98b3d9;
    --primary: #3b82f6;
    --accent-2: #68d6ff;
    --danger: #ff6e72;
    --shadow: 0 18px 55px rgba(1, 8, 20, 0.5);
    --glow: 0 0 0 1px rgba(102, 173, 255, 0.14), 0 0 30px rgba(59, 130, 246, 0.14);
    font-family: "Segoe UI", "Trebuchet MS", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top, rgba(104, 214, 255, 0.12), transparent 28%),
        radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.16), transparent 24%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
    color: var(--text);
    overflow-x: hidden;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: auto;
    width: 32rem;
    height: 32rem;
    border-radius: 999px;
    filter: blur(80px);
    pointer-events: none;
    z-index: 0;
    opacity: 0.35;
}

body::before {
    top: -10rem;
    right: -8rem;
    background: rgba(59, 130, 246, 0.32);
}

body::after {
    bottom: -12rem;
    left: -8rem;
    background: rgba(104, 214, 255, 0.2);
}

a {
    color: inherit;
    text-decoration: none;
}

.shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
    position: relative;
    z-index: 1;
}

.sidebar {
    padding: 24px;
    border-right: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(6, 14, 30, 0.92), rgba(8, 18, 36, 0.84));
    backdrop-filter: blur(18px);
    display: flex;
    flex-direction: column;
    gap: 18px;
    box-shadow: inset -1px 0 0 rgba(113, 173, 255, 0.08);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    animation: fadeDown 0.55s ease both;
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--accent-2));
    color: #061222;
    font-weight: 900;
    font-size: 1.2rem;
    box-shadow: 0 0 24px rgba(59, 130, 246, 0.42);
}

.brand-name {
    font-weight: 800;
    letter-spacing: 0.02em;
}

.brand-sub,
.muted,
.sidebar-card p,
.section-head p,
.template-card p {
    color: var(--muted);
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-link,
.sidebar-card,
.panel,
.stat-card,
.soft-panel,
.template-card,
.gallery-card {
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(10, 22, 43, 0.86), rgba(14, 28, 52, 0.78));
    box-shadow: var(--shadow), var(--glow);
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

.nav-link:hover {
    transform: translateY(-2px);
    border-color: var(--line-strong);
    box-shadow: var(--shadow), 0 0 28px rgba(59, 130, 246, 0.18);
}

.sidebar-card {
    border-radius: 18px;
    padding: 16px;
    animation: fadeUp 0.55s ease both;
}

.sidebar-title {
    font-weight: 700;
    margin-bottom: 8px;
}

.main {
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

body.dashboard-mode {
    overflow: hidden;
}

.shell-dashboard {
    grid-template-columns: minmax(0, 1fr);
    height: 100vh;
}

.main-dashboard {
    padding: 10px;
    gap: 10px;
    min-height: 100vh;
    overflow: auto;
}

.main > * {
    animation: riseIn 0.55s ease both;
}

.main > *:nth-child(2) { animation-delay: 0.04s; }
.main > *:nth-child(3) { animation-delay: 0.08s; }
.main > *:nth-child(4) { animation-delay: 0.12s; }
.main > *:nth-child(5) { animation-delay: 0.16s; }

.page-head h1,
.section-head h2 {
    margin: 0 0 6px;
}

.page-head p {
    margin: 0;
    color: var(--muted);
}

.page-head-copy {
    display: flex;
    align-items: center;
    gap: 14px;
}

.page-icon {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.22), rgba(104, 214, 255, 0.16));
    border: 1px solid var(--line);
    box-shadow: 0 0 24px rgba(59, 130, 246, 0.14);
}

.flash {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
}

.flash-toast {
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    overflow: hidden;
    animation: toastIn .34s ease both;
}

.flash-copy {
    flex: 1;
}

.flash-icon,
.flash-close,
.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon svg {
    width: 100%;
    height: 100%;
}

.flash-icon,
.page-icon .icon {
    width: 22px;
    height: 22px;
}

.flash-close {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid rgba(120, 184, 255, 0.2);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.flash-close .icon,
.button .icon,
.nav-link .icon {
    width: 18px;
    height: 18px;
}

.flash-out {
    animation: toastOut .28s ease forwards;
}

.ui-tooltip-bubble {
    position: absolute;
    z-index: 9999;
    max-width: min(280px, calc(100vw - 16px));
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(121, 187, 255, 0.34);
    background: linear-gradient(180deg, rgba(8, 18, 36, 0.98), rgba(12, 28, 54, 0.96));
    color: #eff7ff;
    font-size: 0.82rem;
    line-height: 1.35;
    box-shadow: 0 18px 42px rgba(2, 10, 24, 0.48), 0 0 22px rgba(73, 184, 255, 0.18);
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px) scale(0.96);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.ui-tooltip-bubble::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -7px;
    width: 12px;
    height: 12px;
    background: rgba(12, 28, 54, 0.98);
    border-right: 1px solid rgba(121, 187, 255, 0.34);
    border-bottom: 1px solid rgba(121, 187, 255, 0.34);
    transform: translateX(-50%) rotate(45deg);
}

.ui-tooltip-bubble.bottom::after {
    top: -7px;
    bottom: auto;
    border-right: 0;
    border-bottom: 0;
    border-left: 1px solid rgba(121, 187, 255, 0.34);
    border-top: 1px solid rgba(121, 187, 255, 0.34);
}

.ui-tooltip-bubble.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.flash-success {
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(104, 214, 255, 0.45);
    box-shadow: 0 0 22px rgba(59, 130, 246, 0.14);
}

.flash-error {
    background: rgba(255, 110, 114, 0.12);
    border-color: rgba(255, 110, 114, 0.42);
}

.panel {
    border-radius: 24px;
    padding: 22px;
}

.soft-panel {
    padding: 16px;
    border-radius: 18px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.grid-two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
}

.tab-nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.tab-button {
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
    color: var(--text);
    transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

.tab-button:hover,
.tab-button.active {
    transform: translateY(-2px);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.24), rgba(104, 214, 255, 0.18));
    border-color: var(--line-strong);
    box-shadow: 0 0 24px rgba(59, 130, 246, 0.18);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: sectionDown 0.45s ease both;
}

.stat-card {
    border-radius: 20px;
    padding: 18px;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(104, 214, 255, 0.05), transparent 55%);
    pointer-events: none;
}

.stat-label,
.field span,
.field-label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.92rem;
}

.stat-card strong {
    font-size: 1.45rem;
}

.field input,
.field select,
.field textarea,
.code-block {
    width: 100%;
    border-radius: 14px;
    border: 1px solid rgba(98, 162, 255, 0.22);
    background: rgba(6, 18, 36, 0.85);
    color: var(--text);
    padding: 12px 14px;
    font: inherit;
    transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

.field select,
.app-filter-row select {
    color-scheme: dark;
}

.field select option,
.app-filter-row select option {
    background: #0b1527;
    color: #eaf4ff;
}

.field textarea {
    resize: vertical;
    min-height: 96px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: rgba(104, 214, 255, 0.7);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.14), 0 0 24px rgba(59, 130, 246, 0.16);
    transform: translateY(-1px);
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.field-grid.four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.field-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-grid.two-strong {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 16px;
}

.toggle-line {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
}

.button-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.button-row.compact {
    gap: 8px;
}

.button-row.wrap {
    flex-wrap: wrap;
}

.button,
button,
.chip-button {
    appearance: none;
    border: 0;
    cursor: pointer;
    font: inherit;
}

.button,
.chip-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: 14px;
    padding: 11px 16px;
    border: 1px solid transparent;
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease, background 0.22s ease;
}

.button:hover,
.chip-button:hover {
    transform: translateY(-2px);
}

.button.primary {
    background: linear-gradient(135deg, var(--primary), var(--accent-2));
    color: #04111f;
    font-weight: 800;
    box-shadow: 0 0 26px rgba(59, 130, 246, 0.28);
}

.button.secondary {
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.16), rgba(104, 214, 255, 0.1));
    border-color: rgba(104, 214, 255, 0.18);
    color: var(--text);
}

.button.ghost,
.chip-button {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
    color: var(--text);
}

.button.ghost:hover,
.chip-button:hover {
    border-color: var(--line-strong);
    box-shadow: 0 0 22px rgba(59, 130, 246, 0.12);
}

.button.ghost.danger {
    color: var(--danger);
}

.google-button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #f8fbff, #d8ecff);
    color: #10325d;
    box-shadow: 0 0 22px rgba(73, 184, 255, 0.22);
}

.google-button:hover {
    background: linear-gradient(135deg, #ffffff, #e8f4ff);
}

.divider-line {
    position: relative;
    margin: 20px 0;
    text-align: center;
}

.divider-line::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    border-top: 1px solid rgba(100, 159, 255, 0.24);
}

.divider-line span {
    position: relative;
    z-index: 1;
    display: inline-block;
    padding: 0 12px;
    background: #081321;
    color: #8fb3d7;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.template-list,
.gallery {
    display: grid;
    gap: 12px;
}

.gallery {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.history-preview {
    display: grid;
    grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.history-preview-media {
    border-radius: 20px;
    overflow: hidden;
    background: #08111f;
    box-shadow: inset 0 0 0 1px rgba(102, 171, 255, 0.12);
}

.history-preview-media img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
}

.history-card {
    cursor: pointer;
}

.template-card,
.gallery-card {
    border-radius: 18px;
    padding: 14px;
    position: relative;
    overflow: hidden;
}

.template-card::before,
.gallery-card::before,
.panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(104, 214, 255, 0.05), transparent 35%);
    pointer-events: none;
}

.template-card {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
}

.gallery-media {
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: 14px;
    background: #09111d;
    margin-bottom: 12px;
    box-shadow: inset 0 0 0 1px rgba(102, 171, 255, 0.12);
}

.gallery-media-empty {
    display: grid;
    place-items: center;
    color: var(--muted);
    padding: 18px;
}

.gallery-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.gallery-card:hover .gallery-media img {
    transform: scale(1.03);
}

.gallery-copy p {
    min-height: 52px;
    margin: 0;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 0.9rem;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid rgba(100, 159, 255, 0.12);
    vertical-align: top;
}

.data-table th {
    color: #cfe3ff;
}

.clamp-cell {
    max-width: 340px;
    word-break: break-word;
}

.auth-panel {
    max-width: 460px;
}

.code-block {
    border-radius: 16px;
    font-family: Consolas, monospace;
    white-space: pre-wrap;
}

.qr-wrap {
    display: flex;
    justify-content: center;
}

.qr-image {
    width: 240px;
    height: 240px;
    border-radius: 22px;
    padding: 10px;
    background: rgba(245, 250, 255, 0.98);
    box-shadow: 0 0 22px rgba(73, 184, 255, 0.26);
}

.qr-local-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #08223d;
}

.qr-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-align: center;
    padding: 0 14px;
}

.qr-local-card svg {
    width: 220px;
    height: 220px;
    display: block;
    border-radius: 18px;
}

.error-copy {
    font-size: 0.86rem;
    text-align: center;
    word-break: break-word;
}

details summary {
    cursor: pointer;
    color: #d9ebff;
    margin-bottom: 0.5rem;
}

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes sectionDown {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-8px) scale(.98);
    }
}

@media (max-width: 1200px) {
    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1100px) {
    .shell,
    .grid-two,
    .history-preview,
    .field-grid.four,
    .field-grid.three,
    .field-grid.two-strong {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

.app-dashboard {
    min-height: calc(100vh - 20px);
    height: auto;
    padding: 8px;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(7, 14, 28, 0.98), rgba(8, 16, 31, 0.95));
}

.app-dashboard-grid {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    min-height: calc(100vh - 36px);
}

.app-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: auto;
    overflow: visible;
    padding-right: 4px;
}

.app-side-shell {
    padding: 12px;
    gap: 12px;
}

.app-side-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-side-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.app-side-nav .button {
    justify-content: flex-start;
}

.app-control-form {
    padding: 10px;
    border-radius: 16px;
    border: 1px solid rgba(90, 149, 240, 0.14);
    background: rgba(4, 10, 21, 0.98);
    box-shadow: var(--shadow), var(--glow);
}

.app-control-form .field-grid.two-strong {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.app-slider-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.app-toolbar,
.app-badges,
.app-stage-meta,
.app-hint-row,
.app-preview-actions,
.app-filter-row,
.app-thumbnail-strip,
.app-mini-list {
    display: flex;
    gap: 10px;
}

.app-toolbar,
.app-ribbon-head {
    justify-content: space-between;
    align-items: center;
}

.app-control-form .field span,
.app-control-form .field-label {
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    color: #a8c4ea;
}

.app-control-form textarea,
.app-control-form input,
.app-control-form select {
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    width: 100%;
    min-width: 0;
}

.app-badges,
.app-stage-meta,
.app-hint-row,
.app-mini-list {
    flex-wrap: wrap;
}

.app-collapse-panel {
    padding: 12px;
}

.app-collapse-panel summary {
    cursor: pointer;
    list-style: none;
    font-weight: 700;
    color: #dff0ff;
}

.app-collapse-panel summary::-webkit-details-marker {
    display: none;
}

.app-collapse-body {
    margin-top: 12px;
}

.app-prompt-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow: auto;
}

.app-prompt-card {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    width: 100%;
    padding: 8px;
    border-radius: 14px;
    border: 1px solid rgba(101, 166, 255, 0.12);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    text-align: left;
    overflow: hidden;
}

.app-prompt-card.active {
    border-color: rgba(133, 162, 255, 0.5);
    background: rgba(166, 178, 212, 0.22);
}

.app-prompt-thumb {
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    min-width: 52px;
    max-width: 52px;
    border-radius: 10px;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.04);
}

.app-prompt-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    max-width: 52px;
    max-height: 52px;
}

.app-prompt-copy {
    min-width: 0;
}

.app-prompt-copy strong,
.app-prompt-copy span {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-prompt-copy span {
    color: var(--muted);
    font-size: 0.78rem;
}

.app-badge,
.app-stage-pill {
    padding: 7px 11px;
    border-radius: 999px;
    border: 1px solid rgba(108, 175, 255, 0.2);
    background: rgba(59, 130, 246, 0.12);
    color: #dff0ff;
    font-size: 0.76rem;
}

.app-inline-link {
    padding: 0;
    border: 0;
    background: transparent;
    color: #8ff0df;
    font-weight: 700;
}

.app-field-grow textarea {
    min-height: 72px;
}

.app-size-row .chip-button {
    padding-inline: 10px;
    min-height: 34px;
}

.app-quick-size-block {
    min-width: 0;
}

.app-size-row {
    flex-wrap: wrap;
}

.app-primary-actions .button {
    flex: 1 1 0;
    justify-content: center;
}

.app-tool-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.app-tool-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
}

.app-modal[hidden] {
    display: none;
}

.app-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
}

.app-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(3, 8, 18, 0.78);
    backdrop-filter: blur(8px);
}

.app-modal-dialog {
    position: relative;
    width: min(92vw, 920px);
    max-height: calc(100vh - 48px);
    overflow: auto;
    margin: 24px auto;
    z-index: 1;
}

.app-modal-wide {
    width: min(96vw, 1080px);
}

.app-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.app-modal-head h2,
.variables-header {
    margin: 0;
}

.app-modal-head p {
    margin: 6px 0 0;
    color: var(--muted);
}

.app-modal-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.app-modal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.app-modal-footer {
    justify-content: flex-end;
}

.app-style-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.app-style-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
}

.app-style-card-button {
    width: 100%;
    text-align: left;
    color: var(--text);
}

.app-style-card-copy {
    min-width: 0;
}

.app-style-card-copy strong,
.app-style-card-copy span {
    display: block;
}

.app-style-card-copy span {
    margin-top: 4px;
    color: var(--muted);
    word-break: break-word;
}

.app-stage {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

.app-preview-shell {
    position: relative;
    padding: 10px 56px 8px 10px;
    border-radius: 18px;
    border: 1px solid rgba(90, 149, 240, 0.14);
    background: linear-gradient(180deg, rgba(8, 14, 29, 0.98), rgba(10, 17, 32, 0.94));
    box-shadow: var(--shadow), var(--glow);
    flex: none;
    min-height: auto;
}

.app-preview-frame {
    min-height: 480px;
    height: auto;
    display: grid;
    place-items: center;
    padding: 10px;
    border-radius: 16px;
    background: #050912;
    overflow: hidden;
}

.app-preview-frame img {
    width: auto;
    max-width: min(100%, 880px);
    max-height: 70vh;
    display: block;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
}

.app-preview-empty {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    color: var(--muted);
}

.app-preview-actions {
    position: absolute;
    right: 10px;
    top: 12px;
    flex-direction: column;
    gap: 9px;
}

.app-icon-button {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid rgba(207, 232, 255, 0.16);
    background: rgba(255, 255, 255, 0.92);
    color: #08192f;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

.app-icon-button:hover {
    border-color: rgba(255, 255, 255, 0.8);
    transform: translateY(-1px);
}

.app-icon-button .icon {
    width: 16px;
    height: 16px;
}

.app-preview-footer {
    margin-top: 10px;
    padding: 10px 12px 2px;
    border-top: 1px solid rgba(95, 152, 240, 0.12);
}

.app-preview-copy p {
    margin: 8px 0 10px;
    max-width: 80ch;
}

.app-history-ribbon {
    padding: 12px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(12, 19, 34, 0.94), rgba(9, 15, 28, 0.96));
    max-height: none;
    overflow: visible;
}

.app-filter-row {
    flex-wrap: wrap;
}

.app-filter-row select,
.app-filter-row input {
    min-width: 130px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(7, 16, 32, 0.94);
    color: var(--text);
}

.app-thumbnail-strip {
    overflow-x: auto;
    overflow-y: visible;
    padding: 4px 0 8px;
    align-items: flex-start;
    flex-wrap: nowrap;
}

.app-thumb-card {
    min-width: 148px;
    max-width: 148px;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid rgba(101, 166, 255, 0.12);
    background: rgba(255, 255, 255, 0.025);
    cursor: pointer;
    flex: 0 0 auto;
}

.app-thumb-card.active {
    border-color: rgba(97, 232, 176, 0.55);
    box-shadow: 0 0 0 1px rgba(97, 232, 176, 0.32), 0 0 18px rgba(97, 232, 176, 0.18);
}

.app-thumb-media {
    aspect-ratio: 4 / 5;
    overflow: visible;
    border-radius: 10px;
    background:
        linear-gradient(180deg, rgba(16, 28, 49, 0.92), rgba(9, 17, 29, 0.96));
    margin-bottom: 6px;
    display: grid;
    place-items: center;
    padding: 4px;
}

.app-thumb-media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.app-thumb-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 6px;
    font-size: 0.78rem;
}

.app-thumb-copy strong,
.app-thumb-copy span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-thumb-check {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 0.72rem;
    color: var(--muted);
}

.app-thumb-check input {
    margin: 0;
}

.app-mini-card {
    width: 100%;
    text-align: left;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
}

.app-mini-card strong,
.app-mini-card span {
    display: block;
}

.app-mini-card span {
    font-size: 0.8rem;
    color: var(--muted);
}

.compact-head h2 {
    font-size: 1rem;
}

.app-warning-note {
    margin-top: 6px;
}

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

    .app-dashboard-grid {
        grid-template-columns: 1fr;
        height: auto;
    }

    .app-controls {
        overflow: visible;
        padding-right: 0;
    }

    .app-preview-shell {
        padding-right: 16px;
        flex: none;
    }

    .app-preview-actions {
        position: static;
        flex-direction: row;
        margin-top: 10px;
    }

    .app-dashboard {
        height: auto;
    }

    .app-history-ribbon {
        max-height: none;
    }

    .app-control-form .field-grid.two-strong,
    .app-slider-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .app-modal-dialog,
    .app-modal-wide {
        width: calc(100vw - 20px);
        margin: 10px auto;
        max-height: calc(100vh - 20px);
    }

    .app-modal-grid {
        grid-template-columns: 1fr;
    }

    .app-control-form .field-grid.two-strong,
    .app-slider-grid {
        grid-template-columns: 1fr;
    }

    .app-primary-actions .button {
        flex-basis: 100%;
    }

    .app-thumb-card {
        min-width: 132px;
        max-width: 132px;
    }
}
