/* AI Training hub & uniform sub-pages. Inherits /styles.css design tokens. */
:root {
  --card: #faf7f0;
  --chip: #ece6d8;
  --pos: #0b6b3a;
  --neg: #b3261e;
  --warm: #9a4a08;
  --pi: #0f766e;
  --grid: rgba(22, 21, 15, 0.07);
  --shadow: 0 1px 0 rgba(22, 21, 15, 0.04), 0 14px 36px -22px rgba(22, 21, 15, 0.28);
}
@media (prefers-color-scheme: dark) {
  :root {
    --card: #181711;
    --chip: #26241b;
    --pos: #4fd18f;
    --neg: #ff7b6e;
    --warm: #f0a35e;
    --pi: #2dd4bf;
    --grid: rgba(239, 234, 223, 0.06);
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.25), 0 18px 42px -24px rgba(0, 0, 0, 0.9);
  }
}

[hidden] { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warm { color: var(--warm); }

.at-main { padding: clamp(24px, 4vw, 48px) 0 72px; }

/* Login gate */
.at-gate {
  max-width: 440px;
  margin: clamp(32px, 8vh, 80px) auto;
  padding: clamp(24px, 4vw, 36px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}
.at-gate h1 { font: 400 clamp(2rem, 4vw, 2.8rem)/1.02 var(--serif); }
.at-gate h1 em { font-style: italic; color: var(--accent); }
.at-field { display: grid; gap: 6px; }
.at-field label { font: 500 12px/1.2 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.at-field input, .at-field select, .at-field textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  font: 400 15px/1.4 var(--sans);
}
.at-field textarea { font-family: var(--mono); font-size: 13px; }
.at-msg { font-size: 13.5px; color: var(--pos); min-height: 18px; }
.at-msg.err { color: var(--neg); }

/* Top bar & subnav */
.at-top {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 14px 24px; margin-bottom: 18px;
}
.at-top h1 { font: 400 clamp(2.2rem, 4.5vw, 3.4rem)/1 var(--serif); letter-spacing: -0.02em; }
.at-top h1 em { font-style: italic; color: var(--accent); }
.at-top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.at-fresh { font: 400 12.5px/1.4 var(--mono); color: var(--muted); }

.at-subnav {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 10px 0 18px; margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.at-subnav a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 15px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card);
  text-decoration: none; font: 500 13.5px/1 var(--sans); color: var(--muted);
  transition: border-color .15s, color .15s, background .15s;
}
.at-subnav a:hover { border-color: var(--ink); color: var(--ink); }
.at-subnav a[aria-current="page"] {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}

/* Status chips & dots */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 11px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase;
  padding: 5px 10px; border-radius: 999px; background: var(--chip); color: var(--muted); white-space: nowrap;
}
.chip.ok { background: color-mix(in srgb, var(--pos) 15%, transparent); color: var(--pos); }
.chip.warm { background: color-mix(in srgb, var(--warm) 16%, transparent); color: var(--warm); }
.chip.miss { background: color-mix(in srgb, var(--neg) 15%, transparent); color: var(--neg); }
.chip.hi { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.chip.pi { background: color-mix(in srgb, var(--pi) 15%, transparent); color: var(--pi); }
.chip.line { background: transparent; border: 1px solid var(--line); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; position: relative; }
.dot.live::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1.5px solid currentColor;
  animation: atPing 1.8s cubic-bezier(0, 0, .2, 1) infinite;
}
@keyframes atPing { 0% { transform: scale(.6); opacity: .9; } 80%, 100% { transform: scale(1.7); opacity: 0; } }

/* Buttons */
.at-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 0 13px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--ink) 26%, transparent);
  background: transparent; color: var(--ink); font: 500 13px/1 var(--sans);
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, transform .1s;
}
.at-btn:hover:not(:disabled) { border-color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.at-btn:active:not(:disabled) { transform: scale(.98); }
.at-btn:disabled { opacity: .45; cursor: not-allowed; }
.at-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.at-btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.at-btn.start { border-color: color-mix(in srgb, var(--pos) 45%, transparent); color: var(--pos); }
.at-btn.start.active, .at-btn.start:hover:not(:disabled) { background: color-mix(in srgb, var(--pos) 14%, transparent); }
.at-btn.stop { border-color: color-mix(in srgb, var(--neg) 40%, transparent); color: var(--neg); }
.at-btn.stop.active, .at-btn.stop:hover:not(:disabled) { background: color-mix(in srgb, var(--neg) 12%, transparent); }
.at-btn.sm { min-height: 29px; padding: 0 11px; font-size: 12px; }
.at-btn.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* Overview 2x2 grid */
.at-ov-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 28px;
}
.at-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(18px, 2.5vw, 24px); box-shadow: var(--shadow);
  display: grid; gap: 16px; align-content: start; min-width: 0;
}
.at-card-h { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px; }
.at-card-h h2, .at-card-h h3 { font: 400 clamp(1.5rem, 2.4vw, 1.95rem)/1.08 var(--serif); margin: 0; }
.at-card-sub { font-size: 13.5px; color: var(--muted); margin-top: 3px; }

/* Uniform 6-KPI grid (matches across overview & sub-pages) */
.at-kpis {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
}
.at-kpis.wide { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.at-kpi {
  background: color-mix(in srgb, var(--paper) 65%, transparent);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
  display: grid; gap: 3px; min-width: 0;
}
.at-kpi .k { font: 500 10.5px/1.2 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.at-kpi .v { font: 400 clamp(1.35rem, 2.2vw, 1.75rem)/1.08 var(--serif); font-variant-numeric: tabular-nums; }
.at-kpi .s { font-size: 12px; color: var(--muted); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }

/* Machine control rows (Mac + Pi) */
.at-mach-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.at-mach {
  border: 1px solid var(--line); border-radius: 12px;
  background: color-mix(in srgb, var(--paper) 55%, transparent);
  padding: 14px 16px; display: grid; gap: 10px; align-content: start;
}
.at-mach-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.at-mach-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14.5px; }
.at-mach-meta { font: 400 12px/1.4 var(--mono); color: var(--muted); }
.at-mach-act { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.at-prog { height: 6px; border-radius: 99px; background: var(--chip); overflow: hidden; }
.at-prog > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }

/* Sub-page sections & charts */
.at-sec { display: grid; gap: 18px; margin-bottom: 24px; }
.at-two { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.85fr); gap: 20px; align-items: start; }
.at-svg { width: 100%; height: auto; display: block; border-radius: 10px; border: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 60%, transparent); }
.at-svg text { font: 400 11px var(--mono); fill: var(--muted); }
.at-svg .ax { stroke: var(--grid); }
.at-svg .zero { stroke: var(--muted); stroke-dasharray: 4 4; opacity: 0.7; }
.at-svg .bestln { stroke: var(--pos); stroke-dasharray: 5 3; stroke-width: 1.5; }
.at-svg .stepln { fill: none; stroke: var(--accent); stroke-width: 2; }
.at-svg .testln { fill: none; stroke: var(--warm); stroke-width: 1.6; stroke-dasharray: 4 3; }

.at-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font: 400 12px/1.3 var(--mono); color: var(--muted); }
.at-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

/* Tables */
.at-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.at-tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.at-tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.at-tbl th, .at-tbl td { padding: 8px 11px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.at-tbl th { font: 500 11px/1.3 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); background: color-mix(in srgb, var(--paper) 65%, transparent); }
.at-tbl td.n, .at-tbl th.n { text-align: right; font-family: var(--mono); }
.at-tbl td.wrap { white-space: normal; min-width: 190px; font-family: var(--mono); font-size: 12px; }
.at-tbl tr:last-child td { border-bottom: 0; }

/* Tooltip */
.at-tip {
  position: fixed; z-index: 90; pointer-events: none;
  background: var(--ink); color: var(--paper); border-radius: 8px;
  padding: 8px 11px; font-size: 12.5px; line-height: 1.4; max-width: 280px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.at-tip .h { font-weight: 600; margin-bottom: 4px; }
.at-tip .r { display: flex; justify-content: space-between; gap: 14px; font-family: var(--mono); font-size: 11.5px; }

/* Toast */
.at-toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 95;
  background: var(--ink); color: var(--paper); padding: 11px 16px; border-radius: 10px;
  font: 500 13px/1.35 var(--sans); box-shadow: 0 12px 32px rgba(0, 0, 0, .28);
  max-width: 360px;
}

/* Chain & tags */
.at-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font: 400 12.5px/1.4 var(--mono); }
.at-chain .node { padding: 3px 9px; border-radius: 6px; border: 1px solid var(--line); background: var(--paper); }
.at-chain .node.cur { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.at-code { font: 400 12px/1.45 var(--mono); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; max-height: 280px; }

.at-gchips { display: flex; flex-wrap: wrap; gap: 6px; }
.at-gchip {
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font: 500 12px/1 var(--mono); cursor: pointer;
}
.at-gchip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.at-bars { display: grid; gap: 8px; }
.at-brow { display: grid; grid-template-columns: 110px 1fr 78px; gap: 10px; align-items: center; font: 400 12.5px/1.2 var(--mono); }
.at-brow .trk { height: 10px; border-radius: 99px; background: var(--chip); overflow: hidden; }
.at-brow .trk i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.at-brow .trk i.pos { background: var(--pos); }
.at-brow .trk i.neg { background: var(--neg); }

@media (max-width: 980px) {
  .at-ov-grid, .at-mach-grid, .at-two { grid-template-columns: minmax(0, 1fr); }
  .at-kpis.wide { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .at-kpis, .at-kpis.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* push progress strip (top of every AI Training page) */
.at-pushbar { position: sticky; top: 0; z-index: 20; margin: 0 0 18px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--card); box-shadow: var(--shadow); display: grid; gap: 8px; }
.at-pb-h { font: 500 11.5px/1.2 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.at-pb-row { display: grid; grid-template-columns: 190px 1fr minmax(200px, auto); align-items: center; gap: 12px; }
.at-pb-who { font-weight: 500; white-space: nowrap; }
.at-pb-bar { position: relative; height: 8px; border-radius: 99px; background: var(--chip); overflow: hidden; }
.at-pb-bar > span { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--accent); transition: width 0.9s linear; }
.at-pb-row.done .at-pb-bar > span { background: var(--pos); }
.at-pb-row.bad .at-pb-bar > span { background: var(--neg); }
.at-pb-row.wait .at-pb-bar { background: repeating-linear-gradient(-45deg, var(--chip) 0 8px, transparent 8px 16px); background-size: 200% 100%;
  animation: at-pb-wait 2.4s linear infinite; }
@keyframes at-pb-wait { to { background-position: -45px 0; } }
.at-pb-txt { font: 400 12.5px/1.3 var(--mono); color: var(--muted); text-align: right; }
@media (max-width: 600px) {
  .at-pb-row { grid-template-columns: 1fr auto; }
  .at-pb-bar { grid-column: 1 / -1; grid-row: 2; }
}
@media (prefers-reduced-motion: reduce) { .at-pb-row.wait .at-pb-bar { animation: none; } .at-pb-bar > span { transition: none; } }

/* "new best" notes */
.at-notes { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; max-width: min(340px, calc(100vw - 32px)); }
.at-note { display: grid; gap: 3px; text-align: left; padding: 10px 14px; border: 1px solid color-mix(in srgb, var(--pos) 35%, var(--line));
  border-radius: 12px; background: var(--card); color: var(--ink); box-shadow: var(--shadow); cursor: pointer; font: inherit;
  animation: at-note-in 0.25s ease-out; }
.at-note-t { font-weight: 600; color: var(--pos); }
.at-note-s { font: 400 12.5px/1.35 var(--mono); color: var(--muted); }
@keyframes at-note-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .at-note { animation: none; } }

/* step pills on the machine cards: slim rounded segments, labels only at the ends */
.at-pills { display: grid; gap: 4px; margin-top: 2px; }
.at-pills-row { display: flex; gap: 3px; }
.at-pills-row i { flex: 1 1 0; min-width: 0; height: 7px; border-radius: 99px; background: var(--chip); }
.at-pills-row i.done { background: var(--accent); }
.at-pills-row i.cur { background: color-mix(in srgb, var(--accent) 45%, var(--chip)); animation: at-pill-now 1.6s ease-in-out infinite; }
@keyframes at-pill-now { 50% { background: color-mix(in srgb, var(--accent) 75%, var(--chip)); } }
.at-pills-ends { display: flex; justify-content: space-between; font: 400 11px/1 var(--mono); color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .at-pills-row i.cur { animation: none; } }
