/* ============================================================
 * utilities.css — atomic utility classes
 *
 * Single-purpose, stackable. Color/border/background utilities
 * reference SEMANTIC tokens only (so theme swaps Just Work).
 * If a class you need isn't here, add one line — keep it auditable.
 * ============================================================ */

/* --- Display --- */
.block        { display: block; }
.inline-block { display: inline-block; }
.inline       { display: inline; }
.flex         { display: flex; }
.inline-flex  { display: inline-flex; }
.grid         { display: grid; }
.inline-grid  { display: inline-grid; }
.contents     { display: contents; }
.hidden       { display: none; }

/* --- Position --- */
.static    { position: static; }
.relative  { position: relative; }
.absolute  { position: absolute; }
.fixed     { position: fixed; }
.sticky    { position: sticky; }
.inset-0   { inset: 0; }
.top-0     { top: 0; }
.right-0   { right: 0; }
.bottom-0  { bottom: 0; }
.left-0    { left: 0; }
.-top-1    { top: calc(-1 * var(--space-1)); }
.-top-2    { top: calc(-1 * var(--space-2)); }
.-bottom-1 { bottom: calc(-1 * var(--space-1)); }
.-bottom-2 { bottom: calc(-1 * var(--space-2)); }
.-left-1   { left: calc(-1 * var(--space-1)); }
.-right-1  { right: calc(-1 * var(--space-1)); }
.top-2     { top: var(--space-2); }
.right-2   { right: var(--space-2); }
.bottom-2  { bottom: var(--space-2); }
.left-2    { left: var(--space-2); }
.top-4     { top: var(--space-4); }
.right-4   { right: var(--space-4); }
.bottom-4  { bottom: var(--space-4); }
.left-4    { left: var(--space-4); }
.top-full  { top: 100%; }

/* --- Overflow --- */
.overflow-auto    { overflow: auto; }
.overflow-hidden  { overflow: hidden; }
.overflow-scroll  { overflow: scroll; }
.overflow-visible { overflow: visible; }
.overflow-x-auto    { overflow-x: auto; }
.overflow-y-auto    { overflow-y: auto; }
.overflow-x-hidden  { overflow-x: hidden; }
.overflow-y-hidden  { overflow-y: hidden; }

/* --- Z-index --- */
.z-base     { z-index: var(--z-base); }
.z-dropdown { z-index: var(--z-dropdown); }
.z-sticky   { z-index: var(--z-sticky); }
.z-overlay  { z-index: var(--z-overlay); }
.z-modal    { z-index: var(--z-modal); }
.z-popover  { z-index: var(--z-popover); }
.z-toast    { z-index: var(--z-toast); }

/* --- Flex --- */
.flex-row         { flex-direction: row; }
.flex-row-reverse { flex-direction: row-reverse; }
.flex-col         { flex-direction: column; }
.flex-col-reverse { flex-direction: column-reverse; }
.flex-wrap        { flex-wrap: wrap; }
.flex-nowrap      { flex-wrap: nowrap; }
.flex-1           { flex: 1 1 0%; }
.flex-auto        { flex: 1 1 auto; }
.flex-initial     { flex: 0 1 auto; }
.flex-none        { flex: none; }
.grow             { flex-grow: 1; }
.grow-0           { flex-grow: 0; }
.shrink           { flex-shrink: 1; }
.shrink-0         { flex-shrink: 0; }

.justify-start   { justify-content: flex-start; }
.justify-end     { justify-content: flex-end; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around  { justify-content: space-around; }
.justify-evenly  { justify-content: space-evenly; }

.items-start    { align-items: flex-start; }
.items-end      { align-items: flex-end; }
.items-center   { align-items: center; }
.items-baseline { align-items: baseline; }
.items-stretch  { align-items: stretch; }

.self-auto    { align-self: auto; }
.self-start   { align-self: flex-start; }
.self-end     { align-self: flex-end; }
.self-center  { align-self: center; }
.self-stretch { align-self: stretch; }

/* --- Grid --- */
.grid-cols-1  { grid-template-columns: repeat(1,  minmax(0, 1fr)); }
.grid-cols-2  { grid-template-columns: repeat(2,  minmax(0, 1fr)); }
.grid-cols-3  { grid-template-columns: repeat(3,  minmax(0, 1fr)); }
.grid-cols-4  { grid-template-columns: repeat(4,  minmax(0, 1fr)); }
.grid-cols-6  { grid-template-columns: repeat(6,  minmax(0, 1fr)); }
.grid-cols-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.col-span-1    { grid-column: span 1 / span 1; }
.col-span-2    { grid-column: span 2 / span 2; }
.col-span-3    { grid-column: span 3 / span 3; }
.col-span-4    { grid-column: span 4 / span 4; }
.col-span-6    { grid-column: span 6 / span 6; }
.col-span-8    { grid-column: span 8 / span 8; }
.col-span-full { grid-column: 1 / -1; }

/* --- Gap --- */
.gap-0    { gap: var(--space-0); }
.gap-0\.5 { gap: 0.125rem; }
.gap-1    { gap: var(--space-1); }
.gap-1\.5 { gap: 0.375rem; }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-5  { gap: var(--space-5); }
.gap-6  { gap: var(--space-6); }
.gap-8  { gap: var(--space-8); }
.gap-10 { gap: var(--space-10); }
.gap-12 { gap: var(--space-12); }
.gap-16 { gap: var(--space-16); }

/* Directional gap — for grids and flex layouts that want different
   row/column spacing. row-gap = vertical between wrapped rows; column-gap
   = horizontal between items in a row. */
.gap-x-1  { column-gap: var(--space-1); }
.gap-x-2  { column-gap: var(--space-2); }
.gap-x-3  { column-gap: var(--space-3); }
.gap-x-4  { column-gap: var(--space-4); }
.gap-y-1  { row-gap: var(--space-1); }
.gap-y-2  { row-gap: var(--space-2); }
.gap-y-3  { row-gap: var(--space-3); }
.gap-y-4  { row-gap: var(--space-4); }

/* --- Padding --- */
.p-0  { padding: var(--space-0); }
.p-1  { padding: var(--space-1); }
.p-2  { padding: var(--space-2); }
.p-3  { padding: var(--space-3); }
.p-4  { padding: var(--space-4); }
.p-5  { padding: var(--space-5); }
.p-6  { padding: var(--space-6); }
.p-8  { padding: var(--space-8); }
.p-10 { padding: var(--space-10); }
.p-12 { padding: var(--space-12); }
.p-16 { padding: var(--space-16); }

.px-0 { padding-inline: var(--space-0); }
.px-0\.5 { padding-inline: 0.125rem; }
.px-1   { padding-inline: var(--space-1); }
.px-1\.5 { padding-inline: 0.375rem; }
.px-2   { padding-inline: var(--space-2); }
.px-3 { padding-inline: var(--space-3); }
.px-4 { padding-inline: var(--space-4); }
.px-5 { padding-inline: var(--space-5); }
.px-6 { padding-inline: var(--space-6); }
.px-8 { padding-inline: var(--space-8); }
.px-10 { padding-inline: var(--space-10); }
.px-12 { padding-inline: var(--space-12); }

.py-0   { padding-block: var(--space-0); }
.py-0\.5 { padding-block: 0.125rem; }
.py-1   { padding-block: var(--space-1); }
.py-1\.5 { padding-block: 0.375rem; }
.py-2   { padding-block: var(--space-2); }
.py-2\.5 { padding-block: 0.625rem; }
.py-3   { padding-block: var(--space-3); }
.py-4   { padding-block: var(--space-4); }
.py-5   { padding-block: var(--space-5); }
.py-6   { padding-block: var(--space-6); }
.py-8   { padding-block: var(--space-8); }
.py-10  { padding-block: var(--space-10); }
.py-12  { padding-block: var(--space-12); }

/* --- Margin --- */
.m-0    { margin: 0; }
.m-1    { margin: var(--space-1); }
.m-2    { margin: var(--space-2); }
.m-4    { margin: var(--space-4); }
.m-6    { margin: var(--space-6); }
.m-auto { margin: auto; }

.mx-0    { margin-inline: 0; }
.mx-2    { margin-inline: var(--space-2); }
.mx-4    { margin-inline: var(--space-4); }
.mx-6    { margin-inline: var(--space-6); }
.mx-auto { margin-inline: auto; }

.my-0 { margin-block: 0; }
.my-1 { margin-block: var(--space-1); }
.my-2 { margin-block: var(--space-2); }
.my-3 { margin-block: var(--space-3); }
.my-4 { margin-block: var(--space-4); }
.my-6 { margin-block: var(--space-6); }
.my-8 { margin-block: var(--space-8); }
.my-12 { margin-block: var(--space-12); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-0   { margin-bottom: 0; }
.mb-0\.5 { margin-bottom: 0.125rem; }
.mb-1   { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.pt-0  { padding-top: 0; }
.pt-2  { padding-top: var(--space-2); }
.pt-3  { padding-top: var(--space-3); }
.pt-4  { padding-top: var(--space-4); }
.pt-6  { padding-top: var(--space-6); }
.pt-8  { padding-top: var(--space-8); }
.pt-12 { padding-top: var(--space-12); }
.pt-16 { padding-top: var(--space-16); }
.pt-20 { padding-top: var(--space-20); }
.pt-24 { padding-top: var(--space-24); }
.pb-0  { padding-bottom: 0; }
.pb-1  { padding-bottom: var(--space-1); }
.pb-2  { padding-bottom: var(--space-2); }
.pb-3  { padding-bottom: var(--space-3); }
.pb-4  { padding-bottom: var(--space-4); }
.pb-6  { padding-bottom: var(--space-6); }
.pb-8  { padding-bottom: var(--space-8); }
.pb-12 { padding-bottom: var(--space-12); }
.pb-16 { padding-bottom: var(--space-16); }
.pb-24 { padding-bottom: var(--space-24); }
.pb-32 { padding-bottom: var(--space-32); }

.pl-2 { padding-left: var(--space-2); }
.pl-3 { padding-left: var(--space-3); }
.pl-4 { padding-left: var(--space-4); }
.pr-2 { padding-right: var(--space-2); }
.pr-3 { padding-right: var(--space-3); }
.pr-4 { padding-right: var(--space-4); }

.ml-auto { margin-left: auto; }
.ml-1 { margin-left: var(--space-1); }
.ml-2 { margin-left: var(--space-2); }
.ml-3 { margin-left: var(--space-3); }
.ml-4 { margin-left: var(--space-4); }

/* --- Sizing --- */
.w-auto   { width: auto; }
.w-full   { width: 100%; }
.w-screen { width: 100vw; }
.w-fit    { width: fit-content; }
.w-min    { width: min-content; }
.w-max    { width: max-content; }
.w-1\/2   { width: 50%; }
.w-1\/3   { width: 33.333333%; }
.w-2\/3   { width: 66.666667%; }
.w-1\/4   { width: 25%; }
.w-3\/4   { width: 75%; }

.h-auto   { height: auto; }
.h-full   { height: 100%; }
.h-screen { height: 100vh; }
.h-fit    { height: fit-content; }
.h-1\/2   { height: 50%; }

/* Fixed sizes (icon/button-sized; tied to spacing scale) */
.w-3 { width: var(--space-3); }
.w-4 { width: var(--space-4); }
.w-5 { width: var(--space-5); }
.w-6 { width: var(--space-6); }
.w-8 { width: var(--space-8); }
.w-9 { width: 2.25rem; }
.w-10 { width: var(--space-10); }
.w-12 { width: var(--space-12); }
.w-14 { width: 3.5rem; }
.w-16 { width: var(--space-16); }
.w-20 { width: var(--space-20); }
.w-48 { width: 12rem; }
.w-56 { width: 14rem; }
.w-60 { width: 15rem; }
.w-64 { width: 16rem; }
.w-72 { width: 18rem; }
.w-0  { width: 0; }
.w-44 { width: 11rem; }
.h-px   { height: 1px; }
.h-0\.5 { height: 0.125rem; }
.h-1    { height: var(--space-1); }
.h-1\.5 { height: 0.375rem; }
.h-2    { height: var(--space-2); }
.w-px   { width: 1px; }
.w-0\.5 { width: 0.125rem; }
.w-1    { width: var(--space-1); }
.w-1\.5 { width: 0.375rem; }
.w-2    { width: var(--space-2); }
.min-w-0  { min-width: 0; }
.min-w-5  { min-width: var(--space-5); }
.min-w-40 { min-width: 10rem; }
.min-w-48 { min-width: 12rem; }
.min-w-64 { min-width: 16rem; }
.min-w-72 { min-width: 18rem; }
.min-w-80 { min-width: 20rem; }
.h-3 { height: var(--space-3); }
.h-4 { height: var(--space-4); }
.h-5 { height: var(--space-5); }
.h-6 { height: var(--space-6); }
.h-8 { height: var(--space-8); }
.h-9 { height: 2.25rem; }
.h-10 { height: var(--space-10); }
.h-11 { height: 2.75rem; }
.h-12 { height: var(--space-12); }
.h-14 { height: 3.5rem; }
.h-16 { height: 4rem; }

.max-w-prose       { max-width: 65ch; }
.max-w-xs          { max-width: 20rem; }
.max-w-sm          { max-width: 24rem; }
.max-w-md          { max-width: 28rem; }
.max-w-lg          { max-width: 32rem; }
.max-w-xl          { max-width: 36rem; }
.max-w-2xl         { max-width: 42rem; }
.max-w-screen-sm   { max-width: 640px; }
.max-w-screen-md   { max-width: 768px; }
.max-w-screen-lg   { max-width: 1024px; }
.max-w-screen-xl   { max-width: 1280px; }
.max-w-full        { max-width: 100%; }
.max-w-fit         { max-width: fit-content; }

.max-h-60 { max-height: 15rem; }
.max-h-64 { max-height: 16rem; }
.max-h-80 { max-height: 20rem; }
.max-h-96 { max-height: 24rem; }

/* Session console — a viewport-bounded log-tailing pane. */
.h-feed     { height: 60vh; }
.min-h-feed { min-height: 24rem; }
.max-h-feed { max-height: 60vh; }
.max-h-drawer { max-height: 85vh; }

.min-h-screen      { min-height: 100vh; }
.min-h-full        { min-height: 100%; }
.min-h-32          { min-height: 8rem; }

/* --- Typography --- */
.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg   { font-size: var(--text-lg); }
.text-xl   { font-size: var(--text-xl); }
.text-2xl  { font-size: var(--text-2xl); }
.text-3xl  { font-size: var(--text-3xl); }
.text-4xl  { font-size: var(--text-4xl); }
.text-5xl  { font-size: var(--text-5xl); }

.font-normal   { font-weight: var(--weight-normal); }
.font-medium   { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold     { font-weight: var(--weight-bold); }

.leading-none    { line-height: 1; }
.leading-tight   { line-height: var(--leading-tight); }
.leading-snug    { line-height: var(--leading-snug, 1.375); }
.leading-normal  { line-height: var(--leading-normal); }
.leading-relaxed { line-height: var(--leading-relaxed); }

.text-left   { text-align: left; }
.text-center { text-align: center; }
.text-right  { text-align: right; }

.uppercase  { text-transform: uppercase; }
.tracking-tight  { letter-spacing: -0.025em; }
.tracking-normal { letter-spacing: 0; }
.tracking-wide   { letter-spacing: 0.025em; }
.tracking-wider  { letter-spacing: 0.05em; }
.tracking-widest { letter-spacing: 0.1em; }
.lowercase  { text-transform: lowercase; }
.capitalize { text-transform: capitalize; }
.normal-case{ text-transform: none; }

.italic     { font-style: italic; }
.not-italic { font-style: normal; }

.underline    { text-decoration: underline; }
.no-underline { text-decoration: none; }
.line-through { text-decoration: line-through; }

/* --- Lists ---
 * The base reset strips list-style + padding from ul/ol. Re-enable
 * here for the few places that explicitly want bullets/numbers
 * (e.g. error summaries with multiple errors). */
.list-none    { list-style: none; }
.list-disc    { list-style-type: disc; }
.list-decimal { list-style-type: decimal; }
.list-inside  { list-style-position: inside; }
.list-outside { list-style-position: outside; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.font-sans { font-family: var(--font-sans); }
.font-mono { font-family: var(--font-mono); }

/* --- Whitespace --- */
.whitespace-normal   { white-space: normal; }
.whitespace-nowrap   { white-space: nowrap; }
.whitespace-pre      { white-space: pre; }
.whitespace-pre-wrap { white-space: pre-wrap; }
.break-words         { overflow-wrap: break-word; }
.break-all           { word-break: break-all; }

/* --- Text color (semantic) --- */
.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-inverse   { color: var(--text-inverse); }
.text-link      { color: var(--text-link); }
.text-accent    { color: var(--accent); }
.text-success   { color: var(--success); }
.text-danger    { color: var(--danger); }
.text-warning   { color: var(--warning); }

/* --- Background (semantic) --- */
/* Depth tiers (HQ-538) — pick the semantic one that matches the
   element's role; the L* scale lives in theme.css. */
.bg-surface-page    { background: var(--surface-page); }
.bg-surface-panel   { background: var(--surface-panel); }
.bg-surface-card    { background: var(--surface-card); }
.bg-surface-popover { background: var(--surface-popover); }
.bg-surface-overlay { background: var(--surface-overlay); }
.bg-surface-sunken  { background: var(--surface-sunken); }

/* Legacy numeric aliases — kept so existing call sites continue to
   render. New work should use the semantic tier classes above. */
.bg-surface-1       { background: var(--surface-1); }
.bg-surface-2       { background: var(--surface-2); }
.bg-surface-3       { background: var(--surface-3); }

.bg-surface-control { background: var(--surface-control); }
.bg-accent        { background: var(--accent); color: var(--accent-fg); }
.bg-accent-muted  { background: var(--accent-muted); }
.bg-success       { background: var(--success); color: var(--success-fg); }
.bg-success-muted { background: var(--success-muted); }
.bg-danger        { background: var(--danger); color: var(--danger-fg); }
.bg-danger-muted  { background: var(--danger-muted); }
.bg-warning       { background: var(--warning); color: var(--warning-fg); }
.bg-warning-muted { background: var(--warning-muted); }
.bg-surface-translucent { background: var(--surface-translucent); }
/* Modal backdrop dim. The legacy name --surface-overlay was repurposed
   in HQ-538 as a surface tier; the dim now lives on --backdrop. */
.bg-overlay       { background: var(--backdrop); }
.bg-backdrop      { background: var(--backdrop); }
.bg-transparent   { background: transparent; }

.backdrop-blur    { -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.backdrop-blur-sm { -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.backdrop-blur-lg { -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }

/* --- Border --- */
.border       { border: 1px solid var(--border-default); }
.border-0     { border: 0; }
.border-2     { border-width: 2px; border-style: solid; border-color: var(--border-default); }
.border-t     { border-top: 1px solid var(--border-default); }
.border-b     { border-bottom: 1px solid var(--border-default); }
.border-l     { border-left: 1px solid var(--border-default); }
.border-l-2   { border-left-width: 2px; border-left-style: solid; border-left-color: var(--border-default); }
.border-r     { border-right: 1px solid var(--border-default); }

.border-subtle  { border-color: var(--border-subtle); }
.border-default { border-color: var(--border-default); }
.border-strong  { border-color: var(--border-strong); }

.border-solid   { border-style: solid; }
.border-dashed  { border-style: dashed; }
.border-dotted  { border-style: dotted; }
.border-accent  { border-color: var(--accent); }
.border-danger  { border-color: var(--danger); }
.border-success { border-color: var(--success); }
.border-warning { border-color: var(--warning); }
.border-transparent { border-color: transparent; }

.rounded-none { border-radius: var(--radius-none); }
.rounded-sm   { border-radius: var(--radius-sm); }
.rounded      { border-radius: var(--radius-md); }
.rounded-md   { border-radius: var(--radius-md); }
.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-xl   { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

/* --- Shadow --- */
.shadow-none { box-shadow: none; }
.shadow-sm   { box-shadow: var(--shadow-sm); }
.shadow      { box-shadow: var(--shadow-md); }
.shadow-md   { box-shadow: var(--shadow-md); }
.shadow-lg   { box-shadow: var(--shadow-lg); }
.shadow-xl   { box-shadow: var(--shadow-xl); }

/* --- Opacity --- */
.opacity-0   { opacity: 0; }
.opacity-25  { opacity: 0.25; }
.opacity-40  { opacity: 0.4; }
.opacity-50  { opacity: 0.5; }
.opacity-75  { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* --- Cursor --- */
.cursor-default     { cursor: default; }
.cursor-pointer     { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }
.cursor-wait        { cursor: wait; }
.cursor-grab        { cursor: grab; }
.cursor-grabbing    { cursor: grabbing; }
.cursor-move        { cursor: move; }

/* --- Pointer events --- */
.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }

/* --- User select --- */
.select-none { user-select: none; }
.select-text { user-select: text; }
.select-all  { user-select: all; }

/* --- Animations --- */
@keyframes hub-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}
.animate-pulse { animation: hub-pulse 1.6s ease-in-out infinite; }

@keyframes hub-spin {
  to { transform: rotate(360deg); }
}
.animate-spin { animation: hub-spin 0.8s linear infinite; transform-origin: 50% 50%; }

@keyframes hub-progress-indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}
.animate-progress-indeterminate { animation: hub-progress-indeterminate 1.4s ease-in-out infinite; }

/* HQ-245 — one-shot heartbeat pulse for the live monitor tiles. Fires
 * when a tile receives a fresh beat: a soft glow that decays back to
 * the resting border. Not infinite — applied once per ratcheted state
 * change in the Preact component. */
@keyframes hub-pulse-once {
  0%   { box-shadow: 0 0 0 0 rgb(var(--color-accent-rgb, 59 130 246) / 0.45); }
  60%  { box-shadow: 0 0 0 8px rgb(var(--color-accent-rgb, 59 130 246) / 0); }
  100% { box-shadow: 0 0 0 0 rgb(var(--color-accent-rgb, 59 130 246) / 0); }
}
.pulse-once { animation: hub-pulse-once 1.4s ease-out 1; }

@media (prefers-reduced-motion: reduce) {
  .animate-pulse,
  .animate-spin,
  .animate-progress-indeterminate { animation-duration: 3s; }
  .pulse-once { animation: none; }
}

/* --- View transitions (named singletons; one per page) --- */
.vt-page-title { view-transition-name: page-title; }
.vt-page-body  { view-transition-name: page-body; }
.vt-hero       { view-transition-name: hero; }

/* --- Placeholder pseudo-element variant --- */
.placeholder\:text-muted::placeholder { color: var(--text-muted); }

/* --- Accessibility utilities --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.not-sr-only,
.focus\:not-sr-only:focus {
  position: static;
  width: auto;
  height: auto;
  padding: revert;
  margin: revert;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* --- Transitions --- */
.transition-none    { transition: none; }
.transition         { transition: all var(--duration-base) var(--ease-standard); }
.transition-colors  { transition: color var(--duration-base) var(--ease-standard), background-color var(--duration-base) var(--ease-standard), border-color var(--duration-base) var(--ease-standard); }
.transition-opacity { transition: opacity var(--duration-base) var(--ease-standard); }
.transition-shadow  { transition: box-shadow var(--duration-base) var(--ease-standard); }
.transition-transform { transition: transform var(--duration-base) var(--ease-standard); }
.transition-width   { transition: width var(--duration-base) var(--ease-standard); }
.transition-grid-rows { transition: grid-template-rows var(--duration-base) var(--ease-standard); }

/* --- Transforms (small-rotation utilities for drag previews etc.) --- */
.rotate-0   { transform: rotate(0deg); }
.rotate-1   { transform: rotate(1deg); }
.rotate-2   { transform: rotate(2deg); }
.rotate-3   { transform: rotate(3deg); }
.-rotate-1  { transform: rotate(-1deg); }
.-rotate-2  { transform: rotate(-2deg); }
.rotate-180 { transform: rotate(180deg); }
.scale-95   { transform: scale(0.95); }
.scale-100  { transform: scale(1); }
.scale-105  { transform: scale(1.05); }
.translate-x-0     { transform: translateX(0); }
.translate-x-full  { transform: translateX(100%); }
.-translate-x-full { transform: translateX(-100%); }
.translate-y-0     { transform: translateY(0); }
.translate-y-full  { transform: translateY(100%); }
.-translate-y-full { transform: translateY(-100%); }
.touch-none { touch-action: none; }
.touch-auto { touch-action: auto; }
.duration-fast { transition-duration: var(--duration-fast); }
.duration-base { transition-duration: var(--duration-base); }
.duration-slow { transition-duration: var(--duration-slow); }

/* --- State variants: hover --- */
.hover\:bg-surface-2:hover   { background: var(--surface-2); }
.hover\:bg-surface-3:hover   { background: var(--surface-3); }
.hover\:bg-surface-panel:hover   { background: var(--surface-panel); }
.hover\:bg-surface-card:hover    { background: var(--surface-card); }
.hover\:bg-surface-popover:hover { background: var(--surface-popover); }
.hover\:bg-surface-sunken:hover  { background: var(--surface-sunken); }
.hover\:bg-accent:hover      { background: var(--accent); color: var(--accent-fg); }
.hover\:bg-accent-hover:hover{ background: var(--accent-hover); color: var(--accent-fg); }
.hover\:bg-accent-muted:hover{ background: var(--accent-muted); }
.hover\:bg-danger:hover       { background: var(--danger); color: var(--danger-fg); }
.hover\:bg-danger-muted:hover { background: var(--danger-muted); }
.hover\:text-accent:hover    { color: var(--accent); }
.hover\:text-primary:hover   { color: var(--text-primary); }
.hover\:text-secondary:hover { color: var(--text-secondary); }
.hover\:text-link:hover      { color: var(--text-link); }
.hover\:underline:hover      { text-decoration: underline; }
.hover\:no-underline:hover   { text-decoration: none; }
.hover\:opacity-75:hover     { opacity: 0.75; }
.hover\:opacity-100:hover    { opacity: 1; }
.hover\:shadow-md:hover      { box-shadow: var(--shadow-md); }
.hover\:shadow-lg:hover      { box-shadow: var(--shadow-lg); }
.hover\:border-strong:hover  { border-color: var(--border-strong); }
.hover\:border-accent:hover  { border-color: var(--accent); }
.hover\:border-default:hover { border-color: var(--border-default); }
.hover\:scale-105:hover      { transform: scale(1.05); }
.hover\:text-danger:hover    { color: var(--danger); }
.last\:border-b-0:last-child { border-bottom: 0; }
.hover\:w-56:hover           { width: 14rem; }

/* --- State variants: group-hover ---
 * Mark an ancestor with .group; descendants with .group-hover\:* react to
 * the ancestor's :hover. Used by the sidebar so children visually expand
 * when the cursor is anywhere over the aside (browser-driven, no JS state). */
.group:hover .group-hover\:opacity-100        { opacity: 1; }
.group:focus-within .group-focus-within\:opacity-100 { opacity: 1; }
.group:hover .group-hover\:w-full        { width: 100%; }
.group:hover .group-hover\:justify-start { justify-content: flex-start; }
.group:hover .group-hover\:gap-3         { gap: var(--space-3); }
.group:hover .group-hover\:pr-2          { padding-right: var(--space-2); }

/* --- Input/form resets --- */
.outline-none    { outline: none; }
.appearance-none { -webkit-appearance: none; appearance: none; }

/* --- State variants: focus / focus-visible / focus-within --- */
.focus\:outline-none:focus { outline: none; }
.ring {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.focus-visible\:ring:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.focus-within\:ring:focus-within {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.focus-within\:border-accent:focus-within { border-color: var(--accent); }
.focus-within\:border-strong:focus-within { border-color: var(--border-strong); }

/* --- State variants: active --- */
.active\:bg-accent-hover:active { background: var(--accent-hover); }
.active\:opacity-75:active      { opacity: 0.75; }

/* --- State variants: disabled --- */
.disabled\:opacity-50:disabled       { opacity: 0.5; }
.disabled\:cursor-not-allowed:disabled { cursor: not-allowed; }
.disabled\:pointer-events-none:disabled { pointer-events: none; }

/* --- Responsive prefixes (sm: 640, md: 768, lg: 1024) ----- */

@media (min-width: 640px) {
  .sm\:block        { display: block; }
  .sm\:inline-block { display: inline-block; }
  .sm\:flex         { display: flex; }
  .sm\:inline-flex  { display: inline-flex; }
  .sm\:grid         { display: grid; }
  .sm\:hidden       { display: none; }
  .sm\:flex-row     { flex-direction: row; }
  .sm\:flex-col     { flex-direction: column; }
  .sm\:items-center { align-items: center; }
  .sm\:justify-between { justify-content: space-between; }
  .sm\:grid-cols-2  { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm\:grid-cols-3  { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sm\:grid-cols-4  { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sm\:p-4   { padding: var(--space-4); }
  .sm\:p-6   { padding: var(--space-6); }
  .sm\:p-8   { padding: var(--space-8); }
  .sm\:px-6  { padding-inline: var(--space-6); }
  .sm\:py-6  { padding-block: var(--space-6); }
  .sm\:gap-4 { gap: var(--space-4); }
  .sm\:gap-6 { gap: var(--space-6); }
  .sm\:text-base { font-size: var(--text-base); }
  .sm\:text-lg   { font-size: var(--text-lg); }
  .sm\:text-xl   { font-size: var(--text-xl); }
  .sm\:text-2xl  { font-size: var(--text-2xl); }
  .sm\:text-3xl  { font-size: var(--text-3xl); }
}

@media (min-width: 768px) {
  .md\:block       { display: block; }
  .md\:flex        { display: flex; }
  .md\:grid        { display: grid; }
  .md\:hidden      { display: none; }
  .md\:flex-row    { flex-direction: row; }
  .md\:flex-col    { flex-direction: column; }
  .md\:items-center { align-items: center; }
  .md\:justify-between { justify-content: space-between; }
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .md\:grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .md\:p-6  { padding: var(--space-6); }
  .md\:p-8  { padding: var(--space-8); }
  .md\:p-12 { padding: var(--space-12); }
  .md\:px-6 { padding-inline: var(--space-6); }
  .md\:px-8 { padding-inline: var(--space-8); }
  .md\:py-8 { padding-block: var(--space-8); }
  .md\:gap-6 { gap: var(--space-6); }
  .md\:gap-8 { gap: var(--space-8); }
  .md\:text-lg  { font-size: var(--text-lg); }
  .md\:text-xl  { font-size: var(--text-xl); }
  .md\:text-2xl { font-size: var(--text-2xl); }
  .md\:text-3xl { font-size: var(--text-3xl); }
  .md\:text-4xl { font-size: var(--text-4xl); }
}

@media (min-width: 1024px) {
  .lg\:block        { display: block; }
  .lg\:flex         { display: flex; }
  .lg\:grid         { display: grid; }
  .lg\:hidden       { display: none; }
  .lg\:flex-row     { flex-direction: row; }
  .lg\:flex-col     { flex-direction: column; }
  .lg\:grid-cols-2  { grid-template-columns: repeat(2,  minmax(0, 1fr)); }
  .lg\:grid-cols-3  { grid-template-columns: repeat(3,  minmax(0, 1fr)); }
  .lg\:grid-cols-4  { grid-template-columns: repeat(4,  minmax(0, 1fr)); }
  .lg\:grid-cols-6  { grid-template-columns: repeat(6,  minmax(0, 1fr)); }
  .lg\:grid-cols-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .lg\:col-span-4   { grid-column: span 4 / span 4; }
  .lg\:col-span-6   { grid-column: span 6 / span 6; }
  .lg\:col-span-8   { grid-column: span 8 / span 8; }
  .lg\:sticky       { position: sticky; }
  .lg\:top-6        { top: var(--space-6); }
  .lg\:self-start   { align-self: start; }
  .lg\:p-8  { padding: var(--space-8); }
  .lg\:p-12 { padding: var(--space-12); }
  .lg\:p-16 { padding: var(--space-16); }
  .lg\:px-10 { padding-inline: var(--space-10); }
  .lg\:px-12 { padding-inline: var(--space-12); }
  .lg\:px-16 { padding-inline: var(--space-16); }
  .lg\:gap-8  { gap: var(--space-8); }
  .lg\:gap-12 { gap: var(--space-12); }
  .lg\:text-xl  { font-size: var(--text-xl); }
  .lg\:text-2xl { font-size: var(--text-2xl); }
  .lg\:text-3xl { font-size: var(--text-3xl); }
  .lg\:text-4xl { font-size: var(--text-4xl); }
  .lg\:text-5xl { font-size: var(--text-5xl); }
}

/* --- Prose (rendered markdown body) --- */
.prose-issue { color: var(--text-primary); }
.prose-issue p          { margin-block: 0.75em; }
.prose-issue p:first-child { margin-top: 0; }
.prose-issue p:last-child  { margin-bottom: 0; }
.prose-issue ul, .prose-issue ol { margin-block: 0.75em; padding-left: 1.5em; }
.prose-issue ul { list-style: disc; }
.prose-issue ol { list-style: decimal; }
.prose-issue li { margin-block: 0.25em; }
.prose-issue h1, .prose-issue h2, .prose-issue h3 {
  font-weight: 600; margin-top: 1.25em; margin-bottom: 0.5em; color: var(--text-primary);
}
.prose-issue h1 { font-size: var(--text-lg); }
.prose-issue h2 { font-size: var(--text-base); }
.prose-issue h3 { font-size: var(--text-sm); text-transform: uppercase; color: var(--text-secondary); }
.prose-issue code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.875em;
  padding: 0.1em 0.35em;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
}
.prose-issue pre {
  margin-block: 0.75em;
  padding: 0.75em 1em;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  overflow-x: auto;
}
.prose-issue pre code { background: transparent; border: 0; padding: 0; }
.prose-issue a { color: var(--accent); text-decoration: underline; }
.prose-issue a:hover { color: var(--accent-hover); }
.prose-issue blockquote {
  margin-block: 0.75em;
  padding-left: 1em;
  border-left: 3px solid var(--border-subtle);
  color: var(--text-secondary);
}
.prose-issue strong { font-weight: 600; }
.prose-issue em { font-style: italic; }

/* prose-plan — same vocabulary as prose-issue, used on PlanPanel
   markdown bodies (HQ-55). Kept as a separate class so we can tune
   spacing/typography for the plan-specific context without ripple. */
.prose-plan { color: var(--text-primary); }
.prose-plan p          { margin-block: 0.75em; }
.prose-plan p:first-child { margin-top: 0; }
.prose-plan p:last-child  { margin-bottom: 0; }
.prose-plan ul, .prose-plan ol { margin-block: 0.75em; padding-left: 1.5em; }
.prose-plan ul { list-style: disc; }
.prose-plan ol { list-style: decimal; }
.prose-plan li { margin-block: 0.25em; }
.prose-plan h1, .prose-plan h2, .prose-plan h3 {
  font-weight: 600; margin-top: 1.25em; margin-bottom: 0.5em; color: var(--text-primary);
}
.prose-plan h1 { font-size: var(--text-lg); }
.prose-plan h2 { font-size: var(--text-base); }
.prose-plan h3 { font-size: var(--text-sm); text-transform: uppercase; color: var(--text-secondary); }
.prose-plan code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.875em;
  padding: 0.1em 0.35em;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
}
.prose-plan pre {
  margin-block: 0.75em;
  padding: 0.75em 1em;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  overflow-x: auto;
}
.prose-plan pre code { background: transparent; border: 0; padding: 0; }
.prose-plan a { color: var(--accent); text-decoration: underline; }
.prose-plan a:hover { color: var(--accent-hover); }
.prose-plan blockquote {
  margin-block: 0.75em;
  padding-left: 1em;
  border-left: 3px solid var(--border-subtle);
  color: var(--text-secondary);
}
.prose-plan strong { font-weight: 600; }
.prose-plan em { font-style: italic; }

/* --- Text truncation (multi-line clamp) --- */
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
