/* ============================================================
   Smooth Power — R&D Lab
   Dark-first, premium minimal, brand-aligned with corporate site.
   ============================================================ */

:root {
  /* surfaces */
  --bg-0: #0b0b0e;
  --bg-1: #131318;
  --bg-2: #1c1c22;
  --bg-3: #25252c;
  --hairline: rgba(255, 255, 255, 0.08);
  --hairline-strong: rgba(255, 255, 255, 0.14);

  /* ink */
  --ink-0: #faf7f2;
  --ink-1: #d9d4cc;
  --ink-2: #918c84;
  --ink-3: #5b574f;
  --ink-4: #38353030;

  /* brand accents */
  --red:        #FF3B44;
  --red-deep:   #DC1E2A;
  --red-soft:   rgba(255, 59, 68, .14);
  --amber:      #FF9F43;
  --amber-soft: rgba(255, 159, 67, .14);
  --violet:     #8B5CF6;
  --cyan:       #06B6D4;
  --emerald:    #10B981;
  --emerald-soft: rgba(16, 185, 129, .14);

  /* effects */
  --shadow-1: 0 1px 0 rgba(255,255,255,.04) inset, 0 12px 32px -16px rgba(0,0,0,.6);
  --shadow-2: 0 1px 0 rgba(255,255,255,.05) inset, 0 24px 60px -24px rgba(0,0,0,.8);
  --radius-s: 10px;
  --radius:   14px;
  --radius-l: 22px;
  --radius-xl: 28px;

  /* type */
  --font-display: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { background: var(--bg-0); color-scheme: dark; overflow-x: hidden; }
body {
  overflow-x: hidden;
  margin: 0;
  font-family: var(--font-display);
  color: var(--ink-0);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(255, 59, 68, .08), transparent 60%),
    radial-gradient(900px 500px at 90% 90%, rgba(139, 92, 246, .08), transparent 70%),
    var(--bg-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ============================================================
   LOGIN
   ============================================================ */
.login {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 100;
}
.login-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 59, 68, .12), transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(6, 182, 212, .1), transparent 55%),
    var(--bg-0);
}
.login-circuit {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: .55;
}
.login-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  padding: 40px 32px 32px;
  background: linear-gradient(180deg, rgba(28, 28, 34, .85), rgba(19, 19, 24, .85));
  backdrop-filter: blur(20px);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2);
  text-align: center;
}
.login-logo { width: 160px; height: auto; margin-bottom: 28px; }
.login-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 0 0 6px;
  background: linear-gradient(90deg, #fff, #d9d4cc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-sub { color: var(--ink-2); margin: 0 0 28px; font-size: 14px; }
.pin-input {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 280px;
  margin: 0 auto 20px;
}
.pin-cell {
  width: 100%;
  aspect-ratio: 1;
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  background: var(--bg-1);
  border: 1.5px solid var(--hairline-strong);
  border-radius: var(--radius-s);
  color: var(--ink-0);
  font-family: var(--font-mono);
  transition: border-color .15s, transform .15s;
}
.pin-cell:focus {
  outline: none;
  border-color: var(--red);
  transform: scale(1.04);
}
.login-msg {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
  margin-bottom: 12px;
}
.login-foot {
  margin: 22px 0 0;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px max(20px, env(safe-area-inset-left)) 14px max(20px, env(safe-area-inset-right));
  background: rgba(11, 11, 14, .82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--hairline);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.brand img { height: 28px; width: auto; }
.brand-sub {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding-left: 12px;
  border-left: 1px solid var(--hairline);
}
.nav { display: flex; gap: 6px; margin-left: auto; }
.nav-link {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-1);
  border-radius: 999px;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.nav-link:hover { color: var(--ink-0); background: rgba(255,255,255,.04); }
.nav-link.active {
  color: var(--ink-0);
  background: rgba(255,255,255,.06);
  border-color: var(--hairline);
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: rgba(255,255,255,.03);
  color: var(--ink-1);
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.icon-btn:hover { color: var(--red); border-color: rgba(255, 59, 68, .35); }

.view {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 max(20px, env(safe-area-inset-left)) 80px max(20px, env(safe-area-inset-right));
}

.footer {
  padding: 24px 20px max(24px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
  border-top: 1px solid var(--hairline);
}
.footer .sep { padding: 0 8px; }

/* ============================================================
   FAB
   ============================================================ */
.fab {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--red), var(--red-deep));
  box-shadow: 0 8px 24px -6px rgba(255, 59, 68, .55), 0 1px 0 rgba(255,255,255,.2) inset;
  border: 1px solid rgba(255,255,255,.16);
  z-index: 40;
  transition: transform .2s, box-shadow .2s;
}
.fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 32px -6px rgba(255, 59, 68, .65); }
.fab:active { transform: translateY(0) scale(.98); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .12s, background .15s, border-color .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--red), var(--red-deep));
  color: #fff;
  box-shadow: 0 6px 18px -6px rgba(255, 59, 68, .5), 0 1px 0 rgba(255,255,255,.2) inset;
  border-color: rgba(255,255,255,.14);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -6px rgba(255, 59, 68, .6); }
.btn-secondary {
  background: rgba(255,255,255,.04);
  border-color: var(--hairline-strong);
  color: var(--ink-0);
}
.btn-secondary:hover { background: rgba(255,255,255,.08); }
.btn-ghost {
  background: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover { color: var(--ink-0); }
.btn-large { padding: 14px 24px; font-size: 15px; width: 100%; }

/* ============================================================
   HERO (home)
   ============================================================ */
.hero {
  position: relative;
  padding: 60px 0 50px;
}
.hero-bg {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 102vw;
  transform: translateX(-50%);
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.hero-orb {
  position: absolute;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .5;
}
.hero-orb-a { background: var(--red); top: -120px; left: -100px; }
.hero-orb-b { background: var(--violet); top: 20%; right: -120px; opacity: .35; }
.hero-orb-c { background: var(--cyan); bottom: -150px; left: 40%; opacity: .25; }
.hero-grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: .8;
}
.hero-inner { position: relative; z-index: 1; max-width: 760px; }
.kicker {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 6px 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  margin-bottom: 22px;
  background: rgba(255,255,255,.02);
}
.hero-title {
  font-size: clamp(34px, 5.5vw, 60px);
  font-weight: 700;
  letter-spacing: -.025em;
  line-height: 1.05;
  margin: 0 0 18px;
}
.grad {
  background: linear-gradient(90deg, var(--red), var(--amber) 40%, var(--violet) 75%, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub {
  font-size: 17px;
  color: var(--ink-1);
  margin: 0 0 36px;
  max-width: 540px;
  line-height: 1.5;
}

.search-wrap { position: relative; max-width: 640px; }
.search-box {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--bg-1);
  border: 1.5px solid var(--hairline-strong);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-1);
  transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within {
  border-color: rgba(255, 59, 68, .55);
  box-shadow: 0 0 0 4px rgba(255, 59, 68, .12), var(--shadow-1);
}
.search-icon { color: var(--ink-2); flex-shrink: 0; }
.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 17px;
  font-weight: 500;
  color: var(--ink-0);
  font-family: var(--font-mono);
}
.search-box input::placeholder { color: var(--ink-3); font-family: var(--font-display); font-weight: 400; }
.kbd {
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--bg-2);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  font-family: var(--font-mono);
}
.search-box-compact { padding: 10px 14px; max-width: 280px; }
.search-box-compact input { font-size: 14px; }
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 360px;
  overflow-y: auto;
  background: var(--bg-1);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  z-index: 20;
  display: none;
}
.search-results.open { display: block; }
.search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline);
  cursor: pointer;
  transition: background .12s;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover, .search-result.hi { background: rgba(255,255,255,.04); }
.search-result-main { display: flex; flex-direction: column; gap: 4px; }
.search-result-pcb { font-family: var(--font-mono); font-weight: 600; font-size: 15px; }
.search-result-sub { font-size: 12px; color: var(--ink-2); }
.search-result-meta { font-size: 11px; color: var(--ink-3); }

.quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}
.chip-btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-1);
  background: rgba(255,255,255,.03);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-mono);
  transition: background .15s, color .15s, border-color .15s;
}
.chip-btn:hover { background: rgba(255, 59, 68, .1); color: var(--red); border-color: rgba(255, 59, 68, .35); }
.chip-btn-ghost { font-family: var(--font-display); color: var(--ink-2); }

/* ============================================================
   HUB (home stats + recent)
   ============================================================ */
.hub { margin-top: 24px; }
.hub-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 18px;
}
.hub-card {
  min-width: 0; /* allow grid track to shrink so long text truncates instead of blowing out */
  background: linear-gradient(180deg, rgba(28,28,34,.6), rgba(19,19,24,.6));
  border: 1px solid var(--hairline);
  border-radius: var(--radius-l);
  padding: 24px;
}
.hub-card-title {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 18px;
}
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-num {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.02em;
  font-feature-settings: "tnum";
}
.stat-label { font-size: 11px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .08em; }

.recent-list { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 12px 14px;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .12s;
}
.recent-item:hover { background: rgba(255,255,255,.05); border-color: var(--hairline-strong); transform: translateX(2px); }
.recent-pcb { font-family: var(--font-mono); font-weight: 600; font-size: 14px; flex-shrink: 0; min-width: 90px; }
.recent-mod { flex: 1; min-width: 0; font-size: 13px; color: var(--ink-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-date { font-size: 12px; color: var(--ink-3); flex-shrink: 0; }

/* ============================================================
   MODEL DETAIL
   ============================================================ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 24px 0 18px;
  padding: 6px 12px 6px 8px;
  font-size: 13px;
  color: var(--ink-2);
  border-radius: 999px;
  transition: background .12s, color .12s;
}
.back-link:hover { color: var(--ink-0); background: rgba(255,255,255,.04); }

.model-page { padding-top: 8px; }
.model-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 32px;
  margin-bottom: 18px;
  background: linear-gradient(135deg, rgba(255,59,68,.08), rgba(139,92,246,.06) 60%, rgba(6,182,212,.05));
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-l);
  position: relative;
  overflow: hidden;
}
.model-head::before {
  content: '';
  position: absolute;
  top: -50%; right: -10%;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(255,59,68,.18), transparent 60%);
  filter: blur(40px);
  pointer-events: none;
}
.model-head-main { position: relative; z-index: 1; }
.model-eyebrow {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 8px;
}
.model-pcb {
  font-family: var(--font-mono);
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 0 0 12px;
  line-height: 1;
}
.model-meta { color: var(--ink-1); margin: 0; font-size: 14px; }
.model-head-actions { display: flex; gap: 10px; position: relative; z-index: 1; }

.model-spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 32px;
}
.spec-card {
  padding: 14px 16px;
  background: var(--bg-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.spec-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.spec-val { font-size: 14px; color: var(--ink-0); font-weight: 500; word-break: break-word; }
.spec-val.empty { color: var(--ink-3); font-style: italic; font-weight: 400; }

/* ============================================================
   TRIAL TIMELINE
   ============================================================ */
.trial-section { margin-top: 12px; }
.trial-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--hairline);
}
.trial-section-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.counter {
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: .08em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.trial-list { display: flex; flex-direction: column; gap: 0; }
.trial {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 0;
  position: relative;
}
.trial-stem {
  position: relative;
  display: flex;
  justify-content: center;
}
.trial-stem::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--hairline-strong);
  transform: translateX(-50%);
}
.trial:first-child .trial-stem::before { top: 24px; }
.trial:last-child .trial-stem::before { bottom: calc(100% - 24px); }
.trial-dot {
  position: relative;
  z-index: 1;
  width: 12px;
  height: 12px;
  margin-top: 18px;
  border-radius: 50%;
  background: var(--ink-3);
  box-shadow: 0 0 0 4px var(--bg-0);
}
.trial.pass .trial-dot { background: var(--emerald); box-shadow: 0 0 0 4px var(--bg-0), 0 0 12px var(--emerald); }
.trial.fail .trial-dot { background: var(--red); box-shadow: 0 0 0 4px var(--bg-0), 0 0 12px var(--red); }
.trial.pending .trial-dot { background: var(--amber); box-shadow: 0 0 0 4px var(--bg-0), 0 0 12px var(--amber); }

.trial-body {
  background: var(--bg-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 8px 0 16px;
  flex: 1;
  transition: border-color .15s, transform .15s;
}
.trial-body:hover { border-color: var(--hairline-strong); }
.trial-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.trial-date {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-family: var(--font-mono);
}
.trial-status {
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  border-radius: 999px;
  font-family: var(--font-mono);
}
.trial-status.pass    { background: var(--emerald-soft); color: var(--emerald); }
.trial-status.fail    { background: var(--red-soft); color: var(--red); }
.trial-status.pending { background: var(--amber-soft); color: var(--amber); }
.trial-status.unknown { background: rgba(255,255,255,.06); color: var(--ink-2); }

.trial-mod {
  font-size: 15px;
  color: var(--ink-0);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 12px;
}
.trial-results {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.trial-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  color: var(--ink-1);
}
.trial-pill strong { color: var(--ink-0); font-weight: 600; }
.trial-faults {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--amber);
  margin-bottom: 8px;
  padding: 8px 12px;
  background: var(--amber-soft);
  border-left: 2px solid var(--amber);
  border-radius: 4px;
}
.trial-faults:empty { display: none; }
.fault-ic { flex-shrink: 0; margin-top: 1px; }
.trial-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-3);
  padding-top: 8px;
  border-top: 1px solid var(--hairline);
}
.link-btn {
  background: none;
  border: none;
  color: var(--ink-3);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color .12s, background .12s;
}
.link-btn:hover { color: var(--red); background: rgba(255, 59, 68, .08); }

.trial-complete {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: var(--amber-soft);
  border: 1px dashed rgba(255,159,67,.4);
  border-radius: var(--radius-s);
}
.trial-complete-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--amber);
  margin-right: 2px;
}
.mini-btn {
  padding: 5px 16px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--hairline-strong);
  background: rgba(255,255,255,.05);
  color: var(--ink-1);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.mini-btn:disabled { opacity: .5; cursor: default; }
.mini-pass:hover { background: var(--emerald-soft); color: var(--emerald); border-color: rgba(16,185,129,.45); }
.mini-fail:hover { background: var(--red-soft); color: var(--red); border-color: rgba(255,59,68,.45); }

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-2);
  font-size: 14px;
  background: var(--bg-1);
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--radius);
}
.empty-state strong { color: var(--ink-0); display: block; font-size: 16px; font-weight: 600; margin-bottom: 6px; }

/* ============================================================
   FORM
   ============================================================ */
.form-page { max-width: 720px; margin: 0 auto; padding-top: 8px; }
.form-title { font-size: 32px; font-weight: 700; letter-spacing: -.02em; margin: 8px 0 6px; }
.form-sub { color: var(--ink-2); margin: 0 0 28px; }
.form-card {
  background: linear-gradient(180deg, rgba(28,28,34,.5), rgba(19,19,24,.5));
  border: 1px solid var(--hairline);
  border-radius: var(--radius-l);
  padding: 28px;
}
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; position: relative; }
.field label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.field input, .field textarea {
  padding: 12px 14px;
  background: var(--bg-1);
  border: 1.5px solid var(--hairline);
  border-radius: var(--radius-s);
  color: var(--ink-0);
  font-family: var(--font-display);
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(255, 59, 68, .12);
}
.field textarea { resize: vertical; min-height: 80px; font-family: var(--font-display); line-height: 1.5; }
.field input[type="date"] { font-family: var(--font-mono); }
.field input::placeholder, .field textarea::placeholder { color: var(--ink-3); }
.hint { color: var(--ink-3); font-size: 12px; margin-top: 4px; }
.field-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.pcb-picker { position: relative; }
.pcb-picker input { font-family: var(--font-mono); font-weight: 600; }
.pcb-suggest {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow-2);
  z-index: 20;
  display: none;
}
.pcb-suggest.open { display: block; }
.pcb-suggest-item {
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-mono);
  cursor: pointer;
  border-bottom: 1px solid var(--hairline);
}
.pcb-suggest-item:last-child { border-bottom: none; }
.pcb-suggest-item:hover, .pcb-suggest-item.hi { background: rgba(255,255,255,.05); }
.pcb-suggest-item small { display: block; font-family: var(--font-display); color: var(--ink-3); margin-top: 2px; font-size: 11px; }

.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--bg-1);
  border: 1.5px solid var(--hairline);
  border-radius: var(--radius-s);
}
.seg-btn {
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-s) - 4px);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.seg-btn:hover { color: var(--ink-0); }
.seg-btn.seg-on {
  background: rgba(255,255,255,.06);
  color: var(--ink-0);
}
.seg-btn[data-val="Pass"].seg-on { background: var(--emerald-soft); color: var(--emerald); }
.seg-btn[data-val="Fail"].seg-on { background: var(--red-soft); color: var(--red); }
.seg-btn[data-val="Pending"].seg-on { background: var(--amber-soft); color: var(--amber); }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
}

/* ============================================================
   ALL MODELS GRID
   ============================================================ */
.all-page { padding-top: 24px; }
.all-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--hairline);
}
.all-head h1 { margin: 0 0 4px; font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.all-sub { margin: 0; color: var(--ink-2); font-size: 14px; }
.all-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.model-card {
  display: flex;
  flex-direction: column;
  padding: 16px 18px;
  background: var(--bg-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s;
}
.model-card:hover {
  background: var(--bg-2);
  border-color: var(--hairline-strong);
  transform: translateY(-2px);
}
.model-card-pcb {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 6px;
}
.model-card-meta { font-size: 12px; color: var(--ink-2); line-height: 1.4; min-height: 32px; }
.model-card-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
  font-size: 11px;
  color: var(--ink-3);
}
.model-card-trials {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--ink-1);
}
.model-card-trials.has-trials { color: var(--cyan); }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 14px 22px;
  background: var(--bg-2);
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  color: var(--ink-0);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 200;
  max-width: calc(100% - 40px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(255, 59, 68, .5); color: #ffd4d7; }
.toast.ok { border-color: rgba(16, 185, 129, .45); }

/* ============================================================
   SKELETON / LOADING
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-1) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-s);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   v2 — IDENTITY, ADMIN, MODALS, RECYCLE BIN
   ============================================================ */
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: 8px; }

.nav-link-admin { color: var(--amber); }
.nav-link-admin:hover { color: var(--amber-2); background: var(--amber-soft); }
.nav-link-admin.active { color: var(--amber); background: var(--amber-soft); border-color: rgba(255,159,67,.3); }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--ink-1);
  cursor: pointer;
  transition: background .15s, border-color .15s;
  max-width: 160px;
}
.user-chip:hover { background: rgba(255,255,255,.08); border-color: var(--hairline-strong); }
.user-avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.user-avatar.avatar-viewing { background: linear-gradient(135deg, #4d4b46, #2b2b32); }
.user-avatar svg { display: block; }
.user-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: var(--amber-soft);
  border: 1px solid rgba(255,159,67,.4);
  border-radius: 999px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background .15s;
}
.admin-chip:hover { background: rgba(255,159,67,.22); }

/* modal overlay (user picker + admin pin) */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 5, 7, .72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.modal-card {
  width: 100%;
  max-width: 440px;
  padding: 32px;
  background: linear-gradient(180deg, rgba(30,30,36,.96), rgba(20,20,25,.96));
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2);
  text-align: center;
}
.modal-card-sm { max-width: 380px; }
.modal-icon {
  display: grid;
  place-items: center;
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--amber-soft);
  color: var(--amber);
}
.modal-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 6px; }
.modal-sub { color: var(--ink-2); font-size: 14px; margin: 0 0 22px; line-height: 1.45; }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }

.user-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
  max-height: 280px;
  overflow-y: auto;
}
.user-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-1);
  border: 1.5px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--ink-0);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .12s;
  text-align: left;
}
.user-pick:hover { background: var(--bg-2); border-color: var(--red); transform: translateY(-1px); }
.user-pick.current { border-color: var(--violet); }
.user-add { display: flex; gap: 8px; }
.user-add input {
  flex: 1;
  padding: 11px 14px;
  background: var(--bg-1);
  border: 1.5px solid var(--hairline);
  border-radius: var(--radius-s);
  color: var(--ink-0);
  font-size: 14px;
  font-family: var(--font-display);
}
.user-add input:focus { outline: none; border-color: var(--red); }
.just-viewing {
  display: block;
  margin: 18px auto 0;
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 999px;
  transition: color .15s, background .15s;
}
.just-viewing:hover { color: var(--ink-0); background: rgba(255,255,255,.04); }
.muted { color: var(--ink-2); font-size: 14px; }

.admin-pin-field {
  width: 100%;
  padding: 14px;
  font-size: 24px;
  letter-spacing: .5em;
  text-align: center;
  font-family: var(--font-mono);
  background: var(--bg-1);
  border: 1.5px solid var(--hairline-strong);
  border-radius: var(--radius-s);
  color: var(--ink-0);
  margin-bottom: 8px;
}
.admin-pin-field:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }

.select-field {
  padding: 12px 14px;
  background: var(--bg-1);
  border: 1.5px solid var(--hairline);
  border-radius: var(--radius-s);
  color: var(--ink-0);
  font-family: var(--font-display);
  font-size: 15px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23918c84' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4 6 8 10 12 6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.select-field:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(255,59,68,.12); }

/* recycle bin */
.bin-list { display: flex; flex-direction: column; gap: 10px; }
.bin-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: var(--bg-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}
.bin-row-main { flex: 1; min-width: 0; }
.bin-row-top { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.bin-pcb { font-family: var(--font-mono); font-weight: 600; font-size: 15px; }
.bin-date { font-size: 12px; color: var(--ink-2); font-family: var(--font-mono); }
.bin-mod { font-size: 14px; color: var(--ink-1); line-height: 1.4; white-space: pre-wrap; word-break: break-word; margin-bottom: 6px; }
.bin-meta { font-size: 11px; color: var(--ink-3); }
.bin-row-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; align-items: flex-end; }
.bin-row-actions .btn { padding: 7px 14px; font-size: 13px; }
.bin-group-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); margin: 18px 2px 4px; }
.bin-group-title:first-child { margin-top: 0; }

/* ============================================================
   SURGE FEATURE — chooser, section switch, surge views
   ============================================================ */

/* section switch in header */
.section-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--hairline);
  border-radius: 999px;
}
.seg-link {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  border-radius: 999px;
  transition: background .15s, color .15s;
}
.seg-link:hover { color: var(--ink-0); }
.seg-link.active[data-section="rnd"] { background: var(--red); color: #fff; }
.seg-link.active[data-section="surge"] { background: var(--cyan); color: #05242a; }

/* chooser landing */
.chooser {
  max-width: 920px;
  margin: 0 auto;
  padding: clamp(40px, 8vh, 90px) 0 60px;
}
.chooser-head { text-align: center; margin-bottom: 44px; }
.chooser-title { font-size: clamp(28px, 4.5vw, 44px); font-weight: 700; letter-spacing: -.025em; margin: 14px 0 10px; }
.chooser-sub { color: var(--ink-2); font-size: 16px; }
.chooser-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.choice-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 34px 30px 28px;
  background: linear-gradient(180deg, rgba(30,30,36,.7), rgba(18,18,23,.7));
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-xl);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.choice-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); }
.choice-rnd:hover { border-color: rgba(255,59,68,.5); }
.choice-surge:hover { border-color: rgba(6,182,212,.5); }
.choice-glow { position: absolute; top: -60px; right: -60px; width: 200px; height: 200px; border-radius: 50%; filter: blur(70px); opacity: .5; pointer-events: none; }
.choice-rnd .choice-glow { background: var(--red); }
.choice-surge .choice-glow { background: var(--cyan); }
.choice-icon {
  display: grid; place-items: center;
  width: 64px; height: 64px;
  border-radius: 18px;
  margin-bottom: 20px;
  border: 1px solid var(--hairline-strong);
}
.choice-rnd .choice-icon { color: var(--red-2); background: rgba(255,59,68,.1); }
.choice-surge .choice-icon { color: var(--cyan); background: rgba(6,182,212,.1); }
.choice-title { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 8px; }
.choice-desc { color: var(--ink-2); font-size: 14px; line-height: 1.5; margin: 0 0 16px; max-width: 320px; }
.choice-stat { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); margin-bottom: 20px; }
.choice-go {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: auto;
  font-size: 14px; font-weight: 600;
  padding: 9px 18px; border-radius: 999px;
}
.choice-rnd .choice-go { background: rgba(255,59,68,.12); color: var(--red-2); }
.choice-surge .choice-go { background: rgba(6,182,212,.12); color: var(--cyan); }
.choice-card:hover .choice-go svg { transform: translateX(3px); }
.choice-go svg { transition: transform .18s; }

/* surge hero accent */
.grad-surge { background: linear-gradient(90deg, var(--cyan), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-orb-s1 { background: var(--cyan); top: -120px; left: -80px; opacity: .4; }
.hero-orb-s2 { background: var(--violet); bottom: -150px; right: -80px; opacity: .28; }
.search-box-surge:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(6,182,212,.12); }

/* surge cards */
.surge-list { display: flex; flex-direction: column; gap: 12px; }
.surge-card {
  padding: 16px 18px;
  background: var(--bg-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}
.surge-all-pcb-link { display: inline-block; font-family: var(--font-mono); font-weight: 700; font-size: 14px; color: var(--cyan); margin-bottom: 10px; }
.surge-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.surge-card-l { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.surge-date { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); }
.surge-kv { font-weight: 700; font-size: 14px; color: var(--cyan); background: rgba(6,182,212,.12); padding: 3px 10px; border-radius: 6px; }
.surge-rating { font-size: 12px; color: var(--ink-2); border: 1px solid var(--hairline); padding: 3px 8px; border-radius: 6px; }
.surge-pill { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 4px 12px; border-radius: 999px; }
.surge-pill.pass { background: var(--emerald-soft); color: var(--emerald); }
.surge-pill.fail { background: var(--red-soft); color: var(--red); }
.surge-pill.pending { background: var(--amber-soft); color: var(--amber); }
.surge-pill.unknown { background: rgba(255,255,255,.06); color: var(--ink-2); }

.piece-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.piece-chip {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 58px; padding: 8px 6px;
  border-radius: var(--radius-s);
  border: 1.5px solid var(--hairline-strong);
  background: rgba(255,255,255,.03);
  cursor: pointer; transition: transform .12s, border-color .15s, background .15s;
}
.piece-chip:hover { transform: translateY(-2px); }
.piece-chip:disabled { opacity: .5; cursor: default; }
.chip-n { font-size: 11px; color: var(--ink-3); font-weight: 600; }
.chip-tag { font-size: 12px; font-weight: 700; }
.piece-chip.chip-pass { border-color: rgba(16,185,129,.5); background: var(--emerald-soft); }
.piece-chip.chip-pass .chip-tag { color: var(--emerald); }
.piece-chip.chip-fail { border-color: rgba(255,59,68,.5); background: var(--red-soft); }
.piece-chip.chip-fail .chip-tag { color: var(--red); }
.piece-chip.chip-none .chip-tag { color: var(--ink-3); }
.surge-summary { font-size: 12px; color: var(--ink-2); margin-bottom: 8px; }
.surge-notes { font-size: 13px; color: var(--ink-1); line-height: 1.45; background: rgba(255,255,255,.03); border-left: 2px solid var(--hairline-strong); padding: 8px 12px; border-radius: 4px; margin-bottom: 10px; white-space: pre-wrap; }
.model-head-surge { background: linear-gradient(135deg, rgba(6,182,212,.10), rgba(139,92,246,.06)); }

/* piece selectors in the new-surge form */
.piece-grid { display: flex; flex-direction: column; gap: 10px; }
.piece { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; background: var(--bg-1); border: 1px solid var(--hairline); border-radius: var(--radius-s); }
.piece-num { font-size: 13px; font-weight: 600; color: var(--ink-1); }
.piece-seg { display: inline-flex; gap: 2px; padding: 3px; background: rgba(0,0,0,.2); border-radius: 999px; }
.piece-btn { padding: 6px 16px; font-size: 13px; font-weight: 600; border: none; background: none; color: var(--ink-2); border-radius: 999px; cursor: pointer; transition: background .15s, color .15s; }
.piece-btn.on { background: var(--bg-3); color: var(--ink-0); }
.piece-btn.piece-pass.on { background: var(--emerald); color: #05231a; }
.piece-btn.piece-fail.on { background: var(--red); color: #fff; }

/* ============================================================
   EDITOR GATING + SURGE DETAIL + ANIMATIONS (round 3)
   ============================================================ */
/* write affordances hidden for viewers (no flash; reactive to body class) */
body:not(.is-editor) .editor-only { display: none !important; }

/* surge card is now a read-only link to its detail */
.surge-card-link { display: block; color: inherit; text-decoration: none; }
.surge-card-link:hover { border-color: rgba(6,182,212,.45); transform: translateY(-2px); box-shadow: var(--shadow-1); }
.surge-card { transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.surge-pcb { font-family: var(--font-mono); font-weight: 700; font-size: 14px; color: var(--cyan); margin-right: 2px; }
.surge-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.surge-open { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--cyan); opacity: .85; }
.surge-card-link:hover .surge-open svg { transform: translateX(2px); }
.surge-open svg { transition: transform .15s; }
.piece-chip.read { cursor: default; }
.piece-chip.read:hover { transform: none; }

/* surge detail — per-piece rows */
.sd-pieces { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.sd-piece { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: var(--bg-1); border: 1px solid var(--hairline); border-radius: var(--radius-s); }
.sd-piece-label { font-size: 14px; font-weight: 600; color: var(--ink-1); }
.sd-piece .piece-chip { min-width: 70px; }
.sd-by { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.model-head-actions { display: flex; align-items: center; gap: 10px; }

/* ---- premium motion (respect reduced-motion) ---- */
@media (prefers-reduced-motion: no-preference) {
  @keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
  @keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  @keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
  @keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

  .view > section, .view > div { animation: viewIn .30s cubic-bezier(.22,.61,.36,1) both; }

  .trial-list > *, .surge-list > *, .all-grid > *, .recent-list > *, .bin-row, .sd-piece {
    animation: cardIn .32s cubic-bezier(.22,.61,.36,1) both;
  }
  /* gentle stagger for the first several items */
  .trial-list > *:nth-child(1), .surge-list > *:nth-child(1), .all-grid > *:nth-child(1), .recent-list > *:nth-child(1) { animation-delay: .02s; }
  .trial-list > *:nth-child(2), .surge-list > *:nth-child(2), .all-grid > *:nth-child(2), .recent-list > *:nth-child(2) { animation-delay: .06s; }
  .trial-list > *:nth-child(3), .surge-list > *:nth-child(3), .all-grid > *:nth-child(3), .recent-list > *:nth-child(3) { animation-delay: .10s; }
  .trial-list > *:nth-child(4), .surge-list > *:nth-child(4), .all-grid > *:nth-child(4), .recent-list > *:nth-child(4) { animation-delay: .14s; }
  .trial-list > *:nth-child(5), .surge-list > *:nth-child(5), .all-grid > *:nth-child(5), .recent-list > *:nth-child(5) { animation-delay: .18s; }
  .trial-list > *:nth-child(n+6), .surge-list > *:nth-child(n+6), .all-grid > *:nth-child(n+6) { animation-delay: .2s; }

  .choice-card { animation: cardIn .4s cubic-bezier(.22,.61,.36,1) both; }
  .choice-card:nth-child(2) { animation-delay: .08s; }

  .modal-overlay:not(.hidden) { animation: overlayIn .18s ease both; }
  .modal-overlay:not(.hidden) .modal-card { animation: modalIn .26s cubic-bezier(.22,.61,.36,1) both; }

  .toast.show { animation: cardIn .24s cubic-bezier(.22,.61,.36,1) both; }
}

/* tactile press feedback (all motion prefs) */
.btn:active, .mini-btn:active, .piece-btn:active, .piece-chip:not(.read):active,
.choice-card:active, .quick-chip:active, .nav-link:active, .seg-link:active { transform: scale(.97); }
.btn, .mini-btn, .piece-btn, .quick-chip, .seg-link { transition: transform .12s ease, background .15s ease, color .15s ease, border-color .15s ease; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 880px) {
  .hub-grid { grid-template-columns: 1fr; }
  .model-head { flex-direction: column; align-items: flex-start; padding: 22px 24px; }
  .model-head-actions { width: 100%; }
  .model-head-actions .btn { flex: 1; justify-content: center; }
}
@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 12px 14px; flex-wrap: wrap; }
  .brand-sub { display: none; }
  .brand img { height: 24px; }
  .nav { gap: 2px; order: 3; width: 100%; overflow-x: auto; padding-bottom: 2px; }
  .nav-link { padding: 6px 10px; font-size: 12px; white-space: nowrap; }
  .topbar-right { margin-left: auto; }
  .user-name { display: none; }
  .user-chip { padding: 4px; }
  .admin-chip { padding: 6px 8px; }
  .user-list { grid-template-columns: 1fr; }
  .bin-row { flex-direction: column; align-items: stretch; }
  .bin-row-actions { flex-direction: row; align-items: stretch; }
  .bin-row-actions .btn, .bin-row-actions .link-btn { flex: 1; justify-content: center; text-align: center; }
  .hero { padding: 36px 0 28px; }
  .hero-title { font-size: 32px; }
  .hero-sub { font-size: 15px; margin-bottom: 24px; }
  .search-box { padding: 14px 16px; }
  .search-box input { font-size: 15px; }
  .quick-row { gap: 6px; }
  .field-grid-2 { grid-template-columns: 1fr; }
  .form-card { padding: 20px; }
  .all-head { flex-direction: column; align-items: stretch; }
  .search-box-compact { max-width: 100%; }
  .stat-num { font-size: 24px; }
  .model-pcb { font-size: 36px; }
  .trial { grid-template-columns: 36px 1fr; }
  .trial-body { padding: 14px 16px; }
  .footer-addr { display: none; }
  .footer .sep { display: none; }
  /* surge feature */
  .section-switch { order: 3; }
  .seg-link { padding: 5px 12px; font-size: 12px; }
  .chooser-grid { grid-template-columns: 1fr; gap: 16px; }
  .chooser { padding: 30px 0 40px; }
  .choice-card { padding: 26px 22px 22px; }
  .piece { flex-direction: column; align-items: stretch; gap: 8px; }
  .piece-seg { justify-content: space-between; }
  .piece-btn { flex: 1; padding: 8px 0; }
  .piece-chip { flex: 1; min-width: 0; }
}
