@layer components {
    * {
        font-family: var(--font-sans);
    }

    body {
        background: var(--bg-primary);
        color: var(--text-primary);
    }

    .font-mono {
        font-family: var(--font-mono);
    }

    /* Custom scrollbar */
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    ::-webkit-scrollbar-track {
        background: var(--bg-secondary);
    }

    ::-webkit-scrollbar-thumb {
        background: var(--border-default);
        border-radius: 4px;
    }

    ::-webkit-scrollbar-thumb:hover {
        background: var(--text-muted);
    }

    /* HTMX loading states */
    .htmx-request {
        opacity: 0.7;
        pointer-events: none;
    }

    /* Form inputs */
    .form-input {
        background: var(--bg-tertiary);
        border: 1px solid var(--border-input);
        color: var(--text-primary);
        border-radius: 0.5rem;
        padding: 0.75rem 1rem;
        font-size: 1rem;
        transition: all 0.2s ease;
        width: 100%;
    }

    .form-input:focus {
        outline: none;
        border-color: var(--accent-primary);
        box-shadow: 0 0 0 2px var(--accent-text);
    }

    .form-input::placeholder {
        color: var(--text-muted);
    }

    .form-input:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    /* Radio and Checkbox styling */
    .form-radio,
    .form-checkbox {
        appearance: none;
        -webkit-appearance: none;
        width: 1.25rem;
        height: 1.25rem;
        border: 2px solid var(--border-input);
        background: var(--bg-elevated);
        cursor: pointer;
        transition: all 0.2s ease;
        flex-shrink: 0;
        position: relative;
    }

    .form-radio {
        border-radius: 50%;
    }

    .form-checkbox {
        border-radius: 0.25rem;
    }

    .form-radio:hover,
    .form-checkbox:hover {
        border-color: var(--accent-secondary);
        box-shadow: 0 0 0 3px var(--accent-glow);
    }

    .form-radio:checked,
    .form-checkbox:checked {
        background: var(--accent-primary);
        border-color: var(--accent-primary);
    }

    .form-radio:checked::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 0.5rem;
        height: 0.5rem;
        background: var(--on-accent);
        border-radius: 50%;
    }

    .form-checkbox:checked::after {
        content: '';
        position: absolute;
        top: 1px;
        left: 5px;
        width: 5px;
        height: 10px;
        border: solid var(--on-accent);
        border-width: 0 2px 2px 0;
        transform: rotate(45deg);
    }

    /* Buttons */
    .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        font-weight: 500;
        line-height: 1.5;
        border-radius: 0.5rem;
        transition: all 0.2s ease;
        cursor: pointer;
        border: 1px solid transparent;
    }

    .btn:disabled,
    .btn[aria-disabled="true"] {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .btn-primary {
        background: var(--accent-primary);
        color: var(--on-accent);
    }

    .btn-primary:hover:not(:disabled) {
        background: var(--accent-hover);
    }

    .btn-secondary {
        background: var(--bg-tertiary);
        color: var(--text-primary);
        border-color: var(--border-subtle);
    }

    .btn-secondary:hover:not(:disabled) {
        background: var(--bg-elevated);
        border-color: var(--border-default);
    }

    .btn-ghost {
        background: transparent;
        color: var(--text-secondary);
    }

    .btn-ghost:hover:not(:disabled) {
        background: var(--bg-tertiary);
        color: var(--text-primary);
    }

    :focus-visible {
        outline: 2px solid var(--accent-secondary);
        outline-offset: 2px;
    }

    /* Cards */
    .card {
        background: var(--bg-secondary);
        border: 1px solid var(--border-subtle);
        border-radius: 0.75rem;
        padding: 1.5rem;
    }

    /* Progress bar */
    .progress-bar {
        height: 0.5rem;
        background: var(--bg-tertiary);
        border-radius: 9999px;
        overflow: hidden;
    }

    .progress-bar-fill {
        height: 100%;
        background: var(--accent-primary);
        border-radius: 9999px;
        transition: width 0.3s ease;
    }

    /* Modal backdrop */
    .modal-backdrop {
        position: fixed;
        inset: 0;
        background: var(--scrim);
        z-index: 50;
    }

    .modal-content {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: var(--bg-secondary);
        border: 1px solid var(--border-subtle);
        border-radius: 0.75rem;
        max-width: 600px;
        width: 90%;
        max-height: 90vh;
        overflow-y: auto;
        z-index: 51;
    }

    /* Question group */
    .question-group {
        border-left: 3px solid var(--accent-primary);
        padding-left: 1.5rem;
        margin-bottom: 2rem;
    }

    /* Required indicator */
    .required::after {
        content: ' *';
        color: var(--error-text);
    }
}
