﻿:root {
    --cf-orange: #f6821f;
    --cf-orange-hover: #ea6c00;
    --cf-orange-active: #d46000;
    --cf-orange-subtle: rgba(246, 130, 31, 0.08);
    --cf-orange-border: rgba(246, 130, 31, 0.35);
    --cf-blue: #0051c3;
    --cf-blue-hover: #0041a3;
    --cf-blue-subtle: rgba(0, 81, 195, 0.08);
    --bg-page: #f4f5f7;
    --bg-surface: #fff;
    --bg-subtle: #f8fafc;
    --bg-hover: #f1f5f9;
    --bg-code: #0b0f19;
    --border: #e2e8f0;
    --border-subtle: #edf2f7;
    --border-strong: #cbd5e1;
    --border-focus: #f6821f;
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dim: #64748b;
    --text-inverse: #fff;
    --status-success: #059669;
    --status-success-bg: rgba(5, 150, 105, 0.1);
    --status-warning: #d97706;
    --status-warning-bg: rgba(217, 119, 6, 0.1);
    --status-error: #dc2626;
    --status-error-bg: rgba(220, 38, 38, 0.1);
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --focus-ring: 0 0 0 3px rgba(246, 130, 31, 0.25)
}

body.dark-mode {
    --bg-page: #0a0e17;
    --bg-surface: #111827;
    --bg-subtle: #172033;
    --bg-hover: #1e293b;
    --bg-code: #070a10;
    --border: #1f293d;
    --border-subtle: #162032;
    --border-strong: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --status-success: #10b981;
    --status-success-bg: rgba(16, 185, 129, 0.15);
    --status-warning: #f59e0b;
    --status-warning-bg: rgba(245, 158, 11, 0.15);
    --status-error: #ef4444;
    --status-error-bg: rgba(239, 68, 68, 0.15)
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

[hidden] {
    display: none !important
}

body {
    background-color: var(--bg-page);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color .25s ease, color .25s ease
}

.container {
    max-width: 1540px;
    margin: 0 auto;
    padding: 24px 24px 48px
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    padding-bottom: 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border)
}

.title-group h1 {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px
}

.title-group h1 .badge {
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .02em;
    background: var(--cf-orange-subtle);
    color: var(--cf-orange);
    border: 1px solid var(--cf-orange-border);
    padding: 2px 8px;
    border-radius: 9999px;
    white-space: nowrap
}

.title-group p {
    color: var(--text-muted);
    font-size: .85rem;
    margin-top: 5px
}

.stat-badges {
    display: flex;
    gap: 12px;
    flex-wrap: wrap
}

.stat-badge {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 8px 16px;
    min-width: 130px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: border-color .2s ease, box-shadow .2s ease
}

.stat-badge:hover {
    border-color: var(--border-strong)
}

.stat-badge .stat-label {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-dim);
    margin-bottom: 2px
}

.stat-badge .stat-val {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main)
}

.stat-badge.highlight {
    border-color: rgba(5, 150, 105, 0.3);
    background: linear-gradient(180deg, var(--bg-surface) 0, var(--bg-subtle) 100%)
}

.stat-badge.highlight .stat-val {
    color: var(--status-success)
}

.theme-toggle {
    position: fixed;
    top: 20px;
    right: 24px;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all .2s ease;
    z-index: 1000
}

.theme-toggle:hover {
    border-color: var(--cf-orange);
    color: var(--cf-orange);
    transform: translateY(-1px)
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start
}

.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 8px
}

.panel > section {
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 8px
}

.panel > section:last-child {
    border-bottom: 0;
    padding-bottom: 0
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px
}

.section-title {
    font-size: .92rem;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 8px
}

.section-desc {
    font-size: .78rem;
    color: var(--text-dim);
    line-height: 1.45
}

.preset-group, .features-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px
}

.features-grid > .feature-card {
    width: min(var(--inbound-card-width, var(--feature-card-width, max-content)), 100%)
}

.preset-group > .btn-preset {
    width: min(var(--preset-card-width, max-content), 100%)
}

.features-grid > .feature-card input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    pointer-events: none
}

.features-grid > .feature-card:has(input:focus-visible) {
    outline: 2px solid var(--cf-orange);
    outline-offset: 2px
}

.btn-preset, .preset-btn, .feature-card {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 7px 14px;
    min-height: 36px;
    height: 36px;
    font-size: .8rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    box-sizing: border-box;
    transition: all .15s ease
}

.btn-preset:hover, .preset-btn:hover, .feature-card:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--text-main)
}

.btn-preset.active, .preset-btn.active, .feature-card.active, .feature-card:has(input:checked) {
    background: var(--cf-orange-subtle);
    border-color: var(--cf-orange);
    color: var(--cf-orange);
    font-weight: 600
}

.feature-card:has(input:disabled) {
    opacity: .45;
    cursor: not-allowed
}

.feature-card span, .feature-card strong, .feature-name {
    display: inline;
    font-size: .8rem;
    font-weight: inherit;
    line-height: 1;
    color: inherit
}

.feature-card small, .feature-desc {
    display: none
}

.feature-card input[type="checkbox"], .checkbox-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 15px;
    height: 15px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background-color: var(--bg-surface);
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
    display: inline-block;
    vertical-align: middle;
    transition: border-color .15s ease, background-color .15s ease
}

.feature-card input[type="checkbox"]:hover, .checkbox-label input[type="checkbox"]:hover {
    border-color: var(--cf-orange)
}

.feature-card input[type="checkbox"]:checked, .checkbox-label input[type="checkbox"]:checked {
    background-color: var(--cf-orange);
    border-color: var(--cf-orange);
    background-image: url("data:image/svg+xml,%3Csvgxmlns='http://www.w3.org/2000/svg'viewBox='001616'fill='%23ffffff'%3E%3Cpathfill-rule='evenodd'd='M12.4163.376a.75.75001.2081.04l-57.5a.75.75001-1.154.114l-3-3a.75.750011.06-1.06l2.3532.3534.493-6.74a.75.750011.04-.207Z'clip-rule='evenodd'/%3E%3C/svg%3E");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 11px 11px
}

.credential-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px
}

.credential-grid .form-group {
    grid-column: 1 / -1;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    min-height: 74px;
    transition: border-color .15s ease
}

.credential-grid .form-group:hover {
    border-color: var(--border-strong)
}

.form-group > label:first-child:not(.checkbox-label) {
    font-size: .76rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center
}

#credential-sni {
    grid-column: 1 / -1;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 10px 14px;
    min-height: 74px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px
}

#credential-sni > label:first-child {
    font-size: .76rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer
}

#credential-sni .checkbox-label {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    font-size: .76rem !important;
    line-height: 1.45 !important;
    color: var(--text-muted) !important;
    gap: 8px !important;
    width: fit-content !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    cursor: pointer !important;
    user-select: none
}

#credential-sni .sni-hint {
    display: block;
    font-size: .68rem;
    line-height: 1.4;
    color: var(--text-dim);
    padding-left: 23px
}

.input-row {
    display: flex;
    gap: 8px
}

input:not([type="checkbox"]), select, textarea {
    font-family: var(--font-mono);
    font-size: .8rem;
    color: var(--text-main);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 7px 12px;
    width: 100%;
    outline: 0;
    transition: border-color .15s ease, box-shadow .15s ease
}

input:not([type="checkbox"]):focus, select:focus {
    border-color: var(--cf-orange);
    box-shadow: var(--focus-ring)
}

.btn-small {
    appearance: none;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: .76rem;
    font-weight: 600;
    padding: 0 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s ease
}

.btn-small:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--text-main)
}

.hash-preview {
    font-family: var(--font-mono);
    font-size: .72rem;
    color: var(--cf-orange);
    background: var(--cf-orange-subtle);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    display: inline-block;
    overflow-wrap: anywhere
}

.parameter-panel {
    display: flex;
    flex-direction: column;
    gap: 10px
}

.table-scroll {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface)
}

.param-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .76rem;
    text-align: left
}

.param-table th {
    background: var(--bg-subtle);
    color: var(--text-dim);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-size: .68rem;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border)
}

.param-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-muted);
    vertical-align: top;
    overflow-wrap: anywhere
}

.param-table tr:last-child td {
    border-bottom: 0
}

.param-table tr:hover td {
    background: var(--bg-subtle)
}

.param-table td:first-child {
    font-weight: 600;
    color: var(--text-main)
}

.param-table td:nth-child(2) {
    font-family: var(--font-mono);
    color: var(--cf-orange)
}

.code-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 24px;
    box-shadow: var(--shadow-sm);
    overflow: hidden
}

.code-header {
    padding: 12px 18px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px
}

.code-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-dim);
    font-family: var(--font-mono)
}

.code-meta span {
    display: inline-flex;
    align-items: center
}

#codeStatus {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 9999px;
    font-family: var(--font-sans);
    color: var(--text-muted);
    font-size: .72rem
}

.code-actions {
    display: flex;
    align-items: center;
    gap: 8px
}

.btn-action {
    appearance: none;
    font-family: var(--font-sans);
    font-size: .78rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    padding: 6px 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all .15s ease;
    line-height: 1.25
}

.btn-primary {
    background: var(--cf-orange);
    border: 1px solid var(--cf-orange);
    color: #fff
}

.btn-primary:hover {
    background: var(--cf-orange-hover);
    border-color: var(--cf-orange-hover)
}

.btn-primary:active {
    background: var(--cf-orange-active)
}

.btn-secondary {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-muted)
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--text-main)
}

button:disabled {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none
}

.selection-summary {
    padding: 10px 18px;
    font-size: .75rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-subtle);
    line-height: 1.6
}

.validation-message {
    margin: 10px 18px;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: .76rem;
    line-height: 1.5;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent
}

.validation-message.error {
    background: var(--status-error-bg);
    color: var(--status-error);
    border-color: rgba(220, 38, 38, 0.2)
}

.validation-message.warning {
    background: var(--status-warning-bg);
    color: var(--status-warning);
    border-color: rgba(217, 119, 6, 0.2)
}

.code-container {
    position: relative;
    background: var(--bg-code);
    flex: 1
}

#codeOutput {
    width: 100%;
    height: 720px;
    min-height: 500px;
    padding: 18px;
    border: 0;
    background: transparent;
    color: #e2e8f0;
    font-family: var(--font-mono);
    font-size: .82rem;
    line-height: 1.6;
    white-space: pre;
    tab-size: 2;
    resize: vertical;
    outline: 0
}

#codeOutput::-webkit-scrollbar {
    width: 10px;
    height: 10px
}

#codeOutput::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.15)
}

#codeOutput::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px
}

#codeOutput::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35)
}

#presets {
    margin-top: 12px !important;
}

footer {
    text-align: center;
    font-size: .75rem;
    color: var(--text-dim);
    padding: 32px 0 16px
}

footer a {
    color: var(--cf-orange);
    text-decoration: none;
    transition: color .15s ease
}

footer a:hover {
    color: var(--cf-orange-hover)
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text-main);
    color: var(--bg-page);
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: .8rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    transform: translateY(120%);
    opacity: 0;
    transition: transform .25s cubic-bezier(0.16, 1, 0.3, 1), opacity .25s ease;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px
}

.toast.show {
    transform: translateY(0);
    opacity: 1
}

@media (max-width: 1180px) {
    .workspace {
        grid-template-columns: minmax(0, 1fr)
    }

    .code-panel {
        position: static
    }

    #codeOutput {
        height: 540px
    }
}

@media (max-width: 680px) {
    .container {
        padding: 16px
    }

    header {
        flex-direction: column;
        align-items: flex-start
    }

    .stat-badges {
        width: 100%
    }

    .stat-badge {
        flex: 1;
        min-width: 100px
    }

    .credential-grid {
        grid-template-columns: minmax(0, 1fr)
    }

    .code-header {
        flex-direction: column;
        align-items: flex-start
    }

    .code-actions {
        width: 100%
    }

    .btn-action {
        flex: 1
    }
}
