/* RigTests Tools: components and tool UI.
   Works best with the RigTests theme; colors fall back to the same dark palette. */
:root {
	--rt-bg: #0b0f15; --rt-panel: #10161f; --rt-surface: #141b26; --rt-surface-2: #1a2230;
	--rt-line: #2a3446; --rt-text: #e8ecf3; --rt-muted: #9aa4b6;
	--rt-accent: #b8ff3c; --rt-accent-ink: #0b0f15;
	--rt-good: #3ddc84; --rt-warn: #ffb02e; --rt-bad: #ff5468;
	--rt-radius: 14px; --rt-radius-sm: 9px;
	--rt-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
	--rt-wide: 1040px;
}
.rt-icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.22em; }
.rt-wide { max-width: var(--rt-wide); margin-left: auto; margin-right: auto; }
.rt-note { color: var(--rt-muted); font-size: 15px; border: 1px dashed var(--rt-line); border-radius: var(--rt-radius-sm); padding: 12px 16px; }
.rt-eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--rt-accent); }
.rt-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rt-accent); box-shadow: 0 0 0 4px rgba(184, 255, 60, 0.15); }
.rt-dot--live { animation: rt-pulse 1.6s ease-in-out infinite; }
@keyframes rt-pulse { 50% { box-shadow: 0 0 0 7px rgba(184, 255, 60, 0.05); } }

/* Breadcrumbs */
.rt-crumbs { font-size: 14px; color: var(--rt-muted); margin-bottom: 12px; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 8px; }
.rt-crumbs a { color: var(--rt-muted); text-decoration: none; }
.rt-crumbs a:hover { color: var(--rt-text); }
.rt-crumbs [aria-current] { color: var(--rt-text); }
.rt-crumbs-sep { opacity: 0.5; }

/* ===== Homepage ===== */
.rt-hero { text-align: center; padding: 26px 0 8px; position: relative; }
.rt-hero::before {
	content: ""; position: absolute; inset: -60px -20px auto; height: 360px; z-index: -1; pointer-events: none;
	background:
		radial-gradient(ellipse 50% 60% at 50% 0%, rgba(184, 255, 60, 0.10), transparent 70%),
		linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px) 0 0 / 32px 32px,
		linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px) 0 0 / 32px 32px;
	-webkit-mask-image: radial-gradient(ellipse 60% 70% at 50% 20%, #000 30%, transparent 75%);
	mask-image: radial-gradient(ellipse 60% 70% at 50% 20%, #000 30%, transparent 75%);
}
.rt-hero-title { font-size: clamp(34px, 5.6vw, 60px); line-height: 1.08; letter-spacing: -0.03em; margin: 16px auto 14px; max-width: 820px; }
.rt-hero-sub { color: var(--rt-muted); font-size: clamp(17px, 2vw, 19.5px); max-width: 640px; margin: 0 auto 28px; }
.rt-search { position: relative; max-width: 600px; margin: 0 auto; text-align: left; }
.rt-search > .rt-icon { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--rt-muted); pointer-events: none; }
.rt-search input[type="search"] {
	width: 100%; height: 58px; padding: 0 20px 0 50px; font-size: 17px;
	background: var(--rt-surface); color: var(--rt-text);
	border: 1px solid var(--rt-line); border-radius: 999px;
	box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.rt-search input[type="search"]:focus { border-color: var(--rt-accent); outline: none; box-shadow: 0 0 0 4px rgba(184,255,60,0.15), 0 10px 30px rgba(0,0,0,0.35); }
.rt-search-results {
	position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 8px); margin: 0; padding: 6px; list-style: none;
	background: var(--rt-surface); border: 1px solid var(--rt-line); border-radius: var(--rt-radius); box-shadow: 0 20px 50px rgba(0,0,0,0.5);
	max-height: 360px; overflow-y: auto;
}
.rt-search-results li { margin: 0; }
.rt-search-results a { display: flex; justify-content: space-between; gap: 12px; padding: 11px 14px; border-radius: var(--rt-radius-sm); color: var(--rt-text); text-decoration: none; }
.rt-search-results a:hover, .rt-search-results a.is-active { background: var(--rt-surface-2); }
.rt-search-results small { color: var(--rt-muted); white-space: nowrap; }
.rt-search-empty { padding: 11px 14px; color: var(--rt-muted); }

.rt-glance { margin-top: 46px; background: var(--rt-panel); border: 1px solid var(--rt-line); border-radius: 20px; padding: 26px; }
.rt-glance-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin-bottom: 18px; }
.rt-glance-head h2 { margin: 0; font-size: 22px; }
.rt-glance-head p { margin: 0; color: var(--rt-muted); font-size: 14.5px; }
.rt-glance-head .rt-eyebrow { width: 100%; }
.rt-glance-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.rt-glance-cell { background: var(--rt-surface); border: 1px solid var(--rt-line); border-radius: var(--rt-radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-height: 108px; }
.rt-glance-label { font-size: 13px; color: var(--rt-muted); font-weight: 600; }
.rt-glance-value { font-family: var(--rt-mono); font-size: 20px; font-weight: 700; color: var(--rt-text); line-height: 1.3; word-break: break-word; }
.rt-glance-value small { display: block; font-family: inherit; font-size: 13px; font-weight: 500; color: var(--rt-muted); }
.rt-glance-link { margin-top: auto; font-size: 13.5px; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
@media (max-width: 860px) { .rt-glance-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .rt-glance { padding: 18px; } .rt-glance-grid { grid-template-columns: 1fr; } }

.entry-content > .rt-section-title { margin-top: 64px; margin-bottom: 8px; }
.entry-content > .rt-section-sub { color: var(--rt-muted); margin-bottom: 18px; }
.entry-content > .rt-section-title + .rt-wide, .entry-content > .rt-section-title + div { margin-top: 18px; }

/* Cards */
.rt-cards, .rt-hubs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.rt-hubs { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.rt-card {
	display: flex; flex-direction: column; gap: 6px; padding: 18px 18px 20px;
	background: var(--rt-surface); border: 1px solid var(--rt-line); border-radius: var(--rt-radius);
	color: var(--rt-text); text-decoration: none;
	transition: border-color .15s ease, transform .15s ease, background .15s ease;
}
a.rt-card:hover, a.rt-card:focus-visible { border-color: rgba(184,255,60,0.55); background: var(--rt-surface-2); transform: translateY(-2px); color: var(--rt-text); text-decoration: none; }
.rt-card-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: rgba(184,255,60,0.09); color: var(--rt-accent); margin-bottom: 6px; }
.rt-card-icon .rt-icon { width: 22px; height: 22px; }
.rt-card-title { font-weight: 700; font-size: 16.5px; line-height: 1.35; }
.rt-card-desc { color: var(--rt-muted); font-size: 14.5px; line-height: 1.5; }
.rt-hub-count { margin-top: auto; padding-top: 8px; font-size: 13px; font-weight: 700; color: var(--rt-accent); font-family: var(--rt-mono); }
.rt-hub-card.is-empty { opacity: 0.55; }
.rt-hub-card.is-empty .rt-hub-count { color: var(--rt-muted); }

.rt-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.rt-chip { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; background: var(--rt-surface); border: 1px solid var(--rt-line); color: var(--rt-text); font-weight: 600; font-size: 15px; text-decoration: none; }
.rt-chip .rt-icon { width: 16px; height: 16px; color: var(--rt-accent); transition: transform .15s ease; }
.rt-chip:hover { border-color: rgba(184,255,60,0.55); color: var(--rt-text); text-decoration: none; }
.rt-chip:hover .rt-icon { transform: translateX(3px); }

.rt-privacy { margin-top: 64px; background: linear-gradient(135deg, rgba(184,255,60,0.08), rgba(184,255,60,0) 60%), var(--rt-panel); border: 1px solid var(--rt-line); border-radius: 20px; padding: 26px 30px; }
.rt-privacy h3 { margin-top: 0; }
.rt-privacy p { margin: 0; color: #c9d0dc; }

/* Under-content sections */
.rt-related { margin-top: 56px; }
.rt-related h2 { font-size: 22px; margin-bottom: 16px; }
.rt-guide-list { list-style: none; padding: 0 !important; margin: 0; display: grid; gap: 8px; }
.rt-guide-list li { margin: 0; }
.rt-guide-list li::marker { content: none; }
.rt-guide-list a { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--rt-radius-sm); background: var(--rt-surface); border: 1px solid var(--rt-line); color: var(--rt-text); text-decoration: none; font-weight: 600; }
.rt-guide-list a:hover { border-color: rgba(184,255,60,0.55); }
.rt-guide-list .rt-icon { color: var(--rt-accent); }
.rt-back { margin-top: 26px; }
.rt-back a { font-weight: 650; text-decoration: none; display: inline-flex; gap: 6px; align-items: center; }
.rt-cta { margin-top: 40px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 24px; border-radius: var(--rt-radius); background: var(--rt-panel); border: 1px solid rgba(184,255,60,0.4); }
.rt-cta > div { display: flex; flex-direction: column; gap: 4px; max-width: 560px; }
.rt-cta strong { font-size: 19px; }
.rt-cta span:not(.rt-eyebrow) { color: var(--rt-muted); font-size: 15px; }
.rt-all-group { margin-top: 44px; }
.rt-all-group h2 { display: flex; align-items: center; gap: 10px; font-size: 22px; }
.rt-all-group h2 .rt-icon { color: var(--rt-accent); }
.rt-all-group h2 a { color: var(--rt-text); text-decoration: none; }

/* ===== Tool UI ===== */
.rt-tool {
	position: relative; margin: 0 auto 34px; padding: 22px;
	background: var(--rt-panel); border: 1px solid var(--rt-line); border-radius: 20px;
	color: var(--rt-text); min-height: 340px; font-size: 16px; line-height: 1.5;
	box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
@media (max-width: 600px) { .rt-tool { padding: 16px; border-radius: 16px; } }
.rt-tool-loading { color: var(--rt-muted); text-align: center; padding: 120px 0; }
.rt-tool * { box-sizing: border-box; }
.rt-tool [hidden] { display: none !important; }
.rt-tool p { margin: 0; }
.rt-tool h3 { margin: 0 0 4px; font-size: 18px; }

.rt-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.rt-row--between { justify-content: space-between; }
.rt-stack { display: flex; flex-direction: column; gap: 14px; }
.rt-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 700px) { .rt-grid2 { grid-template-columns: 1fr; } }
.rt-panel { background: var(--rt-surface); border: 1px solid var(--rt-line); border-radius: var(--rt-radius); padding: 16px; }
.rt-muted { color: var(--rt-muted); font-size: 14.5px; }
.rt-mono { font-family: var(--rt-mono); }

.rt-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	min-height: 44px; padding: 0 18px; border-radius: 999px; cursor: pointer;
	font: inherit; font-weight: 650; font-size: 15px; line-height: 1;
	background: var(--rt-surface-2); color: var(--rt-text); border: 1px solid var(--rt-line);
	text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.rt-btn:hover { border-color: #3d4a61; background: #212a3a; color: var(--rt-text); }
.rt-btn--primary { background: var(--rt-accent); color: var(--rt-accent-ink); border-color: var(--rt-accent); }
.rt-btn--primary:hover { background: #d4ff85; border-color: #d4ff85; color: var(--rt-accent-ink); }
.rt-btn--sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.rt-btn.is-active { border-color: var(--rt-accent); color: var(--rt-accent); }
.rt-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.rt-btn .rt-icon { width: 18px; height: 18px; }

.rt-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--rt-surface); border: 1px solid var(--rt-line); border-radius: 999px; }
.rt-seg button { min-height: 34px; padding: 0 14px; border-radius: 999px; border: 0; background: transparent; color: var(--rt-muted); font: inherit; font-size: 14px; font-weight: 650; cursor: pointer; }
.rt-seg button:hover { color: var(--rt-text); }
.rt-seg button[aria-pressed="true"] { background: var(--rt-accent); color: var(--rt-accent-ink); }
@media (max-width: 480px) { .rt-seg button { padding: 0 11px; } }

.rt-field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--rt-muted); font-weight: 600; min-width: 140px; }
.rt-field select, .rt-field input[type="number"], .rt-field input[type="text"] {
	height: 40px; padding: 0 12px; border-radius: var(--rt-radius-sm); border: 1px solid var(--rt-line);
	background: var(--rt-surface); color: var(--rt-text); font: inherit; font-size: 15px;
}
.rt-field output { color: var(--rt-text); font-family: var(--rt-mono); }
.rt-range { width: 100%; accent-color: var(--rt-accent); }

.rt-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.rt-stat { background: var(--rt-surface); border: 1px solid var(--rt-line); border-radius: var(--rt-radius-sm); padding: 12px 14px; }
.rt-stat-label { display: block; font-size: 12.5px; font-weight: 650; color: var(--rt-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.rt-stat-value { display: block; font-family: var(--rt-mono); font-size: 24px; font-weight: 700; margin-top: 2px; line-height: 1.25; }
.rt-stat-value small { font-size: 13px; color: var(--rt-muted); font-weight: 500; }

.rt-verdict { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--rt-radius-sm); border: 1px solid var(--rt-line); background: var(--rt-surface); }
.rt-verdict::before { content: ""; flex: none; width: 10px; height: 10px; margin-top: 7px; border-radius: 50%; background: var(--rt-muted); }
.rt-verdict strong { display: block; color: var(--rt-text); }
.rt-verdict span { color: #c9d0dc; font-size: 15px; }
.rt-verdict.is-good { border-color: rgba(61,220,132,0.45); background: rgba(61,220,132,0.07); }
.rt-verdict.is-good::before { background: var(--rt-good); }
.rt-verdict.is-warn { border-color: rgba(255,176,46,0.45); background: rgba(255,176,46,0.07); }
.rt-verdict.is-warn::before { background: var(--rt-warn); }
.rt-verdict.is-bad { border-color: rgba(255,84,104,0.5); background: rgba(255,84,104,0.07); }
.rt-verdict.is-bad::before { background: var(--rt-bad); }

.rt-hint { font-size: 13.5px; color: var(--rt-muted); }
.rt-hint kbd { font-size: 12px; }

.rt-pad {
	position: relative; display: grid; place-items: center; text-align: center; gap: 6px;
	min-height: 220px; padding: 20px; border-radius: var(--rt-radius); cursor: pointer; user-select: none; -webkit-user-select: none;
	background: repeating-linear-gradient(135deg, rgba(255,255,255,0.02) 0 12px, transparent 12px 24px), var(--rt-surface);
	border: 1px dashed #3d4a61; outline: none; touch-action: manipulation;
}
.rt-pad:focus-visible, .rt-pad.is-active { border-style: solid; border-color: var(--rt-accent); }
.rt-pad-big { font-family: var(--rt-mono); font-size: clamp(44px, 9vw, 76px); font-weight: 800; line-height: 1; }
.rt-pad-sub { color: var(--rt-muted); font-size: 15px; }
.rt-pad--cps { min-height: clamp(240px, 42vh, 360px); }
.rt-chart { height: 180px; }
.rt-chart--sm { height: 110px; }

.rt-keys { display: flex; flex-wrap: wrap; gap: 8px; }
.rt-key { min-width: 46px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--rt-line); border-bottom-width: 3px; background: var(--rt-surface); text-align: center; font-family: var(--rt-mono); font-size: 13px; line-height: 1.2; }
.rt-key b { display: block; font-size: 14px; color: var(--rt-text); }
.rt-key small { color: var(--rt-muted); }
.rt-key.is-down { border-color: var(--rt-accent); transform: translateY(1px); }
.rt-key.is-bad { border-color: var(--rt-bad); background: rgba(255,84,104,0.12); }
.rt-key.is-bad small { color: #ffb3bd; }

.rt-log { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; font-family: var(--rt-mono); font-size: 13px; }
.rt-log li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px; border-bottom: 1px solid rgba(255,255,255,0.05); margin: 0; }
.rt-log li.is-bad { color: #ffb3bd; }

.rt-canvas-wrap { position: relative; background: #000; border-radius: var(--rt-radius-sm); overflow: hidden; border: 1px solid var(--rt-line); }
.rt-canvas-wrap canvas { display: block; width: 100%; height: 100%; }

.rt-progress { height: 8px; border-radius: 99px; background: var(--rt-surface-2); overflow: hidden; }
.rt-progress > span { display: block; height: 100%; width: 0; background: var(--rt-accent); transition: width .2s linear; }

.rt-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.rt-swatch { width: 38px; height: 38px; border-radius: 10px; border: 2px solid var(--rt-line); cursor: pointer; padding: 0; }
.rt-swatch[aria-pressed="true"] { border-color: var(--rt-accent); box-shadow: 0 0 0 3px rgba(184,255,60,0.25); }

.rt-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.rt-thumb { display: flex; flex-direction: column; gap: 8px; padding: 8px; border-radius: var(--rt-radius-sm); border: 1px solid var(--rt-line); background: var(--rt-surface); color: var(--rt-text); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; text-align: left; }
.rt-thumb:hover { border-color: rgba(184,255,60,0.55); }
.rt-thumb-art { height: 70px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.08); overflow: hidden; position: relative; }
.rt-thumb-art canvas { width: 100%; height: 100%; display: block; }

/* Full-screen overlay used by display tests */
.rt-fs { position: fixed; inset: 0; z-index: 2147483000; background: #000; cursor: none; overflow: hidden; touch-action: manipulation; }
.rt-fs.show-ui { cursor: default; }
.rt-fs canvas.rt-fs-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.rt-fs-hud {
	position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%);
	display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px;
	max-width: calc(100% - 32px); padding: 10px 12px 10px 18px; border-radius: 999px;
	background: rgba(11,15,21,0.86); color: #e8ecf3; border: 1px solid rgba(255,255,255,0.12);
	font: 600 14px/1.3 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	box-shadow: 0 10px 40px rgba(0,0,0,0.5); opacity: 0; pointer-events: none; transition: opacity .25s ease;
	-webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.rt-fs.show-ui .rt-fs-hud { opacity: 1; pointer-events: auto; }
.rt-fs-hud .rt-btn { min-height: 34px; padding: 0 14px; font-size: 13.5px; }
.rt-fs-hud .rt-fs-title { margin-right: 4px; }
.rt-fs-hud .rt-fs-help { color: #9aa4b6; font-weight: 500; font-size: 13px; }
.rt-fs-hud input[type="range"] { width: 130px; accent-color: #b8ff3c; }
@media (max-width: 600px) { .rt-fs-hud { bottom: 14px; border-radius: 16px; } .rt-fs-hud .rt-fs-help { display: none; } }
.rt-fs-info { position: absolute; left: 16px; top: 14px; padding: 6px 10px; border-radius: 8px; background: rgba(0,0,0,0.6); color: #e8ecf3; font: 600 13px/1.3 var(--rt-mono); opacity: 0; transition: opacity .25s; pointer-events: none; }
.rt-fs.show-ui .rt-fs-info { opacity: 1; }
.rt-fs-info:empty { display: none; }
body.rt-fs-open { overflow: hidden; }

/* Controller drawing */
.rt-pad-svg { width: 100%; max-width: 560px; height: auto; display: block; margin: 0 auto; }
.rt-pad-svg .body { fill: #1a2230; stroke: #3d4a61; stroke-width: 2; }
.rt-pad-svg .btn { fill: #222c3c; stroke: #4a5870; stroke-width: 1.5; transition: fill .06s; }
.rt-pad-svg .btn.on { fill: var(--rt-accent); stroke: var(--rt-accent); }
.rt-pad-svg .lbl { fill: #c9d0dc; font: 700 12px var(--rt-mono); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.rt-pad-svg .btn.on + .lbl, .rt-pad-svg .lbl.on { fill: var(--rt-accent-ink); }
.rt-pad-svg .stick-ring { fill: #0f141c; stroke: #3d4a61; stroke-width: 1.5; }
.rt-pad-svg .stick-dot { fill: #e8ecf3; }
.rt-pad-svg .stick-dot.on { fill: var(--rt-accent); }
.rt-pad-svg .trig-bg { fill: #0f141c; stroke: #3d4a61; }
.rt-pad-svg .trig-fill { fill: var(--rt-accent); }
.rt-table { width: 100%; border-collapse: collapse; font-family: var(--rt-mono); font-size: 13px; }
.rt-table td, .rt-table th { padding: 5px 8px; border-bottom: 1px solid rgba(255,255,255,0.06); text-align: left; }
.rt-table th { color: var(--rt-muted); font-weight: 600; }
.rt-bar { height: 6px; border-radius: 9px; background: var(--rt-surface-2); overflow: hidden; min-width: 60px; }
.rt-bar > i { display: block; height: 100%; background: var(--rt-accent); width: 0; }

@media (prefers-reduced-motion: reduce) {
	.rt-card, .rt-chip .rt-icon { transition: none; }
	.rt-dot--live { animation: none; }
}
