/* Consola — component styles. Every value comes from tokens.css (loaded first). */

.cs, .cs * { box-sizing: border-box; }
.cs { font-family: var(--font-body); color: var(--ink); }

/* ---- panel + texture ---- */
.cs-panel { position: relative; background: var(--surface-000); color: var(--ink); border: 1px solid var(--hairline); border-radius: var(--radius-panel); padding: var(--space-6); overflow: hidden; }
.cs-panel > * { position: relative; z-index: 1; }
[data-texture="scanline"]::before { content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: var(--scanline-opacity);
  background: repeating-linear-gradient(0deg, transparent 0 calc(var(--scanline-pitch) - 1px), var(--ink) calc(var(--scanline-pitch) - 1px) var(--scanline-pitch)); }

/* ---- focus ---- */
.cs :focus-visible, .cs-btn:focus-visible, .cs-toggle:focus-visible { outline: var(--focus-ring) solid var(--focus); outline-offset: 2px; }

/* ---- Button ---- */
.cs-btn { display: inline-flex; align-items: center; gap: var(--space-2); font-family: var(--font-mono); font-size: 11px; line-height: 16px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 10px var(--space-4); border-radius: var(--radius-ctl); border: 1px solid transparent; cursor: pointer; box-shadow: var(--bevel); white-space: nowrap;
  transition: background var(--duration-switch) linear, box-shadow var(--duration-switch) linear, transform var(--duration-switch) steps(1); }
.cs-btn svg { width: 16px; height: 16px; }
.cs-btn--primary { background: var(--amber); color: var(--on-amber); border-bottom: 3px solid color-mix(in srgb, var(--amber) 55%, #000); }
.cs-btn--primary:hover { box-shadow: var(--bevel), var(--glow-amber); }
.cs-btn--secondary { background: var(--surface-100); color: var(--teal-text); border-color: var(--teal); }
.cs-btn--ghost { background: transparent; color: var(--ink); border-color: var(--hairline-strong); box-shadow: none; }
.cs-btn--danger { background: var(--signal); color: var(--on-signal); border-bottom: 3px solid color-mix(in srgb, var(--signal) 55%, #000); }
.cs-btn:active { transform: translateY(1px); }
.cs-btn[disabled] { background: var(--surface-100); color: var(--lamp-off); border-color: var(--hairline); box-shadow: none; cursor: not-allowed; }

/* ---- Lamp (shared) ---- */
.cs-lamp { display: inline-block; width: 8px; height: 8px; border-radius: var(--radius-lamp); background: var(--lamp-off); flex: none; }
.cs-lamp--amber { background: var(--amber); box-shadow: var(--glow-amber); }
.cs-lamp--teal { background: var(--teal); box-shadow: var(--glow-teal); }
.cs-lamp--signal { background: var(--signal); }
.cs-lamp--pulse { animation: cs-pulse var(--duration-pulse) steps(2) infinite; }
@keyframes cs-pulse { 0%, 100% { opacity: 1 } 50% { opacity: .55 } }

/* ---- Badge ---- */
.cs-badge { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; line-height: 16px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 4px var(--space-2); border-radius: var(--radius-ctl); background: var(--surface-100); border: 1px solid var(--hairline); color: var(--ink-muted); box-shadow: var(--bevel); }
.cs-badge--live { color: var(--teal-text); border-color: var(--teal); }
.cs-badge--warn { color: var(--amber-text); border-color: var(--amber); }
.cs-badge--danger { color: var(--signal-text); border-color: var(--signal); }

/* ---- Stat ---- */
.cs-stat { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.cs-stat__value { font-family: var(--font-mono); font-weight: 700; font-size: 28px; line-height: 32px; font-variant-numeric: tabular-nums; color: var(--ink); }
.cs-stat--xl .cs-stat__value { font-size: 40px; line-height: 44px; }
.cs-stat--accent .cs-stat__value { color: var(--amber-text); }
.cs-stat__label { font-family: var(--font-mono); font-size: 11px; line-height: 16px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); }
.cs-stat__delta { font-family: var(--font-mono); font-size: 13px; line-height: 18px; font-variant-numeric: tabular-nums; display: inline-flex; gap: 4px; align-items: center; }
.cs-stat__delta--up { color: var(--teal-text); }
.cs-stat__delta--down { color: var(--signal-text); }
.cs-stat__delta svg { width: 14px; height: 14px; }

/* ---- Card ---- */
.cs-card { background: var(--surface-100); border: 1px solid var(--hairline); border-radius: var(--radius-card); box-shadow: var(--bevel); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.cs-card--selected { border-color: var(--hairline-strong); }
.cs-card__eyebrow { font-family: var(--font-mono); font-size: 11px; line-height: 16px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--amber-text); }
.cs-card__eyebrow::before { content: "// "; color: var(--ink-muted); }
.cs-card__title { font-family: var(--font-display); font-weight: 600; font-size: 15px; line-height: 20px; letter-spacing: .01em; color: var(--ink); text-wrap: balance; }
.cs-card__body { font-size: 13px; line-height: 19px; color: var(--ink); }
.cs-card__body .cs-muted { color: var(--ink-muted); }
.cs-card__footer { font-family: var(--font-mono); font-size: 13px; line-height: 18px; color: var(--ink-muted); font-variant-numeric: tabular-nums; display: flex; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; border-top: 1px solid var(--hairline); padding-top: var(--space-2); margin-top: var(--space-1); }

/* ---- LabelPlate ---- */
.cs-plate { position: relative; padding-top: calc(var(--plate-height) + var(--space-3)); display: flex; flex-direction: column; gap: var(--space-1); }
.cs-plate::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: var(--plate-height); background: var(--amber); }
.cs-plate--short::before { width: 96px; }
.cs-plate__eyebrow { font-family: var(--font-mono); font-size: 11px; line-height: 16px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); display: inline-flex; gap: var(--space-2); align-items: center; }
.cs-plate__eyebrow .cs-lamp { width: 6px; height: 6px; }
.cs-plate__title { font-family: var(--font-display); font-weight: 600; letter-spacing: .01em; font-size: 24px; line-height: 28px; color: var(--ink); margin: 0; text-wrap: balance; }
.cs-plate--lg .cs-plate__title { font-size: 32px; line-height: 36px; }

/* ---- Toggle ---- */
.cs-toggle { display: inline-flex; align-items: center; gap: var(--space-3); background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 20px; }
.cs-toggle__track { position: relative; width: 44px; height: 24px; border-radius: var(--radius-ctl); background: var(--surface-200); border: 1px solid var(--hairline-strong); box-shadow: var(--bevel-inset); flex: none; }
.cs-toggle__knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: var(--radius-ctl); background: var(--surface-100); border: 1px solid var(--hairline-strong); box-shadow: var(--bevel); transition: transform var(--duration-switch) steps(2); }
.cs-toggle__knob::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; transform: translate(-50%, -50%); border-radius: var(--radius-lamp); background: var(--lamp-off); transition: background var(--duration-switch) linear; }
.cs-toggle[aria-checked="true"] .cs-toggle__knob { transform: translateX(20px); }
.cs-toggle[aria-checked="true"] .cs-toggle__knob::after { background: var(--amber); box-shadow: var(--glow-amber); }
.cs-toggle__label { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.cs-toggle__hint { font-family: var(--font-mono); font-size: 11px; line-height: 16px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); }

/* ---- Table ---- */
.cs-table-wrap { overflow-x: auto; border: 1px solid var(--hairline); border-radius: var(--radius-card); background: var(--surface-100); box-shadow: var(--bevel); }
.cs-table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 19px; }
.cs-table caption { text-align: left; font-family: var(--font-display); font-weight: 600; font-size: 15px; line-height: 20px; letter-spacing: .01em; padding: var(--space-3) var(--space-3) var(--space-2); color: var(--ink); }
.cs-table th { font-family: var(--font-mono); font-size: 11px; line-height: 16px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); text-align: left; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--hairline-strong); white-space: nowrap; }
.cs-table td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--hairline); vertical-align: baseline; color: var(--ink); }
.cs-table tr:last-child td { border-bottom: 0; }
.cs-table .cs-num { text-align: right; font-family: var(--font-mono); font-size: 13px; line-height: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cs-table .cs-up { color: var(--teal-text); }
.cs-table .cs-down { color: var(--signal-text); }
.cs-table tbody tr:hover td { background: color-mix(in srgb, var(--ink) 4%, transparent); }

/* ---- Terminal ---- */
.cs-terminal { background: var(--surface-200); color: var(--ink); border: 1px solid var(--hairline-strong); border-radius: var(--radius-card); box-shadow: var(--bevel-inset); font-family: var(--font-mono); font-size: 13px; line-height: 20px; overflow: hidden; }
.cs-terminal__bar { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--hairline); font-size: 11px; line-height: 16px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); }
.cs-terminal__bar .cs-lamp { width: 6px; height: 6px; }
.cs-terminal pre { margin: 0; padding: var(--space-3); overflow-x: auto; font: inherit; color: inherit; }
.cs-terminal .cs-prompt { color: var(--amber-text); }
.cs-terminal .cs-dim { color: var(--ink-muted); }
.cs-terminal .cs-ok { color: var(--teal-text); }

/* ---- Timeline ---- */
.cs-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.cs-timeline__item { display: grid; grid-template-columns: 72px 20px minmax(0, 1fr); gap: 0 var(--space-3); padding-bottom: var(--space-4); position: relative; }
.cs-timeline__time { font-family: var(--font-mono); font-size: 13px; line-height: 20px; font-variant-numeric: tabular-nums; color: var(--ink-muted); text-align: right; white-space: nowrap; }
.cs-timeline__rail { position: relative; }
.cs-timeline__rail::before { content: ""; position: absolute; left: 9px; top: 20px; bottom: calc(-1 * var(--space-4)); width: 2px; background: var(--hairline); }
.cs-timeline__item:last-child .cs-timeline__rail::before { display: none; }
.cs-timeline__node { position: relative; width: 20px; height: 20px; display: grid; place-items: center; }
.cs-timeline__node .cs-lamp { width: 10px; height: 10px; border: 1px solid var(--hairline-strong); background: var(--surface-100); }
.cs-timeline__item--active .cs-timeline__node .cs-lamp { background: var(--amber); border-color: var(--amber); box-shadow: var(--glow-amber); }
.cs-timeline__item--done .cs-timeline__node .cs-lamp { background: var(--teal); border-color: var(--teal); }
.cs-timeline__title { font-family: var(--font-display); font-weight: 600; font-size: 15px; line-height: 20px; letter-spacing: .01em; color: var(--ink); }
.cs-timeline__body { font-size: 13px; line-height: 19px; color: var(--ink-muted); margin-top: 2px; }

/* ---- Typewriter ---- */
.cs-type::after { content: "▮"; color: var(--amber-text); animation: cs-pulse var(--duration-pulse) steps(2) infinite; }
.cs-type--done::after { content: none; }

@media (prefers-reduced-motion: reduce) {
  .cs-btn, .cs-toggle__knob, .cs-toggle__knob::after { transition: none; }
  .cs-lamp--pulse, .cs-type::after { animation: none; }
}
