/* Tool page components on the shared layout tokens (assets/layout/layout.css). Bootstrap-free.
   Covers the page frame (head, cards, fields, buttons) and the result widgets the checker pages build in JS:
   verdict banner, check rows, badges, raw JSON panel, toasts, the unified loader and the history panel. */

/* ---------- page frame ----------
   A tool page fills the content area, capped only on very wide screens; a page's own stylesheet (loaded after this
   file by includes/layout.php) can change the cap, e.g. `.rb-page { max-width: none; }` for a full-width workbench.
   Inside, single-line fields and hint text keep a readable measure so a simple form does not stretch across the
   screen, while result grids, tables and cards use the whole width. */
.tool-page { --tool-field-max: 760px; max-width: 1680px; min-width: 0; display: grid; gap: 20px; align-content: start; }
.tool-page .ui-input-row,
.tool-page .ui-field > .ui-input,
.tool-page .ui-field > input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
.tool-page .ui-field > select { max-width: var(--tool-field-max); }
.tool-page .ui-hint, .tool-page .input-hint { max-width: 90ch; }
.tool-head { display: grid; gap: 4px; }
.tool-eyebrow { margin: 0; font-family: var(--f-mono); font-size: 11.5px; color: var(--faint); }
.tool-head h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.02em; color: var(--ink); }
.tool-head p { margin: 0; max-width: 68ch; color: var(--dim); }

.ui-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); padding: 18px; display: grid; gap: 16px; }
.ui-card-sub { background: var(--sub); }
.ui-field { display: grid; gap: 6px; min-width: 0; }
.ui-label { display: flex; align-items: center; gap: 6px; font-weight: 500; color: var(--ink); }
.ui-label-note { font-weight: 400; color: var(--faint); }
.ui-input-row { display: flex; gap: 8px; min-width: 0; }
/* border, colours and the hover / focus / invalid / disabled states come from assets/layout/controls.css */
.ui-input, .ui-field input[type="text"], .ui-field input[type="search"], .ui-field input[type="url"] {
    flex: 1; min-width: 0; width: 100%; height: 36px; padding: 0 10px;
    font-family: var(--f-mono); font-size: 12.5px;
}
.ui-input::placeholder, .ui-field input::placeholder { font-family: var(--f-sans); font-size: 13px; }
.ui-hint, .input-hint { display: block; font-size: 12px; color: var(--faint); line-height: 1.5; }
.ui-hint a, .input-hint a { color: var(--dim); text-decoration: underline; text-decoration-color: var(--line2); text-underline-offset: 2px; }
.ui-hint a:hover, .input-hint a:hover { color: var(--accent); text-decoration-color: currentColor; }

.ui-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ui-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
    border: 1px solid var(--line2); border-radius: 6px; background: var(--bg); color: var(--ink);
    font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.ui-btn:hover { background: var(--hover); text-decoration: none; }
.ui-btn-pri { background: var(--pri); color: var(--pri-ink); border-color: var(--pri); }
.ui-btn-pri:hover { background: var(--pri); opacity: .88; }
.ui-btn-ghost { border-color: transparent; background: none; color: var(--dim); }
.ui-btn-ghost:hover { color: var(--ink); }
.ui-btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.ui-btn .lay-i { width: 14px; height: 14px; }

.ui-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ui-chip {
    display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 999px;
    border: 1px solid var(--line2); background: var(--bg); color: var(--dim); font-size: 12px; cursor: pointer; font-family: inherit;
}
.ui-chip:hover { color: var(--ink); border-color: var(--faint); }

/* related tools row */
.tool-related { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--faint); font-size: 12px; }
.tool-related a {
    display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 6px;
    border: 1px solid var(--line); color: var(--dim); background: var(--bg);
}
.tool-related a:hover { color: var(--ink); border-color: var(--line2); background: var(--hover); text-decoration: none; }
.tool-related .lay-i { width: 14px; height: 14px; }

/* DNS checker record picker */
.record-selector-card { display: grid; gap: 10px; }
.record-selector-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.record-selector-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.record-selector-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.record-option {
    display: flex; align-items: flex-start; gap: 9px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
    background: var(--bg); cursor: pointer; transition: border-color .12s, background .12s; min-width: 0;
}
.record-option:hover { border-color: var(--line2); background: var(--hover); }
.record-option.active { border-color: color-mix(in srgb, var(--accent) 45%, var(--line2)); }
.record-option input { margin: 1px 0 0; flex: none; }
.record-option-title { display: block; font-family: var(--f-mono); font-size: 12px; font-weight: 500; color: var(--ink); }
.record-option-note { display: block; font-size: 11.5px; color: var(--faint); line-height: 1.35; }
.record-selector-summary { font-size: 12px; color: var(--dim); }

/* help icon + popover */
.help-icon {
    display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
    border: 1px solid var(--line2); color: var(--faint); font-size: 10px; font-weight: 600; cursor: default; user-select: none;
}
.help-icon:hover, .help-icon:focus-visible { color: var(--ink); border-color: var(--faint); }
.help-popover {
    position: absolute; z-index: 300; width: min(300px, calc(100vw - 32px)); padding: 10px 12px;
    background: var(--bg); color: var(--ink); border: 1px solid var(--line2); border-radius: 8px; box-shadow: var(--shadow);
    font-size: 12.5px; font-weight: 400; line-height: 1.5;
}
.help-popover-header { font-weight: 600; margin-bottom: 4px; }
.help-popover-header strong { font-weight: 600; }
.help-popover-body { color: var(--dim); }
.help-popover-body strong { color: var(--ink); font-weight: 500; }

/* ---------- results ---------- */
.quick-summary:empty { display: none !important; }
.verdict-banner {
    display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px;
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg);
}
.verdict-icon { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; }
.verdict-icon svg { width: 16px; height: 16px; }
.verdict-pass .verdict-icon { background: var(--ok-bg); color: var(--ok); }
.verdict-warn .verdict-icon { background: var(--warn-bg); color: var(--warn); }
.verdict-fail .verdict-icon { background: var(--bad-bg); color: var(--bad); }
.verdict-pass { box-shadow: inset 3px 0 0 var(--ok); }
.verdict-warn { box-shadow: inset 3px 0 0 var(--warn); }
.verdict-fail { box-shadow: inset 3px 0 0 var(--bad); }
.verdict-text { display: grid; gap: 3px; min-width: 0; }
.verdict-text h3, .verdict-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink); }
.verdict-text p, .verdict-message { margin: 0; color: var(--dim); overflow-wrap: anywhere; }
.verdict-text strong { color: var(--ink); font-weight: 500; }
.verdict-domain { font-family: var(--f-mono); font-size: 12px; color: var(--ink); }

.friendly-result-wrapper { min-width: 0; }
.output-title { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.technical-details-accordion { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); min-width: 0; }
.technical-details-accordion > summary {
    display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; list-style: none;
    font-weight: 500; color: var(--ink); user-select: none;
}
.technical-details-accordion > summary::-webkit-details-marker { display: none; }
.technical-details-accordion > summary::before {
    content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--faint); border-bottom: 1.5px solid var(--faint);
    transform: rotate(-45deg); transition: transform .12s; flex: none; margin-right: 2px;
}
.technical-details-accordion[open] > summary::before { transform: rotate(45deg); }
.technical-details-accordion[open] > summary { border-bottom: 1px solid var(--line); }
.technical-details-body { padding: 4px 0 6px; }
.friendly-result-wrapper > .check-section { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }

.check-section { padding: 0; }
.check-section + .check-section { border-top: 1px solid var(--line); }
.check-section-title {
    padding: 10px 14px 6px; font-size: 11.5px; font-weight: 500; color: var(--faint); letter-spacing: .01em;
}
.check-row {
    display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); min-width: 0;
}
.check-section-title + .check-row { border-top: 0; }
.check-row.expandable { cursor: pointer; }
.check-row.expandable:hover { background: var(--sub); }
.check-row.expandable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.check-status { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; margin-top: 1px; }
.check-status svg { width: 12px; height: 12px; }
.check-pass { background: var(--ok-bg); color: var(--ok); }
.check-fail { background: var(--bad-bg); color: var(--bad); }
.check-warn { background: var(--warn-bg); color: var(--warn); }
.check-info { background: var(--accent-bg); color: var(--accent); }
.check-content { flex: 1; min-width: 0; display: grid; gap: 4px; }
.check-main { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.check-label-group { display: grid; gap: 2px; min-width: 0; }
.check-label { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
.check-hint { color: var(--dim); font-size: 12.5px; }
.check-hint strong { color: var(--ink); font-weight: 500; }
.check-value {
    font-family: var(--f-mono); font-size: 12px; color: var(--dim); overflow-wrap: anywhere;
    padding: 6px 8px; background: var(--sub); border: 1px solid var(--line); border-radius: 6px;
}
.check-value a { color: var(--accent); }
.check-toggle { display: inline-flex; align-items: center; gap: 6px; flex: none; font-size: 12px; color: var(--faint); white-space: nowrap; }
.check-toggle-icon {
    width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg); margin-top: -3px; transition: transform .12s;
}
.check-row.expanded .check-toggle-icon { transform: rotate(-135deg); margin-top: 3px; }
.check-row:hover .check-toggle { color: var(--ink); }
.check-expand-hint { font-size: 11.5px; color: var(--faint); }
.check-row.expanded .check-expand-hint { display: none; }
.check-details { display: none; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; cursor: default; }
.check-details.visible { display: block; }
.check-details-row {
    display: grid; grid-template-columns: minmax(110px, 180px) minmax(0, 1fr); gap: 12px; padding: 7px 10px;
    border-top: 1px solid var(--line); font-size: 12px; position: relative;
}
.check-details-row:first-child { border-top: 0; }
.check-details-label { color: var(--faint); }
.check-details-value { font-family: var(--f-mono); color: var(--ink); overflow-wrap: anywhere; white-space: pre-wrap; }
.check-details-copyable { cursor: pointer; }
.check-details-copyable:hover { background: var(--sub); }
.check-details-row.copied { background: var(--ok-bg); }
.check-details-row.copied::after { content: "Copied"; position: absolute; right: 10px; top: 7px; font-size: 11px; color: var(--ok); font-family: var(--f-sans); }

/* status badge: a dot plus a word */
.badge, [class^="badge-"], [class*=" badge-"] {
    display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; white-space: nowrap;
    padding: 0; background: none; border: 0; border-radius: 0; line-height: 1.4; vertical-align: middle;
}
.badge::before, [class^="badge-"]::before, [class*=" badge-"]::before {
    content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none;
}
.badge-pass { color: var(--ok); }
.badge-warn { color: var(--warn); }
.badge-fail { color: var(--bad); }
.badge-info { color: var(--accent); }

.info-callout {
    display: flex; gap: 10px; align-items: flex-start; margin: 10px 14px 6px; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: 8px; background: var(--sub); color: var(--dim);
}
.info-callout svg { flex: none; width: 16px; height: 16px; color: var(--accent); margin-top: 1px; }
.info-callout strong { color: var(--ink); font-weight: 500; }
.info-callout.is-error { border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: var(--bad-bg); color: var(--bad); }
.info-callout.is-error svg { color: var(--bad); }

/* raw JSON panel (toolbox_render_raw_json_panel) */
.toolbox-raw-json-panel .result-box { position: relative; padding: 0; }
.result-box pre {
    margin: 0; padding: 14px 16px; max-height: 520px; overflow: auto; background: var(--sub);
    font-family: var(--f-mono); font-size: 12px; line-height: 1.65; color: var(--dim); white-space: pre; tab-size: 2;
    border-radius: 0 0 var(--radius) var(--radius);
}
.result-box code { font-family: inherit; font-size: inherit; color: inherit; background: none; padding: 0; }
.copy-wrapper {
    position: absolute; top: 8px; right: 10px; z-index: 1; display: inline-flex; align-items: center; gap: 4px;
    height: 24px; padding: 0 8px; border: 1px solid var(--line2); border-radius: 6px; background: var(--bg);
    color: var(--dim); font-size: 11.5px; cursor: pointer; user-select: none;
}
.copy-wrapper:hover { color: var(--ink); border-color: var(--faint); }
.json-key { color: var(--k); }
.json-string { color: var(--s); }
.json-number, .json-boolean, .json-null { color: var(--n); }
.xml-tag { color: var(--k); }
.xml-attribute { color: var(--n); }
.xml-value { color: var(--s); }

/* ---------- toasts (assets/toast.js) ---------- */
#global-toast { display: none !important; }
#toast-container {
    position: fixed; top: 60px; right: 16px; z-index: 400; display: flex; flex-direction: column; gap: 8px;
    width: min(360px, calc(100vw - 32px)); pointer-events: none;
}
.toast-notification {
    pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; cursor: pointer;
    background: var(--bg); color: var(--ink); border: 1px solid var(--line2); border-radius: 8px; box-shadow: var(--shadow);
    font-size: 13px; line-height: 1.45; overflow-wrap: anywhere;
    opacity: 0; transform: translateY(-6px); transition: opacity .2s ease, transform .2s ease;
}
.toast-notification::before { content: ""; flex: none; width: 7px; height: 7px; margin-top: 6px; border-radius: 50%; background: var(--accent); }
.toast-notification.success::before { background: var(--ok); }
.toast-notification.error::before { background: var(--bad); }
.toast-notification.warning::before { background: var(--warn); }
.toast-notification.show { opacity: 1; transform: none; }
.toast-notification.hide { opacity: 0; transform: translateY(-6px); }
.toast-notification a { color: var(--accent) !important; text-decoration: underline !important; }
.toast-notification span[style*="grayscale"] { filter: none !important; }
/* suggestion buttons the checkers put inside toasts (old Bootstrap class names) */
.toast-notification .btn {
    display: inline-flex; align-items: center; height: 26px; padding: 0 9px; margin: 2px 0 0; border-radius: 6px;
    border: 1px solid var(--line2); background: var(--bg); color: var(--ink); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer; text-decoration: none !important;
}
.toast-notification .btn:hover { background: var(--hover); }

/* ---------- unified loader (assets/loading.js) ----------
   The checkers' loading card looks like admin's loading states: a slim bar along the card's top edge (indeterminate,
   or the real percentage), a ring spinner beside the status text and shimmer skeleton lines standing in for the
   result. The old pulse / wave / spinner styles all show this one look. Animation lives in assets/layout/motion.css. */
.unified-loader {
    display: none; position: relative; overflow: hidden; grid-template-columns: minmax(0, 1fr); gap: 8px; align-content: start;
    padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg);
}
.unified-loader.is-visible { display: grid; }
.unified-loader .loader-bar,
.unified-loader[data-style] .loader-bar { display: block; position: absolute; left: 0; right: 0; top: 0; width: auto; height: 2px; border-radius: 0; background: transparent; overflow: hidden; }
.loader-bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 0 2px 2px 0; }
.loader-bar-fill.indeterminate { width: 40% !important; }
.unified-loader .loader-pulse, .unified-loader .loader-wave, .unified-loader .loader-spinner { display: none !important; }
.loader-status-row { display: inline-flex; align-items: center; gap: 8px; min-width: 0; color: var(--dim); font-size: 12.5px; }
.loader-text { color: var(--dim); font-size: 12.5px; }
.loader-text-icon { flex: none; width: 13px; height: 13px; font-size: 0; color: transparent; }
.unified-loader.is-error .loader-text-icon, .unified-loader.is-done .loader-text-icon { width: auto; height: auto; font-size: 12.5px; color: var(--bad); }
.unified-loader.is-done .loader-text-icon { color: var(--ok); }
.loader-subtext, .loader-percentage { color: var(--faint); font-size: 12px; font-family: var(--f-mono); }
.loader-stages { display: flex; gap: 6px; flex-wrap: wrap; }
.loader-stage { font-size: 11.5px; color: var(--faint); }
.loader-stage.active { color: var(--ink); }
.loader-stage.complete { color: var(--ok); }
.loader-skel { display: grid; gap: 7px; margin-top: 4px; }
.unified-loader.compact .loader-skel { display: none; }

/* page navigation overlay from loading.js: retired on layout pages (motion.js runs the top bar for navigation) */
.lay-app .page-activity-loader { display: none !important; }

/* ---------- history panel (assets/history-sidebar.js) as a right-hand panel under the top bar ---------- */
.lay-app .history-sidebar {
    left: auto !important; right: -300px; top: var(--bar-h) !important; height: calc(100vh - var(--bar-h)) !important;
    width: 280px !important; z-index: 25 !important; transition: right .2s ease !important;
    background: var(--sub) !important; border-left: 1px solid var(--line) !important; border-right: 0 !important; box-shadow: none !important;
}
.lay-app .history-sidebar.open { right: 0 !important; }
.lay-app .history-toggle-btn { display: none !important; }
@media (min-width: 1300px) {
    body.lay-app.lay-history-open .lay-content { padding-right: 312px; }
}
.history-sidebar .history-header {
    background: none !important; color: var(--ink) !important; border-bottom: 1px solid var(--line) !important; padding: 12px 14px !important;
}
.history-sidebar .history-header h3, .history-sidebar .history-header * { color: var(--ink) !important; font-size: 13px !important; font-weight: 600 !important; }
.history-sidebar .history-list { padding: 8px !important; }
.history-sidebar .history-item {
    background: var(--bg) !important; border: 1px solid var(--line) !important; border-left: 1px solid var(--line) !important;
    border-radius: 6px !important; box-shadow: none !important; transform: none !important; margin-bottom: 6px !important;
}
.history-sidebar .history-item:hover { border-color: var(--line2) !important; background: var(--hover) !important; }
.history-sidebar .history-item-tool { color: var(--ink) !important; }
.history-sidebar .history-item-url, .history-sidebar .history-item-summary { color: var(--dim) !important; font-family: var(--f-mono); font-size: 11.5px !important; }
.history-sidebar .history-item-time, .history-sidebar .history-empty, .history-sidebar .history-empty p { color: var(--faint) !important; }
.history-sidebar .history-item-icon { color: var(--dim) !important; background: var(--sub) !important; }
.history-sidebar .history-item-delete { background: var(--bg) !important; border-color: var(--line2) !important; color: var(--bad) !important; }
.history-sidebar .history-footer { border-top: 1px solid var(--line) !important; background: none !important; }
.history-sidebar .history-clear-btn { background: var(--bg) !important; color: var(--bad) !important; border: 1px solid var(--line2) !important; border-radius: 6px !important; }
.confirm-modal-overlay { background: var(--scrim) !important; }
.confirm-modal { background: var(--bg) !important; color: var(--ink) !important; border: 1px solid var(--line2) !important; border-radius: 10px !important; box-shadow: var(--shadow) !important; }
.confirm-modal p { color: var(--dim) !important; }
.confirm-modal-buttons .btn-cancel { background: var(--bg) !important; color: var(--ink) !important; border: 1px solid var(--line2) !important; }
.confirm-modal-buttons .btn-confirm { background: var(--bad) !important; color: #fff !important; border: 1px solid var(--bad) !important; }

@media (max-width: 860px) {
    .ui-card { padding: 14px; }
    .record-selector-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .check-main { flex-direction: column; gap: 4px; }
    .check-details-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
    .lay-app .history-sidebar { width: min(300px, 88vw) !important; right: -110vw; }
}
@media (prefers-reduced-motion: reduce) {
    .toast-notification, .lay-app .history-sidebar { transition: none !important; }
}
