:root {
    --bg: #f5f6fa;
    --panel: rgba(255, 255, 255, 0.76);
    --panel-strong: rgba(255, 255, 255, 0.92);
    --text: #17181d;
    --muted: #6f7683;
    --line: rgba(17, 24, 39, 0.08);
    --primary: #007aff;
    --primary-dark: #0958d9;
    --green: #25b96f;
    --pink: #ff4f7a;
    --yellow: #f2b705;
    --danger: #dc2626;
    --success: #16a34a;
    --shadow: 0 22px 70px rgba(30, 35, 50, 0.14);
    --soft-shadow: 0 14px 38px rgba(20, 24, 35, 0.10);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--text);
    background:
        linear-gradient(135deg, rgba(0, 122, 255, 0.08), transparent 28%),
        linear-gradient(225deg, rgba(255, 79, 122, 0.08), transparent 30%),
        linear-gradient(180deg, #fbfcff 0%, var(--bg) 100%);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    line-height: 1.5;
}

body.template-surface {
    min-height: 100vh;
    padding-bottom: 360px;
    background:
        linear-gradient(150deg, rgba(0, 122, 255, 0.12), transparent 32%),
        linear-gradient(30deg, rgba(37, 185, 111, 0.10), transparent 34%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(242, 244, 249, 0.98)),
    #f5f6fa;
}

body.template-surface.dock-collapsed {
    padding-bottom: 130px;
}

body.template-surface .topbar {
    display: none;
}

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

img {
    display: block;
    max-width: 100%;
}

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

button,
.button,
.tool-pill,
.masonry-card,
.image-card {
    -webkit-tap-highlight-color: transparent;
    transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, border-color 180ms ease, opacity 180ms ease;
}

button:active,
.button:active,
.tool-pill:active {
    transform: scale(0.98);
}

.page {
    width: min(1500px, calc(100% - 80px));
    margin: 24px auto 70px;
}

.panel,
.admin-card,
.install-panel,
.login-card,
.composer,
.result-stage,
.history {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 24px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 68px;
    padding: 14px clamp(18px, 4vw, 48px);
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

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

.brand {
    font-weight: 900;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--green));
    color: #fff;
    font-weight: 1000;
    letter-spacing: 0;
    box-shadow: 0 12px 24px rgba(0, 122, 255, 0.22);
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar nav a {
    padding: 8px 10px;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 750;
}

.topbar nav a:hover {
    background: rgba(0, 122, 255, 0.09);
    color: var(--primary);
}

.topbar nav a.upgrade-link,
.upgrade-link {
    color: #fff;
    background: linear-gradient(135deg, #111827, #5b5ce2);
    box-shadow: 0 12px 24px rgba(17, 24, 39, 0.18);
}

.topbar nav a.upgrade-link:hover {
    color: #fff;
    background: linear-gradient(135deg, #0f172a, #007aff);
}

.site-notice {
    margin: 0 0 16px;
    padding: 13px 16px;
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(242, 183, 5, 0.18), rgba(0, 122, 255, 0.10));
    box-shadow: 0 12px 30px rgba(20, 24, 35, 0.07);
    color: #111827;
    font-weight: 850;
}

.template-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 4px 0 26px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.82);
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.58);
    box-shadow: 0 18px 46px rgba(20, 24, 35, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
}

.template-toolbar h1 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 0;
    font-size: clamp(30px, 4vw, 42px);
    font-weight: 1000;
    letter-spacing: 0;
}

.title-mark {
    width: 44px;
    height: 44px;
    border-radius: 15px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    background: conic-gradient(from 45deg, #007aff, #25b96f, #f2b705, #ff4f7a, #5b5ce2, #007aff);
    box-shadow: 0 16px 32px rgba(0, 122, 255, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.title-mark::before {
    content: "";
    width: 18px;
    height: 18px;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.28);
}

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

.tool-pill,
.template-actions button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.82);
    border-radius: 15px;
    padding: 0 15px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.90), rgba(255, 255, 255, 0.66));
    color: #17191f;
    font-weight: 850;
    box-shadow: 0 10px 28px rgba(20, 24, 35, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.95);
    cursor: pointer;
}

.tool-pill:hover,
.template-actions button:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 34px rgba(20, 24, 35, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.active-pill {
    color: #fff;
    background: linear-gradient(135deg, #111827, #2f3645);
    border-color: rgba(17, 24, 39, 0.08);
}

.official-pill {
    color: #fff;
    background: linear-gradient(135deg, #007aff, #25b96f);
    border-color: rgba(0, 122, 255, 0.18);
}

.creation-mode-switch {
    width: min(560px, 100%);
    margin: -4px auto 26px;
    padding: 7px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.86);
    box-shadow: 0 18px 44px rgba(20, 24, 35, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.creation-mode-switch a {
    min-height: 62px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border-radius: 18px;
    color: #5c6472;
    text-align: center;
    font-weight: 900;
}

.creation-mode-switch a:hover {
    transform: translateY(-1px);
    color: #17191f;
}

.creation-mode-switch a.active {
    color: #fff;
    background: linear-gradient(135deg, #111827, #3b4252);
    box-shadow: 0 14px 30px rgba(17, 24, 39, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.creation-mode-switch span {
    font-size: 16px;
    line-height: 1.1;
}

.creation-mode-switch small {
    color: inherit;
    font-size: 12px;
    opacity: 0.72;
}

.masonry-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
    perspective: 1200px;
}

.masonry-card {
    position: relative;
    overflow: hidden;
    display: block;
    width: 100%;
    margin: 0;
    border-radius: 28px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.70), rgba(255, 255, 255, 0.22)), #e9ebef;
    cursor: pointer;
    isolation: isolate;
    box-shadow: 0 12px 34px rgba(20, 24, 35, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.5);
    transform: translateZ(0);
}

.masonry-card.span-1 {
    aspect-ratio: 1 / 1.23;
}

.masonry-card.span-2 {
    aspect-ratio: 1 / 0.97;
}

.masonry-card.span-3 {
    aspect-ratio: 1 / 1.34;
}

.masonry-card.span-4 {
    aspect-ratio: 1 / 1.04;
}

.masonry-card.span-5 {
    aspect-ratio: 1 / 1.18;
}

.masonry-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 280ms ease;
}

.masonry-card:hover,
.masonry-card.selected {
    transform: translateY(-6px);
    box-shadow: 0 24px 58px rgba(20, 24, 35, 0.15);
}

.masonry-card:hover img,
.masonry-card.selected img {
    transform: scale(1.035);
}

.masonry-card.selected {
    outline: 3px solid rgba(0, 122, 255, 0.38);
}

.card-shade {
    position: absolute;
    inset: auto 0 0;
    height: 48%;
    z-index: 1;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.18) 32%, rgba(0, 0, 0, 0.70) 100%);
}

.masonry-card h3 {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 20px;
    z-index: 2;
    margin: 0;
    color: #fff;
    font-size: 18px;
    font-weight: 1000;
    text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
}

.gallery-block {
    margin-top: 36px;
}

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

.section-head h1,
.section-head h2,
.section-heading h1,
.section-heading h2 {
    margin: 0;
    font-size: 24px;
    letter-spacing: 0;
}

.section-head p {
    margin: 5px 0 0;
    color: var(--muted);
}

.section-head a {
    color: var(--primary);
    font-weight: 850;
}

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

.image-card,
.history-card {
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.82);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: var(--soft-shadow);
    cursor: pointer;
}

.image-card:hover,
.history-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 20px 50px rgba(20, 24, 35, 0.14);
}

.image-card img,
.history-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 13px;
    background: #eef0f5;
}

.image-card strong,
.image-card span,
.image-card small {
    display: block;
    padding: 8px 4px 0;
}

.image-card span {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.image-card small {
    color: var(--danger);
    line-height: 1.45;
}

.image-placeholder,
.thumb-placeholder {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    border-radius: 13px;
    color: #182033;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.90), rgba(237, 241, 248, 0.94));
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.image-placeholder b {
    font-size: 18px;
}

.loader-dot,
.spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(0, 122, 255, 0.16);
    border-top-color: var(--primary);
    animation: spin 900ms linear infinite;
}

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

.history-empty {
    padding: 28px;
    color: var(--muted);
    text-align: center;
}

.composer-dock {
    position: fixed;
    left: max(18px, calc((100vw - 1500px) / 2 + 18px));
    right: max(18px, calc((100vw - 1500px) / 2 + 18px));
    bottom: 18px;
    z-index: 30;
    margin: 0;
    padding: 16px;
    display: grid;
    gap: 14px;
    border-radius: 30px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 250, 255, 0.82));
    border: 1px solid rgba(255, 255, 255, 0.86);
    box-shadow: 0 26px 86px rgba(20, 24, 35, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    max-height: min(58vh, 560px);
    overflow: auto;
    backdrop-filter: blur(26px) saturate(180%);
    -webkit-backdrop-filter: blur(26px) saturate(180%);
}

.composer-title {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}

.composer-badge {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 17px;
    color: #fff;
    background: conic-gradient(from 180deg, #007aff, #25b96f, #f2b705, #ff4f7a, #5b5ce2, #007aff);
    box-shadow: 0 14px 30px rgba(0, 122, 255, 0.24);
    font-weight: 1000;
    letter-spacing: 0;
}

.composer-title h2 {
    margin: 0;
    font-size: 21px;
}

.composer-title p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.composer-toggle {
    min-height: 38px;
    border: 0;
    border-radius: 13px;
    padding: 0 13px;
    color: var(--primary);
    background: rgba(0, 122, 255, 0.09);
    font-weight: 900;
    cursor: pointer;
}

.composer-body {
    display: grid;
    grid-template-columns: minmax(360px, 1fr) minmax(220px, 360px);
    gap: 14px;
    align-items: stretch;
}

.composer-dock.is-collapsed .composer-body {
    display: none;
}

.generate-form {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(180px, 260px);
    gap: 12px;
    align-items: start;
}

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

label em,
.install-hint {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(0, 122, 255, 0.10);
    color: var(--primary);
    font-style: normal;
    font-size: 12px;
    font-weight: 900;
}

.locked-field input[readonly] {
    color: #6b7280;
    background: rgba(17, 24, 39, 0.045);
    cursor: not-allowed;
}

.locked-field small {
    color: var(--muted);
    line-height: 1.55;
    font-weight: 750;
}

.field-link {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(37, 185, 111, 0.12);
    color: #12804d;
    font-size: 12px;
    font-weight: 950;
}

.field-help,
.install-tip {
    color: var(--muted);
    line-height: 1.6;
    font-size: 13px;
    font-weight: 750;
}

.install-tip {
    padding: 13px 14px;
    border: 1px solid rgba(0, 122, 255, 0.13);
    border-radius: 16px;
    background: rgba(0, 122, 255, 0.07);
}

.install-tip a {
    color: var(--primary);
    font-weight: 950;
}

textarea,
input,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    outline: none;
    padding: 10px 12px;
}

textarea {
    resize: vertical;
}

.generate-form textarea {
    min-height: 138px;
    grid-row: span 2;
}

textarea:focus,
input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.13);
}

.quick-controls {
    display: grid;
    gap: 10px;
}

.segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    padding: 5px;
    border-radius: 16px;
    background: rgba(17, 24, 39, 0.06);
}

.segmented label,
.ratio-row label {
    display: block;
    cursor: pointer;
}

.segmented input,
.ratio-row input {
    display: none;
}

.segmented span,
.ratio-row span {
    min-height: 38px;
    display: grid;
    place-items: center;
    padding: 0 10px;
    border-radius: 12px;
    color: #5c6472;
    background: rgba(255, 255, 255, 0.76);
    font-size: 13px;
    font-weight: 900;
    white-space: nowrap;
}

.segmented input:checked + span,
.ratio-row input:checked + span {
    color: #fff;
    background: linear-gradient(135deg, #111827, #3b4252);
    box-shadow: 0 12px 24px rgba(17, 24, 39, 0.18);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: 15px;
    padding: 10px 16px;
    cursor: pointer;
    font-weight: 900;
}

.button.primary,
.send-btn {
    border: 0;
    color: #fff;
    background: linear-gradient(135deg, #007aff, #5b5ce2);
    box-shadow: 0 14px 28px rgba(0, 122, 255, 0.24);
}

.button.primary:hover,
.send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 20px 38px rgba(0, 122, 255, 0.30);
}

.button.ghost {
    border-color: rgba(17, 24, 39, 0.08);
    background: #fff;
    color: var(--text);
}

.button.full {
    width: 100%;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.62;
    transform: none;
}

.inline-message {
    min-height: 22px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 850;
}

.inline-message.success {
    color: var(--success);
}

.inline-message.danger {
    color: var(--danger);
}

.advanced-panel {
    grid-column: 1 / -1;
    border: 1px solid rgba(17, 24, 39, 0.08);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.62);
    overflow: hidden;
}

.advanced-panel summary {
    cursor: pointer;
    padding: 12px 14px;
    color: #2f3645;
    font-weight: 950;
}

.control-block,
.reference-grid {
    padding: 0 14px 14px;
}

.control-block strong {
    display: block;
    margin-bottom: 9px;
}

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

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

.result-frame {
    display: grid;
    place-items: center;
    min-height: 260px;
    height: 100%;
    border: 1px solid rgba(17, 24, 39, 0.08);
    border-radius: 22px;
    overflow: hidden;
    background:
        linear-gradient(90deg, rgba(17, 24, 39, 0.04) 1px, transparent 1px),
        linear-gradient(0deg, rgba(17, 24, 39, 0.04) 1px, transparent 1px),
        #fbfcff;
    background-size: 24px 24px;
}

.result-frame.done {
    display: block;
    background: #111827;
}

.result-frame.done img {
    width: 100%;
    height: min(42vh, 390px);
    object-fit: contain;
    background: #111827;
}

.result-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    background: #fff;
    border-top: 1px solid var(--line);
}

.result-meta div {
    display: grid;
    gap: 2px;
}

.result-meta span {
    color: var(--muted);
    font-size: 13px;
}

.empty-state,
.loading-state,
.error-state {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 22px;
    text-align: center;
    color: var(--muted);
}

.empty-state strong,
.loading-state strong,
.error-state strong {
    color: var(--text);
    font-size: 18px;
}

.preview-mark {
    width: 76px;
    height: 76px;
    border-radius: 22px;
    background:
        linear-gradient(135deg, rgba(0, 122, 255, 0.92), rgba(37, 185, 111, 0.86)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cpath fill='white' fill-opacity='.65' d='M18 68l18-24 13 16 9-10 20 18H18zm12-37a9 9 0 110 18 9 9 0 010-18z'/%3E%3C/svg%3E");
    background-size: cover;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(320px, 0.82fr) minmax(360px, 1.18fr);
    gap: clamp(18px, 3vw, 34px);
    width: min(1440px, calc(100% - 36px));
    margin: 30px auto 54px;
}

.composer,
.result-stage {
    min-height: 640px;
}

.composer {
    padding: clamp(18px, 3vw, 28px);
}

.composer-form,
.install-form,
.settings-form {
    display: grid;
    gap: 18px;
}

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

.form-grid .wide {
    grid-column: 1 / -1;
}

.check-row {
    grid-template-columns: auto 1fr;
    align-items: center;
}

.check-row input {
    width: 18px;
    height: 18px;
    min-height: 18px;
}

.button-row,
.install-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.install-page,
.login-page {
    min-height: 100vh;
}

.install-shell,
.login-shell {
    display: grid;
    place-items: center;
    width: min(980px, calc(100% - 34px));
    min-height: 100vh;
    margin: 0 auto;
    padding: 36px 0;
}

.install-panel,
.login-card {
    width: 100%;
    padding: clamp(22px, 4vw, 34px);
}

.login-card {
    max-width: 460px;
    display: grid;
    gap: 16px;
}

.brand-row h1 {
    margin: 0;
    font-size: 28px;
}

.brand-row p {
    margin: 2px 0 0;
    color: var(--muted);
}

hr {
    width: 100%;
    border: 0;
    border-top: 1px solid var(--line);
    margin: 4px 0;
}

.notice {
    margin: 18px 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.86);
    font-weight: 750;
}

.notice.success {
    border-color: rgba(22, 163, 74, 0.28);
    background: rgba(22, 163, 74, 0.08);
    color: var(--success);
}

.notice.danger {
    border-color: rgba(220, 38, 38, 0.28);
    background: rgba(220, 38, 38, 0.08);
    color: var(--danger);
}

.admin-shell {
    width: min(1180px, calc(100% - 36px));
    margin: 30px auto 54px;
    display: grid;
    gap: 18px;
    min-width: 0;
}

.admin-shell > * {
    min-width: 0;
}

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

.stats-row div {
    display: grid;
    gap: 4px;
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--soft-shadow);
}

.stats-row span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 850;
}

.stats-row strong {
    font-size: 30px;
}

.upgrade-banner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    padding: clamp(18px, 3vw, 26px);
    border: 1px solid rgba(255, 255, 255, 0.86);
    border-radius: 24px;
    background:
        linear-gradient(135deg, rgba(17, 24, 39, 0.94), rgba(0, 122, 255, 0.84)),
        #111827;
    color: #fff;
    box-shadow: 0 24px 60px rgba(17, 24, 39, 0.20);
}

.upgrade-banner span {
    display: inline-flex;
    margin-bottom: 8px;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    color: rgba(255, 255, 255, 0.86);
    font-size: 12px;
    font-weight: 950;
}

.upgrade-banner strong {
    display: block;
    font-size: clamp(20px, 3vw, 30px);
    line-height: 1.22;
}

.upgrade-banner p {
    margin: 8px 0 0;
    color: rgba(255, 255, 255, 0.78);
}

.upgrade-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.upgrade-banner .button.ghost {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.admin-card {
    padding: clamp(18px, 3vw, 28px);
    min-width: 0;
}

.json-box {
    overflow: auto;
    max-height: 440px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #111827;
    color: #e7f2f2;
    font-size: 13px;
}

.table-wrap {
    overflow-x: auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
}

.tasks-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

.tasks-table th,
.tasks-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.tasks-table th {
    color: var(--muted);
    font-size: 13px;
}

.prompt-cell {
    max-width: 360px;
}

code {
    color: var(--primary-dark);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    overflow-wrap: anywhere;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 58px;
    min-height: 28px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.06);
    color: var(--muted);
    font-size: 13px;
    font-weight: 850;
}

.status-pill.succeeded {
    background: rgba(22, 163, 74, 0.10);
    color: var(--success);
}

.status-pill.failed {
    background: rgba(220, 38, 38, 0.10);
    color: var(--danger);
}

.commercial-shell {
    gap: 22px;
}

.commercial-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
    gap: 18px;
    align-items: stretch;
    padding: clamp(22px, 4vw, 34px);
    border: 1px solid rgba(255, 255, 255, 0.82);
    border-radius: 28px;
    background:
        linear-gradient(135deg, rgba(0, 122, 255, 0.14), rgba(37, 185, 111, 0.10)),
        rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    min-width: 0;
}

.commercial-eyebrow {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 3px 10px;
    border-radius: 999px;
    color: var(--primary);
    background: rgba(0, 122, 255, 0.10);
    font-size: 12px;
    font-weight: 950;
}

.commercial-hero h1 {
    max-width: 820px;
    margin: 14px 0 12px;
    font-size: clamp(32px, 4vw, 52px);
    line-height: 1.08;
    letter-spacing: 0;
}

.commercial-hero p,
.commercial-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}

.commercial-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

.commercial-card {
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.82);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--soft-shadow);
    min-width: 0;
}

.commercial-card span {
    display: inline-flex;
    margin-bottom: 10px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 950;
}

.commercial-card strong {
    display: block;
    margin-bottom: 8px;
    font-size: 22px;
    line-height: 1.25;
}

.contact-card {
    display: grid;
    align-content: center;
}

.contact-card strong {
    font-size: 38px;
    letter-spacing: 0;
}

.copy-status {
    min-height: 20px;
    color: var(--success);
    font-weight: 850;
}

.commercial-grid,
.commercial-bottom {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    min-width: 0;
}

.commercial-bottom {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.comparison-wrap {
    border-radius: 18px;
    border: 1px solid rgba(17, 24, 39, 0.06);
    background: rgba(255, 255, 255, 0.62);
}

.comparison-table th {
    color: #111827;
    background: rgba(0, 122, 255, 0.08);
}

.comparison-table td:nth-child(3) {
    color: #10233c;
    background: rgba(37, 185, 111, 0.06);
}

.comparison-table td {
    line-height: 1.65;
}

@media (max-width: 1180px) {
    .template-toolbar {
        justify-content: center;
    }

    .template-actions {
        justify-content: center;
    }

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

    .composer-body {
        grid-template-columns: 1fr;
    }

    .generate-form {
        grid-template-columns: 1fr;
    }

    .generate-form textarea {
        grid-row: auto;
    }

    .result-frame {
        min-height: 300px;
    }

    .commercial-hero,
    .commercial-grid,
    .commercial-bottom {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    body.template-surface {
        padding-bottom: 470px;
    }

    body.template-surface.dock-collapsed {
        padding-bottom: 124px;
    }

    .page {
        width: min(100% - 28px, 1500px);
    }

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

    .masonry-card {
        border-radius: 22px;
    }

    .image-grid,
    .history-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .composer-dock {
        left: 12px;
        right: 12px;
        bottom: 12px;
        max-height: 62vh;
        border-radius: 24px;
    }

    .reference-grid,
    .control-grid,
    .form-grid,
    .stats-row,
    .upgrade-banner {
        grid-template-columns: 1fr;
    }

    .upgrade-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 620px) {
    body.template-surface {
        padding-bottom: 520px;
    }

    body.template-surface.dock-collapsed {
        padding-bottom: 124px;
    }

    .site-notice {
        font-size: 13px;
    }

    .template-toolbar {
        padding: 12px;
        border-radius: 22px;
    }

    .template-toolbar h1 {
        font-size: 30px;
    }

    .template-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tool-pill {
        min-width: 0;
        padding: 0 10px;
        font-size: 13px;
    }

    .creation-mode-switch {
        grid-template-columns: 1fr;
    }

    .masonry-grid {
        grid-template-columns: 1fr;
    }

    .image-grid,
    .history-grid {
        grid-template-columns: 1fr;
    }

    .composer-title {
        grid-template-columns: auto 1fr;
    }

    .composer-toggle {
        grid-column: 1 / -1;
    }

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

    .result-meta {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }
}
