/* Keep the reset with the shared system so every public surface starts consistently. */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html:focus-within {
    scroll-behavior: smooth;
}

body,
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
    margin: 0;
}

ul[role="list"],
ol[role="list"] {
    list-style: none;
}

input,
button,
textarea,
select {
    font: inherit;
    margin: 0;
}

@media (prefers-reduced-motion: reduce) {
    html:focus-within {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

:root {
    --color-ink: #18223a;
    --color-muted: #647089;
    --color-canvas: #f5f7fb;
    --color-surface: #ffffff;
    --color-surface-subtle: #eef2f8;
    --color-border: #d9e0eb;
    --color-border-strong: #bac5d6;
    --color-primary: #5653d9;
    --color-primary-hover: #4441bd;
    --color-primary-soft: #eeedff;
    --color-accent: #0f9f8f;
    --color-accent-hover: #087f73;
    --color-danger: #b4232f;
    --color-danger-soft: #fff0f1;
    --color-warning-soft: #fff7dc;
    --shadow-sm: 0 1px 2px rgba(24, 34, 58, 0.06);
    --shadow-md: 0 12px 35px rgba(24, 34, 58, 0.13);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --content-width: 1500px;
    --z-dialog-backdrop: 1000;
    --z-header: 100;
    --z-dialog: 1010;
    --z-dialog-nested: 1020;
    --z-critical-notice: 1200;
}

html {
    min-height: 100%;
    background: var(--color-canvas);
}

body.site-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: var(--color-ink);
    background:
        radial-gradient(circle at 8% 4%, rgba(86, 83, 217, 0.08), transparent 26rem),
        var(--color-canvas);
    font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.55;
    text-rendering: optimizeSpeed;
}

.wrap {
    width: 100%;
    margin-inline: auto;
    max-width: var(--content-width);
    padding-inline: clamp(14px, 2.2vw, 32px);
}

h1,
h2,
h3,
h4 {
    color: var(--color-ink);
    letter-spacing: -0.025em;
    line-height: 1.2;
}

h1 {
    margin: 0 0 var(--space-4);
    font-size: clamp(1.9rem, 3vw, 2.55rem);
    font-weight: 750;
}

h2 {
    margin: 0 0 var(--space-3);
    font-size: clamp(1.35rem, 2vw, 1.75rem);
    font-weight: 700;
}

h3 {
    margin: 0 0 var(--space-2);
    font-size: 1.1rem;
    font-weight: 700;
}

h4 {
    font-weight: 700;
}

p,
ul,
ol {
    margin-top: 0;
    margin-bottom: var(--space-4);
}

a,
a:visited {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover,
a:focus-visible {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

a:not([class]) {
    text-decoration-skip-ink: auto;
}

blockquote {
    margin: var(--space-4) 0;
    padding-left: var(--space-4);
    border-left: 4px solid var(--color-border);
    color: var(--color-muted);
    font-style: italic;
}

:focus-visible {
    outline: 3px solid rgba(86, 83, 217, 0.32);
    outline-offset: 2px;
}

.skip-link {
    position: fixed;
    left: var(--space-4);
    top: var(--space-3);
    z-index: 2000;
    padding: 10px 14px;
    transform: translateY(-150%);
    border-radius: var(--radius-sm);
    background: var(--color-ink);
    color: white;
}

.skip-link:focus {
    transform: translateY(0);
}

.site-header {
    /* Keep the disclosure above sticky editor controls, but below every dialog. */
    position: relative;
    z-index: var(--z-header);
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(10px);
}

.site-header__inner {
    min-height: 76px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

#homeLinkUrl.site-brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--color-ink);
    text-decoration: none;
}

.site-brand__mark {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 13px;
    background: linear-gradient(145deg, var(--color-primary), #7974ef);
    color: white;
    box-shadow: 0 8px 18px rgba(86, 83, 217, 0.24);
}

.site-brand__mark svg {
    width: 24px;
    height: 24px;
}

.site-brand__copy {
    display: grid;
    line-height: 1.12;
}

.site-brand__name {
    font-size: clamp(1rem, 2vw, 1.28rem);
    font-weight: 750;
    letter-spacing: -0.035em;
}

.site-brand__tagline {
    margin-top: 4px;
    color: var(--color-muted);
    font-size: 0.76rem;
    letter-spacing: 0.015em;
}

.site-header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    white-space: nowrap;
}

.site-header__navigation {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}

.site-explore { position: relative; }
.site-explore > summary { list-style: none; }
.site-explore > summary::-webkit-details-marker { display: none; }
.site-explore[open] > summary { background: var(--color-primary-soft); border-color: var(--color-primary); }
.site-explore[open] .site-explore__chevron { transform: rotate(180deg); }
.site-explore__panel {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    width: min(310px, calc(100vw - 44px));
    padding: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    box-shadow: var(--shadow-md);
}
.site-explore__heading { margin: 0; padding: var(--space-2) var(--space-3); color: var(--color-muted); font-size: .75rem; font-weight: 700; }
.site-explore__panel a { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border-radius: var(--radius-sm); color: var(--color-ink); text-decoration: none; }
.site-explore__panel a > svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--color-primary); }
.site-explore__panel strong, .site-explore__panel small { display: block; }
.site-explore__panel strong { font-size: .9rem; }
.site-explore__panel small { margin-top: 2px; font-size: .75rem; color: var(--color-muted); }
.site-explore__panel a:hover, .site-explore__panel a[aria-current="page"] { background: var(--color-primary-soft); }
.site-explore__panel a[aria-current="page"] strong { color: var(--color-primary); text-decoration: underline; text-underline-offset: 3px; }

.header-action {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-ink) !important;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.header-action:hover {
    background: var(--color-surface-subtle);
    text-decoration: none;
}

.header-action svg {
    width: 18px;
    height: 18px;
}

.header-action--quiet {
    border-color: transparent;
    background: transparent;
    color: var(--color-muted) !important;
    box-shadow: none;
}

.site-main {
    width: 100%;
    display: flex;
    justify-content: center;
    flex-direction: row;
    flex: 1 0 auto;
    padding-top: var(--space-5);
    padding-bottom: var(--space-5);
    gap: var(--space-4);
}

#mainleft:empty,
#mainright:empty {
    display: none;
}

#mainmiddle {
    flex: 1 1 auto;
    min-width: 0;
}

.site-below-main {
    width: 100%;
}

#belowmain {
    max-width: 950px;
    margin-inline: auto;
}

.site-footer {
    flex: 0 0 auto;
    margin-top: auto;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-muted);
}

.site-footer__inner {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    font-size: 0.9rem;
}

.site-footer nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-4);
}

.site-footer a[aria-current="page"] { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* Give labelled navigation its own row before it can crowd the brand or account actions. */
@media (max-width: 640px) {
    .site-header__inner { flex-wrap: wrap; padding-block: var(--space-3); }
    .site-header__navigation { width: 100%; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2); }
    .site-explore__panel { left: 0; right: auto; }
}

input:not([type="button"]):not([type="submit"]):not([type="radio"]):not([type="checkbox"]):not([type="file"]),
textarea,
select {
    min-height: 42px;
    margin: 0;
    padding: 8px 10px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    background-image: none;
    color: var(--color-ink);
}

/* Enabled selects are direct actions, while disabled selects should not appear interactive. */
select:not(:disabled) {
    cursor: pointer;
}

select:disabled {
    cursor: not-allowed;
}

input:not([type="button"]):not([type="submit"]):focus,
textarea:focus,
select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(86, 83, 217, 0.14);
    outline: none;
}

/* Button colours describe the action's role; the base class only supplies structure. */
.btn {
    width: auto;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-ink);
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.btn:hover {
    background: var(--color-surface-subtle);
    color: var(--color-ink);
    text-decoration: none;
}

.btn-primary,
.btn-primary:visited {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    color: white;
    text-decoration: none;
}

.btn-secondary,
.btn-secondary:visited {
    border-color: var(--color-border);
    background: var(--color-surface-subtle);
    color: var(--color-ink);
}

.btn-secondary:hover {
    background: #e2e7f0;
    color: var(--color-ink);
}

.btn-danger,
.btn-danger:visited {
    border-color: #f3c7cc;
    background: var(--color-danger-soft);
    color: var(--color-danger);
}

.btn-danger:hover {
    background: #ffe0e3;
    color: #8c1822;
}

.btn-success,
.btn-success:visited {
    border-color: var(--color-accent);
    background: var(--color-accent);
    color: white;
}

.btn-success:hover {
    border-color: var(--color-accent-hover);
    background: var(--color-accent-hover);
    color: white;
}

.btn-quiet,
.btn-quiet:visited {
    border-color: transparent;
    background: transparent;
    color: var(--color-primary);
    box-shadow: none;
}

.btn-quiet:hover {
    background: var(--color-primary-soft);
    color: var(--color-primary-hover);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.58;
    cursor: not-allowed;
    box-shadow: none;
}

.icon-button,
.event-action,
.text-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-color: var(--color-border);
    color: var(--color-ink);
    cursor: pointer;
}

.icon-button {
    width: 40px;
    height: 40px;
    padding: 8px;
    border-radius: var(--radius-sm);
    background: var(--color-surface);
}

.icon-button svg,
.text-icon-button svg {
    width: 20px;
    height: 20px;
}

.text-icon-button {
    gap: 5px;
    padding: 6px 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--color-surface);
}

.icon-button:hover,
.text-icon-button:hover,
.event-action:hover {
    background: var(--color-surface-subtle);
}

.operation-message,
.status-panel {
    width: min(100% - 28px, 900px);
    margin: var(--space-3) auto 0;
    padding: var(--space-3) var(--space-4);
    border: 1px solid #a7ded5;
    border-radius: var(--radius-md);
    background: #e9faf7;
    color: #12675e;
}

.operation-message {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.operation-message--warning {
    position: fixed;
    top: max(var(--space-3), env(safe-area-inset-top));
    left: 50%;
    z-index: var(--z-critical-notice);
    margin: 0;
    transform: translateX(-50%);
    border-color: #e4c36a;
    background: #fff8df;
    color: #6b4f00;
    box-shadow: var(--shadow-md);
}

.operation-message__action {
    flex: 0 0 auto;
}

.request-wait-notice:not([hidden]) {
    position: fixed;
    top: max(var(--space-3), env(safe-area-inset-top));
    right: var(--space-3);
    z-index: calc(var(--z-critical-notice) - 1);
    max-width: min(320px, calc(100vw - 24px));
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    box-shadow: var(--shadow-md);
    color: var(--color-ink);
    pointer-events: none;
}

.request-wait-status:not([hidden]) {
    display: block;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    background: var(--color-surface-subtle);
    color: var(--color-ink);
}

.web_dialog_overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-dialog-backdrop);
    display: none;
    width: 100%;
    height: 100%;
    background: #0e1730;
    opacity: 0.68;
    backdrop-filter: blur(2px);
}

/* Native confirmation stays above editor dialogs and keeps its own focus boundary. */
.shared-confirm-dialog {
    width: min(420px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-ink);
    box-shadow: var(--shadow-md);
}

.shared-confirm-dialog::backdrop {
    background: rgba(14, 23, 48, 0.68);
}

.shared-confirm-dialog__body {
    position: relative;
    padding: 24px;
}

.shared-confirm-dialog__close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: var(--color-surface-subtle);
    color: var(--color-ink);
    cursor: pointer;
}

.shared-confirm-dialog__icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff0ef;
    color: var(--color-danger);
}

.shared-confirm-dialog__icon svg { width: 20px; height: 20px; }
.shared-confirm-dialog h2 { margin: 14px 0 8px; font-size: 1.25rem; }
.shared-confirm-dialog p { margin: 0; }
.shared-confirm-dialog__error { margin-top: 12px !important; color: var(--color-danger); }
.shared-confirm-dialog__actions { margin-top: 22px; }

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: var(--z-dialog);
    display: none;
    width: calc(100% - 20px);
    max-width: 585px;
    max-height: calc(100% - 20px);
    transform: translate(-50%, -50%);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: clamp(18px, 3vw, 28px);
    background: var(--color-surface);
    box-shadow: var(--shadow-md);
    overflow-y: auto;
}

.modal > h2:first-of-type {
    padding-right: 38px;
}

.close-icon {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: 0;
    border-radius: 50%;
    background: var(--color-surface-subtle);
    color: var(--color-ink);
    box-shadow: none;
    cursor: pointer;
}

.close-icon svg {
    width: 18px;
    height: 18px;
}

.close-icon:hover {
    background: #e2e7f0;
}

.modalButtonOuter {
    display: inline-block;
    width: auto;
    min-width: 130px;
    text-align: center;
}

.modalButton {
    width: 100%;
}

.form-card,
.content-card {
    width: min(100%, 720px);
    margin-inline: auto;
    padding: clamp(20px, 4vw, 36px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
}

.form-card--narrow {
    max-width: 560px;
}

.auth-result__icon {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    margin-bottom: var(--space-4);
    border-radius: 14px;
    background: var(--color-primary-soft);
    color: var(--color-primary);
}

.auth-result__icon svg {
    width: 26px;
    height: 26px;
}

.auth-result__icon--success {
    background: #e9faf7;
    color: var(--color-accent-hover);
}

.auth-result__icon--danger {
    background: var(--color-danger-soft);
    color: var(--color-danger);
}

.form-field {
    display: grid;
    gap: 6px;
    margin-bottom: var(--space-4);
}

.form-field label {
    font-weight: 700;
}

.form-field input,
.form-field textarea,
.form-field select {
    width: 100%;
}

.form-actions,
.dialog-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-5);
}

.eyebrow {
    margin-bottom: var(--space-2);
    color: var(--color-primary);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.lede {
    color: var(--color-muted);
    font-size: 1.06rem;
}

.table-scroll {
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    vertical-align: top;
}

.data-table thead th {
    background: var(--color-surface-subtle);
    color: var(--color-muted);
    font-size: 0.78rem;
    letter-spacing: 0.045em;
    text-transform: uppercase;
}

.data-table tbody tr:hover {
    background: #fafbfe;
}

.text-danger,
.field-validation-error,
.validation-summary-errors {
    color: var(--color-danger);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.operation-message[hidden] {
    display: none;
}

@media (max-width: 700px) {
    .operation-message {
        align-items: stretch;
        flex-direction: column;
    }

    .operation-message__action {
        width: 100%;
    }

    .site-header__inner {
        min-height: 66px;
    }

    .site-brand__mark {
        width: 38px;
        height: 38px;
        border-radius: 11px;
    }

    .site-brand__tagline {
        display: none;
    }

    .site-header__actions .header-action {
        min-height: 38px;
        padding-inline: 10px !important;
        font-size: 0.9rem;
    }

    .site-main {
        padding-top: var(--space-4);
    }

    .site-footer__inner {
        padding-block: var(--space-4);
        flex-direction: column;
        justify-content: center;
    }

    .modal {
        width: calc(100% - 20px);
        max-height: calc(100% - 20px);
    }
}

@media (max-width: 420px) {
    .site-header__inner {
        gap: var(--space-2);
    }

    .site-header__actions {
        gap: 2px;
    }

    .site-header__actions .header-action {
        padding-inline: 7px !important;
        font-size: 0.8rem;
    }
}
