:root {
    color-scheme: light dark;

    --bg: #f7f3f7;
    --surface: rgba(255, 255, 255, .92);
    --surface-strong: #fff;
    --text: #2d2430;
    --muted: #716875;
    --border: rgba(112, 77, 111, .24);
    --border-strong: rgba(112, 77, 111, .42);
    --primary: #b35eaf;
    --primary-soft: rgba(179, 94, 175, .12);
    --danger: #a9364b;
    --success: #2b7a50;

    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #171318;
        --surface: rgba(39, 31, 41, .94);
        --surface-strong: #2a222c;
        --text: #f5edf6;
        --muted: #c6b8c9;
        --border: rgba(235, 170, 232, .24);
        --border-strong: rgba(235, 170, 232, .5);
        --primary: #eaaae8;
        --primary-soft: rgba(234, 170, 232, .13);
        --danger: #ff9aac;
        --success: #8ed8ad;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;

    color: var(--text);
    background: var(--bg);
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    opacity: .5;
    cursor: default;
}

a {
    color: var(--primary);
}

code {
    font-family:
        ui-monospace,
        SFMono-Regular,
        Consolas,
        monospace;
}

.helper-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 52px;
}

.helper-header {
    display: grid;
    gap: 10px;

    margin-bottom: 20px;
}

.helper-kicker {
    margin: 0;

    color: var(--primary);

    font-size: .78rem;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.helper-header h1 {
    margin: 0;

    font-size: clamp(1.7rem, 4vw, 2.55rem);
    line-height: 1.08;
}

.helper-description {
    max-width: 800px;

    margin: 0;

    color: var(--muted);

    line-height: 1.6;
}

.helper-path {
    width: fit-content;

    margin: 0;
    padding: 5px 9px;

    color: var(--muted);
    background: var(--primary-soft);

    border: 1px solid var(--border);
    border-radius: 8px;

    font-family:
        ui-monospace,
        SFMono-Regular,
        Consolas,
        monospace;
    font-size: .78rem;
}

.helper-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;

    margin-bottom: 18px;
}

.helper-button,
.file-button {
    min-height: 40px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 8px 13px;

    color: var(--text);
    background: var(--surface);

    border: 1px solid var(--border-strong);
    border-radius: 10px;

    font-weight: 800;
    text-decoration: none;
}

.helper-button:hover,
.helper-button:focus-visible,
.file-button:hover,
.file-button:focus-within {
    border-color: var(--primary);
}

.helper-button.is-primary {
    color: #fff;
    background: #a44da1;
    border-color: #a44da1;
}

.file-button input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.helper-notice,
.helper-status {
    margin: 0 0 16px;
    padding: 11px 13px;

    border: 1px solid var(--border);
    border-radius: 10px;

    line-height: 1.5;
}

.helper-notice {
    color: var(--muted);
    background: var(--surface);
}

.helper-status[hidden] {
    display: none;
}

.helper-status[data-type="success"] {
    color: var(--success);
}

.helper-status[data-type="error"] {
    color: var(--danger);
}

.helper-grid {
    display: grid;
    grid-template-columns:
        minmax(0, 1.08fr)
        minmax(340px, .92fr);
    gap: 18px;
    align-items: start;
}

.helper-panel {
    min-width: 0;

    padding: 18px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 16px;
}

.helper-panel h2 {
    margin: 0 0 14px;

    font-size: 1.03rem;
}

.form-sections {
    display: grid;
    gap: 18px;
}

.form-section {
    display: grid;
    gap: 12px;
}

.form-section + .form-section {
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.form-section-title {
    margin: 0;
    font-size: .93rem;
}

.form-section-help {
    margin: -6px 0 0;

    color: var(--muted);

    font-size: .78rem;
    line-height: 1.5;
}

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

.field {
    min-width: 0;

    display: grid;
    gap: 6px;
}

.field.is-wide {
    grid-column: 1 / -1;
}

.field-label {
    font-size: .78rem;
    font-weight: 850;
}

.field-help {
    margin: -2px 0 0;

    color: var(--muted);

    font-size: .72rem;
    line-height: 1.45;
}

.field input[type="text"],
.field input[type="url"],
.field input[type="date"],
.field input[type="time"],
.field input[type="number"],
.field textarea {
    width: 100%;

    padding: 9px 10px;

    color: var(--text);
    background: var(--surface-strong);

    border: 1px solid var(--border);
    border-radius: 9px;

    outline: none;
}

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

.field input:focus,
.field textarea:focus {
    border-color: var(--primary);
}

.checkbox-row {
    min-height: 40px;

    display: flex;
    align-items: center;
    gap: 8px;

    padding: 8px 10px;

    background: var(--surface-strong);

    border: 1px solid var(--border);
    border-radius: 9px;
}

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

.array-block {
    display: grid;
    gap: 10px;

    grid-column: 1 / -1;
}

.array-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.array-toolbar h3 {
    margin: 0;
    font-size: .9rem;
}

.array-items {
    display: grid;
    gap: 10px;
}

.array-item {
    padding: 13px;

    background: var(--surface-strong);

    border: 1px solid var(--border);
    border-radius: 12px;
}

.array-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;

    margin-bottom: 11px;
}

.array-item-title {
    margin: 0;

    font-size: .8rem;
    font-weight: 900;
}

.array-actions {
    display: flex;
    gap: 5px;
}

.array-action {
    min-width: 32px;
    min-height: 30px;

    padding: 4px 7px;

    color: var(--text);
    background: transparent;

    border: 1px solid var(--border);
    border-radius: 8px;
}

.array-action:hover,
.array-action:focus-visible {
    border-color: var(--primary);
}

.json-preview {
    width: 100%;
    min-height: 560px;

    padding: 13px;

    color: var(--text);
    background: var(--surface-strong);

    border: 1px solid var(--border);
    border-radius: 10px;

    font-family:
        ui-monospace,
        SFMono-Regular,
        Consolas,
        monospace;
    font-size: .78rem;
    line-height: 1.5;

    resize: vertical;
}

.preview-help {
    margin: 10px 0 0;

    color: var(--muted);

    font-size: .72rem;
    line-height: 1.5;
}

.helper-index-grid {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.helper-card {
    display: grid;
    gap: 7px;

    padding: 15px;

    color: var(--text);
    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 14px;

    text-decoration: none;
}

.helper-card:hover,
.helper-card:focus-visible {
    border-color: var(--primary);
}

.helper-card strong {
    font-size: .95rem;
}

.helper-card span {
    color: var(--muted);

    font-size: .76rem;
    line-height: 1.45;
}

@media (max-width: 820px) {
    .helper-grid {
        grid-template-columns: 1fr;
    }

    .json-preview {
        min-height: 380px;
    }
}

@media (max-width: 560px) {
    .helper-shell {
        width: min(100% - 20px, 1120px);
        padding-top: 18px;
    }

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

    .helper-panel {
        padding: 14px;
    }
}
