/*
 * Handy Live Console — styles. Everything is scoped under `.hc` so the
 * console can be embedded into an existing site without leaking styles.
 * Dark, high-contrast, large touch targets (min 44px, primary 64px+).
 */
.hc {
  /* Surfaces */
  --hc-bg: #0a0b0d;
  --hc-surface: #121418;
  --hc-surface-2: #181b20;
  --hc-surface-3: #20242a;
  --hc-border: #2a2f37;
  --hc-border-strong: #3a414b;
  /* Text */
  --hc-text: #eef1f4;
  --hc-muted: #a3abb6;
  --hc-faint: #6b7380;
  /* Signal colors — each has exactly one meaning */
  --hc-accent: #8fa3ff;        /* selection / focus / waveform */
  --hc-accent-ink: #0b1030;
  --hc-go: #3ddc84;            /* moving / connected / acknowledged */
  --hc-go-ink: #04210f;
  --hc-stop: #ff4d4f;          /* stop / error / recording */
  --hc-warn: #ffb547;          /* reconnecting / pending */
  --hc-wave: var(--hc-accent);
  --hc-wave-fill: rgba(143, 163, 255, 0.13);
  --hc-grid: rgba(255, 255, 255, 0.07);

  --hc-radius: 12px;
  --hc-radius-sm: 8px;
  --hc-font: 'Geist', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --hc-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --hc-text-xs: 0.75rem;
  --hc-text-sm: 0.875rem;
  --hc-text-base: 1rem;
  --hc-text-lg: 1.25rem;

  color-scheme: dark;
  background: var(--hc-bg);
  color: var(--hc-text);
  font-family: var(--hc-font);
  font-size: var(--hc-text-base);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
.hc *, .hc *::before, .hc *::after { box-sizing: border-box; }
.hc svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hc :where(button, input, select) { font: inherit; color: inherit; }
.hc :where(button) { cursor: pointer; }
.hc :focus-visible { outline: 3px solid var(--hc-accent); outline-offset: 2px; }
.hc [hidden] { display: none !important; }
.hc h2 { font-size: var(--hc-text-sm); font-weight: 600; letter-spacing: 0.01em; margin: 0; }
.hc kbd {
  font-family: var(--hc-mono); font-size: 0.6875rem; line-height: 1; padding: 3px 5px;
  border-radius: 4px; border: 1px solid currentColor; opacity: 0.55; font-weight: 500;
}
.hc .hc-muted { color: var(--hc-muted); font-size: var(--hc-text-sm); }
.hc .hc-hint { color: var(--hc-faint); font-size: var(--hc-text-xs); }
.hc .hc-help { color: var(--hc-muted); font-size: var(--hc-text-sm); margin: 0; }
.hc .hc-help a { color: var(--hc-accent); }
.hc .hc-warn { color: var(--hc-warn); }
.hc .hc-spacer { flex: 1; }

/* ---------------------------------------------------------------- Header */
.hc-top {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--hc-border);
  background: var(--hc-surface); position: sticky; top: 0; z-index: 20;
}
.hc-brand { display: flex; flex-direction: column; line-height: 1.1; margin-right: 8px; }
.hc-brand__name { font-weight: 700; font-size: 1.0625rem; letter-spacing: -0.01em; }
.hc-brand__sub { font-size: var(--hc-text-xs); color: var(--hc-faint); }
.hc-conn {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 14px 6px 12px;
  border-radius: 999px; border: 1px solid var(--hc-border-strong); background: var(--hc-surface-2); text-align: left;
}
.hc-conn:hover { background: var(--hc-surface-3); }
.hc-conn__text { display: flex; flex-direction: column; line-height: 1.15; }
.hc-conn__text strong { font-size: var(--hc-text-sm); }
.hc-conn__text small { font-size: var(--hc-text-xs); color: var(--hc-muted); max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--hc-faint); flex: none; }
.hc-dot[data-s='connected'] { background: var(--hc-go); box-shadow: 0 0 0 4px rgba(61, 220, 132, 0.18); }
.hc-dot[data-s='connecting'], .hc-dot[data-s='reconnecting'] { background: var(--hc-warn); animation: hc-blink 1s steps(2, start) infinite; }
.hc-dot[data-s='error'] { background: var(--hc-stop); }
@keyframes hc-blink { to { opacity: 0.25; } }
.hc-top__meta { font-family: var(--hc-mono); font-size: var(--hc-text-xs); color: var(--hc-faint); margin-left: auto; }
.hc-estop {
  display: inline-flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 20px;
  border: 0; border-radius: var(--hc-radius); background: var(--hc-stop); color: #fff;
  font-weight: 800; letter-spacing: 0.08em; font-size: 1rem;
}
.hc-estop:hover { filter: brightness(1.08); }
.hc-estop:active { transform: translateY(1px); }
.hc-estop svg { width: 22px; height: 22px; }

/* ---------------------------------------------------------------- Layout */
.hc-main {
  flex: 1; display: grid; gap: 16px; padding: 16px;
  grid-template-columns: minmax(0, 1.15fr) minmax(380px, 1fr);
  align-items: start;
}
.hc-stage, .hc-panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (min-width: 1024px) {
  .hc-stage { position: sticky; top: 88px; }
}
.hc-card {
  background: var(--hc-surface); border: 1px solid var(--hc-border); border-radius: var(--hc-radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.hc-card__head { display: flex; align-items: center; gap: 10px; }
.hc-card__head--sub { margin-top: 6px; }
.hc-readout { margin-left: auto; font-family: var(--hc-mono); font-size: var(--hc-text-lg); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Video */
.hc-video {
  position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--hc-radius);
  border: 1px solid var(--hc-border); overflow: hidden;
}
.hc-video video { width: 100%; height: 100%; object-fit: cover; display: none; }
.hc-video.is-on video { display: block; }
.hc-video.is-mirror video { transform: scaleX(-1); }
.hc-video__empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; text-align: center; padding: 24px; color: var(--hc-muted);
  background: radial-gradient(ellipse at center, #151820 0%, #07080a 75%);
}
.hc-video__empty > svg { width: 36px; height: 36px; color: var(--hc-faint); }
.hc-video__empty p { margin: 0; font-size: var(--hc-text-sm); max-width: 38ch; }
.hc-video__empty strong { color: var(--hc-text); }
.hc-video__err { color: var(--hc-stop); font-size: var(--hc-text-xs); min-height: 1em; }
.hc-video.is-on .hc-video__empty { display: none; }
.hc-video__hud { position: absolute; top: 12px; left: 12px; display: flex; gap: 8px; align-items: center; }
.hc-tally {
  font-family: var(--hc-mono); font-weight: 700; font-size: var(--hc-text-xs); letter-spacing: 0.08em;
  padding: 6px 10px; border-radius: 6px; background: rgba(0, 0, 0, 0.7); border: 1px solid var(--hc-border-strong);
}
.hc-tally[data-s='on'] { background: var(--hc-go); color: var(--hc-go-ink); border-color: transparent; }
.hc-tally[data-s='pause'] { background: var(--hc-warn); color: #2a1800; border-color: transparent; }
.hc-tally[data-s='off'] { color: var(--hc-warn); }
.hc-hud__src { font-size: var(--hc-text-xs); padding: 6px 10px; border-radius: 6px; background: rgba(0, 0, 0, 0.65); font-weight: 500; }
.hc-video__pos {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%); height: 58%;
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 8px 10px;
  border-radius: 10px; background: rgba(0, 0, 0, 0.65); border: 1px solid var(--hc-border-strong);
}
.hc-video__pos span { font-family: var(--hc-mono); font-size: 0.625rem; font-weight: 700; letter-spacing: 0.08em; color: var(--hc-muted); }
.hc-video__rail { position: relative; flex: 1; width: 14px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); }
.hc-video__band { position: absolute; left: 0; right: 0; background: rgba(143, 163, 255, 0.4); border-radius: 4px; }
.hc-video__mark { position: absolute; left: -4px; right: -4px; height: 6px; margin-bottom: -3px; border-radius: 3px; background: var(--hc-go); box-shadow: 0 0 0 2px #000; }
.hc-video__bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; align-items: center;
  padding: 10px 12px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  opacity: 0; transition: opacity 0.15s;
}
.hc-video.is-on .hc-video__bar { opacity: 1; }
.hc-video:not(.is-on) .hc-video__bar { pointer-events: none; }
.hc-video__bar select { max-width: 50%; }

/* ---------------------------------------------------------------- Controls */
.hc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: var(--hc-radius-sm);
  border: 1px solid var(--hc-border-strong); background: var(--hc-surface-2);
  font-size: var(--hc-text-sm); font-weight: 600; white-space: nowrap;
}
.hc-btn:hover:not(:disabled) { background: var(--hc-surface-3); }
.hc-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.hc-btn--primary { background: var(--hc-accent); color: var(--hc-accent-ink); border-color: transparent; }
.hc-btn--primary:hover:not(:disabled) { background: #a9b8ff; }
.hc-btn--ghost { background: transparent; border-color: transparent; }
.hc-btn--ghost:hover:not(:disabled) { background: var(--hc-surface-2); }
.hc-btn--danger-ghost { color: #ff8a8b; }
.hc-btn--sm { min-height: 40px; padding: 0 12px; }
.hc-btn--icon { width: 44px; padding: 0; }
.hc-btn--xs { width: 32px; min-height: 32px; }
.hc-btn--xs svg { width: 16px; height: 16px; }
.hc-btn--step { width: 52px; min-height: 52px; flex: none; }
.hc select, .hc input:not([type='checkbox']):not([type='radio']):not([type='range']) {
  min-height: 44px; padding: 0 12px; border-radius: var(--hc-radius-sm);
  border: 1px solid var(--hc-border-strong); background: var(--hc-bg); color: var(--hc-text); min-width: 0;
}
.hc select:focus, .hc input:focus { border-color: var(--hc-accent); outline: none; }
.hc-field { display: flex; flex-direction: column; gap: 6px; font-size: var(--hc-text-xs); color: var(--hc-muted); font-weight: 500; }
.hc-field--grow { flex: 1; min-width: 160px; }
.hc-check { display: inline-flex; align-items: center; gap: 8px; font-size: var(--hc-text-sm); min-height: 44px; cursor: pointer; }
.hc-check input { width: 18px; height: 18px; accent-color: var(--hc-accent); }

/* Switch */
.hc-switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-size: var(--hc-text-sm); }
.hc-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.hc-switch__ui { width: 42px; height: 24px; border-radius: 12px; background: var(--hc-surface-3); border: 1px solid var(--hc-border-strong); position: relative; flex: none; transition: background 0.15s; }
.hc-switch__ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--hc-muted); transition: transform 0.15s, background 0.15s; }
.hc-switch input:checked + .hc-switch__ui { background: var(--hc-accent); border-color: transparent; }
.hc-switch input:checked + .hc-switch__ui::after { transform: translateX(18px); background: var(--hc-accent-ink); }
.hc-switch input:focus-visible + .hc-switch__ui { outline: 3px solid var(--hc-accent); outline-offset: 2px; }

/* Range control */
.hc-ctlrow { display: flex; align-items: center; gap: 12px; }
.hc-ctlrow > div { flex: 1; }
.hc-ctlrow--solo { padding: 0 6px; }
.hc-range { position: relative; height: 56px; touch-action: none; cursor: pointer; user-select: none; }
.hc-range__track { position: absolute; left: 0; right: 0; top: 50%; height: 12px; margin-top: -6px; border-radius: 6px; background: var(--hc-surface-3); }
.hc-range__fill { position: absolute; top: 0; bottom: 0; border-radius: 6px; background: var(--hc-accent); }
.hc-range__thumb {
  position: absolute; top: 50%; width: 36px; height: 36px; margin: -18px 0 0 -18px; border-radius: 50%;
  background: var(--hc-text); border: 4px solid var(--hc-bg); box-shadow: 0 0 0 1px var(--hc-border-strong), 0 2px 8px rgba(0, 0, 0, 0.5);
}
.hc-range__thumb:focus-visible { outline: 3px solid var(--hc-accent); outline-offset: 2px; }
.hc-range.is-dragging .hc-range__thumb:focus::after, .hc-range__thumb:focus-visible::after {
  content: attr(data-label); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  font-family: var(--hc-mono); font-size: var(--hc-text-xs); background: var(--hc-text); color: var(--hc-bg);
  padding: 3px 6px; border-radius: 4px; white-space: nowrap; font-weight: 600;
}

/* ---------------------------------------------------------------- Transport */
.hc-transport { flex-direction: row; gap: 16px; align-items: stretch; }
.hc-transport__btns { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.hc-transport__row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hc-big {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 64px; border-radius: var(--hc-radius); border: 1px solid var(--hc-border-strong);
  background: var(--hc-surface-2); font-weight: 700; font-size: 1rem; padding: 0 16px;
}
.hc-big kbd { position: absolute; right: 10px; top: 8px; }
.hc-big:hover:not(:disabled) { background: var(--hc-surface-3); }
.hc-big:disabled { opacity: 0.5; cursor: not-allowed; }
.hc-big:active:not(:disabled) { transform: translateY(1px); }
.hc-big--go { min-height: 96px; font-size: 1.375rem; letter-spacing: 0.01em; background: var(--hc-go); color: var(--hc-go-ink); border-color: transparent; }
.hc-big--go:hover:not(:disabled) { background: #5ae69a; }
.hc-big--go svg { width: 30px; height: 30px; }
.hc-big--go[data-mode='stop'] { background: var(--hc-stop); color: #fff; }
.hc-big--go[data-mode='connect'] { background: var(--hc-surface-3); color: var(--hc-text); border: 1px dashed var(--hc-border-strong); }
.hc-big--go[data-mode='connect']:hover { background: #2a2f37; }
.hc-big--go[data-mode='connect'] kbd { display: none; }
.hc-big--go[data-mode='stop']:hover:not(:disabled) { background: #ff6668; }
.hc-big.is-acked { animation: hc-ack 0.5s ease-out; }
@keyframes hc-ack { 0% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0.8); } 100% { box-shadow: 0 0 0 10px rgba(61, 220, 132, 0); } }
.hc-estop.is-acked { animation: hc-ack-red 0.5s ease-out; }
@keyframes hc-ack-red { 0% { box-shadow: 0 0 0 0 rgba(255, 77, 79, 0.9); } 100% { box-shadow: 0 0 0 10px rgba(255, 77, 79, 0); } }
.hc-ack {
  display: flex; align-items: center; gap: 8px; font-size: var(--hc-text-xs); color: var(--hc-muted);
  font-family: var(--hc-mono); min-height: 28px; padding: 4px 10px; border-radius: 6px; background: var(--hc-bg);
  overflow: hidden; white-space: nowrap;
}
.hc-ack span:last-child { overflow: hidden; text-overflow: ellipsis; }
.hc-ack__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--hc-faint); flex: none; }
.hc-ack[data-state='sent'] .hc-ack__dot { background: var(--hc-warn); }
.hc-ack[data-state='ack'] .hc-ack__dot { background: var(--hc-go); }
.hc-ack[data-state='error'] { color: #ff9b9c; }
.hc-ack[data-state='error'] .hc-ack__dot { background: var(--hc-stop); }

/* Position meter (vertical) */
.hc-meter { display: grid; grid-template-columns: auto 44px; grid-template-rows: 1fr auto; gap: 6px 8px; min-height: 230px; }
.hc-meter__scale { display: flex; flex-direction: column; justify-content: space-between; font-family: var(--hc-mono); font-size: 0.6875rem; color: var(--hc-faint); text-align: right; }
.hc-meter__track { position: relative; border-radius: 10px; background: var(--hc-bg); border: 1px solid var(--hc-border); }
.hc-meter__band { position: absolute; left: 4px; right: 4px; border-radius: 6px; background: rgba(143, 163, 255, 0.22); border: 1px dashed rgba(143, 163, 255, 0.55); }
.hc-meter__idle { position: absolute; left: -6px; width: 8px; height: 2px; background: var(--hc-warn); margin-bottom: -1px; }
.hc-meter__mark { position: absolute; left: -4px; right: -4px; height: 10px; margin-bottom: -5px; border-radius: 5px; background: var(--hc-go); box-shadow: 0 0 0 2px var(--hc-surface); }
.hc-meter__ghost { position: absolute; left: 6px; right: 6px; height: 4px; margin-bottom: -2px; border-radius: 2px; background: var(--hc-text); opacity: 0.55; }
.hc-meter__val { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.hc-meter__val strong { font-family: var(--hc-mono); font-size: var(--hc-text-lg); font-variant-numeric: tabular-nums; }
.hc-meter__val small { font-size: 0.6875rem; color: var(--hc-faint); text-transform: uppercase; letter-spacing: 0.06em; }

/* Pattern-mode: dim speed (it only applies in manual) */
.hc.is-pattern [data-ref='speedRange'] { opacity: 0.55; }

/* ---------------------------------------------------------------- Presets */
.hc-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.hc-preset {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  min-height: 92px; padding: 10px 12px; border-radius: var(--hc-radius); border: 2px solid var(--hc-border);
  background: var(--hc-surface-2); overflow: hidden;
}
.hc-preset:hover { border-color: var(--hc-border-strong); background: var(--hc-surface-3); }
.hc-preset kbd { position: absolute; top: 8px; right: 8px; }
.hc-preset__name { font-weight: 650; font-size: var(--hc-text-sm); padding-right: 22px; line-height: 1.2; }
.hc-preset__spark { width: 100%; height: 28px; display: block; margin-top: auto; }
.hc-preset__meta { font-size: 0.6875rem; color: var(--hc-faint); font-family: var(--hc-mono); }
.hc-preset.is-armed { border-color: var(--hc-accent); }
.hc-preset.is-live { border-color: var(--hc-go); background: #0f2219; }
.hc-preset.is-live::before {
  content: 'LIVE'; position: absolute; bottom: 8px; right: 8px; font-family: var(--hc-mono); font-size: 0.625rem; font-weight: 700;
  background: var(--hc-go); color: var(--hc-go-ink); padding: 2px 5px; border-radius: 3px; letter-spacing: 0.06em;
}
.hc-preset.is-live .hc-preset__spark { --hc-wave: var(--hc-go); --hc-wave-fill: rgba(61, 220, 132, 0.15); }

/* ---------------------------------------------------------------- Waveform */
.hc-wave { width: 100%; height: 96px; display: block; border-radius: var(--hc-radius-sm); background: var(--hc-bg); }
.hc-wave--edit { height: 170px; touch-action: none; cursor: crosshair; }
.hc-now__empty { margin: 0; color: var(--hc-muted); font-size: var(--hc-text-sm); }

/* ---------------------------------------------------------------- Tabs */
.hc-tabs { display: flex; gap: 4px; align-items: center; border-bottom: 1px solid var(--hc-border); margin: -4px -4px 0; padding: 0 4px; flex-wrap: wrap; }
.hc-tabs [role='tab'] {
  min-height: 44px; padding: 0 12px; border: 0; background: transparent; color: var(--hc-muted); font-weight: 600;
  font-size: var(--hc-text-sm); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.hc-tabs [role='tab'][aria-selected='true'] { color: var(--hc-text); border-bottom-color: var(--hc-accent); }

/* ---------------------------------------------------------------- Editor */
.hc-editor, .hc-rec, .hc-settings { display: flex; flex-direction: column; gap: 12px; }
.hc-editor__top, .hc-editor__actions, .hc-editor__io { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.hc-editor__io { border-top: 1px solid var(--hc-border); padding-top: 10px; gap: 4px; }
.hc-steps { display: flex; flex-direction: column; gap: 4px; max-height: 360px; overflow: auto; }
.hc-steps__head, .hc-step {
  display: grid; grid-template-columns: 28px minmax(150px, 1.6fr) 104px minmax(96px, 1fr) 62px 104px; gap: 8px; align-items: center;
}
.hc-steps__head { font-size: 0.6875rem; color: var(--hc-faint); text-transform: uppercase; letter-spacing: 0.05em; padding: 0 8px; }
.hc-step { padding: 6px 8px; border-radius: var(--hc-radius-sm); background: var(--hc-surface-2); border: 1px solid transparent; }
.hc-step.is-sel { border-color: var(--hc-accent); }
.hc-step__n { font-family: var(--hc-mono); color: var(--hc-faint); font-size: var(--hc-text-xs); text-align: center; }
.hc-step__pos, .hc-step__dur { display: flex; align-items: center; gap: 6px; min-width: 0; }
.hc-step__pos input[type='range'] { flex: 1; min-width: 60px; accent-color: var(--hc-accent); height: 28px; }
.hc-step input[type='number'] { width: 62px; min-height: 40px !important; padding: 0 6px !important; font-family: var(--hc-mono); font-size: var(--hc-text-sm); }
.hc-step__dur input[type='number'] { width: 72px; }
.hc-step em { font-style: normal; color: var(--hc-faint); font-size: var(--hc-text-xs); }
.hc-step select { min-height: 40px !important; font-size: var(--hc-text-sm); padding: 0 6px !important; width: 100%; }
.hc-step__spd { font-family: var(--hc-mono); font-size: var(--hc-text-xs); color: var(--hc-muted); }
.hc-step__act { display: flex; justify-content: flex-end; }

/* ---------------------------------------------------------------- Recorder */
.hc-rec__body { display: grid; grid-template-columns: 1fr 220px; gap: 16px; }
.hc-pad {
  width: 100%; height: 280px; border-radius: var(--hc-radius); background: var(--hc-bg); border: 1px dashed var(--hc-border-strong);
  touch-action: none; cursor: ns-resize; display: block;
}
.hc-rec__side { display: flex; flex-direction: column; gap: 10px; }
.hc-big--rec { min-height: 72px; }
.hc-big--rec svg { color: var(--hc-stop); }
.hc-big--rec.is-on { background: var(--hc-stop); color: #fff; border-color: transparent; }
.hc-big--rec.is-on svg { color: #fff; animation: hc-blink 1s steps(2, start) infinite; }
.hc-rec__time { font-family: var(--hc-mono); font-size: 1.75rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Log */
.hc-log { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; font-size: var(--hc-text-sm); }
.hc-log__row { display: grid; grid-template-columns: 74px 70px 1fr; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--hc-border); align-items: baseline; }
.hc-log__row time { font-family: var(--hc-mono); font-size: var(--hc-text-xs); color: var(--hc-faint); }
.hc-log__row b { font-size: var(--hc-text-xs); font-weight: 600; color: var(--hc-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.hc-log__row--preset b { color: var(--hc-accent); }
.hc-log__row--start b { color: var(--hc-go); }
.hc-log__row--stop b, .hc-log__row--error b { color: var(--hc-stop); }
.hc-log__row--connect b { color: var(--hc-text); }
.hc-log--cmd .hc-log__row b { font-family: var(--hc-mono); text-transform: none; }
.hc-cmd--ack b { color: var(--hc-go) !important; }
.hc-cmd--sent b { color: var(--hc-warn) !important; }
.hc-cmd--error b { color: var(--hc-stop) !important; }
.hc-log__empty { color: var(--hc-faint); font-size: var(--hc-text-sm); padding: 10px 4px; list-style: none; margin: 0; }
.hc-usage table { width: 100%; border-collapse: collapse; font-size: var(--hc-text-sm); }
.hc-usage th { text-align: left; font-size: var(--hc-text-xs); color: var(--hc-faint); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--hc-border); }
.hc-usage td { padding: 8px 4px; border-bottom: 1px solid var(--hc-border); font-variant-numeric: tabular-nums; }
.hc-usage td:not(:first-child) { font-family: var(--hc-mono); }

/* ---------------------------------------------------------------- Dialog */
.hc-dialog {
  border: 1px solid var(--hc-border-strong); border-radius: 16px; background: var(--hc-surface); color: var(--hc-text);
  padding: 0; width: min(480px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.hc-dialog::backdrop { background: rgba(0, 0, 0, 0.65); }
.hc-dialog__body { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.hc-dialog__head { display: flex; align-items: center; justify-content: space-between; }
.hc-dialog__head h2 { font-size: var(--hc-text-lg); }
.hc-dialog__actions { display: flex; gap: 10px; align-items: center; }
.hc-dialog__err { color: #ff8a8b; font-size: var(--hc-text-sm); margin: 0; min-height: 0; }
.hc-dialog__err:empty { display: none; }
[data-ref='handyFields'] { display: flex; flex-direction: column; gap: 12px; }
.hc-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 10px; background: var(--hc-bg); }
.hc-seg label { position: relative; }
.hc-seg input { position: absolute; opacity: 0; }
.hc-seg span { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 8px; font-weight: 600; font-size: var(--hc-text-sm); color: var(--hc-muted); cursor: pointer; }
.hc-seg input:checked + span { background: var(--hc-surface-3); color: var(--hc-text); }
.hc-seg input:focus-visible + span { outline: 3px solid var(--hc-accent); }
.hc-keys { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0; font-size: var(--hc-text-sm); }
.hc-keys dt { white-space: nowrap; }
.hc-keys dd { margin: 0; color: var(--hc-muted); }
.hc-keys kbd { opacity: 0.9; font-size: var(--hc-text-xs); padding: 4px 7px; }

/* ---------------------------------------------------------------- Toasts */
.hc-toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; pointer-events: none; max-width: min(420px, calc(100vw - 32px)); }
.hc-toast {
  padding: 12px 14px; border-radius: 10px; background: var(--hc-surface-3); border: 1px solid var(--hc-border-strong);
  border-left: 4px solid var(--hc-accent); font-size: var(--hc-text-sm); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transition: opacity 0.3s, transform 0.3s;
}
.hc-toast--ok { border-left-color: var(--hc-go); }
.hc-toast--warn { border-left-color: var(--hc-warn); }
.hc-toast--error { border-left-color: var(--hc-stop); }
.hc-toast.is-out { opacity: 0; transform: translateY(6px); }

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 1100px) {
  .hc-steps__head { display: none; }
  .hc-step { grid-template-columns: 24px 1fr 1fr; grid-template-areas: 'n pos pos' 'n dur ease' 'n spd act'; row-gap: 6px; }
  .hc-step__n { grid-area: n; } .hc-step__pos { grid-area: pos; } .hc-step__dur { grid-area: dur; }
  .hc-step select { grid-area: ease; } .hc-step__spd { grid-area: spd; } .hc-step__act { grid-area: act; }
}
@media (max-width: 900px) {
  .hc-main { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .hc-stage { position: static; }
  /* Controls first on narrow screens; camera follows */
  .hc-panel { order: -1; }
  .hc-logcard { order: 3; }
}
@media (max-width: 560px) {
  .hc-top { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .hc-brand { display: none; }
  .hc-conn { flex: 1; min-width: 0; }
  .hc-top__meta, [data-ref='kbdBtn'] { display: none; }
  .hc-estop { padding: 0 14px; }
  .hc-estop kbd { display: none; }
  .hc-transport { flex-direction: row; }
  .hc-meter { min-height: 200px; grid-template-columns: auto 36px; }
  .hc-big kbd { display: none; }
  .hc-rec__body { grid-template-columns: 1fr; }
  .hc-pad { height: 220px; }
  .hc-presets { grid-template-columns: repeat(2, 1fr); }
  .hc-card { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .hc *, .hc *::before, .hc *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------------------------------------------------------------- Programs (ramp + cycles) */
.hc-prog__panel { display: flex; flex-direction: column; gap: 12px; }
.hc-prog__status { font-family: var(--hc-mono); font-size: var(--hc-text-xs); color: var(--hc-go); font-weight: 600; }
.hc-seg--3 { grid-template-columns: repeat(3, 1fr); }
.hc-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.hc-chips button {
  min-height: 44px; min-width: 64px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--hc-border-strong);
  background: var(--hc-surface-2); font-weight: 600; font-size: var(--hc-text-sm); color: var(--hc-text);
}
.hc-chips button:hover { background: var(--hc-surface-3); }
.hc-chips button[aria-pressed='true'] { background: var(--hc-accent); color: var(--hc-accent-ink); border-color: transparent; }
.hc-chips__custom { display: inline-flex; align-items: center; gap: 6px; }
.hc-chips__custom input { width: 96px; border-radius: 999px !important; font-family: var(--hc-mono); }
.hc-chips__custom em { font-style: normal; color: var(--hc-faint); font-size: var(--hc-text-xs); }
.hc-levels { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.hc-levels button {
  min-height: 52px; border-radius: var(--hc-radius-sm); border: 1px solid var(--hc-border-strong);
  background: var(--hc-surface-2); font-family: var(--hc-mono); font-weight: 700; font-size: 1.0625rem; color: var(--hc-text);
}
.hc-levels button:hover { background: var(--hc-surface-3); }
.hc-levels button[aria-pressed='true'] { background: var(--hc-accent); color: var(--hc-accent-ink); border-color: transparent; }
.hc-prog__run { display: flex; flex-direction: column; gap: 10px; }
.hc-big--prog { min-height: 64px; background: var(--hc-go); color: var(--hc-go-ink); border-color: transparent; font-size: 1.0625rem; }
.hc-big--prog:hover:not(:disabled) { background: #5ae69a; }
.hc-big--prog[data-on='true'] { background: var(--hc-stop); color: #fff; }
.hc-big--prog[data-on='true']:hover:not(:disabled) { background: #ff6668; }
.hc-progress { display: flex; flex-direction: column; gap: 6px; }
.hc-progress__bar { height: 12px; border-radius: 6px; background: var(--hc-surface-3); overflow: hidden; }
.hc-progress__bar > div { height: 100%; width: 0; background: var(--hc-go); border-radius: 6px; transition: width 0.2s linear; }
.hc-progress span { font-family: var(--hc-mono); font-size: var(--hc-text-sm); color: var(--hc-muted); font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .hc-levels { grid-template-columns: repeat(5, 1fr); }
  .hc-seg--3 span { font-size: var(--hc-text-xs); }
}

/* Log toolbar: keep on one row */
.hc-logcard .hc-tabs { flex-wrap: nowrap; }
.hc-logcard .hc-tabs [role='tab'] { padding: 0 10px; white-space: nowrap; }
.hc-logcard .hc-tabs .hc-btn { padding: 0 8px; flex: none; }
@media (max-width: 1280px) and (min-width: 901px), (max-width: 480px) { .hc-hide-md { display: none; } }
@media (max-width: 400px) { .hc-logcard .hc-tabs [role='tab'] { padding: 0 6px; font-size: var(--hc-text-xs); } }
@media (max-width: 480px) {
  .hc-logcard .hc-tabs { gap: 0; }
  .hc-logcard .hc-tabs [role='tab'] { padding: 0 7px; font-size: var(--hc-text-xs); }
  .hc-logcard .hc-tabs .hc-btn { padding: 0 6px; min-width: 0; }
}

/* ---------------------------------------------------------------- Background art */
.hc { position: relative; isolation: isolate; }
.hc-bgart { display: none; }
.hc.has-bgart .hc-bgart {
  display: block; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: url('assets/background.jpg') center 20% / cover no-repeat;
}
/* Dark wash over the art so text and controls keep full contrast. */
.hc.has-bgart .hc-bgart::after {
  content: ''; position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(10, 11, 13, calc(var(--hc-bg-dim, 0.7) * 0.75)) 0%, rgba(10, 11, 13, var(--hc-bg-dim, 0.7)) 55%, rgba(10, 11, 13, calc(var(--hc-bg-dim, 0.7) + 0.1)) 100%);
}
.hc.has-bgart { background: #050506; }
.hc.has-bgart .hc-card { background: rgba(18, 20, 24, 0.88); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.hc.has-bgart .hc-top { background: rgba(18, 20, 24, 0.9); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
@media (min-width: 901px) {
  /* On wide screens, sit the portrait on the left, behind the camera column. */
  .hc.has-bgart .hc-bgart { background-position: left 30% center; background-size: auto 115%; background-color: #0b0405; }
}
