/* ============================================
   FORMS — canonical input system
   New code uses .input. Legacy .newsletter-input
   and .tool-input keep their existing rules
   until they are migrated.
   ============================================ */

/* ============================================
   Base input
   ============================================ */
.input {
    width: 100%;
    padding: 0.625rem 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--font-md);
    line-height: var(--line-normal);
    outline: 2px solid transparent;
    outline-offset: 2px;
    transition: var(--transition-fast);
}

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

.input:hover:not(:disabled):not(:focus) {
    border-color: var(--color-border-light);
}

.input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
}

.input:focus-visible {
    outline-color: var(--color-primary);
}

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

/* ============================================
   Sizes
   ============================================ */
.input--sm {
    padding: 0.4rem 0.75rem;
    font-size: var(--font-sm);
    border-radius: var(--radius-md);
}

.input--lg {
    padding: 0.875rem 1.25rem;
    font-size: var(--font-base);
}

/* ============================================
   Modifiers
   ============================================ */
.input--mono {
    font-family: var(--font-mono);
}

.input--error,
.input[aria-invalid="true"] {
    border-color: var(--color-error);
}

.input--error:focus,
.input[aria-invalid="true"]:focus {
    border-color: var(--color-error);
    box-shadow: 0 0 0 3px rgba(var(--color-error-rgb), 0.15);
}

/* ============================================
   Textarea — same look as .input, just multi-line
   ============================================ */
textarea.input {
    resize: vertical;
    min-height: 6rem;
    line-height: var(--line-relaxed);
}

/* ============================================
   Form field — label + input + helper/error
   ============================================ */
.form-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.form-field-label {
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    line-height: var(--line-normal);
}

.form-field-label .form-field-required {
    color: var(--color-error);
    margin-left: 2px;
}

.form-field-helper {
    font-size: var(--font-xs);
    color: var(--color-text-muted);
    line-height: var(--line-normal);
}

.form-field-error {
    font-size: var(--font-xs);
    color: var(--color-error);
    line-height: var(--line-normal);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.form-field-error svg {
    width: var(--icon-xs);
    height: var(--icon-xs);
    flex-shrink: 0;
}

/* ============================================
   Form row — inline group of fields + button
   Simple case: <input class="input"> + <button class="btn">
   Multi-field case: several <.form-field> wrappers + <button class="btn">,
   each .form-field sized via .form-field--grow / --sm / --md.
   ============================================ */
.form-row {
    display: flex;
    gap: var(--space-sm);
    align-items: end;
}

.form-row > .input {
    flex: 1;
    min-width: 0;
}

.form-row > .form-field {
    min-width: 0;
}

.form-row > .btn {
    flex-shrink: 0;
}

/* Bump gap when the row contains labeled fields — separates field-pairs
   visually from the label-to-input gap inside each .form-field */
.form-row:has(> .form-field) {
    gap: var(--space-md);
}

/* ============================================
   Form field — sizing modifiers for use inside .form-row
   ============================================ */
.form-field--grow {
    flex: 1 1 220px;
}

.form-field--sm {
    /* Sized to fit a 5-digit port plus the .input-number-next spinner column */
    flex: 0 0 10ch;
}

.form-field--md {
    flex: 0 0 14ch;
}

@media (max-width: 480px) {
    .form-row {
        flex-direction: column;
        align-items: stretch;
    }

    .form-row > .btn {
        width: 100%;
    }

    .form-row > .form-field,
    .form-row > .form-field--grow,
    .form-row > .form-field--sm,
    .form-row > .form-field--md {
        flex: 1 1 auto;
        width: 100%;
    }
}

/* ============================================
   Segmented control — form-shape (flat, input-height)
   For in-form choices (TCP/UDP, On/Off, etc.). Distinct
   from .pricing-toggle-pill / .frequency-pills which are
   prominent pill-shaped marketing toggles.
   ============================================ */
.input-segmented {
    display: inline-flex;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition-fast);
}

.input-segmented:hover {
    border-color: var(--color-border-light);
}

.input-segmented:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
}

.input-segmented-btn {
    padding: 0.625rem 1rem;
    background: transparent;
    border: 0;
    color: var(--color-text-secondary);
    font-family: inherit;
    font-size: var(--font-md);
    font-weight: 500;
    line-height: var(--line-normal);
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.input-segmented-btn:not(:last-child) {
    border-right: 1px solid var(--color-border);
}

.input-segmented-btn:not(.active):hover {
    background: rgba(var(--color-primary-rgb), 0.05);
    color: var(--color-text);
}

.input-segmented-btn.active {
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
}

/* Sizes — match .input--sm / .input--lg */
.input-segmented--sm .input-segmented-btn {
    padding: 0.4rem 0.75rem;
    font-size: var(--font-sm);
}
.input-segmented--sm {
    border-radius: var(--radius-md);
}

.input-segmented--lg .input-segmented-btn {
    padding: 0.875rem 1.25rem;
    font-size: var(--font-base);
}

/* Inside .form-row, the segmented control should not stretch */
.form-row > .input-segmented {
    flex: 0 0 auto;
}

/* ============================================
   Select-next — fully custom dropdown
   Uses <select class="select-next"> as the source of truth.
   forms-select.js builds the visible widget alongside it and
   hides the native <select>. Form submission keeps working.
   ============================================ */
select.select-next {
    /* Hide the native control once the JS enhancer has wrapped it.
       Keep it as a focusable form-submit source via opacity/position
       trick — we set [data-select-next-enhanced] from JS so unenhanced
       selects (no JS) still render natively as a graceful fallback. */
}
select.select-next[data-select-next-enhanced="1"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    pointer-events: none;
}

.select-next-wrap {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    width: 100%;
}

.select-next-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    width: 100%;
    text-align: left;
    cursor: pointer;
    /* .input class is added by JS so we inherit padding/border/etc. */
}

.select-next-trigger:focus-visible {
    outline-color: var(--color-primary);
}

.select-next-trigger[disabled] {
    cursor: not-allowed;
    opacity: 0.5;
}

.select-next-value {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.select-next-value.is-placeholder {
    color: var(--color-text-muted);
}

.select-next-chevron {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    color: var(--color-text-secondary);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), color var(--transition-fast);
}

.select-next-trigger:hover:not([disabled]) .select-next-chevron,
.select-next-trigger:focus-visible:not([disabled]) .select-next-chevron {
    color: var(--color-primary);
}

.select-next-wrap[data-state="open"] .select-next-chevron,
.select-next-wrap[data-state="closing"] .select-next-chevron {
    transform: rotate(180deg);
    color: var(--color-primary);
}

.select-next-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    /* No `right: 0` — let the panel grow under content when an option
       is wider than the trigger (mirrors native <select> behaviour).
       min-width keeps it at least as wide as the trigger; max-width
       caps it so a single very long option doesn't blow out the row. */
    min-width: 100%;
    max-width: 24rem;
    width: max-content;
    z-index: 50;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    overflow: hidden; /* clip inner scroll content to the rounded shape */
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.35),
        0 0 0 1px rgba(var(--color-primary-rgb), 0.04),
        0 6px 24px rgba(var(--color-primary-rgb), 0.08);
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top center;
    transition: opacity 0.16s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.16s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.select-next-wrap[data-state="open"] .select-next-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.select-next-wrap[data-state="closing"] .select-next-panel {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    pointer-events: none;
}

/* The actual scroll surface — native scrollbar hidden across all
   engines (Firefox, Chromium, Safari, legacy Edge / IE). The list
   stays fully scrollable via wheel / trackpad / keyboard, and a
   custom "plump" scrollbar (.select-next-scrollbar + thumb, built
   from forms-select.js) overlays the right edge with full visual
   control — no native end buttons exist in this rendering path. */
.select-next-list {
    max-height: 18rem;
    overflow-y: auto;
    padding: var(--space-xs);
    /* padding-right gets bumped by JS only when the custom scrollbar
       is actually shown — otherwise option labels use the full width. */
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.select-next-list[data-scrollbar="visible"] {
    padding-right: calc(var(--space-xs) + 10px);
}
.select-next-list::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* ---- Plump custom scrollbar — overlays the right edge of the
   panel. Track is a faint tinted rail; thumb is primary-tinted and
   "puffs up" on hover via scaleX. Drag the thumb to scroll, click
   the track to jump. Designed to be lifted into a generic
   .scrollbar-plump rule once we apply it elsewhere on the site. ---- */
.select-next-scrollbar {
    position: absolute;
    top: var(--space-sm);
    right: 5px;
    bottom: var(--space-sm);
    width: 6px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.04);
    z-index: 1;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1),
                background 0.15s ease;
    transform-origin: center;
}

.select-next-scrollbar[hidden] {
    display: none;
}

.select-next-scrollbar:hover,
.select-next-scrollbar:has(.select-next-scrollbar-thumb.is-dragging) {
    background: rgba(255, 255, 255, 0.07);
    transform: scaleX(1.6);
}

.select-next-scrollbar-thumb {
    position: absolute;
    left: 0;
    right: 0;
    min-height: 28px;
    background: rgba(var(--color-primary-rgb), 0.45);
    border-radius: var(--radius-full);
    cursor: grab;
    touch-action: none;
    transition: background-color 0.15s ease;
}

.select-next-scrollbar-thumb:hover,
.select-next-scrollbar:hover .select-next-scrollbar-thumb {
    background: rgba(var(--color-primary-rgb), 0.65);
}

.select-next-scrollbar-thumb.is-dragging {
    background: rgba(var(--color-primary-rgb), 0.8);
    cursor: grabbing;
}

.select-next-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: 0;
    border-radius: var(--radius-lg);
    color: var(--color-text);
    font-family: inherit;
    font-size: var(--font-md);
    line-height: var(--line-normal);
    text-align: left;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.select-next-option + .select-next-option {
    margin-top: 1px;
}

.select-next-option:hover:not(:disabled),
.select-next-option:focus-visible:not(:disabled) {
    background: rgba(var(--color-primary-rgb), 0.1);
    color: var(--color-primary);
    outline: none;
}

.select-next-option[aria-selected="true"] {
    background: rgba(var(--color-primary-rgb), 0.14);
    color: var(--color-primary);
    font-weight: 600;
}

.select-next-option[aria-selected="true"]:hover {
    background: rgba(var(--color-primary-rgb), 0.2);
}

.select-next-option:disabled {
    color: var(--color-text-muted);
    cursor: not-allowed;
}

.select-next-option-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.select-next-check {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    color: var(--color-primary);
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.select-next-option[aria-selected="true"] .select-next-check {
    opacity: 1;
    transform: scale(1);
}

/* Live in a .form-row gracefully */
.form-row > .select-next-wrap {
    flex: 1 1 auto;
}

/* ============================================
   Number input — fully custom spinner
   <input type="number" class="input input-number-next">
   forms-number.js wraps the input with a slim spinner
   column on the right edge — two stacked chevron buttons,
   primary-tinted on hover, with hold-to-repeat acceleration
   and at-limit dimming. Native browser spinners are hidden
   in every engine. The input itself remains the source of
   truth: form submission, ↑/↓ keyboard, mouse wheel and
   typing all keep working unchanged. Sizes inherit from
   the input's .input--sm / .input--lg modifiers via the
   wrap's data-size attribute.
   ============================================ */

/* Hide native spinners across engines */
input[type="number"].input-number-next {
    -moz-appearance: textfield;
    appearance: textfield;
}
input[type="number"].input-number-next::-webkit-inner-spin-button,
input[type="number"].input-number-next::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-number-next-wrap {
    position: relative;
    display: block;
    width: 100%;
}

/* Reserve room on the right for the spinner column. The native
   value text gets a slimmer left padding too, so a 5-digit port
   still fits comfortably inside .form-field--sm (10ch). */
.input-number-next-wrap > .input-number-next {
    padding-right: 1.875rem;
}

.input-number-next-wrap[data-size="sm"] > .input-number-next {
    padding-right: 1.625rem;
}

.input-number-next-wrap[data-size="lg"] > .input-number-next {
    padding-right: 2.125rem;
}

/* The spinner column — sits inside the input's border, splits
   into two equal-height chevron buttons. The column itself is
   transparent; only the buttons take pointer events. */
.input-number-next-spinner {
    position: absolute;
    top: 1px;
    right: 1px;
    bottom: 1px;
    width: 1.5rem;
    display: flex;
    flex-direction: column;
    pointer-events: none;
}

.input-number-next-wrap[data-size="sm"] .input-number-next-spinner {
    width: 1.25rem;
}

.input-number-next-wrap[data-size="lg"] .input-number-next-spinner {
    width: 1.75rem;
}

.input-number-next-btn {
    flex: 1 1 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
    color: var(--color-text-muted);
    cursor: pointer;
    pointer-events: auto;
    transition: background-color 0.12s ease, color 0.12s ease, transform 0.08s ease, opacity 0.15s ease;
}

/* Hug the input's inner corners so the hover backdrop fills the
   matching radius. Account for the 1px input border. */
.input-number-next-btn--up {
    border-radius: 0 calc(var(--radius-lg) - 1px) 0 0;
}
.input-number-next-btn--down {
    border-radius: 0 0 calc(var(--radius-lg) - 1px) 0;
}

.input-number-next-wrap[data-size="sm"] .input-number-next-btn--up {
    border-radius: 0 calc(var(--radius-md) - 1px) 0 0;
}
.input-number-next-wrap[data-size="sm"] .input-number-next-btn--down {
    border-radius: 0 0 calc(var(--radius-md) - 1px) 0;
}

/* Awaken the chevrons whenever the input is hovered or focused
   anywhere. Keeps them present-but-restrained at idle. */
.input-number-next-wrap:hover .input-number-next-btn,
.input-number-next-wrap:focus-within .input-number-next-btn {
    color: var(--color-text-secondary);
}

/* Hover the specific button: primary-tinted backdrop + chevron */
.input-number-next-btn:hover:not([data-at-limit]):not([disabled]) {
    background: rgba(var(--color-primary-rgb), 0.12);
    color: var(--color-primary);
}

/* Active / held — deeper tint and a tiny push-down. data-pressed
   mirrors :active so the visual stays during pointer-capture or
   while the cursor briefly drifts off the button mid-hold. */
.input-number-next-btn[data-pressed],
.input-number-next-btn:active:not([data-at-limit]):not([disabled]) {
    background: rgba(var(--color-primary-rgb), 0.2);
    color: var(--color-primary);
    transform: scale(0.9);
}

.input-number-next-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
    z-index: 1;
}

.input-number-next-btn[data-at-limit] {
    color: var(--color-text-muted);
    opacity: 0.3;
    cursor: not-allowed;
}

.input-number-next-btn[disabled] {
    cursor: not-allowed;
    opacity: 0.4;
}

.input-number-next-btn svg {
    width: 11px;
    height: 11px;
    stroke-width: 2.5;
}

.input-number-next-wrap[data-size="sm"] .input-number-next-btn svg {
    width: 10px;
    height: 10px;
}

.input-number-next-wrap[data-size="lg"] .input-number-next-btn svg {
    width: 12px;
    height: 12px;
}

/* Whole input disabled — fade the spinner together with the input */
.input-number-next-wrap:has(.input-number-next:disabled) .input-number-next-spinner {
    opacity: 0.5;
    pointer-events: none;
}

/* Live in .form-row gracefully */
.form-row > .input-number-next-wrap {
    flex: 1 1 auto;
    min-width: 0;
}

/* ============================================
   Form examples — "Try: …" chip row
   Sits under a form to offer one-click prefill of canned
   inputs. Chips are pill-shaped, mono-typed, light-touch
   in idle and primary-tinted on hover with a small lift.
   forms-examples.js wires up generic prefill via
   data-fill-{name} attributes that target inputs in the
   wrap's [data-form="#id"] (or the closest <form>).
   ============================================ */
.form-examples {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    font-size: var(--font-sm);
}

.form-examples-label {
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-right: var(--space-xs);
    line-height: var(--line-normal);
}

.form-example-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.3rem 0.85rem;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(var(--color-primary-rgb), 0.18);
    border-radius: var(--radius-full);
    color: var(--color-text-secondary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: var(--line-normal);
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1),
                background-color 0.15s ease,
                border-color 0.15s ease,
                color 0.15s ease,
                box-shadow 0.2s ease;
}

.form-example-chip:hover:not(:disabled) {
    transform: translateY(-1px);
    background: rgba(var(--color-primary-rgb), 0.1);
    border-color: rgba(var(--color-primary-rgb), 0.5);
    color: var(--color-primary);
    box-shadow: 0 6px 14px rgba(var(--color-primary-rgb), 0.15);
}

.form-example-chip:active:not(:disabled) {
    transform: translateY(0);
    background: rgba(var(--color-primary-rgb), 0.16);
    box-shadow: 0 2px 6px rgba(var(--color-primary-rgb), 0.2);
}

.form-example-chip:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

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

/* Tone dots — optional left-of-label coloured circle that hints
   at the kind of example (success/warning/danger/info). Use via
   <button class="form-example-chip" data-tone="success">…</button>. */
.form-example-chip[data-tone]::before {
    content: '';
    flex-shrink: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.form-example-chip:hover[data-tone]::before {
    opacity: 1;
}

.form-example-chip[data-tone="success"]::before {
    background: var(--color-success);
    opacity: 0.85;
}
.form-example-chip[data-tone="warning"]::before {
    background: var(--color-warning);
    opacity: 0.85;
}
.form-example-chip[data-tone="danger"]::before {
    background: var(--color-error);
    opacity: 0.85;
}
.form-example-chip[data-tone="info"]::before {
    background: var(--color-primary);
    opacity: 0.85;
}

/* Chip with active state — used while the prefill is "current",
   so the user can see which example they last clicked. JS toggles
   it on click. */
.form-example-chip.is-active {
    background: rgba(var(--color-primary-rgb), 0.14);
    border-color: rgba(var(--color-primary-rgb), 0.55);
    color: var(--color-primary);
}

/* ============================================
   Form note — privacy / context callout under a form
   Soft elevated row with a small icon column (padlock by
   default — the privacy note that lives on every /tools/*
   page) and body text on the right. Faint primary-tinted
   backdrop and border. Replaces .tool-privacy-note.
   ============================================ */
.form-note {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    padding: 0.6rem 0.875rem;
    background: rgba(var(--color-primary-rgb), 0.05);
    border: 1px solid rgba(var(--color-primary-rgb), 0.16);
    border-radius: var(--radius-lg);
    color: var(--color-text-secondary);
    font-size: var(--font-sm);
    line-height: var(--line-normal);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.form-note:hover,
.form-note:focus-within {
    border-color: rgba(var(--color-primary-rgb), 0.28);
    background: rgba(var(--color-primary-rgb), 0.07);
}

.form-note-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 2px;
    color: var(--color-primary);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* When the link inside the note is hovered or focused, the lock
   "ticks" — small rotation that hints the icon is alive. */
.form-note:hover .form-note-icon,
.form-note:focus-within .form-note-icon {
    transform: rotate(-6deg);
}

.form-note-body {
    flex: 1 1 auto;
    min-width: 0;
}

.form-note-body strong {
    color: var(--color-text);
    font-weight: 600;
    margin-right: 4px;
}

.form-note-body a {
    color: var(--color-primary);
    text-decoration: none;
    border-bottom: 1px solid rgba(var(--color-primary-rgb), 0.4);
    transition: color 0.15s ease, border-color 0.15s ease;
}

.form-note-body a:hover,
.form-note-body a:focus-visible {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* Tone variants — default tint is primary (privacy). Other tones
   re-skin the same shape with status-colour backdrops, borders,
   and icon colour. Use sparingly; .form-note is meant for static
   informational notes, not for runtime feedback (use Alerts for
   that). */
.form-note--info {
    background: rgba(var(--color-info-rgb), 0.06);
    border-color: rgba(var(--color-info-rgb), 0.2);
}
.form-note--info .form-note-icon { color: var(--color-info); }
.form-note--info .form-note-body a {
    color: var(--color-info);
    border-bottom-color: rgba(var(--color-info-rgb), 0.4);
}
.form-note--info .form-note-body a:hover { border-bottom-color: var(--color-info); }

.form-note--warning {
    background: rgba(var(--color-warning-rgb), 0.06);
    border-color: rgba(var(--color-warning-rgb), 0.22);
}
.form-note--warning .form-note-icon { color: var(--color-warning); }
.form-note--warning .form-note-body a {
    color: var(--color-warning);
    border-bottom-color: rgba(var(--color-warning-rgb), 0.45);
}
.form-note--warning .form-note-body a:hover { border-bottom-color: var(--color-warning); }

.form-note--success {
    background: rgba(var(--color-success-rgb), 0.06);
    border-color: rgba(var(--color-success-rgb), 0.2);
}
.form-note--success .form-note-icon { color: var(--color-success); }
.form-note--success .form-note-body a {
    color: var(--color-success);
    border-bottom-color: rgba(var(--color-success-rgb), 0.4);
}
.form-note--success .form-note-body a:hover { border-bottom-color: var(--color-success); }

/* ============================================
   Form error — runtime error slot under a form
   Single-element container that consumer JS fills via
   textContent (no inner structure required). The warning
   icon lives in ::before so it survives every textContent
   update — paired with margin-left padding so the message
   text flows around the icon. Replaces .tool-error.
   Initial visibility via style="display: none" on the
   element; consumer toggles display: block to reveal.
   ============================================ */
.form-error {
    margin-top: var(--space-md);
    padding: 0.65rem 0.95rem 0.65rem 2.5rem;
    position: relative;
    background: rgba(var(--color-error-rgb), 0.08);
    border: 1px solid rgba(var(--color-error-rgb), 0.28);
    border-radius: var(--radius-lg);
    color: var(--color-error);
    font-size: var(--font-sm);
    line-height: var(--line-normal);
    box-shadow: 0 4px 12px rgba(var(--color-error-rgb), 0.08);
}

/* Warning-triangle icon — danger-coloured stroke baked into
   the data URL so the icon survives any textContent updates
   from consumer JS (.tool-error JS just sets el.textContent). */
.form-error::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0.85rem;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23D32F2F' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px 16px;
}

/* Empty error stays out of the way even if a stylesheet override
   accidentally removes display:none — keeps the form layout clean. */
.form-error:empty {
    display: none;
}

/* ============================================
   Form lead — short intro paragraph above a form
   The "what this tool does" / "what to expect" line that
   sets context before the input. Token-driven typography,
   constrained measure for readability, brighter colour
   on inline <strong> highlights. Replaces the two diverging
   definitions of .tool-check-description (style.css small-muted
   on home, tools.css md-secondary on /tools/*).
   ============================================ */
.form-lead {
    margin: 0 0 var(--space-md) 0;
    max-width: 60ch;
    color: var(--color-text-secondary);
    font-size: var(--font-md);
    line-height: var(--line-normal);
}

.form-lead strong {
    color: var(--color-text);
    font-weight: 600;
}

.form-lead a {
    color: var(--color-primary);
    text-decoration: none;
    border-bottom: 1px solid rgba(var(--color-primary-rgb), 0.4);
    transition: border-color 0.15s ease;
}

.form-lead a:hover,
.form-lead a:focus-visible {
    border-bottom-color: var(--color-primary);
}

/* Compact variant — for the home-page tool tabs where 5 descriptions
   are toggled in the same vertical slot and the rest of the card is
   tight. Smaller font, muted instead of secondary. */
.form-lead--compact {
    font-size: var(--font-sm);
    color: var(--color-text-muted);
}
