[data-theme="pichcha"] {
    --paper: #fefcfa;
    --panel: #fefcfa;
    --ink: #201408;
    --muted: #786040;
    --accent: #b8903a;
    --accent-text: #90702d;
    --border: #f0e0c8;
    --field: #fefcfa;
    --field-border: #f0e0c8;
    --on-accent: #201408;
    --placeholder: #867054;
}

[data-theme="nil-manel"] {
    --paper: #f5f4ff;
    --panel: #f5f4ff;
    --ink: #180a30;
    --muted: #5848a0;
    --accent: #7060c0;
    --accent-text: #7060c0;
    --border: #c8bce8;
    --field: #f5f4ff;
    --field-border: #c8bce8;
    --on-accent: #ffffff;
    --placeholder: #7264b0;
}

[data-theme="binara"] {
    --paper: #f2f4ff;
    --panel: #f2f4ff;
    --ink: #080a28;
    --muted: #484890;
    --accent: #3848d0;
    --accent-text: #3848d0;
    --border: #b0b8f0;
    --field: #f2f4ff;
    --field-border: #b0b8f0;
    --on-accent: #ffffff;
    --placeholder: #6969a5;
}

[data-theme="nelum"] {
    --paper: #fff5f8;
    --panel: #fff5f8;
    --ink: #300018;
    --muted: #904060;
    --accent: #d45080;
    --accent-text: #bd4772;
    --border: #f0b8cc;
    --field: #fff5f8;
    --field-border: #f0b8cc;
    --on-accent: #240014;
    --placeholder: #a05b77;
}

[data-theme="erabudu"] {
    --paper: #fff8f4;
    --panel: #fff8f4;
    --ink: #280e00;
    --muted: #885030;
    --accent: #d05820;
    --accent-text: #bf511d;
    --border: #f0c8a8;
    --field: #fff8f4;
    --field-border: #f0c8a8;
    --on-accent: #1f0a00;
    --placeholder: #98664a;
}

[data-theme="kohomba"] {
    --paper: #f4f8f0;
    --panel: #f4f8f0;
    --ink: #161e08;
    --muted: #607048;
    --accent: #6a7a38;
    --accent-text: #687837;
    --border: #c8d4a8;
    --field: #f4f8f0;
    --field-border: #c8d4a8;
    --on-accent: #ffffff;
    --placeholder: #66754f;
}

[data-theme="lily"] {
    --paper: #fefdf8;
    --panel: #fefdf8;
    --ink: #201008;
    --muted: #8f6f4f;
    --accent: #c07840;
    --accent-text: #a36636;
    --border: #f0dfc0;
    --field: #fefdf8;
    --field-border: #f0dfc0;
    --on-accent: #201008;
    --placeholder: #8f6f4f;
}

[data-theme="rosamal"] {
    --paper: #fef8f5;
    --panel: #fef8f5;
    --ink: #281008;
    --muted: #956859;
    --accent: #d08870;
    --accent-text: #9a6553;
    --border: #f0d0c0;
    --field: #fef8f5;
    --field-border: #f0d0c0;
    --on-accent: #281008;
    --placeholder: #956859;
}

@media (max-width: 640px) {
    .btn-primary {
        gap: 6px;
        padding-left: 12px;
        padding-right: 12px;
        font-size: var(--text-sm);
    }

    .checkbox-label {
        align-items: flex-start !important;
    }

    .checkbox-box {
        margin-top: 5px;
    }
}

.layout {
    flex: 1;
}

:root {
    --split-sticky-top: 42px;
}

.column-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.alert {
    margin-bottom: 20px;
}

.field-row {
    display: flex;
    flex-direction: column;
}

#form > .field-row:first-of-type {
    margin-top: 18px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 0;
}

.btn {
    margin-top: 20px;
    line-height: var(--leading-control);
}

.input:disabled {
    background: var(--field-disabled, var(--field));
    border-color: var(--field-border);
    color: var(--muted);
    cursor: not-allowed;
    opacity: 0.65;
}

/* Glyph drawn with borders + pseudo-elements: an <img> costs a request and a data-URI background is refused by the CSP (img-src 'self' https:, no data:). Inherits currentColor to follow focus. */
.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--field);
    border: 1px solid var(--field-border);
    border-radius: var(--radius);
    transition: border-color 0.15s ease;
}

/* Border lives on the wrapper now; focus color moves to :focus-within. Left padding matches .input so all fields align. */
.input-wrap .input {
    flex: 1 1 auto;
    min-width: 0;
    /* Load-bearing: auto widths the input by its size attr (~240px min-content) and overflows the row; 100% contributes nothing intrinsic. */
    width: 100%;
    padding-right: 40px;
    background: transparent;
    border: 0;
    border-radius: 0;
}

.input-wrap:focus-within {
    border-color: var(--accent);
}

.input-wrap .input:focus {
    outline: none;
}

.input-wrap:has(.input.has-error) {
    border-color: var(--danger);
}

.input-wrap .input.has-error {
    border-color: transparent;
}

/* tabular-nums stops the slots shifting per keystroke. 0.1em tracking: capped at 0.12em by the audit (WCAG 1.4.12). */
.input--slots {
    letter-spacing: 0.1em;
    font-variant-numeric: tabular-nums;
}

.input-icon {
    position: absolute;
    right: 13px;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;
    border: 1.5px solid currentColor;
    border-radius: 3px;
    color: var(--placeholder);
    transition: color 0.15s ease;
    pointer-events: none;
}

.input-icon::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 3.5px;
    height: 1.5px;
    background: currentColor;
}

.input-icon::after {
    content: "";
    position: absolute;
    left: 3.5px;
    top: -2.5px;
    width: 1.5px;
    height: 5px;
    background: currentColor;
    box-shadow: 7px 0 0 currentColor;
}

.input-icon--clock {
    border-radius: 50%;
}

.input-icon--clock::before {
    display: none;
}

.input-icon--clock::after {
    left: 50%;
    top: 4px;
    height: 5px;
    transform: translateX(-50%);
    box-shadow: none;
    /* Minute hand as box-shadow: a rotated pseudo needs an origin awkward to express at this size. */
}

.input-wrap:focus-within .input-icon {
    color: var(--accent);
}

.input-wrap:hover .input-icon {
    color: var(--muted);
}

.textarea {
    resize: vertical;
    min-height: 44px;
    max-height: 168px;
    overflow-y: auto;
}

.textarea-tall {
    max-height: 300px;
}

.field-hint {
    margin-bottom: 5px;
}

/* Server marks edit mode on <html> in the first response, so this hides
   create-only parts before first paint. JS does the same later. */
html[data-mode="edit"] [data-create-only] {
    display: none !important;
}

.field-status {
    margin: 0;
    font-size: var(--text-xs);
    line-height: 1.5;
    color: var(--muted);
}

.field-status.is-error {
    color: var(--danger);
}

.swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.swatch {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 13px 8px 9px;
    background: var(--field);
    border: 1px solid var(--field-border);
    border-radius: 999px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--ink);
    transition: border-color 0.15s ease;
}

.swatch[aria-checked="true"] {
    /* Selected swatch: palette olive, 4.62:1 on #fff (needs 3:1 per WCAG 1.4.11). Named color so it reads as a choice, not a grey. */
    border-color: #90702d;
}

.swatch-chips {
    display: flex;
    gap: 3px;
}

.swatch-chips i {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.swatch-chips i:nth-child(1) {
    background: var(--paper);
}

.swatch-chips i:nth-child(2) {
    background: var(--accent);
}

.swatch-chips i:nth-child(3) {
    background: var(--ink);
}

.swatch-name {
    white-space: nowrap;
}

.column-side {
    display: flex;
    flex-direction: column;
}

/* Ready screen: drop the preview column. display:none (not visibility:hidden) so it takes no space and leaves the a11y tree. Shell stays 1000px so the header aligns. */
.shell.is-ready .column-side {
    display: none;
}

/* display:none leaves the 320px grid track behind, so collapse it too. Scoped here (not layout.css): is-ready is builder-only. */
.shell.is-ready .split {
    grid-template-columns: minmax(0, 1fr);
}

.credentials-block {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin-top: 22px;
}

.credentials-box {
    display: flex;
    flex-direction: column;
    padding: 4px 16px;
    background: var(--field);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
}

.credential {
    display: flex;
    align-items: baseline;
    gap: 16px;
    padding: 11px 0;
    min-width: 0;
}

.credential + .credential {
    border-top: 1px solid var(--field-border);
}

.credential-label {
    flex: none;
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    min-width: 62px;
}

.credential-value {
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    line-height: 1.5;
    color: var(--ink);
    text-align: left;
    overflow-wrap: anywhere;
}

.credential-value[type="password"],
.credential-value[type="text"] {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--field-border);
    border-radius: var(--radius);
    background: var(--field);
    color: var(--ink);
    font-family: var(--font-mono);
}

.credential-value[type="password"]:focus,
.credential-value[type="text"]:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-color: var(--accent);
}

.credential-secret .credential-value {
    flex: 1 1 auto;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    letter-spacing: 0.04em;
    color: var(--ink);
    line-height: 1.5;
    text-align: left;
}

.credential-secret .credential-value[type="password"],
.credential-secret .credential-value[type="text"] {
    font-size: var(--text-sm);
    letter-spacing: 0.04em;
}

.credentials-warn {
    margin: 0;
    font-size: var(--text-xs);
    line-height: 1.55;
    color: var(--muted);
}

/* .field already gives this margin-top and the label/hint/input gap -- only
   the divider is new here, separating it from the secret above. */
.recovery-email-block {
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.credentials-block .row-actions {
    align-items: center;
    margin-top: 2px;
}

/* Matched pair: equal size via flex-basis 0 so rewording one label can't skew them. Scoped here so .btn-copy stays small elsewhere. */
.credentials-block .credentials-actions {
    flex-wrap: nowrap;
    margin-top: 10px;
    margin-bottom: 10px;
}

.credentials-block .credentials-actions .btn {
    flex: 1 1 0;
    min-width: 0;
}

/* Both labels are real <span>s: a loose text node is an anonymous flex item and wraps differently, unmatching the heights. */
.credentials-block .credentials-actions .btn > span {
    min-width: 0;
    white-space: nowrap;
}

/* Below 480px the labels can't share a line (measured: 400 still clipped at 414px, 560 wasted room), so stack to full width. */
@media (max-width: 480px) {
    .credentials-block .credentials-actions {
        flex-direction: column;
    }

    .credentials-block .credentials-actions .btn {
        /* flex:none: basis 0 on the height axis collapses an auto-height column. */
        flex: none;
        width: 100%;
    }
}

/* .btn-copy's flex-shrink:0 is right elsewhere; here it must shrink. Stated outright, not left to shorthand specificity. */
.credentials-block .credentials-actions .btn-copy {
    flex-shrink: 1;
    padding: 12px 20px;
    font-size: var(--text-sm);
}

@media (min-width: 860px) {
    .field-row {
        flex-direction: row;
        gap: 16px;
    }

    .field-row .field {
        flex: 1 1 0;
        /* min-width:0 overrides the automatic min-content floor so the pair can share the width. */
        min-width: 0;
    }

    .btn-primary {
        width: auto;
        min-width: 210px;
    }
}

.saved-dialog {
    width: 100%;
    max-width: 320px;
    padding: 24px;
    background: var(--field);
    border: 1px solid var(--field-border);
    border-radius: var(--radius-lg);
    color: var(--ink);
    box-shadow: 0 18px 50px rgba(122, 104, 72, 0.14);
}

/* UA centers <dialog> with margin:auto; the flex column is the layout. */
.saved-dialog[open] {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.saved-dialog::backdrop {
    background: rgba(40, 34, 28, 0.42);
}

.saved-dialog-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
}

.saved-dialog-title {
    margin: 0;
    font-size: var(--text-md);
    font-weight: 500;
    line-height: 1.4;
    color: var(--accent);
}

.saved-dialog.is-error .saved-dialog-title {
    color: var(--danger);
}

.saved-dialog-text {
    margin: 0;
    color: var(--muted);
    font-size: var(--text-sm);
    line-height: 1.6;
}

/* Only centered dialog here: justify-content (not margin:auto) so a wrapped second button centres as a group. */
.saved-dialog .row-actions {
    margin-top: 0;
    justify-content: center;
}

.saved-dialog .btn {
    width: auto;
    margin-top: 0;
}

#previewFrame {
    height: var(--preview-height, 546px);
}

.submit-note {
    font-size: var(--text-xs);
    color: rgba(0, 0, 0, 0.6);
    line-height: var(--leading-snug);
    font-weight: 400;
    margin: 12px 0 0 0;
    padding: 0;
    text-align: left;
}

.submit-note a {
    color: inherit;
    text-decoration: underline;
}

#form {
    position: relative;
}

.submit-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.cf-turnstile {
    margin-top: 1.4em;
    width: 300px;
    max-width: 100%;
    height: 65px;
    min-height: 65px;
    line-height: 0;
    background: #f8f8f8;
}

.cf-turnstile iframe {
    display: block;
}

.checkbox-label {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--ink);
    user-select: none;
}

.checkbox-label .checkbox-input {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
    width: 20px;
    height: 20px;
    margin: 0;
}

.checkbox-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border: 1.5px solid #b8b0a4;
    border-radius: 3px;
    background: var(--field);
    transition: all 0.15s ease;
}

.checkbox-check {
    opacity: 0;
    transition: opacity 0.15s ease;
}

.checkbox-label:hover .checkbox-box {
    border-color: var(--accent);
}

.checkbox-label:has(.checkbox-input:checked) .checkbox-box {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-label:has(.checkbox-input:checked) .checkbox-check {
    opacity: 1;
}

.checkbox-label:has(.checkbox-input:disabled) {
    cursor: not-allowed;
    opacity: 0.6;
}

.checkbox-label:has(.checkbox-input:disabled) .checkbox-input {
    cursor: not-allowed;
}

.checkbox-label.disabled {
    cursor: not-allowed;
    opacity: 0.6;
    pointer-events: none;
}

#submit {
    min-width: 280px;
}

/* Time zone picker. The list sits over the fields below it, so it needs its own stacking. */
.combo {
    position: relative;
    display: flex;
    flex-direction: column;
}

.combo-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 240px;
    margin: 0;
    padding: 4px;
    overflow-y: auto;
    list-style: none;
    background: var(--field);
    border: 1px solid var(--field-border);
    border-radius: var(--radius);
    box-shadow: 0 18px 50px rgba(122, 104, 72, 0.14);
}

.combo-list[hidden] {
    display: none;
}

.combo-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--ink);
    font-size: var(--text-sm);
    line-height: var(--leading-control);
    cursor: pointer;
}

.combo-option[aria-selected="true"] {
    background: var(--paper);
}

.combo-empty {
    padding: 8px 10px;
    color: var(--muted);
    font-size: var(--text-sm);
}

.combo-offset {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: var(--text-xs);
}

/* Icon fields. Every single-line field gets an SVG glyph on the right, like the date and time fields. The globe, a leading icon, sits left of the time zone search. */
.input-icon--svg {
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 0;
}

.input-icon--svg::before,
.input-icon--svg::after {
    display: none;
}

.input-icon--svg svg {
    display: block;
    width: 100%;
    height: 100%;
}

.input-icon--chevron {
    width: 16px;
    height: 16px;
}

/* Leading icon sits left of the text, so the text gets room on that side too. */
.input-wrap--leading .input {
    padding-left: 42px;
}

.input-icon--leading {
    right: auto;
    left: 13px;
}

/* Covers the builder while the form and the card load, so neither half-built shows. */
.spinner {
    display: inline-flex;
    width: 15px;
    height: 15px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
