        :root {
            --bg: #f6f6f9;
            --surface: #ffffff;
            --surface-soft: #eff0f5;
            --text: #17181c;
            --muted: #6f7388;
            --line: #dfe1ea;
            --primary: #504ac6;
            --primary-dark: #3b35a7;
            --green: #282471;
            --red: #dc2626;
            --amber: #2b2697;
            --shadow: 0 8px 22px rgba(21, 20, 42, 0.07);
            --radius: 8px;
            --nav-height: 62px;
        }

        * { box-sizing: border-box; }
        html { background: var(--bg); }
        body {
            margin: 0;
            min-height: 100vh;
            -webkit-font-smoothing: antialiased;
        }

        button, input, textarea {
            font: inherit;
        }

        button {
            border: 0;
            cursor: pointer;
            color: inherit;
        }

        button:focus { outline: none; }

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

        .app {
            width: min(1080px, 100%);
            margin: 0 auto;
            padding: 0 12px calc(var(--nav-height) + env(safe-area-inset-bottom) + 18px);
        }

        .topbar {
            position: sticky;
            top: 0;
            z-index: 20;
            backdrop-filter: blur(18px);
            -webkit-backdrop-filter: blur(18px);
        }

        .brand-row, .row-between {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
        }

        .brand {
            min-width: 0;
        }

        .brand-title {
            margin: 0;
            line-height: 1.1;
            letter-spacing: 0;
        }

        .brand-subtitle {
            margin: 2px 0 0;
            color: var(--muted);
            font-size: 12px;
            line-height: 1.25;
        }

        .quota-pill {
            flex: 0 0 auto;
            white-space: nowrap;
        }

        .quota-pill strong {
            color: var(--text);
        }

        .search-wrap {
            position: relative;
        }

        .search-wrap input {
            width: 100%;
            padding: 0 12px 0 36px;
            border: 1px solid var(--line);
            border-radius: var(--radius);
            color: var(--text);
            background: var(--surface);
            outline: none;
            box-shadow: none;
        }

        .search-wrap input:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(80, 74, 198, 0.12);
        }

        .search-icon {
            position: absolute;
            left: 12px;
            top: 50%;
            transform: translateY(-50%);
            width: 16px;
            height: 16px;
            color: var(--muted);
        }

        .category-nav {
            overflow-x: auto;
            scrollbar-width: none;
        }

        .category-nav::-webkit-scrollbar { display: none; }

        .chip {
            flex: 0 0 auto;
            padding: 0 11px;
            border: 1px solid var(--line);
            border-radius: 999px;
            font-size: 13px;
            font-weight: 750;
            white-space: nowrap;
        }


        .view { display: none; }
        .view.active { display: block; animation: appear 180ms ease-out; }

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





        .category-count {
            flex: 0 0 auto;
        }

        .pin-badge {
            display: inline-flex;
            align-items: center;
            min-height: 20px;
            padding: 0 7px;
            border-radius: 999px;
            background: rgba(80, 74, 198, 0.1);
            color: var(--primary);
            font-size: 11px;
            font-weight: 850;
        }

        .template-grid {
            align-items: start;
        }


        .template-card {
            width: 100%;
            min-height: 0;
            border-radius: var(--radius);
            text-align: left;
        }

        .template-card:active {
            transform: translateY(1px);
        }

        .template-media {
            width: 100%;
            aspect-ratio: 3 / 4;
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            background: var(--surface-soft);
            background-image: var(--preview-image);
            background-position: center center;
            background-repeat: no-repeat;
            background-size: contain;
        }

        .template-media img {
            width: 1px;
            height: 1px;
            opacity: 0;
            pointer-events: none;
        }

        .template-meta {
            color: var(--text);
        }

        .template-title {
            margin: 0;
            overflow-wrap: anywhere;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        .template-category {
            margin-top: 3px;
            font-size: 11px;
            line-height: 1.2;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .template-description {
            margin: 6px 0 0;
            font-size: 12px;
            overflow-wrap: anywhere;
        }

        .template-description.compact {
            display: -webkit-box;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        .editor-template-preview {
            align-items: center;
            justify-content: center;
            width: 100%;
            border-radius: var(--radius);
        }

        .editor-template-preview img {
            height: auto;
            max-width: 100%;
        }

        .editor-workspace {
            display: grid;
            gap: 12px;
            align-items: stretch;
        }

        @media (min-width: 720px) {
            .editor-workspace {
                grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
            }

            .editor-template-preview {
                margin: 0;
                min-height: 240px;
            }
        }

        .surface {
            background: var(--surface);
            border: 1px solid var(--line);
            border-radius: var(--radius);
        }


        .section-title {
            margin: 0 0 12px;
            font-size: 18px;
            line-height: 1.2;
            font-weight: 800;
        }

        .muted {
            color: var(--muted);
        }

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

        .metric {
            border: 1px solid var(--line);
            border-radius: var(--radius);
        }

        .metric-label {
            font-size: 12px;
            font-weight: 800;
            text-transform: uppercase;
        }

        .metric-value {
            margin-top: 8px;
            font-size: 22px;
            font-weight: 850;
            line-height: 1;
        }

        .credit-icon {
            justify-content: center;
            width: 18px;
            height: 18px;
            border-radius: 999px;
            font-size: 11px;
            font-weight: 900;
        }



        .package-head {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 10px;
        }





        .legal-text {
            margin: 12px 0 0;
        }

        .legal-text a {
            color: var(--primary);
            font-weight: 800;
        }

        .status-line {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-top: 12px;
            padding: 12px;
            border: 1px solid var(--line);
            color: var(--muted);
            line-height: 1.35;
        }

        .dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: var(--amber);
            flex: 0 0 auto;
        }

        .dot.ok { background: var(--green); }

        .form-label {
            display: block;
            margin: 14px 0 7px;
            color: var(--muted);
            font-size: 12px;
            font-weight: 850;
            text-transform: uppercase;
        }

        .field, .textarea {
            width: 100%;
            border: 1px solid var(--line);
            border-radius: var(--radius);
            background: #ffffff;
            color: var(--text);
            outline: none;
        }

        .field {
            height: 44px;
            padding: 0 12px;
        }

        .textarea {
            min-height: 122px;
            padding: 12px;
            resize: vertical;
            line-height: 1.45;
        }

        .textarea.small-textarea {
            min-height: 76px;
        }

        .field:focus, .textarea:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(80, 74, 198, 0.12);
        }

        .segmented {
            display: grid;
            grid-template-columns: repeat(5, minmax(0, 1fr));
            margin: 8px 0 14px;
            padding: 0;
        }

        .model-grid {
            display: grid;
            margin: 8px 0 10px;
        }

        .model-option {
            width: 100%;
            display: flex;
            justify-content: space-between;
            gap: 12px;
            border: 1px solid var(--line);
            border-radius: var(--radius);
            text-align: left;
        }


        .model-name {
            display: block;
            font-weight: 850;
        }

        .model-desc {
            display: block;
            color: var(--muted);
            font-size: 12px;
        }

        .model-cost {
            flex: 0 0 auto;
            padding: 6px 8px;
            border-radius: 999px;
            font-size: 12px;
            font-weight: 850;
        }

        .model-note {
            margin: -1px 0 12px;
            color: var(--muted);
            font-size: 12px;
            line-height: 1.35;
        }

        .segment {
            width: 100%;
            border: 1px solid var(--line);
            color: var(--muted);
            font-weight: 850;
            display: grid;
            place-items: center;
        }


        .ratio-shape {
            display: block;
            width: var(--w);
            height: var(--h);
            max-width: 100%;
            border: 2px solid currentColor;
            border-radius: 4px;
            background: rgba(80, 74, 198, 0.08);
            opacity: 0.9;
        }

        .segment.active .ratio-shape {
            background: rgba(255, 255, 255, 0.18);
        }

        .sr-only {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            white-space: nowrap;
            border: 0;
        }

        .check-row {
            display: flex;
            align-items: flex-start;
            gap: 10px;
            padding: 12px;
            margin: 10px 0 16px;
            border: 1px solid var(--line);
            color: var(--muted);
            line-height: 1.35;
        }

        .check-row input {
            width: 18px;
            height: 18px;
            margin-top: 1px;
            accent-color: var(--primary);
        }

        .check-row strong {
            display: block;
            color: var(--text);
        }

        .button {
            min-height: 46px;
            width: 100%;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 0 14px;
            font-weight: 800;
            text-decoration: none;
        }

        .button:disabled {
            cursor: default;
        }


        .button.secondary:active { background: var(--surface-soft); }
        .button.danger { background: var(--red); }

        .prompt-tools {
            display: grid;
            gap: 10px;
        }

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

        .idea-chip {
            color: var(--text);
            font-size: 12px;
            font-weight: 800;
            text-align: left;
        }

        .custom-note {
            margin: 0 0 12px;
            color: var(--muted);
            font-size: 13px;
            line-height: 1.35;
        }

        .button-row {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
            margin-top: 12px;
        }

        .button-row.three {
            grid-template-columns: repeat(2, minmax(0, 1fr));
        }

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

        .back-button {
            padding: 0 10px;
            margin-bottom: 12px;
        }

        .upload-zone {
            display: grid;
            place-items: center;
            width: 100%;
            padding: 16px;
            border: 1.5px dashed #b6bbd1;
            border-radius: var(--radius);
            text-align: center;
        }

        .upload-zone strong {
            display: block;
            margin-bottom: 4px;
        }

        @media (min-width: 720px) {
            .editor-workspace .upload-zone {
                min-height: 240px;
            }
        }

        .preview-row {
            display: flex;
            gap: 10px;
            overflow-x: auto;
            scrollbar-width: none;
        }

        .preview-row::-webkit-scrollbar { display: none; }

        .preview {
            position: relative;
            flex: 0 0 76px;
            width: 76px;
            height: 76px;
            border-radius: var(--radius);
            overflow: hidden;
            background: var(--surface-soft);
        }

        .preview img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .remove {
            position: absolute;
            top: 4px;
            right: 4px;
            width: 24px;
            height: 24px;
            border-radius: 50%;
            background: rgba(18, 17, 39, 0.82);
            color: #ffffff;
            font-weight: 900;
        }

        .status {
            display: none;
            margin-top: 12px;
        }

        .status.show { display: block; }
        .status a { color: inherit; font-weight: 850; }

        .admin-layout {
            display: grid;
            gap: 14px;
        }

        @media (min-width: 860px) {
            .admin-layout {
                grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
                align-items: start;
            }
        }

        .admin-row {
            display: grid;
            grid-template-columns: 52px minmax(0, 1fr);
            gap: 10px;
            align-items: center;
            border-bottom: 1px solid var(--line);
        }

        @media (min-width: 560px) {
            .admin-row {
                grid-template-columns: 52px minmax(0, 1fr) auto;
            }
        }

        .admin-row:last-child { border-bottom: 0; }

        .admin-thumb {
            width: 52px;
            height: 68px;
            object-fit: contain;
            border-radius: var(--radius);
        }

        .admin-title {
            font-weight: 850;
            line-height: 1.2;
            overflow-wrap: anywhere;
        }

        .admin-category {
            margin-top: 4px;
            color: var(--muted);
            font-size: 12px;
            overflow-wrap: anywhere;
        }

        .admin-actions {
            grid-column: 1 / -1;
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 8px;
        }

        @media (min-width: 560px) {
            .admin-actions {
                grid-column: auto;
                display: flex;
                justify-content: flex-end;
            }
        }

        .small-button {
            min-height: 36px;
            padding: 0 10px;
            border-radius: var(--radius);
            border: 1px solid var(--line);
            background: var(--surface);
            color: var(--text);
            font-size: 13px;
            font-weight: 850;
        }

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

        .admin-toolbar {
            display: grid;
            gap: 10px;
            margin-bottom: 12px;
        }

        .admin-category-chips,
        .admin-filter-chips {
            display: flex;
            flex-wrap: wrap;
            gap: 7px;
            margin-top: 8px;
        }

        .mini-chip {
            min-height: 30px;
            padding: 0 10px;
            border: 1px solid var(--line);
            border-radius: 999px;
            background: var(--surface);
            color: var(--muted);
            font-size: 12px;
            font-weight: 800;
        }

        .mini-chip.active {
            border-color: var(--primary);
            background: rgba(80, 74, 198, 0.1);
            color: var(--primary);
        }

        .admin-form-head {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 12px;
            margin-bottom: 4px;
        }

        .admin-mode {
            padding: 6px 8px;
            border-radius: var(--radius);
            color: var(--muted);
            font-size: 12px;
            font-weight: 850;
            white-space: nowrap;
        }

        .field-hint {
            display: flex;
            justify-content: space-between;
            gap: 10px;
            margin-top: 6px;
            color: var(--muted);
            font-size: 12px;
        }

        .admin-cover-preview {
            margin: 12px 0 4px;
        }

        .admin-preview-card {
            position: relative;
            width: min(180px, 100%);
            aspect-ratio: 3 / 4;
            overflow: hidden;
            border-radius: var(--radius);
            background: var(--surface-soft);
            border: 1px solid var(--line);
        }

        .admin-preview-card img {
            width: 100%;
            height: 100%;
            object-fit: contain;
            background: var(--surface-soft);
        }

        .admin-preview-card.placeholder {
            display: grid;
            place-items: center;
            color: var(--muted);
            font-size: 13px;
            text-align: center;
            padding: 12px;
        }

        .admin-preview-title {
            position: absolute;
            inset: auto 0 0;
            min-height: 40%;
            display: flex;
            align-items: flex-end;
            padding: 36px 10px 10px;
            background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
            color: #ffffff;
            font-size: 14px;
            line-height: 1.15;
            font-weight: 850;
            overflow-wrap: anywhere;
        }

        .icon-button {
            width: 38px;
            height: 38px;
            background: var(--surface);
            border: 1px solid var(--line);
            font-weight: 900;
        }

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


        .bottom-nav {
            position: fixed;
            z-index: 30;
            left: 0;
            right: 0;
            bottom: 0;
        }

        .bottom-nav-inner {
            margin: 0 auto;
            display: flex;
        }

        .nav-btn {
            flex: 1 1 0;
            min-width: 0;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            white-space: nowrap;
        }

        .nav-btn svg {
            flex: 0 0 auto;
        }


        /* Compact product shell */
        :root {
            --bg: #f4f5f8;
            --surface-soft: #eeeff4;
            --text: #16161a;
            --muted: #666a7d;
            --line: #dcdee8;
            --primary: #4741c3;
            --primary-dark: #36319c;
            --accent: #d97706;
            --shadow: 0 8px 24px rgba(16, 15, 42, 0.06);
        }

        main { padding-top: 2px; }

        .topbar {
            margin-bottom: 10px;
        }

        .brand-title {
            font-size: 15px;
        }
        .brand-subtitle { display: none; }

        .quota-pill {
            display: inline-flex;
            align-items: center;
            gap: 4px;
        }

        .search-wrap { margin-top: 7px; }
        .search-wrap input { height: 36px; }

        .catalog-guide {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            margin: 0 0 14px;
            overflow: hidden;
            border: 1px solid var(--line);
            border-radius: var(--radius);
        }

        .guide-step {
            min-width: 0;
            padding: 10px 8px;
            color: var(--muted);
            font-size: 11px;
            line-height: 1.25;
            text-align: center;
        }

        .guide-step strong {
            display: block;
            margin-bottom: 2px;
            color: var(--text);
            font-size: 12px;
        }

        .page-head {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 12px;
        }


        .flow-steps {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            margin: 0 0 14px;
        }

        .flow-step {
            min-width: 0;
            padding: 8px 6px;
            border: 1px solid var(--line);
            color: var(--muted);
            font-size: 11px;
            font-weight: 750;
            line-height: 1.2;
            text-align: center;
        }


        .step-title {
            line-height: 1.25;
        }

        .step-title:first-child { margin-top: 0; }


        .template-description.compact { -webkit-line-clamp: 1; }

        .section {
            margin-bottom: 12px;
        }

        .model-grid { gap: 7px; }

        .model-option {
            min-height: 0;
            align-items: flex-start;
            padding: 11px;
            box-shadow: none;
        }


        .model-option > span:first-child { min-width: 0; }
        .model-desc { margin-top: 4px; line-height: 1.35; }
        .model-cost { display: inline-flex; align-items: center; white-space: nowrap; }
        .model-note { display: none; }

        .upload-zone {
            min-height: 104px;
        }

        .segmented { gap: 5px; }
        .segment { height: 42px; padding: 5px; box-shadow: none; }
        .ratio-shape { max-height: 28px; }

        .check-row {
            margin-bottom: 12px;
            background: #f9f9fb;
        }

        .profile-action {
            margin-top: 12px;
        }

        .profile-tip {
            margin: 12px 0 0;
            color: var(--muted);
            font-size: 12px;
            line-height: 1.4;
        }

        .promo-panel {
            padding-top: 14px;
        }

        .promo-panel .step-title { margin: 0 0 5px; }

        .promo-copy {
            margin: 0 0 10px;
            color: var(--muted);
            font-size: 13px;
            line-height: 1.4;
        }

        .inline-form {
            align-items: center;
        }

        .inline-form .button {
            width: auto;
            min-width: 124px;
        }

        .promo-code-input {
            text-transform: uppercase;
            font-weight: 800;
        }

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

        .promo-list { margin-top: 14px; }

        .promo-row {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            gap: 10px;
            align-items: center;
            border-top: 1px solid var(--line);
        }

        .promo-row:first-child { border-top: 0; }

        .promo-name {
            font-size: 14px;
            font-weight: 900;
            overflow-wrap: anywhere;
        }

        .promo-meta {
            margin-top: 4px;
            color: var(--muted);
            font-size: 12px;
            line-height: 1.35;
        }

        .promo-row.inactive .promo-name,
        .promo-row.inactive .promo-meta { opacity: 0.55; }



        .nav-btn {
            flex-direction: column;
            gap: 2px;
            padding: 4px 3px;
            border-radius: 6px;
            font-size: 10px;
        }

        .nav-btn svg { width: 17px; height: 17px; }


        /* Unified visual system */
        :root {
            --bg: #f3f4f8;
            --surface: #ffffff;
            --surface-soft: #f1f2f6;
            --text: #111028;
            --muted: #6a6e81;
            --line: #dadce7;
            --primary: #423cbe;
            --primary-dark: #353097;
            --accent: #e4513f;
            --green: #292574;
            --amber: #332cb0;
            --shadow: 0 7px 22px rgba(17, 16, 40, 0.055);
        }

        body {
            background: var(--bg);
        }

        .app { padding-inline: 14px; }

        .topbar {
            margin-inline: -14px;
            border-bottom-color: rgba(218, 220, 231, 0.78);
        }

        .brand-title {
            color: #0e0d29;
            font-weight: 900;
            white-space: normal;
        }



        .search-wrap input,
        .field,
        .textarea {
            border-color: #d6d8e4;
            background: #ffffff;
            box-shadow: 0 1px 2px rgba(17, 16, 40, 0.025);
        }

        .search-wrap input::placeholder,
        .field::placeholder,
        .textarea::placeholder { color: #9298b9; }

        .chip {
            box-shadow: 0 1px 3px rgba(17, 16, 40, 0.025);
        }


        .catalog-guide {
            gap: 0;
            background: #ffffff;
        }

        .guide-step {
            position: relative;
            border-right: 1px solid var(--line);
            background: #ffffff;
        }

        .guide-step:last-child { border-right: 0; }
        .guide-step:nth-child(1) strong { color: var(--primary); }
        .guide-step:nth-child(2) strong { color: var(--accent); }
        .guide-step:nth-child(3) strong { color: var(--green); }


        .category-heading {
            padding-inline: 1px;
        }

        .category-heading h2 {
            color: #111028;
        }

        .category-count {
            min-width: 24px;
            height: 24px;
            display: inline-grid;
            place-items: center;
            padding-inline: 7px;
            border-radius: 999px;
        }


        .template-card {
            padding: 0;
            overflow: hidden;
            transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
        }

        .template-media {
            border-radius: 0;
            padding: 7px;
            background-color: #eff0f5;
        }

        .template-meta {
            min-height: 50px;
            padding: 9px 10px 10px;
            border-top: 1px solid #edeef4;
            background: #ffffff;
        }

        .template-title {
            color: #111028;
            line-height: 1.25;
        }

        .template-category { color: #7b7f93; }

        .surface {
            border-color: #d9dbe7;
            box-shadow: var(--shadow);
        }

        .section { padding: 15px; }



        .flow-steps { gap: 0; }

        .flow-step {
            border-radius: 0;
            border-right-width: 0;
            background: rgba(255, 255, 255, 0.72);
        }

        .flow-step:first-child { border-radius: 8px 0 0 8px; }
        .flow-step:last-child {
            border-right-width: 1px;
            border-radius: 0 8px 8px 0;
        }

        .flow-step.active {
            border-color: #b9b7e8;
            background: #f2f3f7;
            color: #3933a3;
        }

        .step-title {
            text-transform: uppercase;
        }

        .upload-zone {
            border-color: #a8aec8;
            background: #f8f9fb;
            color: #6a6e81;
            transition: border-color 160ms ease, background 160ms ease;
        }

        .upload-zone strong { color: #27282f; }

        .model-option {
            border-color: #d6d8e4;
            background: #ffffff;
        }

        .model-option.active {
            border-color: #a19ee0;
            background: #fcf6f5;
            box-shadow: inset 3px 0 0 var(--primary), 0 3px 12px rgba(66, 60, 190, 0.06);
        }

        .model-cost {
            background: #ebedf3;
            color: #3d3f4b;
        }

        .model-option.active .model-cost {
            background: #eaebf1;
            color: #3933a3;
        }


        .segment.active {
            box-shadow: 0 5px 14px rgba(17, 16, 40, 0.18);
        }

        .check-row,
        .status-line {
            border-color: #dcdee9;
            background: #f8f8fa;
        }

        .button {
            transition: transform 140ms ease, background 140ms ease, box-shadow 140ms ease;
        }

        .button.secondary {
            border-color: #d1d3e1;
        }

        .button:active { transform: translateY(1px); }

        .metric {
            position: relative;
            overflow: hidden;
            padding: 15px;
            border-color: #dcdee9;
            background: #f9f9fb;
        }

        .metric::before {
            content: "";
            position: absolute;
            inset: 0 auto 0 0;
            width: 3px;
            background: var(--primary);
        }

        .metric:nth-child(2)::before { background: var(--green); }
        .metric-label { color: #6a6e81; }
        .metric-value { color: #111028; }

        .promo-panel {
            margin-top: 16px;
            padding: 16px 0 0;
            border-top: 2px solid #d6d5f2;
            border-radius: 0;
            background: transparent;
        }

        .promo-panel .step-title {
            color: #2f2a87;
            text-transform: none;
        }

        .promo-row {
            padding: 12px 0;
        }

        .promo-name { color: #27282f; }

        .admin-form-head,
        .row-between { align-items: center; }

        .admin-mode {
            border: 1px solid #d9dbe7;
            background: #f5f5f8;
        }

        .admin-row {
            padding: 12px 0;
        }

        .admin-thumb {
            border: 1px solid #dcdee9;
            background: #f3f4f8;
        }

        .small-button {
            border-color: #d1d3e1;
            box-shadow: 0 1px 3px rgba(17, 16, 40, 0.035);
        }

        .empty {
            border-color: #bec2d5;
        }

        .bottom-nav {
            padding-inline: 12px;
        }


        .nav-btn {
            font-weight: 800;
        }


        @media (hover: hover) {
            .template-card:hover {
                transform: translateY(-2px);
                border-color: #b0b4cc;
                box-shadow: 0 10px 24px rgba(17, 16, 40, 0.1);
            }

            .button:hover { background: var(--primary-dark); }
            .button.secondary:hover { background: #f8f8fa; }
            .upload-zone:hover { border-color: var(--primary); background: #fcf6f5; }
        }

        @media (min-width: 720px) {
            .model-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
            .model-option { min-height: 118px; }
        }

        @media (max-width: 370px) {
            .brand-title { font-size: 14px; }
            .quota-pill { padding: 6px 7px; font-size: 11px; }
            .guide-step { padding-inline: 4px; }
            .nav-btn { font-size: 9px; }
            .inline-form { grid-template-columns: 1fr; }
            .inline-form .button { width: 100%; }
        }

        .quota-total {
            color: var(--text);
            font-size: 14px;
            font-weight: 900;
            line-height: 1;
        }


        .advanced-settings summary {
            list-style: none;
        }

        .advanced-settings summary::-webkit-details-marker { display: none; }
        .advanced-settings summary::after {
            content: "+";
            flex: 0 0 auto;
            font-size: 20px;
            line-height: 1;
        }
        .advanced-settings[open] summary::after { content: "−"; }
        .settings-current {
            margin-left: auto;
            color: var(--muted);
            font-size: 11px;
            font-weight: 750;
            text-align: right;
        }
        .advanced-content {
            border-top: 1px solid var(--line);
        }

        .model-heading {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            gap: 6px;
        }
        .model-tech {
            color: var(--muted);
            font-size: 11px;
            font-weight: 700;
        }
        .model-badge {
            display: inline-flex;
            align-items: center;
            min-height: 20px;
            padding: 0 6px;
            border-radius: 999px;
            background: #ebecf2;
            color: #25216a;
            font-size: 10px;
            font-weight: 900;
        }

        .generation-summary {
            min-height: 48px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            margin: 10px 0;
            padding: 10px 12px;
            border: 1px solid #cdcbed;
            border-radius: var(--radius);
            background: #f6f7fa;
            color: var(--muted);
            font-size: 13px;
        }
        .generation-summary strong {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            color: var(--text);
            font-size: 14px;
        }

        .photo-count {
            margin-top: 8px;
        }

        .admin-tabs {
            display: flex;
            overflow-x: auto;
            margin: 0 0 12px;
            padding-bottom: 2px;
            scrollbar-width: none;
        }
        .admin-tabs::-webkit-scrollbar { display: none; }
        .admin-tab {
            flex: 0 0 auto;
            padding: 0 12px;
            border: 1px solid var(--line);
            background: var(--surface);
            color: var(--muted);
        }
        .admin-tab.active {
            color: #ffffff;
        }
        .admin-tab-count {
            display: inline-grid;
            place-items: center;
            min-width: 20px;
            height: 20px;
            margin-left: 4px;
            padding: 0 5px;
            border-radius: 999px;
            background: #b42318;
            color: #ffffff;
            font-size: 11px;
        }
        #viewAdmin .surface[data-admin-panel] { display: none; }
        #viewAdmin[data-admin-active="analytics"] [data-admin-panel="analytics"],
        #viewAdmin[data-admin-active="templates"] [data-admin-panel="templates"],
        #viewAdmin[data-admin-active="settings"] [data-admin-panel="settings"],
        #viewAdmin[data-admin-active="users"] [data-admin-panel="users"],
        #viewAdmin[data-admin-active="promo"] [data-admin-panel="promo"],
        #viewAdmin[data-admin-active="categories"] [data-admin-panel="categories"],
        #viewAdmin[data-admin-active="feedback"] [data-admin-panel="feedback"] { display: block; }
        #viewAdmin .admin-layout { display: block; }
        #viewAdmin .admin-layout > div { display: contents; }

        .analytics-head,
        .analytics-section-head {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            flex-wrap: wrap;
            gap: 10px;
        }
        .analytics-periods {
            display: inline-flex;
            padding: 3px;
            border: 1px solid var(--line);
            border-radius: 8px;
            background: var(--surface-soft);
        }
        .analytics-controls {
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .analytics-refresh {
            display: inline-grid;
            place-items: center;
            padding: 0;
            border: 1px solid var(--line);
            border-radius: 8px;
            background: var(--surface);
            color: var(--text);
            font-size: 21px;
            line-height: 1;
        }
        .analytics-refresh:disabled { opacity: .5; }
        .analytics-period {
            padding: 0 9px;
            border: 0;
            border-radius: 6px;
            background: transparent;
            color: var(--muted);
            font-weight: 900;
        }
        .analytics-period.active {
            background: var(--surface);
            box-shadow: 0 2px 8px rgba(26, 24, 65, .09);
            color: var(--text);
        }
        .analytics-period-label { margin: 3px 0 0; color: var(--muted); }
        .analytics-metrics {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 8px;
            margin-top: 14px;
        }
        .analytics-metric {
            min-width: 0;
            padding: 12px;
            border: 1px solid var(--line);
            border-radius: var(--radius);
            background: #f9f9fb;
        }
        .analytics-metric-label { color: var(--muted); font-size: 10px; font-weight: 850; text-transform: uppercase; }
        .analytics-metric-value { margin-top: 6px; color: var(--text); font-size: 22px; font-weight: 900; line-height: 1; overflow-wrap: anywhere; }
        .analytics-metric-note { min-height: 16px; margin-top: 7px; color: var(--muted); font-size: 10px; line-height: 1.3; }
        .analytics-delta { font-weight: 900; }
        .analytics-delta.up { color: var(--green); }
        .analytics-delta.down { color: #d64545; }
        .analytics-delta.neutral { color: var(--muted); }
        .analytics-block {
            margin-top: 12px;
            padding-top: 14px;
            border-top: 1px solid var(--line);
        }
        .analytics-block-title { margin: 0; font-size: 14px; font-weight: 900; }
        .analytics-block-copy { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
        .analytics-insights { display: grid; gap: 7px; margin-top: 10px; }
        .analytics-insight {
            display: grid;
            grid-template-columns: 8px minmax(0, 1fr);
            gap: 9px;
            padding: 10px;
            border-radius: var(--radius);
            background: #f7f8fa;
            font-size: 12px;
            line-height: 1.4;
        }
        .analytics-insight::before { content: ""; width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: var(--primary); }
        .analytics-insight.good::before { background: var(--green); }
        .analytics-insight.warn::before { background: var(--amber); }
        .analytics-chart-wrap { overflow-x: auto; margin-top: 12px; padding-bottom: 4px; }
        .analytics-chart {
            min-width: 100%;
            height: 172px;
            display: flex;
            align-items: flex-end;
            gap: 3px;
            padding: 8px 4px 24px;
            border-bottom: 1px solid var(--line);
        }
        .analytics-day { position: relative; flex: 1 0 7px; min-width: 7px; height: 100%; display: flex; align-items: flex-end; gap: 1px; }
        .analytics-bar { flex: 1; min-height: 2px; border-radius: 3px 3px 0 0; background: var(--primary); }
        .analytics-bar.failed { background: #e06464; }
        .analytics-day-label { position: absolute; left: 50%; bottom: -20px; transform: translateX(-50%); color: var(--muted); font-size: 8px; white-space: nowrap; }
        .analytics-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; color: var(--muted); font-size: 11px; }
        .analytics-legend span { display: inline-flex; align-items: center; gap: 5px; }
        .analytics-legend i { width: 8px; height: 8px; border-radius: 2px; background: var(--primary); }
        .analytics-legend .failed { background: #e06464; }
        .analytics-split { display: grid; gap: 12px; }
        .analytics-list { display: grid; gap: 8px; margin-top: 10px; }
        .analytics-rank { min-width: 0; }
        .analytics-rank-head { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; }
        .analytics-rank-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
        .analytics-rank-value { flex: 0 0 auto; color: var(--muted); }
        .analytics-track { height: 6px; margin-top: 5px; overflow: hidden; border-radius: 999px; background: #eaecf2; }
        .analytics-fill { height: 100%; border-radius: inherit; background: var(--primary); }
        .analytics-fill.good { background: var(--green); }
        .analytics-funnel { display: grid; gap: 8px; margin-top: 10px; }
        .analytics-funnel-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #f9f9fb; }
        .analytics-funnel-row strong { font-size: 14px; }
        .analytics-funnel-row span { display: block; color: var(--muted); font-size: 11px; }
        .analytics-table-wrap { overflow-x: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius); }
        .analytics-table { width: 100%; min-width: 560px; border-collapse: collapse; background: var(--surface); font-size: 11px; }
        .analytics-table th, .analytics-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
        .analytics-table tr:last-child td { border-bottom: 0; }
        .analytics-table th { background: var(--surface-soft); color: var(--muted); font-size: 11px; text-transform: none; }
        .analytics-user-link { padding: 0; border: 0; background: transparent; color: var(--primary); font: inherit; font-weight: 900; text-decoration: underline; text-underline-offset: 2px; }
        .analytics-error { padding: 10px; border-left: 3px solid #e06464; border-radius: 0 var(--radius) var(--radius) 0; background: #fff6f6; }
        .analytics-error strong { display: block; font-size: 11px; }
        .analytics-error span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
        .analytics-empty { padding: 16px 0; color: var(--muted); font-size: 12px; text-align: center; }
        .analytics-method { margin: 14px 0; padding: 12px 0; border-block: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.6; }
        .analytics-method summary { cursor: pointer; color: var(--text); font-weight: 700; }
        .analytics-method p { margin: 10px 0 0; }
        .analytics-table caption { text-align: left; padding: 10px; color: var(--muted); }
        .analytics-block select { max-width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; }
        .analytics-block-title { overflow-wrap: anywhere; }
        .analytics-funnel-row > * { min-width: 0; }
        @media (min-width: 720px) {
            .analytics-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
            .analytics-split { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        }

        .feedback-kind-grid {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 6px;
            margin-bottom: 10px;
        }
        .feedback-kind {
            min-height: 38px;
            padding: 6px;
            border: 1px solid var(--line);
            border-radius: var(--radius);
            background: var(--surface);
            color: var(--muted);
            font-size: 12px;
            font-weight: 850;
        }
        .feedback-kind.active {
            border-color: var(--primary);
            background: #f2f3f7;
            color: var(--primary);
        }
        .feedback-list { display: grid; gap: 10px; }
        .feedback-row {
            padding: 12px;
            border: 1px solid var(--line);
            border-radius: var(--radius);
            background: #f9f9fb;
        }
        .feedback-row-head {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            flex-wrap: wrap;
            gap: 10px;
        }
        .feedback-row-title {
            font-size: 14px;
            font-weight: 900;
        }
        .feedback-row-meta,
        .feedback-context {
            margin-top: 4px;
            color: var(--muted);
            font-size: 11px;
            line-height: 1.4;
            overflow-wrap: anywhere;
        }
        .feedback-message {
            margin: 10px 0;
            font-size: 13px;
            line-height: 1.45;
            white-space: pre-wrap;
            overflow-wrap: anywhere;
        }
        .feedback-controls {
            display: grid;
            gap: 8px;
        }
        @media (min-width: 720px) {
            .feedback-controls { grid-template-columns: 160px minmax(0, 1fr) auto; align-items: end; }
        }

        /* Stable vertical rhythm for compact mobile forms. */
        .advanced-content > .step-title:first-child { margin-top: 12px; }
        .field-hint + .button,
        .promo-create-grid + .button,
        #grantBtn,
        #renameCategoryBtn,
        #savePresetBtn { margin-top: 12px; }
        .feedback-kind-grid + .textarea { margin-top: 0; }
        .surface.section > .status:first-child { margin-top: 0; }

        /* Bright compact catalog shell. */
        :root {
            --bg: #f4f5f8;
            --surface-soft: #f0f1f5;
            --text: #111028;
            --muted: #626577;
            --line: #d2d5e2;
            --primary: #514bc6;
            --primary-dark: #3a34a3;
            --accent: #ef5747;
            --green: #2d2982;
            --amber: #d67a0c;
            --shadow: 0 8px 24px rgba(26, 24, 65, 0.08);
        }

        .catalog-toolbar {
            justify-content: space-between;
        }


        .quota-pill {
            border-color: #c7c5ed;
        }

        .quota-pill .credit-icon {
            color: #3a34a3;
        }

        .compact-search {
            position: relative;
            flex: 1 1 auto;
            width: auto;
            min-width: 0;
            height: 36px;
            margin: 0;
            border: 1px solid #bdc1d4;
            border-radius: var(--radius);
            background: #ffffff;
            transition: border-color 160ms ease, box-shadow 160ms ease;
        }

        .compact-search:focus-within {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(81, 75, 198, 0.1);
        }

        .compact-search input {
            height: 34px;
            padding: 0 10px 0 38px;
            border: 0;
            opacity: 1;
            pointer-events: auto;
            box-shadow: none;
        }

        .compact-search input:focus {
            border: 0;
            box-shadow: none;
        }

        .search-toggle {
            position: absolute;
            z-index: 2;
            inset: 0 auto 0 0;
            width: 36px;
            display: grid;
            place-items: center;
            padding: 0;
            background: transparent;
            color: var(--primary);
        }

        .compact-search .search-icon {
            position: static;
            width: 18px;
            height: 18px;
            transform: none;
        }

        .category-nav {
            padding-top: 0;
        }

        .chip {
            min-height: 29px;
            padding-inline: 10px;
            border-color: #cdd0df;
            background: #ffffff;
            color: #3d3f4b;
        }

        .chip.active {
            border-color: var(--primary);
            background: var(--primary);
            color: #ffffff;
            box-shadow: 0 4px 12px rgba(81, 75, 198, 0.22);
        }

        .catalog-guide {
            border-color: #cfd2e0;
            box-shadow: 0 5px 16px rgba(26, 24, 65, 0.07);
        }

        .guide-step:nth-child(1) { background: #f4f5f8; }
        .guide-step:nth-child(2) { background: #f1f1fb; }
        .guide-step:nth-child(3) { background: #eeeff4; }

        .category-heading {
            gap: 8px;
            padding-left: 0;
        }

        .category-heading h2 {
            min-width: 0;
            display: inline-flex;
            align-items: center;
            gap: 7px;
        }

        .category-heading h2::before {
            content: "";
            flex: 0 0 auto;
            width: 5px;
            height: 20px;
            border-radius: 3px;
            background: var(--primary);
        }

        .category-section:nth-child(3n + 2) .category-heading h2::before { background: var(--accent); }
        .category-section:nth-child(3n + 3) .category-heading h2::before { background: var(--green); }
        .category-count { margin-left: auto; }

        .pin-icon {
            flex: 0 0 auto;
            width: 20px;
            height: 20px;
            display: inline-grid;
            place-items: center;
        }

        .pin-icon svg { width: 16px; height: 16px; }

        .new-badge {
            position: absolute;
            z-index: 2;
            display: inline-flex;
            align-items: center;
            min-height: 22px;
            box-shadow: 0 4px 12px rgba(81, 75, 198, 0.28);
        }

        .template-media { position: relative; }

        .template-card {
            border-color: #cfd2e0;
        }

        .template-meta { border-top-color: #dfe1eb; }


        .button.success { background: var(--green); }

        .icon-button {
            display: inline-grid;
            place-items: center;
            padding: 0;
            border-color: #bfc3d6;
            color: #31323b;
        }

        .icon-button svg { width: 20px; height: 20px; }
        .back-button { width: 40px; min-height: 40px; margin: 0; }

        .mini-chip.with-icon {
            display: inline-flex;
            align-items: center;
            gap: 5px;
        }

        .mini-chip.with-icon svg {
            width: 13px;
            height: 13px;
        }


        .package-badge {
            display: inline-flex;
            align-items: center;
            min-height: 22px;
        }


        .balance-hero {
            justify-items: start;
        }

        .balance-label,
        .balance-breakdown { font-size: 12px; font-weight: 650; }
        .balance-total {
            display: flex;
            align-items: center;
            gap: 7px;
        }
        .balance-total .credit-icon {
            color: #ffffff;
            font-size: 14px;
            transform: none;
        }

        .profile-quick-actions {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
        }

        .profile-quick-action {
            min-width: 0;
            display: grid;
            justify-items: center;
            align-content: center;
            gap: 6px;
            text-align: center;
        }
        .profile-quick-action svg { width: 21px; height: 21px; }
        .profile-quick-action span { min-width: 0; }
        .profile-quick-action strong,
        .profile-quick-action small { display: block; }
        .profile-quick-action small {
            margin-top: 2px;
            color: var(--muted);
        }
        .profile-quick-action.promo svg { color: var(--green); }
        .referral-progress {
            display: grid;
            gap: 7px;
        }
        .referral-progress-head {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 10px;
        }
        .referral-progress-head strong,
        .referral-progress-head span { display: block; }
        .referral-progress-head strong { font-size: 12px; }
        .referral-progress-head span,
        .referral-progress-note { color: var(--muted); }
        .referral-progress-value { flex: 0 0 auto; color: var(--primary); font-size: 12px; font-weight: 900; }
        .referral-progress-track { height: 6px; overflow: hidden; border-radius: 999px; background: #e2e4ed; }
        .referral-progress-fill { height: 100%; border-radius: inherit; }

        .profile-details { overflow: hidden; }
        .profile-details > summary {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            cursor: pointer;
            list-style: none;
        }
        .profile-details > summary::-webkit-details-marker { display: none; }
        .profile-details > summary span { min-width: 0; }
        .profile-details > summary strong,
        .profile-details > summary small { display: block; }
        .profile-details > summary small {
            margin-top: 3px;
            color: var(--muted);
            font-size: 11px;
        }
        .profile-details > summary > svg {
            flex: 0 0 auto;
            width: 18px;
            height: 18px;
            color: var(--muted);
            transition: transform 160ms ease;
        }
        .profile-details[open] > summary > svg { transform: rotate(90deg); }
        .details-content { padding: 0 14px 14px; }
        .compact-note {
            margin: 0 0 10px;
            color: var(--muted);
            font-size: 12px;
            line-height: 1.4;
        }

        .shop-grid { margin-top: 0; }
        .package-card {
            grid-template-columns: minmax(0, 1fr) auto auto;
        }
        .package-price { text-align: right; }
        .package-old-price { display: block; margin: 2px 0 0; }
        .package-buy {
            padding: 0 9px;
            font-size: 11px;
        }
        .legal-text { margin-top: 9px; }
        .legal-text details { border-top: 1px solid var(--line); padding-top: 8px; }
        .legal-text summary { cursor: pointer; color: var(--primary); font-weight: 800; }
        .legal-text p { margin: 7px 0 0; }
        .shop-more { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
        .shop-more > summary { cursor: pointer; color: var(--primary); font-size: 12px; font-weight: 850; }
        .shop-more .shop-grid { margin-top: 8px; }


        .bottom-nav-inner {
            border-color: #c9cddd;
        }

        .nav-btn { min-height: 44px; color: #595c6d; }
        .nav-btn:nth-child(2):not(.active) svg { color: var(--accent); }
        .nav-btn[data-view="profile"]:not(.active) svg { color: var(--green); }
        .nav-btn.active {
            border: 0;
            background: var(--primary);
            color: #ffffff;
            box-shadow: 0 5px 14px rgba(81, 75, 198, 0.24);
        }

        /* Guided custom generation. */
        .custom-flow {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            margin: 0 0 12px;
            border: 1px solid #cfd2e0;
            border-radius: var(--radius);
            overflow: hidden;
            background: #ffffff;
        }

        .custom-flow-step {
            min-width: 0;
            min-height: 48px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            padding: 7px 5px;
            border-right: 1px solid #dddfe9;
            color: #5d6172;
            font-size: 10px;
            font-weight: 800;
            text-align: center;
        }

        .custom-flow-step:last-child { border-right: 0; }
        .custom-flow-step:first-child { color: var(--primary); background: #f5f5f8; }

        .custom-flow-step b {
            flex: 0 0 auto;
            width: 19px;
            height: 19px;
            display: grid;
            place-items: center;
            border-radius: 50%;
            background: #eaecf2;
            color: #505361;
            font-size: 10px;
        }

        .custom-flow-step:first-child b { background: var(--primary); color: #ffffff; }
        .custom-builder { padding-top: 4px; }

        .custom-step-block {
            padding: 14px 0;
            border-bottom: 1px solid #e2e3ec;
        }

        .custom-step-block:first-child { padding-top: 10px; }
        .custom-step-block:last-of-type { border-bottom: 0; }

        .custom-step-heading,
        .custom-settings-title {
            display: flex;
            align-items: flex-start;
            gap: 9px;
        }

        .custom-step-number {
            flex: 0 0 auto;
            width: 24px;
            height: 24px;
            display: grid;
            place-items: center;
            border-radius: 50%;
            background: var(--primary);
            color: #ffffff;
            font-size: 12px;
            font-weight: 900;
        }

        .custom-step-heading strong,
        .custom-settings-title strong {
            display: block;
            color: var(--text);
            font-size: 15px;
            line-height: 1.2;
        }

        .custom-step-heading small,
        .custom-settings-title small {
            display: block;
            margin-top: 3px;
            color: var(--muted);
            font-size: 11px;
            font-weight: 650;
            line-height: 1.35;
        }

        .custom-prompt-note {
            display: flex;
            gap: 8px;
            margin: 11px 0 9px;
            padding: 9px 10px;
            border-left: 3px solid var(--primary);
            background: #f6f7fa;
            color: #505362;
            font-size: 11px;
            line-height: 1.4;
        }

        .custom-prompt-note svg { flex: 0 0 auto; width: 17px; height: 17px; color: var(--primary); }
        #customPrompt.prompt-ready { border-color: #8c90a1; box-shadow: 0 0 0 3px rgba(45, 41, 130, 0.08); }
        #customPromptGuide.is-ready { color: var(--green); font-weight: 750; }

        .prompt-checklist {
            display: flex;
            flex-wrap: wrap;
            gap: 5px;
            margin-top: 8px;
        }

        .prompt-checklist span {
            padding: 4px 7px;
            border-radius: 999px;
            background: #eff0f4;
            color: #5f6274;
            font-size: 10px;
            font-weight: 750;
        }

        .prompt-examples-title {
            margin: 13px 0 7px;
            color: #3d3f4b;
            font-size: 11px;
            font-weight: 850;
        }

        .prompt-ideas { margin: 0; }

        .idea-chip {
            min-height: 64px;
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 9px;
            border-color: #cfd2e0;
            transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
        }

        .idea-chip:active { transform: scale(0.98); }

        .idea-chip > svg {
            flex: 0 0 auto;
            width: 19px;
            height: 19px;
            color: var(--primary);
        }

        .idea-chip span { min-width: 0; }
        .idea-chip strong,
        .idea-chip small { display: block; }
        .idea-chip strong { font-size: 11px; line-height: 1.2; }
        .idea-chip small { margin-top: 3px; color: var(--muted); font-size: 9px; font-weight: 650; line-height: 1.2; }

        .optional-badge {
            display: inline-flex;
            align-items: center;
            min-height: 19px;
            margin-left: 5px;
            padding: 0 6px;
            border-radius: 999px;
            background: #eff0f4;
            color: #676b7e;
            font-size: 9px;
            font-weight: 850;
            vertical-align: middle;
        }

        .custom-upload-zone {
            min-height: 82px;
            display: flex;
            place-items: unset;
            align-items: center;
            justify-content: flex-start;
            gap: 11px;
            margin-top: 11px;
            padding: 12px;
            text-align: left;
        }

        .custom-upload-zone > svg {
            flex: 0 0 auto;
            width: 27px;
            height: 27px;
            color: var(--primary);
        }

        .custom-upload-zone span { min-width: 0; }
        .custom-upload-zone strong { font-size: 13px; }
        .custom-upload-zone small { display: block; color: var(--muted); font-size: 10px; line-height: 1.3; }
        .custom-upload-zone.has-files { border-style: solid; border-color: #8a91b5; background: #f3f4f8; }
        .custom-upload-zone.has-files > svg { color: var(--green); }

        .custom-advanced-settings { margin: 14px 0 10px; background: #ffffff; }
        .custom-advanced-settings summary { min-height: 58px; padding: 9px 11px; }
        .custom-advanced-settings .custom-settings-title { align-items: center; text-align: left; }

        .custom-generation-summary { margin-top: 10px; background: #f5f5f8; }
        .custom-generation-summary > span:first-child { min-width: 0; }
        .custom-generation-summary .summary-title { display: block; color: var(--text); font-size: 13px; }
        .custom-generation-summary small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.25; }
        .custom-generation-summary .summary-cost { flex: 0 0 auto; text-align: right; }
        .custom-generation-summary .summary-cost strong { justify-content: flex-end; }

        @media (max-width: 350px) {
            .custom-flow-step { gap: 4px; padding-inline: 3px; font-size: 9px; }
            .custom-flow-step b { width: 17px; height: 17px; font-size: 9px; }
            .prompt-ideas { grid-template-columns: 1fr; }
            .idea-chip { min-height: 60px; padding: 7px; }
            .idea-chip strong { font-size: 12px; }
            .idea-chip small { font-size: 10px; }
            .custom-advanced-settings summary { min-height: 52px; }
            .custom-advanced-settings .custom-settings-title strong { font-size: 13px; white-space: nowrap; }
            .custom-advanced-settings .custom-settings-title small { display: none; }
            .custom-advanced-settings .segment { min-width: 0; padding: 0; overflow: hidden; }
        }

        /* Prompt workspace: one composition, with settings in reach. */
        #viewCustom { --custom-muted: #525564; padding: 4px 2px 0; }
        #viewCustom > .page-head { margin: 6px 0 18px; }
        #viewCustom > .page-head p { color: var(--custom-muted); }
        .custom-builder { display: grid; padding: 0; }
        .custom-composer, .custom-settings { min-width: 0; }
        #viewCustom .custom-label { display: block; margin: 0; color: var(--text); font-size: 15px; font-weight: 800; line-height: 1.4; }
        #viewCustom .custom-help { margin: 6px 0 0; color: var(--custom-muted); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
        #customPromptHint { margin-bottom: 10px; }
        #customPrompt { display: block; min-height: 160px; max-height: 420px; padding: 14px; background: #ffffff; color: var(--text); font-size: 16px; line-height: 1.6; caret-color: var(--primary); box-shadow: none; }
        #customPrompt::placeholder { color: #626678; }
        #customPrompt:focus { border-color: var(--primary); outline: 2px solid var(--primary); outline-offset: 2px; }
        #customPrompt[aria-invalid="true"] { border-color: #b42318; }
        #customPrompt::selection { background: #cac8ea; color: #16143b; }
        .custom-field-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 8px; color: var(--custom-muted); font-size: 11px; line-height: 1.5; }
        .custom-counter { flex-shrink: 0; font-variant-numeric: tabular-nums; }
        #viewCustom .prompt-examples { margin: 8px 0 0; padding: 0; border: 0; background: transparent; }
        #viewCustom .prompt-examples > summary { display: flex; align-items: center; gap: 7px; min-height: 44px; width: fit-content; padding: 6px 0; list-style: none; color: var(--primary-dark); font-size: 12px; font-weight: 700; cursor: pointer; }
        #viewCustom .prompt-examples > summary::-webkit-details-marker { display: none; }
        #viewCustom .prompt-examples > summary > svg:last-child { width: 15px; margin-left: 2px; }
        #viewCustom .prompt-examples[open] > summary > svg:last-child { transform: rotate(180deg); }
        #viewCustom svg { flex-shrink: 0; }
        #viewCustom .prompt-ideas { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin: 4px 0 12px; }
        #viewCustom .idea-chip { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 44px; padding: 8px 10px; border: 1px solid #c7cadb; border-radius: 6px; color: var(--text); background: #ffffff; font-size: 12px; font-weight: 700; text-align: left; transition: none; }
        #viewCustom .idea-chip.active { background: #e7e9f0; border-color: var(--primary); color: var(--primary-dark); }
        #viewCustom .idea-chip svg, #viewCustom .custom-small-button svg, #viewCustom .prompt-examples > summary > svg { width: 18px; height: 18px; }
        #viewCustom .custom-example-text { margin: 0 0 12px; color: #383a44; font-size: 13px; line-height: 1.6; }
        .custom-photos { margin-top: 18px; }
        .custom-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
        #viewCustom .custom-label-row .custom-help { margin: 0; }
        .custom-photo-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
        #viewCustom .custom-small-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 9px 10px; border: 1px solid #b6bbd1; border-radius: 6px; background: #ffffff; color: var(--primary-dark); font-size: 12px; font-weight: 750; }
        #customUploadZone { background: #e7e9f0; border-color: #9aa0be; }
        #viewCustom .custom-small-button:disabled { background: #ebecf2; color: #65697b; border-color: #cbcede; cursor: default; }
        #customPreviewRow { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 8px; overflow: visible; padding: 14px 0 2px; }
        #customPreviewRow:empty { display: none; }
        #customPreviewRow .preview { width: 100%; max-width: 96px; height: auto; aspect-ratio: 3/4; border-radius: 6px; overflow: visible; }
        #customPreviewRow img { border-radius: inherit; object-fit: contain; }
        #customPreviewRow .remove { top: -5px; right: -4px; width: 28px; height: 28px; display: grid; place-items: center; border: 2px solid var(--bg); border-radius: 50%; background: #2c2d35; }
        #customPreviewRow .remove svg { width: 14px; height: 14px; }
        .custom-photo-number { position: absolute; left: 4px; bottom: 4px; min-width: 20px; padding: 2px 4px; border-radius: 3px; background: #ffffff; color: #2c2d35; font-size: 11px; font-weight: 800; text-align: center; }
        #customPhotoCountHint { margin-top: 10px; }
        .custom-settings { padding-top: 20px; }
        #customModelControls { display: grid; grid-auto-columns: minmax(0,1fr); grid-auto-flow: column; gap: 6px; margin: 10px 0; }
        .custom-model-choice { display: grid; justify-items: center; align-content: center; gap: 5px; min-width: 0; padding: 9px 5px; }
        .custom-model-choice .credit-text { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; }
        .custom-model-choice .credit-icon { width: 13px; height: 13px; }
        #viewCustom .custom-model-caption { min-height: 66px; margin: 0 0 18px; color: var(--custom-muted); font-size: 12px; line-height: 1.5; }
        .custom-model-caption strong { display: block; margin-bottom: 3px; color: var(--text); font-size: 12px; }
        .custom-model-caption span { display: block; }
        #customAspectControls { margin: 0 0 16px; gap: 6px; }
        #customAspectControls .segment { display: grid; grid-template-rows: 30px 16px; align-content: center; gap: 5px; height: 66px; min-width: 0; padding: 6px 2px; background: #ffffff; border-color: #c7cadb; color: #383a44; font-size: 11px; box-shadow: none; }
        #customAspectControls .segment.active { background: #e7e9f0; border-color: var(--primary); color: var(--primary-dark); }
        #customAspectControls .ratio-shape { max-width: none; background: transparent; opacity: 1; border-radius: 2px; }
        #viewCustom .custom-file-option { align-items: center; gap: 10px; margin: 0; padding: 8px 0; border: 0; background: transparent; cursor: pointer; }
        .custom-file-option input { flex-shrink: 0; margin: 0; }
        .custom-file-option strong { font-size: 12px; }
        .custom-file-option small { display: block; margin-top: 2px; color: var(--custom-muted); font-size: 11px; }
        #customReadySummary { margin: 0 0 9px; }
        #customGenerateBtn { min-height: 50px; font-size: 15px; box-shadow: none; }
        #customGenerateBtn .credit-icon { background: transparent; color: inherit; }
        #viewCustom .custom-delivery { line-height: 1.5; text-align: center; }
        #customAccessHint { margin-top: 8px; font-size: 11px; text-align: center; }
        #viewCustom button:focus-visible, #viewCustom summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
        @media (hover: hover) {
            #viewCustom .custom-small-button:not(:disabled):hover, #viewCustom .idea-chip:hover, .custom-model-choice:hover, #customAspectControls .segment:hover { border-color: var(--primary); background: #eeeff4; }
            #customGenerateBtn:not(:disabled):hover { background: var(--primary-dark); }
        }
        @media (min-width: 760px) {
            .custom-builder { grid-template-columns: minmax(0,1.35fr) minmax(0,1fr); gap: 30px; align-items: start; }
            .custom-settings { padding: 0 0 0 28px; border-top: 0; border-left: 1px solid var(--line); }
            #customPrompt { min-height: 224px; }
        }

        /* Compact catalog, full category views, and accessible bottom sheets. */
        :root { --primary: #221f63; --primary-dark: #191748; --accent: #ed6480; --bg: #f4f5f8; }
        body { letter-spacing: 0; }
        .catalog-toolbar { display: flex; align-items: center; }
        .catalog-toolbar .search-wrap { flex: 1; width: auto; }
        .catalog-toolbar .quota-pill { flex: 0 0 auto; margin: 0; cursor: pointer; }
        .catalog-toolbar input { width: 100%; min-height: 42px; }
        .catalog-toolbar .compact-search { height: 44px; }
        .catalog-toolbar .quota-pill { border-color: #c0c4d7; }
        .catalog-toolbar .quota-pill .credit-icon { color: #1f1c59; }
        .credit-icon { display: inline-flex; align-items: center; vertical-align: middle; line-height: 1; }
        .topbar { box-shadow: none; padding-top: 8px; padding-bottom: 8px; }
        .category-nav { display: flex; margin-top: 8px; padding: 0; align-items: center; }
        .category-nav .chip { min-height: 42px; border-radius: 6px; background: transparent; border: 1px solid transparent; box-shadow: none; font-size: 12px; }
        .category-nav .chip.active { background: #e2e3ec; color: #191748; border-color: #c0c4d7; }
        .category-nav .category-picker { display: flex; gap: 5px; align-items: center; }
        .catalog-tools { display: flex; align-items: center; flex-wrap: wrap; }
        .catalog-tools select { max-width: 100%; font: inherit; }
        .selected-categories { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
        .selected-categories button { display: flex; gap: 6px; align-items: center; border-radius: 6px; padding: 6px 10px; background: #e2e3ec; font-size: 12px; }
        .category-heading h2 { letter-spacing: 0; }
        .template-item { position: relative; min-width: 0; }
        .template-item .template-card { width: 100%; height: 100%; text-align: left; }
        .template-item .template-media { height: auto; }
        .save-template { position: absolute; display: grid; place-items: center; }
        .save-template[aria-pressed="true"] { border-color: #221f63; }
        .save-template[aria-pressed="true"] svg { fill: currentColor; }
        .catalog-more { width: 100%; }
        .pin-icon { color: #585b6c; background: transparent; }
        [data-lucide], .lucide { width: 19px; height: 19px; flex: 0 0 auto; }
        .catalog-welcome { display: flex; gap: 12px; align-items: center; justify-content: space-between; border-bottom: 1px solid #dadce7; }
        .catalog-welcome strong { display: block; }
        .catalog-welcome p { margin: 4px 0 0; }
        .catalog-welcome button { width: 38px; height: 38px; background: transparent; }
        .catalog-toast { position: fixed; bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 16px); left: 50%; transform: translateX(-50%); z-index: 100; background: #1a183f; color: white; padding: 12px 18px; border-radius: 8px; width: max-content; max-width: calc(100% - 32px); font-size: 13px; box-shadow: var(--shadow); }
        dialog.catalog-dialog { padding: 0; color: var(--text); width: min(480px,100%); max-height: 85dvh; }
        dialog.catalog-dialog::backdrop { background: #10291f66; }
        dialog.catalog-dialog[open] { display:flex; flex-direction:column; overflow:hidden; }
        .catalog-dialog .sheet-head, .catalog-dialog .sheet-footer { flex-shrink:0; }
        .catalog-dialog .sheet-body { min-height:0; overflow-y:auto; overscroll-behavior:contain; }
        .sheet-head { display: flex; align-items: center; gap: 12px; padding: 20px; border-bottom: 1px solid #dcdbf0; }
        .sheet-head h2 { margin: 0; font-size: 20px; flex: 1; }
        .sheet-body { padding: 18px 20px; }
        .sheet-body p { font-size: 14px; line-height: 1.65; margin: 0 0 16px; color: #515463; }
        .category-options { overflow: visible; }
        .category-option { display: flex; width: 100%; align-items: center; gap: 12px; min-height: 49px; padding: 10px 4px; background: white; text-align: left; border-bottom: 1px solid #ebedf3; }
        .category-option span { flex: 1; overflow-wrap: anywhere; }
        .category-option small { color: #65697b; }
        .category-option.selected { color: #221f63; font-weight: 800; }
        .sheet-footer { padding: 16px 20px max(16px,env(safe-area-inset-bottom)); display: grid; gap: 10px; border-top: 1px solid #dcdbf0; }
        .subscription-links { display: grid; gap: 8px; margin-bottom: 14px; }
        .subscription-links a { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 12px; border: 1px solid #c0c4d7; border-radius: 6px; color: #1f1c59; text-decoration: none; font-weight: 700; }
        .editor-reactions { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
        .editor-reactions button { display: flex; align-items: center; gap: 7px; }
        .generation-next-actions { width:100%; margin-bottom:2px; }
        .generation-next-actions button { width:100%; justify-content:center; border:1px solid transparent; font-family:inherit; font-weight:700; line-height:1.25; text-align:center; cursor:pointer; }
        .generation-next-actions button svg { width:18px; height:18px; flex:0 0 auto; }
        .generation-next-actions .generation-next { background:#221f63; border-color:#221f63; color:#ffffff; box-shadow:0 5px 14px rgba(34, 31, 99, .18); }
        .generation-next-actions .generation-credits { background:#ffffff; border-color:#8990b4; color:#1e1b56; box-shadow:0 3px 10px rgba(26, 24, 60, .08); }
        .generation-next-actions button:active { transform:translateY(1px); box-shadow:none; }
        @media (max-width:430px) {
            .generation-next-actions { grid-template-columns:1fr; }
        }
        .bottom-nav { padding-top: 8px; padding-bottom: max(8px,env(safe-area-inset-bottom)); }
        @media (min-width: 700px) { .template-grid { grid-template-columns: repeat(4,minmax(0,1fr)); } }
        @media (max-width: 520px) { dialog.catalog-dialog { margin: auto 0 0; max-width: 100%; } }
        @media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
        .hidden { display: none !important; }
        .community-bar { display:flex; align-items:center; gap:10px; width:100%; padding:12px 0; margin-bottom:12px; border:0; border-bottom:1px solid #d8dae6; background:transparent; text-align:left; font-family:inherit; font-size:13px; font-weight:600; line-height:1.4; cursor:pointer; }
        .community-bar span { flex:1; } .community-bar svg { width:18px; height:18px; flex-shrink:0; }
        #communityDetails h3 { font-size:20px; line-height:1.3; margin:16px 0 8px; }
        #communityDetails p { margin:12px 0; } #communityDetails progress { width:100%; height:8px; accent-color:#221f63; }
        .share-preview { display:block; width:100%; max-height:220px; object-fit:contain; margin-bottom:16px; }
        .catalog-subscription { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:12px; align-items:center; margin:0 0 14px; color:#19173f; }
        .catalog-subscription strong { display:block; margin-bottom:3px; }
        .catalog-subscription p { margin:0; line-height:1.45; }
        .catalog-subscription-actions { display:flex; gap:7px; }
        .catalog-subscription-actions button { border:1px solid #25216a; font:inherit; font-size:12px; cursor:pointer; }
        @media (max-width:520px) { .catalog-subscription { grid-template-columns:1fr; padding:12px; } .catalog-subscription-actions { display:grid; grid-template-columns:1fr 1fr; } }
        .shared-prompt { white-space:pre-wrap; overflow-wrap:anywhere; font:inherit; font-size:13px; line-height:1.6; color:#545766; }
        #shareSheet details { padding:12px 0; border-block:1px solid #dfe1ea; } #shareSheet summary { cursor:pointer; font-weight:650; }
        #shareExplanation { font-size:13px; line-height:1.6; color:#545766; margin:16px 0; }
        .share-link { color:#221f63; font-weight:650; overflow-wrap:anywhere; } #shareSheet .button svg { width:18px; height:18px; vertical-align:middle; margin-right:8px; }
        #communityForm .button-row > div { min-width:0; flex:1; } #communityForm .field { width:100%; }
        .balance-overview { background:transparent; border:0; box-shadow:none; }
        .balance-overview .subscription-box { background:#edeef4; }
        .subscription-status a, #subscriptionText a { color:#221f63; text-underline-offset:3px; }
        .admin-tab { border-radius:6px; font-weight:650; }
        .admin-tab.active { background:#221f63; border-color:#221f63; }
        #viewAdmin .model-note { display:block; font-size:13px; line-height:1.6; margin:12px 0; color:#545766; }
        .catalog-filters { margin:0 0 10px; }
        @media (max-width: 699px) {
            #catalogTopbar { padding-top:6px; padding-bottom:6px; margin-bottom:6px; }
            .catalog-toolbar .search-wrap { margin:0; }
            .catalog-toolbar input { font-size:16px; }
            .catalog-toolbar .quota-pill { max-width:108px; overflow:hidden; }
            .catalog-toolbar .quota-pill strong,
            .catalog-toolbar .quota-pill .quota-total { min-width:0; overflow:hidden; text-overflow:ellipsis; }
            .catalog-filters { margin:0 0 6px; }
            .catalog-filters .chip { flex-shrink:0; padding:8px; }
            #catalogGuide { display:none; }
            .community-bar { padding:6px 0; margin:0 0 12px; font-size:12px; }
            .community-bar svg { width:16px; height:16px; }
            .category-heading h2 { font-size:17px; }
        }
        .activity-strip { display:flex; align-items:center; gap:10px; width:100%; margin:0 0 12px; padding:12px; border:1px solid var(--line); border-radius:8px; background:var(--surface); color:var(--text); font:inherit; font-size:13px; text-align:left; cursor:pointer; }
        .activity-strip span { flex:1; min-width:0; }
        .activity-strip svg { width:20px; height:20px; flex-shrink:0; }
        .draft-reminder { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px; padding:12px; font-size:13px; }
        .history-items { display:grid; gap:18px; }
        .history-item { min-width:0; border-bottom:1px solid var(--line); padding-bottom:18px; }
        .history-item img { display:block; width:100%; height:200px; object-fit:contain; background:var(--surface-soft); border-radius:8px; margin-bottom:10px; }
        .history-preview { min-height:200px; display:grid; align-items:center; margin-bottom:10px; background:var(--surface-soft); border-radius:8px; }
        .history-preview img { margin:0; }
        .history-preview [hidden] { display:none !important; }
        .history-preview button { justify-self:center; max-width:100%; padding:12px; border:1px solid var(--line); border-radius:8px; background:var(--surface); color:var(--text); font:inherit; cursor:pointer; }
        .balance-overview > .compact-note { margin:12px 0; }
        .prompt-examples { margin-top:16px; }
        .prompt-examples summary { padding:12px 0; color:var(--text); font-weight:600; cursor:pointer; }
        .history-item h3 { margin:0 0 5px; font-size:16px; overflow-wrap:anywhere; }
        .history-item p { font-size:12px; color:var(--muted); margin:5px 0 10px; }
        .history-actions { display:flex; flex-wrap:wrap; gap:8px; }
        .history-actions button { display:inline-flex; align-items:center; gap:6px; padding:8px 10px; font:inherit; font-size:12px; border:1px solid var(--line); border-radius:8px; background:var(--surface); color:var(--text); cursor:pointer; }
        .history-actions svg { width:16px; height:16px; }
        .personal-photo-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin:12px 0; }
        .personal-photo-grid img { display:block; width:100%; height:130px; object-fit:contain; background:var(--surface-soft); border-radius:6px; }
        .personal-photo-grid label { display:block; min-width:0; }
        .personal-photo-grid small { display:block; font-size:11px; }
        .personal-photo-grid > .compact-note { grid-column:1 / -1; margin:0; }
        .personal-photo-grid:empty { display:none; }
        .personal-photo-grid .photo-select { display:flex; gap:6px; align-items:center; min-height:36px; }
        .photo-storage-note { font-size:12px; color:var(--muted); margin:10px 0; }
        .photo-storage-note summary { cursor:pointer; padding:8px 0; }
        #savedPhotosPanel > button { margin-top:10px; }
        .source-picker { width:100%; min-height:44px; display:flex; align-items:center; justify-content:center; gap:8px; padding:10px 14px; margin-top:10px; border:1px solid var(--line); border-radius:8px; background:var(--surface); color:var(--text); font:inherit; font-size:13px; font-weight:600; cursor:pointer; }
        .source-picker svg { width:18px; height:18px; flex:0 0 18px; }
        .source-picker:hover { border-color:var(--primary); }
        .bottom-nav-inner .nav-btn { display:grid; grid-template-rows:20px 14px; align-content:center; justify-items:center; gap:4px; line-height:14px; letter-spacing:0; }
        .bottom-nav-inner .nav-btn svg, .bottom-nav-inner .nav-btn i { width:20px; height:20px; stroke-width:1.8; }
        .bottom-nav-inner .nav-btn span { white-space:nowrap; }
        .photo-library-tabs { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:4px; flex-shrink:0; padding:4px; }
        .photo-library-tabs button { min-height:40px; padding:8px; border:1px solid transparent; background:transparent; color:var(--muted); font:inherit; font-size:13px; font-weight:600; }
        .photo-library-tabs button[aria-selected="true"] { background:var(--surface); border-color:var(--line); color:var(--text); }
        .photo-library-tabs button:focus-visible, .source-picker:focus-visible { outline:2px solid var(--primary); outline-offset:2px; }
        #journeyTemplates .analytics-funnel-row { grid-template-columns:minmax(0,1fr); }
        #journeyTemplates .analytics-funnel-row span { font-size:12px; margin-top:6px; }
        #journeyTemplates b { overflow-wrap:anywhere; }
        #editResultPreview { display:block; width:100%; height:150px; object-fit:contain; margin:12px 0; }
        #viewCustom.editing-result > .page-head { display:none; }
        #viewCustom.editing-result .custom-prompt-note,
        #viewCustom.editing-result .custom-step-number,
        #viewCustom.editing-result .prompt-examples { display:none; }
        #sharePreview[hidden] { display:none; }
        #confirmDeleteImage { background:#b42318; color:#ffffff; }
        #historyMore { margin-top:16px; }
        #historySheet .model-note, #creditDraftNote { display:block; font-size:12px; }
        #creditSheet .sheet-footer { display:grid; gap:8px; }

        /* Shared studio language: photo, prompt, balance, help and admin. */
        :root { --text:#1b1c21; --muted:#525564; --line:#d2d5e2; --surface-soft:#ecedf3; --primary:#221f63; --primary-dark:#191748; --green:#221f63; --accent:#ad3e60; --shadow:none; --radius:8px; --nav-height:76px; }
        html { scroll-padding-top:68px; scroll-padding-bottom:90px; }
        #feedbackPanel { scroll-margin-top:72px; }
        select, summary { font:inherit; }
        ::selection { background:#cfcee9; color:#19173c; }
        :where(button,a,summary,input,textarea,select):focus-visible { outline:2px solid var(--primary); outline-offset:3px; }
        :where(input,textarea,select) { accent-color:var(--primary); caret-color:var(--primary); }
        .button, .button.secondary { line-height:1.4; }
        .button svg { width:18px; height:18px; flex-shrink:0; }
        .button .credit-icon { background:transparent; color:inherit; transform:none; }
        .button.secondary:disabled { background:#ebedf3; color:#65697c; border-color:var(--line); }
        .icon-button, .small-button, .source-picker { min-height:44px; }
        .icon-button { min-width:44px; border-radius:6px; box-shadow:none; }
        .credit-icon { transform:none; background:#e5e7ef; color:var(--primary-dark); }
        .page-head .section-title { color:var(--text); }
        .page-head p { max-width:65ch; line-height:1.5; }
        .section-title { letter-spacing:0; }
        #catalogTopbar { padding:6px 12px; margin-bottom:14px; background:var(--bg); border-bottom:1px solid var(--line); backdrop-filter:none; -webkit-backdrop-filter:none; }
        .catalog-toolbar { min-height:44px; gap:6px; }
        .catalog-toolbar .search-wrap { order:0; min-width:0; margin:0; background:#ffffff; border:1px solid var(--line); box-shadow:none; }
        .catalog-toolbar .search-wrap input { width:100%; min-width:0; height:42px; padding-inline:40px 6px; }
        .catalog-toolbar .quota-pill { order:2; min-height:44px; max-width:110px; min-width:50px; font-size:14px; box-shadow:none; }
        #workspaceModes { display:contents; }
        .workspace-mode { order:1; display:inline-flex; align-items:center; justify-content:center; gap:5px; flex-shrink:0; min-height:44px; padding:8px; border:1px solid #b0b5cd; border-radius:6px; background:#ffffff; color:var(--primary-dark); font-size:12px; font-weight:750; }
        .workspace-mode svg { width:18px; height:18px; }
        .workspace-mode.active { background:var(--primary); color:#ffffff; border-color:var(--primary); }
        .workspace-back { order:0; flex:1; min-width:0; min-height:44px; font-size:13px; }
        #workspaceHelp { order:3; flex-shrink:0; background:#ffffff; border:1px solid var(--line); }
        .auth-notice { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:12px; align-items:center; margin:0 0 18px; padding:14px; color:#26244b; }
        .auth-notice p { margin:4px 0 0; font-size:13px; line-height:1.5; }
        .auth-notice .button { font-size:13px; white-space:normal; }
        .bottom-nav { padding:8px; backdrop-filter:none; -webkit-backdrop-filter:none; }
        .bottom-nav-inner { width:min(600px,100%); min-height:52px; gap:2px; padding:3px; border-radius:8px; }
        .bottom-nav-inner .nav-btn { min-height:48px; padding:4px 1px; font-size:11px; }
        .bottom-nav-inner .nav-btn.active, .bottom-nav-inner .nav-btn[aria-expanded="true"] { box-shadow:none; }
        .catalog-subscription { border-color:#abb0c9; }
        .category-heading h2 { font-weight:800; }
        .category-count, .template-category, .category-pinned, .new-badge { font-size:11px; }
        .template-card { box-shadow:none; border:1px solid var(--line); background:var(--surface); }
        .template-title { font-size:14px; font-weight:750; }
        .template-description { color:var(--muted); line-height:1.5; }
        .catalog-tools .selected-categories { gap:6px; }
        #viewEditor > .photo-editor { padding:0; border:0; border-radius:0; background:transparent; box-shadow:none; }
        .photo-editor .editor-template-preview { min-height:0; padding:8px; margin:0; background:#e9eaf1; border:1px solid var(--line); border-radius:6px; }
        .photo-editor .editor-template-preview img { max-height:170px; width:100%; object-fit:contain; }
        .photo-editor .editor-workspace { align-items:center; gap:16px; margin:16px 0 10px; }
        .photo-editor .source-picker { min-width:0; margin:0; padding:9px 7px; border:1px solid #b0b5cd; color:var(--primary-dark); font-size:12px; background:#ffffff; }
        .photo-editor .source-picker svg { width:18px; height:18px; }
        #uploadZone { background:#e7e9f0; min-height:44px; }
        .photo-editor .step-title { margin:12px 0 9px; font-size:14px; color:var(--text); text-transform:none; }
        .editor-optional { margin-left:5px; }
        #previewRow, #customPreviewRow { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:8px; overflow:visible; padding:14px 0 4px; }
        #previewRow:empty, #customPreviewRow:empty { display:none; }
        #previewRow .preview { width:100%; max-width:96px; height:auto; aspect-ratio:3/4; border-radius:6px; overflow:visible; }
        #previewRow img { border-radius:inherit; object-fit:contain; }
        #previewRow .remove { top:-5px; right:-4px; width:28px; height:28px; display:grid; place-items:center; border:2px solid var(--bg); background:#2c2d35; }
        #previewRow .remove svg { width:14px; height:14px; }
        #photoCountHint { color:var(--muted); font-size:12px; margin:10px 0 16px; }
        #editorAdvancedSettings { margin:16px 0; border:0; border-top:1px solid var(--line); border-bottom:1px solid var(--line); border-radius:0; background:transparent; }
        #editorAdvancedSettings > summary { min-height:48px; padding:12px 0; gap:12px; }
        #editorAdvancedSettings .advanced-content { padding:0 0 12px; }
        #modelControls, #customModelControls { display:grid; grid-auto-columns:minmax(0,1fr); grid-auto-flow:column; gap:6px; margin:10px 0; }
        #modelControls .custom-model-choice, #customModelControls .custom-model-choice { min-height:66px; padding:8px 3px; font-size:12px; box-shadow:none; }
        .generation-model-caption { min-height:60px; margin:0 0 18px; line-height:1.5; }
        .generation-model-caption strong, .generation-model-caption span { display:block; }
        .generation-model-caption strong { margin-bottom:3px; }
        #aspectControls .segment { height:66px; grid-template-rows:30px 16px; align-content:center; gap:5px; min-width:0; padding:6px 2px; font-size:11px; color:#383a44; border-color:#c7cadb; box-shadow:none; }
        #aspectControls .segment.active { background:#e7e9f0; color:var(--primary-dark); border-color:var(--primary); }
        #aspectControls .ratio-shape { max-width:none; border-radius:2px; opacity:1; background:transparent; }
        .photo-editor .check-row { align-items:center; padding:10px 0; margin:0; border:0; background:transparent; }
        .photo-editor .check-row strong { font-size:12px; }
        .photo-editor .check-row small { display:block; color:var(--muted); font-size:11px; margin-top:3px; }
        .photo-editor #generateBtn { min-height:50px; font-size:15px; }
        .photo-editor #editorAccessHint { font-size:11px; text-align:center; }
        .generation-delivery { margin:12px 0 0; color:var(--primary-dark); font-size:12px; line-height:1.5; text-align:center; }
        .generation-next-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
        .generation-next-actions button { min-height:44px; box-shadow:none; }
        .generation-next { background:#ffffff; color:var(--primary-dark); border:1px solid #9ba1bf; }
        .generation-credits { background:#e4e5ed; color:var(--primary-dark); border:1px solid #9ba1bf; }
        #viewProfile > .surface { box-shadow:none; }
        #viewProfile > .profile-details { margin: 0; padding: 0 var(--pad-card); border: 0; border-radius: var(--radius-lg); background: var(--surface); }
        .balance-label { color:#e8eaf1; opacity:1; }
        .balance-total { font-weight:800; }
        .balance-breakdown { width:100%; margin-top:8px; opacity:1; }
        .balance-breakdown span { min-width:0; }
        .balance-breakdown small { display:block; font-weight:500; }
        .balance-breakdown b { display:block; margin-top:3px; font-weight:750; }
        .balance-breakdown b small { display:inline; font-size:11px; }
        .profile-quick-actions { margin-top:16px; }
        .profile-quick-action { min-height:90px; padding:10px 4px; }
        .profile-quick-action strong { font-size:12px; }
        .profile-quick-action small { font-size:11px; line-height:1.4; }
        .profile-quick-action.shop svg { color:#ffffff; }
        .profile-quick-action.shop small { color:#e8e9f0; }
        .profile-quick-action.referral svg { color:var(--accent); }
        .referral-progress { padding:14px; margin-top:16px; }
        .referral-progress-head span, .referral-progress-note { font-size:12px; line-height:1.5; }
        .package-card { border-color:var(--line); box-shadow:none; }
        .package-title { flex-wrap:wrap; }
        .package-price { color:var(--text); }
        .package-description.compact { margin-top:6px; color:var(--muted); font-size:12px; line-height:1.5; }
        .legal-text { color:var(--muted); font-size:12px; line-height:1.6; }
        .legal-text a, .share-link { text-underline-offset:3px; }
        .draft-reminder { border-left:0; border:1px solid #b0b5cd; border-radius:6px; background:#eff0f4; }
        .history-actions button { min-height:44px; border-color:#babed3; }
        .help-topics details { padding:14px 0; }
        .help-topics details:first-child { padding-top:0; }
        .help-topics summary { font-size:14px; cursor:pointer; }
        .help-topics details p { font-size:13px; line-height:1.65; }
        .history-empty p { line-height:1.6; }
        .catalog-dialog .sheet-body, .catalog-dialog .sheet-footer { padding:16px; }
        .admin-layout > .surface { padding:20px 0; border:0; border-top:1px solid var(--line); border-radius:0; box-shadow:none; background:transparent; }
        .admin-tabs { gap:6px; }
        .admin-tab { min-height:44px; font-size:12px; }
        .metric-label, .analytics-metric-label, .analytics-metric-note, .analytics-block-copy, .analytics-rank-head, .field-hint { font-size:11px; line-height:1.5; }
        #viewAdmin .metric::before { display:none; }
        #viewAdmin .metric { box-shadow:none; }
        @media (max-width:520px) {
            .auth-notice { grid-template-columns:1fr; }
            .auth-notice .button { justify-self:start; }
            .photo-editor .editor-workspace { grid-template-columns:minmax(0,.75fr) minmax(0,1.25fr); gap:12px; align-items:start; }
            .editor-photo-actions { grid-template-columns:1fr; }
            .photo-editor .editor-template-preview img { height:158px; }
            .photo-editor .compact-note { font-size:12px; line-height:1.5; }
            .catalog-toolbar .search-wrap input { font-size:16px; }
            .photo-editor .source-picker { font-size:12px; gap:5px; }
        }
        @media (hover:hover) {
            .button:not(:disabled):not(.secondary):hover { background:var(--primary-dark); }
            .button.secondary:not(:disabled):hover, .workspace-mode:not(.active):hover { border-color:var(--primary); background:#edeef4; }
            .template-card:hover { border-color:#959bbb; box-shadow:none; transform:none; }
        }
        #viewAdmin.active { display:grid; grid-template-columns:166px minmax(0,1fr); gap:20px 26px; align-items:start; }
        #viewAdmin > .page-head { grid-column:1/-1; margin:0; }
        #viewAdmin .admin-tabs { display:grid; gap:4px; position:sticky; top:78px; padding:0; margin:0; overflow:visible; }
        #viewAdmin .admin-tab { display:flex; align-items:center; justify-content:flex-start; gap:10px; width:100%; min-height:46px; padding:11px 12px; border:0; background:transparent; color:var(--muted); text-align:left; font-weight:700; font-size:13px; }
        #viewAdmin .admin-tab svg { width:18px; height:18px; flex-shrink:0; }
        #viewAdmin .admin-tab.active { background:#dee0ea; color:#1b184d; }
        #viewAdmin .admin-tab:hover { background:#e6e7ef; color:var(--text); }
        #viewAdmin .admin-layout { min-width:0; margin:0; }
        #viewAdmin [data-admin-panel] { padding:0; border:0; box-shadow:none; border-radius:0; background:transparent; min-width:0; }
        #viewAdmin .admin-layout > [data-admin-panel="templates"] { padding-bottom:24px; margin-bottom:24px; border-bottom:1px solid var(--line); }
        .admin-mobile-nav, .analytics-mobile-nav { display:none; }
        .analytics-head { gap:16px; padding-bottom:16px; }
        .analytics-head .section-title { margin:0; font-size:22px; }
        .analytics-period-label { max-width:100%; font-size:12px; line-height:1.6; }
        .analytics-period { min-width:46px; min-height:40px; font-size:12px; }
        .analytics-refresh { width:46px; height:46px; }
        .analytics-refresh svg { width:18px; height:18px; }
        .analytics-subnav { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:4px; padding:0 0 16px; border-bottom:1px solid var(--line); }
        .analytics-subnav button { min-width:0; min-height:44px; padding:8px 6px; border:0; border-radius:6px; color:var(--muted); background:transparent; font:inherit; font-size:12px; font-weight:700; cursor:pointer; }
        .analytics-subnav button[aria-pressed="true"] { color:#ffffff; background:var(--primary); }
        .analytics-subnav button:not([aria-pressed="true"]):hover { background:#e6e7ef; }
        [data-admin-panel="analytics"] [data-analytics-panel] { display:none; }
        [data-analytics-active="overview"] [data-analytics-panel="overview"],
        [data-analytics-active="income"] [data-analytics-panel="income"],
        [data-analytics-active="audience"] [data-analytics-panel="audience"],
        [data-analytics-active="content"] [data-analytics-panel="content"],
        [data-analytics-active="service"] [data-analytics-panel="service"],
        [data-analytics-active="report"] [data-analytics-panel="report"] { display:block; }
        [data-analytics-active="overview"] #analyticsMetrics,
        [data-analytics-active="income"] #analyticsIncomeMetrics,
        [data-analytics-active="audience"] #analyticsAudienceMetrics { display:grid; }
        #analyticsData[hidden] { display:none !important; }
        .analytics-separated { display:contents; }
        #viewAdmin .analytics-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin-top:20px; }
        #viewAdmin .analytics-metric { padding:16px; background:#ffffff; border-color:#d2d5e2; }
        #viewAdmin .analytics-metric-label { text-transform:none; color:#525564; font-size:12px; }
        #viewAdmin .analytics-metric-value { font-size:25px; font-variant-numeric:tabular-nums; line-height:1.15; }
        #viewAdmin .analytics-metric-note { font-size:12px; line-height:1.5; margin-top:8px; }
        #viewAdmin .analytics-block { padding-top:22px; margin-top:22px; }
        #viewAdmin .analytics-block-title { font-size:16px; line-height:1.4; }
        #viewAdmin .analytics-block-copy { font-size:13px; line-height:1.6; margin-top:8px; }
        #viewAdmin .analytics-insight { display:block; padding:14px 16px; font-size:13px; line-height:1.6; background:#eaebf1; border:0; }
        #viewAdmin .analytics-insight::before { display:none; }
        #viewAdmin .analytics-insight.warn { background:#ededfa; color:#1e1a69; }
        #viewAdmin .analytics-rank-head { flex-wrap:wrap; gap:4px 16px; font-size:13px; line-height:1.5; }
        #viewAdmin .analytics-rank-name { white-space:normal; overflow-wrap:anywhere; }
        #viewAdmin .analytics-rank-value { flex:0 1 auto; }
        #viewAdmin .analytics-list { gap:14px; margin-top:14px; }
        #viewAdmin .analytics-track { height:5px; margin-top:8px; }
        #viewAdmin .analytics-day-label { font-size:11px; }
        #viewAdmin .analytics-chart { padding-inline:20px; }
        #viewAdmin .analytics-chart-wrap { max-width:100%; }
        #viewAdmin .analytics-funnel-row { padding:14px 16px; font-size:13px; line-height:1.5; background:#ffffff; }
        #viewAdmin .analytics-funnel-row span { font-size:12px; }
        #viewAdmin .analytics-table { font-size:13px; }
        #viewAdmin .analytics-table th { font-size:12px; }
        #viewAdmin .analytics-table td, #viewAdmin .analytics-table th { padding:12px 14px; }
        #viewAdmin .analytics-table caption { padding:14px; font-size:12px; line-height:1.6; }
        #viewAdmin .analytics-user-link { min-height:44px; }
        #viewAdmin .analytics-error { padding:16px; border:1px solid #edc7c8; border-radius:8px; background:#fff4f3; }
        #viewAdmin .analytics-error strong, #viewAdmin .analytics-error span { font-size:12px; line-height:1.6; }
        #viewAdmin .analytics-block select { min-height:44px; margin-top:8px; font-size:13px; }
        .analytics-spaced { margin-top:24px !important; }
        .analytics-overview-note { margin:16px 0 0; color:var(--muted); font-size:12px; line-height:1.6; }
        #viewAdmin .analytics-subnav, #viewAdmin .analytics-mobile-nav { border-bottom:0; }
        .analytics-report-actions { display:flex; flex-wrap:wrap; gap:10px; margin-top:20px; }
        .analytics-report-actions .button { width:auto; min-width:144px; }
        .analytics-report-text { min-height:260px; max-height:60dvh; resize:vertical; font-family:ui-monospace,SFMono-Regular,Consolas,monospace; font-size:12px; line-height:1.6; }
        #analyticsFeedbackBtn { width:auto; margin-top:16px; }
        .analytics-tool-link { width:auto; margin-top:16px; }
        @media (min-width:1120px) { #viewAdmin .analytics-metrics { grid-template-columns:repeat(4,minmax(0,1fr)); } }
        @media (max-width:879px) {
            #viewAdmin.active { display:block; }
            #viewAdmin .admin-tabs, .analytics-subnav { display:none; }
            .admin-mobile-nav, .analytics-mobile-nav { display:grid; gap:8px; color:var(--muted); font-size:12px; font-weight:700; }
            .admin-mobile-nav { padding:18px 0; margin-bottom:6px; }
            .analytics-mobile-nav { padding-bottom:18px; border-bottom:1px solid var(--line); }
            .admin-mobile-nav .field, .analytics-mobile-nav .field { margin:0; min-height:46px; font-size:16px; background:#ffffff; color:var(--text); }
            #viewAdmin .analytics-head { display:block; }
            #viewAdmin .analytics-head .section-title { display:none; }
            .analytics-controls { margin-top:14px; justify-content:space-between; }
            .analytics-periods { flex:1; }
            .analytics-period { flex:1; }
            #viewAdmin .analytics-metric { padding:12px; }
            #viewAdmin .analytics-metric-value { font-size:23px; }
            #viewAdmin .analytics-funnel-row { gap:8px; padding:12px; }
            #journeyTemplates .analytics-funnel-row { grid-template-columns:1fr; }
            .analytics-report-actions .button { flex:1; min-width:0; font-size:13px; padding-inline:10px; }
        }

        /* ==========================================================================
           «Электрик» — дизайн-система (docs/DESIGN.md).
           Этот слой идёт последним и задаёт итоговые токены и компоненты.
           ========================================================================== */
        :root {
            --bg: #f3f4f8;
            --surface: #ffffff;
            --surface-soft: #eceef4;
            --surface-blush: #e8ebff;
            --text: #15161c;
            --muted: #6b6f7d;
            --line: #e3e5ec;
            --line-strong: #cfd3de;
            --primary: #4338ca;
            --primary-2: #0369a1;
            --primary-dark: #3730a3;
            --primary-soft: #e8ebff;
            --brand: linear-gradient(100deg, var(--primary), var(--primary-2));
            --brand-hover: linear-gradient(100deg, #3730a3, #075985);
            --glow: rgba(67, 56, 202, 0.28);
            --accent: #4338ca;
            --gold: #b7791f;
            --green: #15803d;
            --green-soft: #e7f6ec;
            --red: #b42318;
            --red-soft: #fdecea;
            --amber: #92400e;
            --amber-soft: #fef3e2;
            --font-ui: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
            --font-display: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
            --fs-display: 40px;
            --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
            --space-5: 20px; --space-6: 24px; --space-8: 32px;
            /* Шкала отступов по смыслу (docs/DESIGN.md → «Отступы») */
            --pad-page: 16px;      /* поля экрана */
            --pad-card: 16px;      /* внутри карточки */
            --gap-section: 32px;   /* между крупными разделами (категории каталога) */
            --gap-block: 16px;     /* между блоками и карточками экрана */
            --gap-stack: 12px;     /* между элементами внутри карточки, в списках */
            --gap-title: 8px;      /* заголовок → его подпись или содержимое */
            --gap-tight: 4px;      /* подпись к полю, строки одной группы */
            --control-h: 48px;     /* высота полей и вторичных кнопок */
            --icon-btn: 44px;      /* кнопки-иконки в шапке */
            --radius-sm: 12px;
            --radius: 16px;
            --radius-lg: 20px;
            --radius-pill: 999px;
            --shadow: 0 6px 20px rgba(21, 22, 28, 0.06);
            --shadow-lift: 0 14px 34px rgba(21, 22, 28, 0.12);
            --nav-height: 78px;
        }

        html, body { background: var(--bg); }
        body { color: var(--text); font-family: var(--font-ui); font-size: 15px; line-height: 1.5; }
        :focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
        button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

        /* Типографика */
        .section-title, .page-head .section-title, .catalog-dialog .sheet-head h2, .sheet-head h2,
        .category-heading h2, .catalog-tools h2, .catalog-welcome strong, .balance-total {
            font-family: var(--font-display);
            font-weight: 600;
            letter-spacing: 0;
            color: var(--text);
        }
        .page-head .section-title { font-size: 26px; line-height: 1.15; font-weight: 600; margin-bottom: 6px; }
        .page-head p { font-size: 14px; color: var(--muted); }
        .compact-note, .custom-help, .model-note { color: var(--muted); font-size: 13px; line-height: 1.45; }

        /* Шапка */
        .topbar {
            background: rgba(245, 245, 248, 0.92);
            border-bottom: 1px solid transparent;
        }
        .topbar.in-workspace { border-bottom-color: var(--line); }
        .catalog-toolbar .search-wrap, .catalog-toolbar .compact-search { height: 44px; border: 1px solid var(--line); background: var(--surface); }
        .catalog-toolbar .search-wrap input, .catalog-toolbar .compact-search input { height: 42px; border: 0; border-radius: var(--radius-pill); background: transparent; box-shadow: none; }
        .catalog-toolbar .compact-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(66, 61, 164, 0.12); }
        .quota-pill {
            min-height: 44px; padding: 0 14px; border-radius: var(--radius-pill);
            border: 1px solid var(--line); background: var(--surface); color: var(--text);
            font-size: 14px; font-weight: 700; box-shadow: none;
        }
        .quota-pill .credit-icon { background: transparent; }

        /* Кнопки */
        .button, .button.secondary {
            min-height: 52px; border-radius: var(--radius); font-family: var(--font-ui);
            font-size: 16px; font-weight: 700; letter-spacing: 0; box-shadow: none;
        }
        .button { color: #ffffff; }
        .button.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); font-size: 15px; }
        .button:disabled { color: var(--muted); }
        .button[aria-busy="true"] { cursor: progress; }
        .catalog-more {
            min-height: 48px;
            border: 1px solid var(--line-strong);
            background: var(--surface);
            font-size: 14px;
            font-weight: 700;
        }
        @media (hover: hover) {
            .button.secondary:not(:disabled):hover, .catalog-more:hover { border-color: var(--primary); background: var(--surface); }
        }

        /* Чипы категорий */
        .category-nav { gap: 8px; }
        .category-nav .chip, .category-nav .category-picker {
            min-height: 40px;
            padding: 8px 16px;
            border: 1px solid transparent;
            font-size: 14px;
            font-weight: 600;
            flex-shrink: 0;
        }
        .community-bar { color: var(--muted); border-bottom-color: var(--line); }
        .catalog-welcome { padding: 0; margin: 4px 0 var(--space-6); }
        .catalog-welcome strong { font-size: 24px; line-height: 1.2; }
        .catalog-welcome p { font-size: 14px; color: var(--muted); }
        .catalog-subscription {
            border-radius: var(--radius-lg); border: 0; background: var(--surface-blush); padding: var(--space-4);
            margin-bottom: var(--space-5);
        }
        .catalog-subscription strong { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
        .catalog-subscription p { color: var(--muted); font-size: 13px; }
        .catalog-subscription-actions button { min-height: 44px; border-radius: var(--radius-pill); padding: 8px 16px; font-weight: 700; }
        .catalog-subscribe { background: var(--primary); color: #ffffff; border-color: var(--primary); }
        .catalog-check { background: var(--surface); color: var(--primary-dark); border-color: var(--line-strong); }

        /* Каталог */
        .catalog-sections { display: grid; }
        .category-section { display: grid; }
        .category-heading { display: flex; align-items: baseline; justify-content: space-between; margin: 0; padding: 0; }
        .category-heading h2 { line-height: 1.2; margin: 0; }
        .category-heading h2::before { display: none; }
        .category-count { background: transparent; color: var(--muted); font-family: var(--font-ui); font-size: 13px; font-weight: 600; }
        .template-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .catalog-sections.is-overview .template-grid {
            grid-template-columns: none;
            grid-auto-flow: column;
            gap: var(--space-3);
            overflow-x: auto;
            scroll-snap-type: x mandatory;
            scrollbar-width: none;
            margin: 0 calc(-1 * var(--space-4)) -18px;
            padding: 0 var(--space-4) 22px;
            scroll-padding: 0 var(--space-4);
        }
        .catalog-sections.is-overview .template-grid::-webkit-scrollbar { display: none; }
        .catalog-sections.is-overview .template-item { scroll-snap-align: start; }
        .template-item .template-card {
            position: relative;
            display: block;
            border: 0;
            background: var(--surface-soft);
            overflow: hidden;
            transition: transform .2s ease, box-shadow .2s ease;
        }
        .template-item .template-media { aspect-ratio: 3 / 4; border-radius: 0; padding: 0; background: var(--surface-soft) !important; }
        .template-item .template-media img { width: 100%; height: 100%; opacity: 1; object-fit: cover; object-position: center 30%; }
        .template-item .template-meta {
            position: absolute;
            inset: auto 0 0 0;
            min-height: 0;
            border: 0;
        }
        .template-item .template-title { color: #ffffff; line-height: 1.3; text-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
        .template-item .template-description { margin-top: 2px; color: rgba(255, 255, 255, .86); font-size: 12px; -webkit-line-clamp: 1; }
        .save-template {
            right: 10px; top: 10px; width: 40px; height: 40px; border-radius: var(--radius-pill);
            border: 0; background: rgba(255, 255, 255, .9); color: var(--text); box-shadow: 0 2px 8px rgba(35, 36, 43, .12);
        }
        .save-template svg { width: 18px; height: 18px; }
        .save-template[aria-pressed="true"] { color: #ffffff; }
        .new-badge {
            left: 10px;
            top: 10px;
            padding: 4px 10px;
            font-size: 11px;
            font-weight: 700;
            letter-spacing: .02em;
        }
        .category-section > .catalog-more { min-height: 44px; border: 0; background: transparent; justify-content: flex-start; padding: 0; text-align: left; width: auto; justify-self: start; }
        .category-section > .catalog-more::after { content: " →"; }
        @media (hover: hover) {
            .template-item .template-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
        }
        @media (min-width: 720px) {
            .template-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-6) var(--space-4); }
            .catalog-sections.is-overview .template-grid { gap: var(--space-4); margin: 0 0 -18px; padding: 0 0 22px; }
        }
        @media (min-width: 1000px) {
            .template-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
        }

        /* Загрузка и пустые состояния */
        .skeleton-card, .skeleton-line {
            animation: skeleton 1.4s ease-in-out infinite;
        }
        .skeleton-card { aspect-ratio: 3 / 4; border-radius: var(--radius-lg); }
        .skeleton-line { display: block; width: 140px; height: 22px; border-radius: 8px; }
        .catalog-sections:not(.is-overview) .skeleton-section .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        @keyframes skeleton { from { background-position: 100% 0; } to { background-position: -100% 0; } }
        .empty {
            display: grid; justify-items: center; gap: var(--space-3); padding: var(--space-8) var(--space-4);
            border: 0; border-radius: var(--radius-lg); background: var(--surface); color: var(--muted);
            font-size: 14px; line-height: 1.5; text-align: center;
        }
        .empty.hidden { display: none; }
        .empty p { margin: 0; max-width: 34ch; }
        .empty .catalog-more { width: auto; padding: 0 20px; }
        .empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--surface-blush); color: var(--primary); }
        .empty-icon svg { width: 24px; height: 24px; }
        .empty.error .empty-icon { background: var(--red-soft); color: var(--red); }

        /* Статусы */
        .status { border-radius: var(--radius); padding: 12px 14px; font-size: 14px; line-height: 1.5; border: 0; }
        .status.ok { background: var(--green-soft); color: #2c5a3e; }
        .status.error { background: var(--red-soft); color: #8c1d16; }
        .status.warn { background: var(--amber-soft); color: #6e4510; }

        /* Экран шаблона */
        .editor-layout { display: grid; }
        .editor-template-preview { margin: 0; padding: 0; border: 0; background: transparent; }
        .editor-template-preview img {
            width: 100%;
            max-height: 46vh;
            aspect-ratio: 3 / 4;
            object-fit: cover;
            object-position: center 30%;
            background: var(--surface-soft);
        }
        .editor-panel { display: grid; min-width: 0; }
        .editor-intro { display: grid; }
        .editor-kicker { font-weight: 700; }
        .editor-intro .section-title { font-size: 26px; line-height: 1.15; margin: 0; }
        .editor-intro .template-description { color: var(--muted); font-size: 15px; margin: 0; }
        .editor-intro .editor-reactions { margin-top: 6px; }
        .editor-reactions button { min-height: 40px; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--surface); padding: 0 14px; font-size: 13px; font-weight: 600; }
        .editor-reactions button[aria-pressed="true"] { background: var(--primary-soft); border-color: transparent; color: var(--primary-dark); }
        .editor-step {
            display: grid; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-lg);
            background: var(--surface); box-shadow: var(--shadow);
        }
        .step-title { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; color: var(--text); }
        .step-number {
            display: inline-grid;
            place-items: center;
            width: 26px;
            height: 26px;
            flex: 0 0 26px;
            border-radius: 50%;
            font-size: 13px;
            font-weight: 700;
        }
        .editor-optional { color: var(--muted); font-size: 13px; font-weight: 500; }
        .editor-photo-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
        .source-picker, .custom-small-button {
            min-height: 48px; border-radius: var(--radius); border: 1px solid var(--line-strong);
            background: var(--surface); color: var(--text); font-size: 14px; font-weight: 700;
        }
        .source-picker.primary-picker { border-color: transparent; }
        .photo-count { color: var(--muted); font-size: 13px; }
        .preview-row:empty { display: none; }
        .preview img { border-radius: var(--radius-sm); }
        .advanced-settings { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 0; }
        .advanced-settings summary {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            font-size: 14px;
            font-weight: 700;
            color: var(--text);
            cursor: pointer;
        }
        .advanced-settings summary > span:first-child { display: inline-flex; align-items: center; gap: 8px; }
        .advanced-settings summary svg { width: 18px; height: 18px; color: var(--muted); }
        .advanced-settings .settings-current { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 600; }
        .advanced-settings summary::after { color: var(--muted); }
        .advanced-content { display: grid; }
        .advanced-content .step-title { font-size: 14px; }
        .custom-model-choice {
            min-height: 64px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
            color: var(--text); font-size: 13px; font-weight: 700;
        }
        .custom-model-choice.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); box-shadow: inset 0 0 0 1px var(--primary); }
        .segment { border-radius: var(--radius-sm); border-color: var(--line); background: var(--surface); }
        .segment.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }
        .generation-model-caption { color: var(--muted); font-size: 13px; }
        .generation-model-caption strong { color: var(--text); margin-right: 6px; }
        .launch-summary { text-align: center; }
        .launch-summary:empty { display: none; }
        .generation-delivery, .custom-delivery { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }
        .check-row { border-radius: var(--radius); }
        @media (min-width: 900px) {
            .editor-layout { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--space-8); align-items: start; padding-top: var(--space-4); }
            .editor-template-preview img { max-height: calc(100vh - 180px); }
        }

        /* Своя идея */
        .custom-composer, .custom-settings {
            padding: var(--space-4); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow);
        }
        .custom-settings { border-top: 0; display: grid; gap: var(--space-3); align-content: start; }
        .custom-label { font-size: 16px; font-weight: 700; }
        .textarea, .field { border-radius: var(--radius); border-color: var(--line-strong); background: var(--surface); font-size: 15px; }
        .textarea:focus, .field:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(66, 61, 164, 0.12); }
        .field::placeholder, .textarea::placeholder { color: #828598; }
        .idea-chip { border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--surface-soft); }
        .idea-chip.active { background: var(--primary-soft); border-color: transparent; color: var(--primary-dark); }
        .custom-launch { display: grid; margin-top: 0; padding-top: 0; border-top: 0; }
        #viewCustom .custom-delivery { margin: 0; color: var(--muted); font-size: 13px; font-weight: 500; }
        #customReadySummary { text-align: center; }

        /* Баланс */
        .balance-hero {
            display: grid;
            gap: var(--space-3);
            border-radius: var(--radius-lg);
            color: #ffffff;
        }
        .balance-hero .balance-label { color: rgba(255, 255, 255, .82); font-size: 13px; font-weight: 600; }
        .balance-total { color: #ffffff; font-size: var(--fs-display); line-height: 1; }
        .balance-total .credit-icon { background: rgba(255, 255, 255, .16); }
        .balance-breakdown { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); border-top: 1px solid rgba(255, 255, 255, .2); padding-top: var(--space-3); color: #ffffff; }
        .balance-breakdown small { color: rgba(255, 255, 255, .8); font-size: 11px; line-height: 1.3; }
        .balance-breakdown b { color: #ffffff; font-size: 18px; }
        .balance-overview > .balance-rules { margin: var(--space-3) 0; }
        .status-line { border-radius: var(--radius); border-color: var(--line); background: var(--surface); font-size: 13px; }
        .profile-quick-action { border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: none; }
        .profile-quick-action.shop { background: var(--primary); border-color: var(--primary); color: #ffffff; }
        .referral-progress { border-radius: var(--radius); }
        .profile-details > summary strong { font-family: var(--font-display); font-size: 19px; font-weight: 600; }
        .shop-grid { display: grid; }
        .package-card {
            display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
            padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface);
        }
        .package-card.featured { border-color: var(--line-strong); }
        .package-main { display: grid; gap: 4px; min-width: 0; }
        .package-title { display: flex; align-items: baseline; gap: 6px; margin: 0; font-size: 24px; font-weight: 800; line-height: 1.1; }
        .package-unit { font-size: 14px; font-weight: 600; color: var(--muted); }
        .package-badge { justify-self: start; padding: 3px 10px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 700; }
        .package-description { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
        .package-side { display: grid; justify-items: end; gap: 4px; flex-shrink: 0; text-align: right; }
        .package-price { font-size: 20px; font-weight: 800; white-space: nowrap; }
        .package-old-price { color: var(--muted); font-size: 13px; font-weight: 500; text-decoration: line-through; margin-left: 4px; }
        .package-rate { color: var(--muted); font-size: 11px; }
        .package-buy {
            display: inline-flex; align-items: center; justify-content: center; min-width: 96px; min-height: 44px; margin-top: 4px;
            border-radius: var(--radius-pill); background: var(--primary); color: #ffffff; font-weight: 700; text-decoration: none; border: 0;
        }
        .package-buy:disabled { background: var(--surface-soft); color: var(--muted); cursor: not-allowed; }

        /* Нижняя навигация */
        .bottom-nav { border-top: 1px solid var(--line); }
        .bottom-nav-inner { border: 0; background: transparent; box-shadow: none; }
        .bottom-nav-inner .nav-btn { border-radius: var(--radius); color: var(--muted); font-weight: 600; }
        .bottom-nav-inner .nav-btn svg { color: currentColor !important; }

        /* Листы */
        dialog.catalog-dialog { border-radius: var(--radius-lg); border: 0; box-shadow: var(--shadow-lift); background: var(--surface); }
        .catalog-dialog::backdrop { background: rgba(35, 36, 43, .42); }
        .catalog-dialog .sheet-head { border-bottom-color: var(--line); }
        .catalog-dialog .sheet-head h2 { font-size: 21px; }
        .help-topics details { border-bottom: 1px solid var(--line); }
        .help-topics summary { font-weight: 700; }
        .photo-library-tabs { border-radius: var(--radius-pill); background: var(--surface-soft); }
        .photo-library-tabs button { border-radius: var(--radius-pill); }
        @media (max-width: 520px) { dialog.catalog-dialog { border-radius: var(--radius-lg) var(--radius-lg) 0 0; } }

        /* Админка: общий стиль */
        #viewAdmin .surface, #viewAdmin .analytics-block, #viewAdmin .metric { border-radius: var(--radius); }
        .admin-tab.active, .analytics-subnav [aria-pressed="true"] { background: var(--primary-soft); color: var(--primary-dark); }
        .auth-notice { border-radius: var(--radius-lg); background: var(--surface-blush); border: 0; }

        @media (prefers-reduced-motion: reduce) {
            .skeleton-card, .skeleton-line { animation: none; }
        }
        .history-empty { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-6) var(--space-2); text-align: center; }
        .history-empty > svg { width: 56px; height: 56px; padding: 16px; border-radius: 50%; background: var(--surface-blush); color: var(--primary); }
        .history-empty strong { font-family: var(--font-display); font-size: 19px; font-weight: 600; }
        .history-empty p { margin: 0 0 var(--space-2); color: var(--muted); font-size: 14px; max-width: 32ch; }
        .generation-model-caption, .custom-model-caption { margin: 0; color: var(--muted); font-size: 13px; }
        .generation-model-caption strong, .custom-model-caption strong { display: none; }

        /* Навигация и мелочи после проверки удобства */
        .catalog-tools h2 { font-size: 22px; }
        .catalog-tools select {
            min-height: 40px; padding: 0 32px 0 14px; border-radius: var(--radius-pill); border: 1px solid var(--line);
            background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2376675f' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
            appearance: none; -webkit-appearance: none; font-size: 13px; font-weight: 600; color: var(--text);
        }
        .catalog-tools .icon-button { width: 44px; height: 44px; border: 1px solid var(--line); background: var(--surface); }
        .category-nav .chip { padding: 8px 14px; }
        #customPrompt[aria-invalid="true"] ~ .custom-field-meta #customPromptGuide { color: var(--red); font-weight: 600; }
        .help-topics summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; }
        .help-topics summary::-webkit-details-marker { display: none; }
        .help-topics summary::after { content: "+"; color: var(--muted); font-size: 20px; font-weight: 400; }
        .help-topics details[open] summary::after { content: "−"; }
        .shop-more > summary, #shopLegal summary { list-style: none; cursor: pointer; color: var(--primary-dark); font-weight: 700; display: flex; align-items: center; }
        .shop-more > summary::-webkit-details-marker, #shopLegal summary::-webkit-details-marker { display: none; }
        .shop-more > summary::after, #shopLegal summary::after { content: " +"; margin-left: 6px; color: var(--muted); }
        .launch-summary { margin: 0; }
        #statusMessage:not(.show) , #customStatusMessage:not(.show) { display: none; }
        @media (max-width: 520px) {
            /* «Мои фото» — раздел нижнего меню, поэтому на телефоне открывается на весь экран, как остальные разделы. */
            dialog.catalog-dialog.photo-library { height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
        }
        .history-items h3 { font-family: var(--font-display); font-size: 18px; font-weight: 600; margin: 0 0 4px; }
        .history-state { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.45; }
        .history-state.done { color: var(--green); }
        .history-state.failed { color: var(--red); }
        .history-state.pending { color: var(--amber); }
        .history-meta { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
        @media (max-width: 520px) {
            dialog.catalog-dialog.photo-library .sheet-body { flex: 1; }
        }
        .catalog-toolbar .quota-pill { margin-left: auto; }
        @media (max-width: 420px) {
            .category-nav { gap: 6px; }
            .category-nav .chip, .category-nav .category-picker { padding: 8px 10px; font-size: 13px; gap: 5px; }
            .category-nav .category-picker svg { width: 16px; height: 16px; }
        }

        /* ==========================================================================
           «Электрик»: компоненты в духе фоторедакторов (макет docs/mockups/c.html).
           ========================================================================== */
        .section-title, .page-head .section-title, .catalog-dialog .sheet-head h2, .sheet-head h2,
        .category-heading h2, .catalog-tools h2, .catalog-welcome strong, .balance-total,
        .editor-intro .section-title, .history-items h3, .history-empty strong,
        .profile-details > summary strong, .catalog-subscription strong {
            font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em;
        }
        .page-head .section-title, .editor-intro .section-title { font-size: 26px; }
        .category-heading h2 { font-size: 21px; }
        .catalog-toolbar .search-wrap, .catalog-toolbar .compact-search { border-radius: 14px; border-color: transparent; }
        .catalog-toolbar .quota-pill { display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; border-radius: 14px; border: 0; background: var(--surface); color: var(--text); font-weight: 700; }
        .catalog-toolbar .quota-pill .credit-icon { flex: 0 0 18px; border-radius: 50%; background: var(--brand); font-size: 0; }
        .icon-button, #workspaceHelp { border-radius: 14px; border-color: transparent; background: var(--surface); }
        .category-nav .chip, .category-nav .category-picker { border-radius: 12px; background: transparent; color: var(--muted); }
        .category-nav .category-picker { background: var(--surface); border-color: transparent; color: var(--text); }
        .category-nav .chip.active, .category-nav .chip[aria-pressed="true"] { background: var(--text); color: #fff; border-color: var(--text); }

        /* Главная кнопка и «фирменные» акценты — один градиент индиго → океан */
        /* Градиенты не анимируются, поэтому при наведении фон не меняем, а плавно затемняем внутренней тенью. */
        .button {
            background: var(--brand); border: 0; border-radius: 18px;
            box-shadow: 0 10px 22px var(--glow), inset 0 0 0 100vmax rgba(10, 8, 48, 0);
            transition: transform 140ms ease, box-shadow 180ms ease;
        }
        .button:not(:disabled):not(.secondary):active { box-shadow: 0 6px 14px var(--glow), inset 0 0 0 100vmax rgba(10, 8, 48, 0.22); }
        @media (hover: hover) { .button:not(:disabled):not(.secondary):hover { background: var(--brand); box-shadow: 0 12px 26px var(--glow), inset 0 0 0 100vmax rgba(10, 8, 48, 0.14); } }
        .button.secondary { box-shadow: none; border-radius: 16px; }
        .button:disabled { background: var(--surface-soft); box-shadow: none; }
        .catalog-more { border-radius: 16px; border-color: var(--line); color: var(--primary); }
        .catalog-subscribe, .package-buy, .profile-quick-action.shop { background: var(--brand); border-color: transparent; }
        .new-badge { background: var(--brand); color: #fff; border-radius: 9px; }
        .save-template[aria-pressed="true"] { background: var(--primary); }

        /* Карточки каталога: крупное фото, название и «Попробовать» внизу */
        .template-item .template-card { border-radius: 20px; box-shadow: none; }
        .template-item .template-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 48px 12px 12px; background: linear-gradient(180deg, rgba(21, 22, 28, 0) 0%, rgba(21, 22, 28, 0.6) 100%); }
        .template-item .template-meta > * { min-width: 0; }
        .template-item .template-title { font-size: 15px; font-weight: 700; }
        .template-item .template-description { display: none; }
        .catalog-sections.is-overview .template-item .template-meta::after {
            content: "Попробовать"; flex-shrink: 0; padding: 6px 12px; border-radius: 10px;
            background: #fff; color: var(--text); font-size: 13px; font-weight: 700;
        }
        .catalog-sections.is-overview .template-grid { grid-auto-columns: 58%; }
        @media (min-width: 720px) { .catalog-sections.is-overview .template-grid { grid-auto-columns: calc((100% - 3 * var(--space-4)) / 4); } }

        /* Экран шаблона */
        .editor-template-preview { position: relative; }
        .editor-template-preview img { border-radius: 24px; box-shadow: none; }
        .editor-template-preview::before {
            content: "Пример результата"; position: absolute; left: 12px; top: 12px; z-index: 1;
            padding: 5px 10px; border-radius: 9px; background: rgba(21, 22, 28, 0.72); color: #fff; font-size: 12px; font-weight: 600;
        }
        .editor-kicker { color: var(--primary); text-transform: none; letter-spacing: 0; font-size: 13px; }
        .editor-step, .custom-composer, .custom-settings { box-shadow: none; border-radius: 20px; }
        .step-number { background: var(--primary-soft); color: var(--primary); }
        .source-picker.primary-picker { background: var(--primary-soft); color: var(--primary); border: 1.5px solid var(--primary); }
        .custom-model-choice.active, .segment.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); box-shadow: none; }
        .editor-reactions button[aria-pressed="true"], .idea-chip.active { background: var(--primary-soft); color: var(--primary); }

        /* Баланс */
        .balance-hero { background: var(--brand); box-shadow: 0 12px 28px var(--glow); }
        .referral-progress { background: var(--primary-soft); }
        .referral-progress-fill { background: var(--brand); }
        .profile-quick-action.referral svg, .profile-quick-action.promo svg { color: var(--primary); }
        .package-badge { background: var(--primary-soft); color: var(--primary); }
        .package-card, .profile-details, .status-line { border-color: var(--line); }

        /* Нижнее меню */
        .bottom-nav { background: var(--surface); }
        .bottom-nav-inner .nav-btn.active, .bottom-nav-inner .nav-btn[aria-expanded="true"] { background: transparent; color: var(--text); font-weight: 700; }
        .bottom-nav-inner .nav-btn.active svg { color: var(--primary) !important; }
        .empty-icon, .history-empty > svg { background: var(--primary-soft); color: var(--primary); }
        .skeleton-card, .skeleton-line { background: linear-gradient(100deg, var(--surface-soft) 30%, #f7f8fb 50%, var(--surface-soft) 70%); background-size: 200% 100%; }
        .editor-template-preview { display: block; align-self: start; height: auto; min-height: 0; }
        @media (min-width: 900px) { .editor-template-preview { position: sticky; top: 80px; } }

        /* One outline wallet for every credit amount; color follows its text. */
        .credit-icon, .quota-pill .credit-icon, .catalog-toolbar .quota-pill .credit-icon,
        .custom-model-choice .credit-icon, .balance-total .credit-icon {
            display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
            width: 18px; height: 18px; min-width: 18px;
            border-radius: 0; background: transparent; box-shadow: none; color: inherit;
            font-size: inherit; line-height: 1; transform: none; vertical-align: middle; align-self: center;
        }
        .credit-icon > svg { display: block; width: 100%; height: 100%; stroke-width: 1.9; }
        .catalog-toolbar .quota-pill .credit-icon { width: 22px; height: 22px; min-width: 22px; flex-basis: 22px; color: var(--muted); }
        .balance-total .credit-icon { width: 28px; height: 28px; min-width: 28px; }
        .button .credit-icon, #customGenerateBtn .credit-icon, .balance-hero .credit-icon { background: transparent; color: inherit; }

        /* ==========================================================================
           Отступы: единая шкала. Интервалы задают gap контейнеров,
           поэтому у их прямых потомков margin обнулён.
           ========================================================================== */
        .app { padding-left: var(--pad-page); padding-right: var(--pad-page); }
        .topbar { margin: 0 calc(-1 * var(--pad-page)) var(--gap-stack); padding: 8px var(--pad-page); }
        .view.active:not(#viewAdmin):not(#viewVideo) { display: flex; flex-direction: column; gap: var(--gap-block); }
        .view:not(#viewAdmin):not(#viewVideo) > * { margin-top: 0; margin-bottom: 0; }
        .page-head { margin: var(--gap-tight) 0 var(--gap-title); }
        .page-head .section-title { margin: 0 0 var(--gap-title); }
        .page-head p { margin: 0; }

        /* Каталог */
        .category-nav { margin: 0; }
        .catalog-tools { margin: 0; gap: var(--gap-stack); }
        .catalog-tools h2 { display: flex; align-items: baseline; gap: var(--gap-title); flex: 1; min-width: 0; margin: 0; }
        .catalog-tools .selected-categories { margin: 0; }
        .catalog-sections { gap: var(--gap-section); }
        .category-section { gap: var(--gap-stack); }
        .category-section > .catalog-more { margin: 0; }
        .template-grid { gap: var(--gap-block) var(--gap-stack); }
        .catalog-sections > .catalog-more { margin: 0; }
        .catalog-welcome, .catalog-subscription, .community-bar { margin: 0; }

        /* Карточки-блоки: одинаковые поля и интервалы внутри */
        .editor-layout { gap: var(--gap-block); padding-top: 0; }
        .editor-panel { gap: var(--gap-block); }
        .editor-intro { gap: var(--gap-title); }
        .editor-step, .custom-composer, .custom-settings { padding: var(--pad-card); gap: var(--gap-stack); }
        .editor-intro > *, .editor-step > *, .editor-step .advanced-content > *, .custom-settings > *,
        .custom-launch > *, .custom-prompt-field > *, .custom-photos > *, .custom-settings .advanced-content > * { margin-top: 0; margin-bottom: 0; }
        .step-title { margin: 0; }
        .editor-step > .compact-note { margin: 0; }
        .advanced-settings { margin: 0; }
        .advanced-settings summary { padding: 0; min-height: var(--control-h); }
        .advanced-content { gap: var(--gap-stack); padding: var(--gap-tight) 0 var(--gap-stack); }
        .preview-row { margin: 0; padding: 0; }
        .photo-count { font-weight: 500; }
        .custom-builder { gap: var(--gap-block); }
        .custom-composer { display: grid; }
        .custom-prompt-field, .custom-photos { display: grid; gap: var(--gap-title); }
        .custom-prompt-field .textarea { margin-top: var(--gap-tight); }
        .custom-photos { padding-top: var(--gap-block); border-top: 1px solid var(--line); }
        .custom-label-row { margin: 0; }
        .prompt-examples { margin: 0; }
        .custom-launch { gap: var(--gap-title); }

        /* Баланс */
        .balance-overview { display: flex; flex-direction: column; gap: var(--gap-stack); margin: 0; padding: 0; }
        .balance-overview > * { margin: 0; }
        .balance-hero { padding: var(--space-5); }
        .profile-quick-actions { gap: var(--gap-title); margin: 0; }
        .profile-details { margin: 0; padding: 0 var(--pad-card); background: var(--surface); border: 0; border-radius: var(--radius-lg); box-shadow: none; }
        .profile-details > summary { min-height: 0; padding: var(--pad-card) 0; }
        .profile-details .details-content { display: grid; gap: var(--gap-stack); padding: 0 0 var(--pad-card); }
        .profile-details .details-content > * { margin: 0; }
        .shop-grid { gap: var(--gap-stack); }
        .shop-more > summary, #shopLegal summary { min-height: 40px; }
        .inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--gap-title); margin: 0; }
        .inline-form .field, .inline-form .button { height: var(--control-h); min-height: var(--control-h); margin: 0; }
        .inline-form .button { padding: 0 20px; box-shadow: none; border-radius: var(--radius); }
        .feedback-kind-grid { margin: 0; }
        .field-hint { margin: 0; }

        /* Шторки */
        .catalog-dialog .sheet-head { padding: var(--pad-card); gap: var(--gap-stack); }
        .catalog-dialog .sheet-body { padding: var(--pad-card); display: grid; gap: var(--gap-stack); align-content: start; }
        .catalog-dialog .sheet-body > * { margin-top: 0; margin-bottom: 0; }
        .catalog-dialog .sheet-footer { padding: var(--pad-card); display: grid; gap: var(--gap-title); }
        .photo-library-tabs { margin: var(--gap-stack) var(--pad-card) 0; }
        .help-topics { gap: 0; }
        .catalog-dialog .help-topics { gap: 0; padding-top: 0; padding-bottom: 0; }
        .catalog-dialog .help-topics details { padding: 0; }
        .catalog-dialog .help-topics summary { min-height: 56px; }
        .catalog-dialog .help-topics details[open] { padding-bottom: var(--gap-stack); }
        .help-topics details p { margin: var(--gap-title) 0 0; }

        /* Кнопки-иконки: одна форма и размер для «назад», «помощь», «закрыть» */
        .icon-button, #workspaceHelp, .catalog-tools .icon-button {
            display: inline-grid; place-items: center; flex: 0 0 var(--icon-btn);
            width: var(--icon-btn); height: var(--icon-btn); padding: 0;
            border: 0; border-radius: 14px; background: var(--surface); color: var(--text);
        }
        .icon-button svg, #workspaceHelp svg { width: 22px; height: 22px; stroke-width: 1.9; }
        #workspaceHelp { color: var(--muted); }
        .workspace-back {
            display: inline-flex; align-items: center; gap: 6px; height: var(--icon-btn);
            padding: 0 14px 0 10px; border: 0; border-radius: 14px; background: var(--surface); color: var(--text); font-weight: 600;
        }
        .workspace-back svg { width: 20px; height: 20px; stroke-width: 2; }
        .catalog-dialog .sheet-head .icon-button { flex-basis: 40px; width: 40px; height: 40px; border-radius: 12px; background: var(--surface-soft); }
        .catalog-dialog .sheet-head .icon-button svg { width: 20px; height: 20px; }
        @media (hover: hover) {
            .icon-button:hover, #workspaceHelp:hover, .workspace-back:hover { background: var(--primary-soft); }
        }
        /* Перебиваем наслоённые правила прошлых версий с более высокой специфичностью. */
        #viewEditor .editor-step > *, #viewEditor .editor-intro > *, #viewEditor .advanced-content > *,
        #viewCustom .custom-settings > *, #viewCustom .custom-launch > *, #viewCustom .custom-prompt-field > *,
        #viewCustom .custom-photos > *, #viewCustom .advanced-content > *,
        #viewProfile .balance-overview > *, #viewProfile .details-content > * { margin-top: 0; margin-bottom: 0; }
        #viewEditor .advanced-settings, #viewCustom .advanced-settings { border-top: 0; border-bottom: 1px solid var(--line); padding: 0; }
        #viewEditor .editor-step > .editor-photo-actions, #viewCustom .custom-photo-actions { margin: 0; }
        .catalog-toolbar .workspace-back { flex: 0 0 auto; width: auto; margin-right: auto; }

        /* Approved compact catalog: one grid, two rows of controls. */
        #catalogTopbar { border-bottom: 0; padding: 16px var(--pad-page) 12px; margin-bottom: 0; }
        .catalog-toolbar { gap: 8px; }
        .catalog-toolbar .search-wrap, .catalog-toolbar .quota-pill, #catalogSavedBtn { border-radius: 12px; }
        .catalog-toolbar .search-wrap input { font-size: 16px; font-weight: 400; letter-spacing: 0; }
        .catalog-toolbar .search-icon { width: 20px; height: 20px; }
        #workspaceModes:empty { display: none; }
        .catalog-toolbar .quota-pill { order: 2; flex: 0 0 auto; min-width: 62px; max-width: 110px; padding: 0 12px; gap: 8px; font-size: 15px; letter-spacing: 0; }
        .catalog-toolbar .quota-pill > svg { flex: 0 0 22px; width: 22px; height: 22px; color: var(--muted); stroke-width: 1.9; }
        #catalogSavedBtn, #workspaceHelp { order: 3; }
        #catalogSavedBtn[aria-pressed="true"] { color: var(--primary); background: var(--primary-soft); }
        #catalogSavedBtn[aria-pressed="true"] svg { fill: currentColor; }
        #viewCatalog.active { gap: 16px; }
        #categoryNav { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; overflow: visible; padding: 0; margin: 0 0 2px; }
        #categoryNav .category-picker { min-width: 0; height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; letter-spacing: 0; }
        #categoryNav .category-picker span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
        #categoryNav .category-picker svg { flex: 0 0 18px; width: 18px; height: 18px; color: var(--muted); }
        .catalog-sort-control { position: relative; min-width: 0; display: flex; align-items: center; height: 44px; border-radius: 12px; background: var(--surface); }
        .catalog-sort-control > svg { position: absolute; width: 17px; height: 17px; left: 12px; color: var(--muted); pointer-events: none; }
        .catalog-sort-control > svg:last-child { left: auto; right: 10px; width: 16px; }
        .catalog-sort-control select { appearance: none; -webkit-appearance: none; width: 100%; min-width: 0; height: 100%; border: 0; border-radius: inherit; background: transparent; color: var(--text); font: inherit; font-size: 13px; font-weight: 500; letter-spacing: 0; padding: 0 26px 0 34px; cursor: pointer; text-overflow: ellipsis; }
        #catalogTools .selected-categories { display: flex; flex-wrap: wrap; gap: 6px; }
        #catalogTools .selected-categories:empty { display: none; }
        #catalogTools .selected-categories button { min-height: 44px; max-width: 100%; padding: 8px 12px; border-radius: 8px; overflow-wrap: anywhere; }
        #gallery .template-grid { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; overflow: visible; margin: 0; padding: 0; }
        #gallery .template-media { aspect-ratio: 17 / 25; }
        #gallery .template-card { border-radius: 14px; }
        #gallery .template-meta { padding: 42px 12px 14px; }
        #gallery .template-title { font-size: 15px; line-height: 1.3; letter-spacing: 0; }
        #gallery .save-template { top: 2px; right: 2px; width: 44px; height: 44px; border: 6px solid transparent; background-clip: padding-box; box-shadow: none; }
        #gallery .new-badge { top: 8px; left: 8px; max-width: calc(100% - 64px); padding: 5px 8px; font-size: 11px; letter-spacing: 0; }
        .bottom-nav { padding: 8px 8px max(8px, env(safe-area-inset-bottom)); }
        .bottom-nav-inner { min-height: 48px; padding: 0; gap: 0; }
        .bottom-nav-inner .nav-btn { grid-template-rows: 22px 17px; min-height: 52px; gap: 5px; font-size: 12px; line-height: 17px; letter-spacing: 0; }
        .bottom-nav-inner .nav-btn svg { width: 22px; height: 22px; }
        .bottom-nav-inner .nav-btn.active, .bottom-nav-inner .nav-btn[aria-expanded="true"] { color: var(--primary); }
        .bottom-nav-inner .nav-btn:focus-visible, #catalogSavedBtn:focus-visible,
        #categoryNav button:focus-visible, .catalog-sort-control select:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
        #viewProfile .page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
        @media (max-width: 389px) {
            .catalog-sort-control > svg:first-child { display: none; }
            .catalog-sort-control select { padding-left: 12px; font-size: 13px; }
        }
        @media (max-width: 359px) {
            #catalogTopbar { padding-top: 10px; padding-bottom: 8px; }
            .catalog-toolbar .search-wrap input { font-size: 16px; }
            .catalog-sort-control > svg:first-child { display: none; }
            .catalog-sort-control select { padding-left: 12px; font-size: 12px; }
            .bottom-nav-inner .nav-btn { font-size: 11px; }
        }
        @media (min-width: 720px) { #gallery .template-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
        @media (min-width: 1000px) { #gallery .template-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
