/* Split from the original style.css; loaded in original order (after style.css). */
/* ── Native Dialog ──────────────────────────────────────────────────────── */
dialog.native-dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-2);
    color: var(--text);
    box-shadow: var(--shadow);
    width: min(540px, calc(100vw - 2rem));
    max-height: 90vh;
    outline: none;
    z-index: 50;
}

dialog.native-dialog:not([open]) {
    display: none !important;
}

dialog.native-dialog[open] {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

dialog.native-dialog::backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
}

dialog.native-dialog.modal-panel--wide {
    width: min(800px, calc(100vw - 2rem));
}

/* ── Modals ────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
}

.modal-panel {
    position: relative;
    z-index: 1;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: min(540px, 100%);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-panel--wide {
    width: min(800px, 100%);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.modal-header .muted {
    font-size: var(--text-sm);
    margin-top: 0.2rem;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    scrollbar-gutter: stable both-edges;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.modal-body:focus {
    outline: none;
}

.modal-panel--wide .modal-body {
    padding: 1.5rem 1.75rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.6rem;
    flex-shrink: 0;
    box-sizing: border-box;
}

.modal-footer.modal-footer-stack,
.modal-footer:has(.modal-footer-stack) {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
}

.modal-footer-stack {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    width: 100%;
    box-sizing: border-box;
}

.modal-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    box-sizing: border-box;
}

.modal-footer-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
    margin-left: auto;
}

/* ── Sample modal content ──────────────────────────────────────────────── */
.sample-block {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sample-block-label {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sample-pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    font-family: var(--mono);
    font-size: var(--text-xs);
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 280px;
    overflow-y: auto;
    color: var(--text);
}

#sample-content {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.sample-block-label--split {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.results-title-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    /* Transparent 1px border keeps solid variants (.btn-primary, .btn-danger-solid)
       the exact same height as bordered variants (.btn-secondary, .btn-ghost). */
    border: 1px solid transparent;
    transition:
        opacity 0.15s,
        background 0.15s,
        box-shadow 0.15s;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}

/* :disabled only matches real form controls, so <a class="btn"> has to say it
   with aria-disabled — and would otherwise look fully clickable while dead. */
.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled):not([aria-disabled="true"]) {
    opacity: 0.9;
}

.btn-secondary {
    background: var(--bg-3);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled):not([aria-disabled="true"]) {
    background: var(--border);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled):not([aria-disabled="true"]) {
    color: var(--text);
    border-color: var(--text-muted);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--fail);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.btn-danger:hover:not(:disabled):not([aria-disabled="true"]) {
    background: rgba(239, 68, 68, 0.22);
}

/* Same geometry as .btn-primary; solid red for destructive toolbar actions. */
.btn-danger-solid {
    background: var(--fail);
    color: #fff;
}

.btn-danger-solid:hover:not(:disabled):not([aria-disabled="true"]) {
    opacity: 0.9;
}

.btn-sm {
    padding: 0.5rem 0.9rem;
    font-size: var(--text-xs);
}

.btn-xs {
    padding: 0.35rem 0.65rem;
    font-size: var(--text-xs);
}

/* A link that leaves the page says so with an arrow raised to the top-right of
   its label. The arrow is a visual cue only, so the span is aria-hidden and the
   link's name stays just "Gateway 记录". */
.btn-ext {
    align-self: flex-start;
    margin-top: 0.1rem;
    font-size: 0.9em;
    line-height: 1;
}

.btn.btn-danger-icon {
    flex-shrink: 0;
    /* Square, and as tall as the header inputs it deletes: a 2.2rem block sat
       visibly lower than the 2.5rem row it belongs to. Same token as the
       inputs, so both sides of the row stay level at every breakpoint. */
    width: var(--control-h);
    height: var(--control-h);
    padding: 0;
    background: transparent;
    color: var(--fail);
    border: 1px solid transparent;
}

.btn.btn-danger-icon:hover:not(:disabled):not([aria-disabled="true"]) {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.25);
}

/* ── Status / alerts ───────────────────────────────────────────────────── */
.state-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.alert {
    border-radius: var(--radius-sm);
    padding: 0.85rem 1.1rem;
    margin-bottom: 1rem;
    font-size: var(--text-sm);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-info {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--text);
}

.form-error {
    color: var(--fail);
    font-size: var(--text-xs);
    min-height: 1.2em;
}

.modal-footer-error {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    font-size: var(--text-sm);
    line-height: 1.4;
    text-align: left;
    overflow-wrap: anywhere;
    max-height: 6rem;
    overflow-y: auto;
}

.form-ok {
    color: var(--ok);
    font-size: var(--text-xs);
}

/* ── Misc ──────────────────────────────────────────────────────────────── */
.muted {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

/* Layout helpers. These exist so no markup needs a style attribute: the CSP
   sets style-src 'self', which blocks inline styles but not CSSOM writes. */
.empty-note {
    padding: 1rem 0;
}

.field-row {
    display: flex;
    gap: 0.5rem;
}

.settings-proxy-fields {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.settings-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.no-shrink {
    flex-shrink: 0;
}

.input-concurrency {
    width: 7rem;
}

.mono-list {
    font-family: var(--mono);
    font-size: var(--text-xs);
    word-break: break-all;
    line-height: 1.8;
}

code {
    font-family: var(--mono);
    background: var(--bg-3);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 1em;
}

.ok {
    color: var(--ok);
}

.fail {
    color: var(--fail);
}

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

.tabular-nums {
    font-variant-numeric: tabular-nums;
}
