:root {
    --rsl-field-bg: #111418;
    --rsl-field-border: #2d3440;
    --rsl-field-radius: 10px;
    --rsl-field-text: #e5e7eb;
    --rsl-field-muted: #9ca3af;
    --rsl-field-focus: #6e7bff;
    --rsl-field-error: #f97373;
    --rsl-field-success: #22c55e;
    --rsl-chip-bg: #0b0f17;
    --rsl-chip-border: #374151;
    --rsl-choice-bg: #0b0f17;
    --rsl-select-bg: #111418;
    --rsl-toggle-off: #4b5563;
    --rsl-toggle-on: #22c55e;
    --rsl-slider-track: #1f2933;
    --rsl-slider-fill: #6e7bff;
    --rsl-file-bg: #0b0f17;
}

/* Section spacing when used with slot-layout */

.demo-wrap {
    margin-block: 1.5rem 2rem;
}

/* Generic form demo helpers */

.rsl-form-demo {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-block: 0.75rem 1.25rem;
}

.rsl-fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

.rsl-fieldset-legend {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--rsl-field-muted);
    margin-bottom: 0.35rem;
}

/* Field tile */

.rsl-field-tile {
    border-radius: var(--rsl-field-radius);
    background: var(--rsl-field-bg);
    border: 1px solid var(--rsl-field-border);
    padding: 0.75rem 0.9rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition:
        border-color 140ms ease,
        box-shadow 140ms ease,
        transform 140ms ease,
        background 140ms ease;
}

.rsl-field-tile:hover {
    border-color: #3b3f46;
}

.rsl-field-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--rsl-field-muted);
}

.rsl-field-body {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.rsl-field-input {
    border: none;
    outline: none;
    background: transparent;
    color: var(--rsl-field-text);
    font-size: 0.95rem;
    width: 100%;
}

.rsl-field-input::placeholder {
    color: #4b5563;
}

.rsl-field-helper {
    font-size: 0.75rem;
    color: var(--rsl-field-muted);
}

.rsl-field-bar {
    height: 2px;
    border-radius: 999px;
    background: #1f2933;
    transform-origin: center;
    transform: scaleX(0.3);
    transition:
        background 140ms ease,
        transform 140ms ease;
}

/* Focus state driven by :focus-visible */
.rsl-field-tile:has(.rsl-field-input:focus-visible) {
    box-shadow: 0 0 0 1px var(--rsl-field-focus);
    transform: translateY(-1px);
}

.rsl-field-tile:has(.rsl-field-input:focus-visible) .rsl-field-bar {
    background: var(--rsl-field-focus);
    transform: scaleX(1);
}

/* Validation error states */
.rsl-field-input.input-error,
.rsl-field-tile:has(.rsl-field-input.input-error) {
    border-color: var(--rsl-field-error) !important;
    box-shadow: 0 0 0 1px var(--rsl-field-error) !important;
}

.rsl-field-tile:has(.rsl-field-input.input-error) .rsl-field-bar {
    width: 100%;
    background-color: var(--rsl-field-error);
    transform: scaleX(1);
}

/* Chip checkboxes */

.rsl-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.rsl-chip {
    --chip-bg: var(--rsl-chip-bg);
    --chip-border: var(--rsl-chip-border);
    --chip-active-bg: #141a28;
    --chip-active-border: var(--rsl-field-focus);

    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--chip-border);
    cursor: pointer;
    user-select: none;
    font-size: 0.85rem;
    color: var(--rsl-field-text);
    background: var(--chip-bg);
    transition:
        border-color 140ms ease,
        background 140ms ease,
        transform 120ms ease,
        box-shadow 120ms ease;
}

.rsl-chip:hover {
    border-color: #4b5563;
}

.rsl-chip-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.rsl-chip-check {
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 999px;
    border: 1px solid #4b5563;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    opacity: 0;
    transform: scale(0.4);
    transition:
        opacity 120ms ease,
        transform 120ms ease,
        border-color 120ms ease,
        background 120ms ease;
}

.rsl-chip-label {
    white-space: nowrap;
}

/* Checked state via :checked */
.rsl-chip-input:checked ~ .rsl-chip-check {
    opacity: 1;
    transform: scale(1);
    border-color: var(--chip-active-border);
    background: #111827;
}

.rsl-chip-input:checked ~ .rsl-chip-label {
    font-weight: 600;
}

.rsl-chip-input:checked:focus-visible ~ .rsl-chip-check {
    outline: 2px solid var(--rsl-field-focus);
    outline-offset: 2px;
}

/* Choice cards (radios) */

.rsl-choice-card {
    display: block;
    position: relative;
    cursor: pointer;
}

.rsl-choice-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.rsl-choice-inner {
    background: var(--rsl-choice-bg);
    border-radius: 12px;
    border: 1px solid var(--rsl-field-border);
    padding: 0.75rem 0.8rem;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    transition:
        border-color 140ms ease,
        box-shadow 140ms ease,
        transform 120ms ease,
        background 140ms ease;
}

.rsl-choice-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}

.rsl-choice-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--rsl-field-text);
}

.rsl-choice-price {
    font-size: 0.8rem;
    color: var(--rsl-field-muted);
}

.rsl-choice-desc {
    font-size: 0.78rem;
    color: var(--rsl-field-muted);
}

/* Selected */
.rsl-choice-input:checked + .rsl-choice-inner {
    border-color: var(--rsl-field-focus);
    box-shadow: 0 0 0 1px rgba(110, 123, 255, 0.65);
    background: #141a28;
    transform: translateY(-1px);
}

/* Custom select */

.rsl-select {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-width: 280px;
}

.rsl-select-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--rsl-field-radius);
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--rsl-field-border);
    background: var(--rsl-select-bg);
    color: var(--rsl-field-text);
    font-size: 0.9rem;
    cursor: pointer;
    gap: 0.5rem;
    transition:
        border-color 140ms ease,
        box-shadow 140ms ease,
        background 140ms ease;
}

.rsl-select-toggle:hover {
    border-color: #3b3f46;
}

.rsl-select[data-open="true"] .rsl-select-toggle {
    box-shadow: 0 0 0 1px var(--rsl-field-focus);
    border-color: var(--rsl-field-focus);
}

.rsl-select-value {
    flex: 1 1 auto;
    text-align: left;
}

.rsl-select-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.rsl-select[data-open="true"] .rsl-select-icon {
    transform: rotate(180deg);
}

/* Dropdown panel */

.rsl-select-list {
    margin: 0.25rem 0 0;
    padding: 0.25rem 0;
    border-radius: 10px;
    border: 1px solid var(--rsl-field-border);
    background: #050810;
    list-style: none;
    max-height: 230px;
    overflow-y: auto;
    font-size: 0.85rem;
    box-shadow:
        0 12px 30px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(15, 23, 42, 0.7);
    z-index: 30;
}

.rsl-select-option {
    padding: 0.4rem 0.7rem;
    cursor: pointer;
    color: var(--rsl-field-text);
    transition: background 120ms ease, color 120ms ease;
}

.rsl-select-option:hover {
    background: #111827;
}

.rsl-select-option[aria-selected="true"] {
    background: #141a28;
    color: #e5e7ff;
}

/* Toggle */

.rsl-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    cursor: pointer;
    user-select: none;
}

.rsl-toggle-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.rsl-toggle-track {
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: #111827;
    border: 1px solid var(--rsl-toggle-off);
    display: inline-flex;
    align-items: center;
    padding: 2px;
    transition:
        background 140ms ease,
        border-color 140ms ease;
}

.rsl-toggle-thumb {
    width: 17px;
    height: 17px;
    border-radius: 999px;
    background: var(--rsl-toggle-off);
    transform: translateX(0);
    transition:
        transform 140ms ease,
        background 140ms ease;
}

/* On state */
.rsl-toggle-input:checked + .rsl-toggle-track {
    border-color: var(--rsl-toggle-on);
    background: rgba(34, 197, 94, 0.1);
}

.rsl-toggle-input:checked + .rsl-toggle-track .rsl-toggle-thumb {
    transform: translateX(16px);
    background: var(--rsl-toggle-on);
}

.rsl-toggle-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.rsl-toggle-label {
    font-size: 0.9rem;
    color: var(--rsl-field-text);
}

.rsl-toggle-helper {
    font-size: 0.76rem;
    color: var(--rsl-field-muted);
}

/* Slider */

.rsl-slider {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-width: 320px;
}

.rsl-slider-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.rsl-slider-input {
    flex: 1 1 auto;
    appearance: none;
    height: 6px;
    border-radius: 999px;
    background: var(--rsl-slider-track);
    outline: none;
}

/* WebKit thumb & track */
.rsl-slider-input::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    background: var(--rsl-slider-fill);
    cursor: pointer;
    border: 2px solid #030712;
    margin-top: -5px;
}

.rsl-slider-input::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    background: var(--rsl-slider-fill);
    cursor: pointer;
    border: 2px solid #030712;
}

.rsl-slider-value {
    min-width: 3ch;
    text-align: right;
    font-size: 0.85rem;
    color: var(--rsl-field-text);
}

/* File tile */

.rsl-file-tile {
    border-radius: 12px;
    background: var(--rsl-file-bg);
    border: 1px dashed var(--rsl-field-border);
    padding: 0.75rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.rsl-file-label {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    cursor: pointer;
}

.rsl-file-icon {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #1f2937;
    color: #c4d0ff;
    font-size: 1.1rem;
}

.rsl-file-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.rsl-file-title {
    font-size: 0.9rem;
    color: var(--rsl-field-text);
}

.rsl-file-helper {
    font-size: 0.78rem;
    color: var(--rsl-field-muted);
}

.rsl-file-input {
    display: none;
}

.rsl-file-filename {
    font-size: 0.78rem;
    color: var(--rsl-field-muted);
}

/* Buttons & actions */

.rsl-form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.rsl-btn-primary,
.rsl-btn-ghost {
    border-radius: 999px;
    border: 1px solid var(--rsl-field-border);
    font-size: 0.9rem;
    padding: 0.45rem 1.1rem;
    cursor: pointer;
    background: transparent;
    color: var(--rsl-field-text);
    transition:
        background 140ms ease,
        border-color 140ms ease,
        box-shadow 140ms ease;
}

.rsl-btn-primary {
    background: #6e7bff;
    border-color: #6e7bff;
    color: #050816;
    font-weight: 600;
}

.rsl-btn-primary:hover {
    box-shadow: 0 8px 20px rgba(110, 123, 255, 0.45);
}

.rsl-btn-ghost:hover {
    background: rgba(148, 163, 184, 0.06);
}
