/* Coding agent rules generator. Builds on ../tools.css and ../studio.css: a light form on the left, and the kit in a
   dark AI-studio window (lime accent) on pastel wallpaper on the right; the rules check spans the width below. */
.ag { --ag-lime: #D6FF3D; --ag-lime-ink: #14170A; }
.ag .st-chip { --st-c: var(--accent); --st-on: var(--on-accent); }
.ag .st-chip small { font-size: 12px; font-weight: 600; opacity: 0.75; }
.ag [hidden] { display: none !important; }
.ag-noscript { margin: 0 0 14px; padding: 10px 14px; border-radius: 12px; background: var(--accent-light); color: var(--accent-ink); font-size: 14px; }

.ag-top { margin-bottom: 20px; }
.ag-mode { max-width: 620px; }
.ag-mode .st-chip, .ag-level .st-chip { font: 700 14.5px/1.2 var(--font-body); min-height: 44px; padding: 0 10px; text-align: center; }

.ag-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr); gap: 24px; align-items: start; }
.ag-form { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ag-step { display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: 18px; background: var(--bg-card-subtle); min-width: 0; }
.ag-h3 { display: flex; align-items: center; gap: 9px; margin: 0; font: 700 16px/1.3 var(--font-display); color: var(--ink-primary); }
.ag-h3-sub { margin-top: 6px; font-size: 14px; }
.ag-n { display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--ink-primary); color: var(--bg-paper); font: 700 12.5px/1 var(--font-body); }
.ag-step .st-field { gap: 10px; }
.ag-step textarea, .ag-more textarea, .ag-more input { font-size: 15.5px; }
.ag-hint { margin: -2px 0 0; font-size: 13px; color: var(--ink-muted); }

.ag-ex { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ag-ex::before { content: "Try:"; font-size: 13px; font-weight: 600; color: var(--ink-muted); }
.ag-ex button { min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-line); background: var(--bg-card); color: var(--ink-secondary); font: 500 13px/1.2 var(--font-body); cursor: pointer; }
.ag-ex button:hover { border-color: var(--accent); color: var(--accent-ink); }

.ag-types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ag-type { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 58px; padding: 9px 12px; border-radius: 13px; border: 1.5px solid var(--border-line); background: var(--bg-card); color: var(--ink-primary); text-align: left; cursor: pointer; font: inherit; }
.ag-type b { font: 700 14.5px/1.25 var(--font-body); }
.ag-type span { font-size: 12.5px; line-height: 1.3; color: var(--ink-muted); }
.ag-type:hover { border-color: var(--outline-strong); }
.ag-type[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-light); box-shadow: inset 0 0 0 1px var(--accent); }
.ag-type[aria-pressed="true"] span { color: var(--accent-ink); }

.ag-jump { display: none; }
.ag-stack { display: flex; flex-direction: column; gap: 14px; }
.ag-field .st-label { font-size: 13px; }
.ag-note { margin: 0; font-size: 13px; line-height: 1.45; color: var(--ink-secondary); }
.ag-stack-d { display: block; }
.ag-stack-d > summary { list-style: none; cursor: pointer; min-height: 44px; align-items: flex-start; }
.ag-stack-d > summary::-webkit-details-marker { display: none; }
.ag-stack-d > summary::after { content: ""; flex: none; width: 9px; height: 9px; margin: 6px 4px 0 auto; border-right: 2px solid var(--ink-muted); border-bottom: 2px solid var(--ink-muted); transform: rotate(45deg); }
.ag-stack-d[open] > summary::after { margin-top: 10px; transform: rotate(-135deg); }
.ag-sum-t { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ag-stack-sum { font: 500 13px/1.4 var(--font-body); color: var(--ink-muted); }
.ag-stack-d[open] .ag-stack-sum { display: none; }
.ag-stack-d > .ag-hint { margin: 10px 0 12px; }
.ag-warn { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ag-warn:empty { display: none; }
.ag-warn li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; }
.ag-warn-ico { display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; font: 800 12px/1 var(--font-body); }
.ag-warn-warn { background: #FFF4E0; color: #6B4300; }
.ag-warn-warn .ag-warn-ico { background: #B45309; color: #FFFFFF; }
.ag-warn-info { background: var(--accent-light); color: var(--accent-ink); }
.ag-warn-info .ag-warn-ico { background: var(--accent); color: var(--on-accent); }
[data-theme="dark"] .ag-warn-warn { background: #2E2312; color: #FFD9A3; }
[data-theme="dark"] .ag-warn-warn .ag-warn-ico { background: #F2C45A; color: #2E2312; }

.ag-more { border-radius: 18px; background: var(--bg-card-subtle); }
.ag-more summary { display: flex; align-items: center; min-height: 48px; padding: 0 18px; font: 700 15px/1.3 var(--font-display); color: var(--ink-primary); cursor: pointer; }
.ag-more-body { display: flex; flex-direction: column; gap: 12px; padding: 0 18px 18px; }
.ag-reset { align-self: flex-start; }

/* ---------- the kit window (Design H: dark studio, lime accent, pastel wallpaper) ---------- */
.ag-out { display: flex; flex-direction: column; gap: 16px; min-width: 0; outline: none; }
.ag-wall { padding: clamp(10px, 2vw, 18px); border-radius: 22px; background: linear-gradient(135deg, #FBD3E9 0%, #C9D6FF 55%, #E2D1FF 100%); }
[data-theme="dark"] .ag-wall { background: linear-gradient(135deg, #3B2240 0%, #22305C 55%, #34265A 100%); }
.ag-win { --w-bg: #101015; --w-line: #26262E; --w-fg: #ECECE6; --w-mut: #A3A3AE; display: flex; flex-direction: column; overflow: hidden; border-radius: 14px; background: var(--w-bg); color: var(--w-fg); box-shadow: 0 18px 40px -12px rgba(30, 20, 70, 0.45); }
.ag-bar { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--w-line); }
.ag-path { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 400 12.5px/1.3 var(--font-mono); color: var(--w-mut); }
.ag-badge { margin-left: auto; flex: none; display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 999px; font: 700 12px/1 var(--font-body); text-decoration: none; background: #2A2A33; color: var(--w-fg); }
.ag-badge.is-great { background: var(--ag-lime); color: var(--ag-lime-ink); }
.ag-badge.is-good { background: #9EE6C2; color: #08281A; }
.ag-badge.is-meh { background: #FFC46B; color: #2E1C00; }
.ag-badge.is-weak { background: #FF8A8A; color: #2B0606; }
.ag-tabs { display: flex; gap: 2px; padding: 6px 8px 0; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--w-line); }
.ag-tabs::-webkit-scrollbar { display: none; }
.ag-tab { flex: none; min-height: 40px; padding: 0 12px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--w-mut); font: 500 13px/1 var(--font-mono); cursor: pointer; }
.ag-tab:hover { color: var(--w-fg); }
.ag-tab.is-edited::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: #FFC46B; vertical-align: 2px; }
.ag-tab[aria-selected="true"] { color: var(--ag-lime); border-bottom-color: var(--ag-lime); }
.ag-tab:focus-visible, .ag-btn:focus-visible, .ag-badge:focus-visible, .ag-link:focus-visible { outline: 2px solid var(--ag-lime); outline-offset: 2px; }
.ag-panel { display: flex; }
.ag-text { display: block; width: 100%; height: clamp(320px, 52vh, 500px); margin: 0; padding: 14px 16px; border: 0; resize: vertical; background: var(--w-bg); color: var(--w-fg); font: 400 13px/1.62 var(--font-mono); tab-size: 2; white-space: pre-wrap; overflow-wrap: anywhere; }
.ag-text:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ag-lime); }
.ag-text::selection { background: rgba(214, 255, 61, 0.3); }
.ag-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 14px; border-top: 1px solid var(--w-line); font-size: 12.5px; color: var(--w-mut); }
.ag-meter { display: inline-flex; align-items: center; gap: 9px; }
.ag-meter-bar { position: relative; width: 84px; height: 6px; border-radius: 999px; background: #2A2A33; overflow: hidden; }
.ag-meter-bar i { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 999px; background: var(--ag-lime); }
.ag-meter-bar i.is-over { background: #FF8A8A; }
.ag-edited { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; color: #FFC46B; }
.ag-link { min-height: 30px; padding: 0 6px; border: 0; background: none; color: var(--ag-lime); font: 600 12.5px/1 var(--font-body); text-decoration: underline; cursor: pointer; }
.ag-acts { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px 14px; }
.ag-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 16px; border-radius: 999px; border: 1px solid #3A3A44; background: transparent; color: var(--w-fg); font: 600 14px/1.2 var(--font-body); cursor: pointer; }
.ag-btn:hover { border-color: var(--w-mut); }
.ag-btn-go { background: var(--ag-lime); border-color: var(--ag-lime); color: var(--ag-lime-ink); }
.ag-btn-go:hover { background: #E3FF73; border-color: #E3FF73; }

.ag-kit { display: flex; flex-direction: column; gap: 12px; }
.ag-where { margin: 0; padding: 12px 14px; border-left: 3px solid var(--accent); border-radius: 0 12px 12px 0; background: var(--bg-card-subtle); font-size: 13.5px; line-height: 1.5; color: var(--ink-secondary); }
.ag-review { display: flex; flex-direction: column; gap: 8px; }

/* ---------- rules check ---------- */
.ag-check { display: flex; flex-direction: column; gap: 14px; padding: 18px; border-radius: 18px; border: 1px solid var(--border-line); background: var(--bg-card); }
.ag-check-wide { margin-top: 22px; }
.ag-check-head { display: flex; align-items: center; gap: 14px; }
.ag-check h3 { margin: 0; font: 700 19px/1.25 var(--font-display); color: var(--ink-primary); }
.ag-check-sum { margin: 2px 0 0; font-size: 14px; color: var(--ink-secondary); }
.ag-ring { --c: var(--ink-muted); position: relative; flex: none; width: 64px; height: 64px; }
.ag-ring svg { display: block; transform: rotate(-90deg); }
.ag-ring circle { fill: none; stroke-width: 5; }
.ag-ring-bg { stroke: var(--border-line); }
.ag-ring-val { stroke: var(--c); stroke-linecap: round; }
.ag-ring b { position: absolute; inset: 0; display: grid; place-items: center; font: 800 19px/1 var(--font-display); color: var(--c); }
.ag-ring.is-great, .ag-f-ok .ag-pill { --c: #047857; }
.ag-ring.is-good { --c: #1A45C2; }
.ag-ring.is-meh, .ag-f-tip .ag-pill { --c: #A04A00; }
.ag-ring.is-weak, .ag-f-fix .ag-pill { --c: #B42318; }
[data-theme="dark"] .ag-ring.is-great, [data-theme="dark"] .ag-f-ok .ag-pill { --c: #5FD3A2; }
[data-theme="dark"] .ag-ring.is-good { --c: #8FB0FF; }
[data-theme="dark"] .ag-ring.is-meh, [data-theme="dark"] .ag-f-tip .ag-pill { --c: #F2C45A; }
[data-theme="dark"] .ag-ring.is-weak, [data-theme="dark"] .ag-f-fix .ag-pill { --c: #FF8A8A; }
.ag-findings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.ag-f { display: flex; gap: 10px; align-items: flex-start; min-width: 0; padding: 10px 12px; border-radius: 12px; background: var(--bg-card-subtle); }
.ag-f div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ag-f b { font-size: 14px; line-height: 1.35; color: var(--ink-primary); overflow-wrap: anywhere; }
.ag-f-d { font: 400 12.5px/1.45 var(--font-mono); color: var(--ink-muted); overflow-wrap: anywhere; }
.ag-f-fix { font-size: 13px; line-height: 1.45; color: var(--ink-secondary); }
.ag-pill { flex: none; margin-top: 1px; padding: 3px 8px; border-radius: 999px; border: 1px solid currentColor; color: var(--c); font: 700 11px/1 var(--font-body); text-transform: uppercase; letter-spacing: 0.04em; }

.ag-checkmode { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.ag-checkmode textarea { font: 400 13.5px/1.55 var(--font-mono); }
.ag-checkmode .ag-findings { grid-template-columns: 1fr; }

/* ---------- reference content below the tool ---------- */
/* The browser skips layout and paint of these sections until they come near the screen */
.tw-frame ~ .seo-section { content-visibility: auto; contain-intrinsic-size: auto 640px; }
.ag-verified { font-size: 14px; color: var(--ink-muted); }
.seo-section ul:not(.linklist) a, .ag-verified a { text-decoration: underline; text-underline-offset: 2px; }
.table-wrap[tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

/* The kit stays in view while you change options further down (only when the screen is tall enough) */
@media (min-width: 1000px) and (min-height: 820px) {
  .ag-out { position: sticky; top: 84px; }
}
@media (max-width: 999px) {
  .ag-grid, .ag-checkmode { grid-template-columns: minmax(0, 1fr); }
  .ag-jump { display: inline-flex; align-items: center; align-self: flex-start; min-height: 44px; padding: 0 14px; margin-top: 4px; border-radius: 999px; background: var(--ink-primary); color: var(--bg-paper); font: 600 14px/1 var(--font-body); text-decoration: none; }
  .ag-jump::after { content: " ↓"; white-space: pre; }
}
@media (max-width: 640px) {
  .ag-step { padding: 14px; }
  .ag .st-chip, .ag-ex button, .ag-tab, .ag-btn, .ag-link, .ag-badge { min-height: 44px; }
  .ag-link { min-width: 44px; }
  .ag-findings { grid-template-columns: minmax(0, 1fr); }
  .ag-mode .st-chip { font-size: 13.5px; padding: 0 6px; }
  .ag-acts .ag-btn { flex: 1 1 auto; }
  .ag-text { height: 380px; font-size: 12.5px; }
}
@media (max-width: 380px) {
  .ag-types { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: no-preference) {
  .ag-type, .ag-tab, .ag-btn, .ag-ex button { transition: background-color 0.15s, border-color 0.15s, color 0.15s; }
  .ag-meter-bar i { transition: width 0.2s; }
}
