/* Amy operator dashboard. System fonts, light theme with a dark variant. */

:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e5e8ed;
  --border: #dde1e6;
  --border-strong: #c3c9d2;
  --text: #15181c;
  --muted: #5d6671;
  --accent: #1f5fd6;
  --accent-hover: #184db0;
  --accent-soft: #e5edfc;
  --on-accent: #ffffff;
  --ok: #14783a;
  --ok-soft: #e1f3e7;
  --warn: #9a5300;
  --warn-soft: #fff0d9;
  --warn-border: #f1c98a;
  --bad: #c22323;
  --bad-soft: #fde7e7;
  --info: #1f5fd6;
  --info-soft: #e5edfc;
  --beta: #7c3aed;
  --beta-soft: #f1e9fe;
  --stop: #d50000;
  --stop-hover: #b30000;
  --stop-ring: rgba(213, 0, 0, 0.22);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, 0.22);
  --radius: 12px;
  --gutter: 20px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0e1014;
    --surface: #161920;
    --surface-2: #1d2129;
    --surface-3: #272c36;
    --border: #2a303b;
    --border-strong: #3b4250;
    --text: #e7e9ec;
    --muted: #9aa3af;
    --accent: #5d9bff;
    --accent-hover: #7cafff;
    --accent-soft: #1b2944;
    --on-accent: #08111f;
    --ok: #4fc477;
    --ok-soft: #14301e;
    --warn: #f2a93b;
    --warn-soft: #362710;
    --warn-border: #6b4b17;
    --bad: #ff6b6b;
    --bad-soft: #3a1717;
    --info: #5d9bff;
    --info-soft: #1b2944;
    --beta: #b895ff;
    --beta-soft: #2a1f45;
    --stop: #e01414;
    --stop-hover: #ff2b2b;
    --stop-ring: rgba(255, 40, 40, 0.25);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.6);
  }
}

@media (max-width: 640px) {
  :root {
    --gutter: 12px;
  }
}

/* ------------------------------------------------------------------ base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 15px;
  font-weight: 650;
}

p {
  margin: 0 0 8px;
}

p:last-child {
  margin-bottom: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mono {
  font-family: var(--mono);
  font-size: 0.92em;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12.5px;
}

.sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.hint {
  font-size: 12.5px;
  color: var(--muted);
}

.warn-text {
  color: var(--warn);
}

.error-text,
.form-error {
  color: var(--bad);
}

.form-error:empty {
  display: none;
}

.pre-wrap {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

.spacer {
  flex: 1 1 auto;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.boot {
  padding: 40px;
  text-align: center;
}

/* ------------------------------------------------------------------ top bar */

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 10px var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--beta));
  flex: none;
}

.topnav {
  display: flex;
  gap: 4px;
}

.topnav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 550;
}

.topnav a:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.topnav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.conn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  white-space: nowrap;
  cursor: pointer;
}

.conn .dot {
  width: 8px;
  height: 8px;
}

.conn-open .dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}

.conn-connecting .dot {
  background: var(--warn);
  animation: pulse 1s ease-in-out infinite;
}

.conn-waiting,
.conn-off {
  color: var(--bad);
  border-color: var(--bad-soft);
}

.conn-waiting .dot,
.conn-off .dot {
  background: var(--bad);
}

@media (max-width: 520px) {
  .brand-text {
    display: none;
  }
}

/* ------------------------------------------------------------------ layout */

.main {
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--gutter);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.page-hint {
  margin-top: -6px;
  max-width: 80ch;
}

.card {
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card.flush {
  padding: 0;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 12px;
}

.card-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-danger {
  border-color: color-mix(in srgb, var(--bad) 35%, var(--border));
}

.notice + .sub-title {
  margin-top: 14px;
}

.sub-title {
  margin: 4px 0 8px;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

@media (max-width: 920px) {
  /* One column; the cards' `order` puts the controls right after the status. */
  .grid-2 {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .col {
    display: contents;
  }
}

.empty {
  padding: 36px 16px;
  text-align: center;
}

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}

.btn:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--bad) 85%, #000);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
}

.btn-ghost:hover {
  background: var(--accent-soft);
}

.btn-ghost-danger {
  background: transparent;
  color: var(--bad);
}

.btn-ghost-danger:hover {
  background: var(--bad-soft);
}

.btn-sm {
  min-height: 30px;
  padding: 3px 10px;
  font-size: 13.5px;
}

.btn-block {
  width: 100%;
}

.btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.motion-tag {
  padding: 0 5px;
  border-radius: 4px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn-primary .motion-tag {
  background: rgba(255, 255, 255, 0.22);
  color: inherit;
}

@media (max-width: 640px) {
  .btn {
    min-height: 40px;
  }

  .btn-sm {
    min-height: 34px;
  }
}

/* ------------------------------------------------------------------ badges, dots, meters */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 21px;
  white-space: nowrap;
}

a.badge:hover {
  text-decoration: none;
  filter: brightness(0.96);
}

.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.badge-info {
  background: var(--info-soft);
  color: var(--info);
}

.badge-beta {
  background: var(--beta-soft);
  color: var(--beta);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  font-weight: 550;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-strong);
  flex: none;
}

.dot-online {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}

.dot-offline {
  background: var(--bad);
}

.dot-pending {
  background: var(--warn);
}

.battery {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.battery-bar {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 12px;
  padding: 1.5px;
  border: 1.5px solid var(--border-strong);
  border-radius: 3px;
}

.battery-bar::after {
  content: '';
  position: absolute;
  top: 2.5px;
  right: -4px;
  width: 2.5px;
  height: 4px;
  border-radius: 0 1px 1px 0;
  background: var(--border-strong);
}

.battery-fill {
  display: block;
  height: 100%;
  border-radius: 1px;
  background: var(--ok);
}

.battery.mid .battery-fill {
  background: var(--warn);
}

.battery.low .battery-fill {
  background: var(--bad);
}

.rollout {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.meter {
  display: inline-block;
  width: 64px;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.lvl {
  display: inline-block;
  min-width: 46px;
  padding: 0 6px;
  border-radius: 4px;
  font: 700 10.5px/18px var(--font);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-3);
  color: var(--muted);
}

.lvl-info {
  background: var(--info-soft);
  color: var(--info);
}

.lvl-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.lvl-error {
  background: var(--bad-soft);
  color: var(--bad);
}

.spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin 0.8s linear infinite;
}

/* ------------------------------------------------------------------ tables */

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  overflow-wrap: break-word;
}

.table td .mono,
.addr-list > div {
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.robots-table td {
  vertical-align: middle;
}

.robot-row {
  cursor: pointer;
}

.robot-row:hover td {
  background: var(--surface-2);
}

.robot-row.is-offline .battery,
.robot-row.is-offline .badges {
  opacity: 0.6;
}

.robot-link {
  font-weight: 650;
  font-size: 15px;
  color: var(--text);
}

.addr-list {
  line-height: 1.5;
}

.commands-table td:nth-child(7) {
  min-width: 220px;
}

@media (max-width: 760px) {
  /* Tables become one card per row. */
  .table-responsive thead {
    display: none;
  }

  .table-responsive tr {
    display: block;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
  }

  .table-responsive tbody tr:last-child {
    border-bottom: 0;
  }

  .table-responsive td {
    display: flex;
    gap: 12px;
    padding: 3px 0;
    border: 0;
  }

  .table-responsive td::before {
    content: attr(data-label);
    flex: 0 0 96px;
    color: var(--muted);
    font-size: 12px;
    padding-top: 2px;
  }

  .table-responsive td:not([data-label])::before,
  .table-responsive td[data-label='']::before {
    display: none;
  }

  .table-responsive td > * {
    min-width: 0;
  }

  .table-responsive td .mono,
  .table-responsive .addr-list > div {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

/* ------------------------------------------------------------------ forms */

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field-label {
  font-size: 13px;
  font-weight: 650;
}

input[type='text'],
input[type='password'],
input[type='url'],
input[type='number'],
input[type='search'],
input[type='datetime-local'],
select,
textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
  resize: vertical;
  min-height: 60px;
}

@media (max-width: 640px) {
  /* 16px stops iOS from zooming into fields. */
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  cursor: pointer;
}

.check input {
  margin-top: 3px;
  width: 17px;
  height: 17px;
  flex: none;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 550;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: relative;
  width: 38px;
  height: 22px;
  margin: 0;
  border-radius: 999px;
  background: var(--border-strong);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: background 0.15s;
  flex: none;
}

.switch input::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}

.switch input:checked {
  background: var(--ok);
}

.switch input:checked::after {
  transform: translateX(16px);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 14px;
  margin-bottom: 12px;
}

.toolbar .field {
  flex: 0 1 220px;
}

/* ------------------------------------------------------------------ notices, dialogs, toasts */

.notice {
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--info-soft);
}

.notice-warn {
  background: var(--warn-soft);
  border-color: var(--warn-border);
}

.notice-bad {
  background: var(--bad-soft);
  border-color: color-mix(in srgb, var(--bad) 35%, transparent);
}

.notice .dismiss {
  float: right;
  margin: -4px -6px 0 8px;
}

.notice.flash {
  animation: flash 0.9s ease-in-out 2;
}

.alert-slot:not(:empty) {
  margin-bottom: 14px;
}

dialog.dlg {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

dialog.dlg[open] {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 50;
  margin: 0;
  overflow: auto;
  transform: translate(-50%, -50%);
}

.dlg-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(8, 10, 14, 0.55);
}

.dlg-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
}

.dlg-title {
  font-size: 18px;
}

.dlg-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dlg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
}

.toast {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--info);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  animation: toast-in 0.18s ease-out;
}

.toast-ok {
  border-left-color: var(--ok);
}

.toast-warn {
  border-left-color: var(--warn);
}

.toast-error {
  border-left-color: var(--bad);
}

@media (max-width: 640px) {
  .toasts {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
}

/* ------------------------------------------------------------------ login */

.login-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 16px;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(380px, 100%);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ------------------------------------------------------------------ robot detail */

.robot-bar {
  position: sticky;
  top: 0;
  z-index: 45; /* above the dialog overlay, so STOP stays usable while a dialog is open */
  margin: calc(-1 * var(--gutter)) calc(-1 * var(--gutter)) 0;
  padding: 10px var(--gutter);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.robot-bar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  flex: none;
}

.back:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.robot-title {
  min-width: 0;
  flex: 1 1 auto;
}

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

.robot-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-top: 3px;
  font-size: 13.5px;
}

.stop-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.stop-note {
  max-width: 220px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: right;
}

.stop-note.ok {
  color: var(--ok);
}

.stop-note.bad {
  color: var(--bad);
  font-weight: 600;
}

.btn-stop {
  min-width: 128px;
  min-height: 54px;
  padding: 8px 24px;
  border: 0;
  border-radius: 12px;
  background: var(--stop);
  color: #fff;
  font: 800 21px/1 var(--font);
  letter-spacing: 0.1em;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.28), 0 0 0 4px var(--stop-ring);
  touch-action: manipulation;
}

.btn-stop:hover {
  background: var(--stop-hover);
}

.btn-stop:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.28), 0 0 0 6px var(--stop-ring);
}

@media (max-width: 640px) {
  /* One compact row on phones: back, name and status, STOP. */
  .robot-bar {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .robot-bar-inner {
    gap: 6px;
  }

  .back {
    width: 26px;
    margin-left: -6px;
  }

  .robot-title {
    flex: 1 1 0;
  }

  .robot-name {
    font-size: 17px;
  }

  .robot-meta {
    gap: 2px 8px;
    font-size: 12.5px;
  }

  .robot-meta .badge {
    font-size: 11px;
    line-height: 18px;
    padding: 0 6px;
  }

  .stop-wrap {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 4px;
  }

  .btn-stop {
    min-width: 100px;
    min-height: 52px;
    padding: 6px 14px;
    font-size: 19px;
  }

  .stop-note {
    max-width: 100px;
    font-size: 11px;
    line-height: 1.25;
    text-align: center;
  }

  .stop-note:empty {
    display: none;
  }
}

.tabs {
  display: flex;
  gap: 2px;
  margin: 10px 0 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: 9px 14px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 550;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
  text-decoration: none;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
}

.tile {
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.tile.wide {
  grid-column: span 2;
}

.tile-label {
  font-size: 12px;
  color: var(--muted);
}

.tile-value {
  font-weight: 650;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.tone-ok .tile-value {
  color: var(--ok);
}

.tone-warn {
  background: var(--warn-soft);
}

.tone-warn .tile-value {
  color: var(--warn);
}

.tone-bad {
  background: var(--bad-soft);
}

.tone-bad .tile-value {
  color: var(--bad);
}

#main .card > .hint {
  margin-top: 10px;
}

.kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 16px;
  margin: 0;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.kv + .kv,
.table-wrap + .kv {
  margin-top: 14px;
}

.speak-form {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.speak-form .btn {
  align-self: stretch;
  min-width: 88px;
}

.points {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.point {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.point-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 160px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.save-point {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.save-point .row {
  display: flex;
  gap: 8px;
}

.dock-row {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.danger-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

details.more > summary {
  cursor: pointer;
  font-weight: 650;
}

details.more[open] > summary {
  margin-bottom: 12px;
}

.console .hint:empty {
  display: none;
}

.console .form-grid {
  margin-top: 10px;
}

.console .form-grid:empty {
  display: none;
}

/* Lists of commands and events */

.items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.item {
  min-width: 0;
  padding: 7px 10px;
  border-left: 3px solid var(--border-strong);
  border-radius: 0 6px 6px 0;
  background: var(--surface-2);
}

.item-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  min-width: 0;
}

.item-body {
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.empty-li {
  padding: 6px 0;
  background: none;
  border: 0;
}

.cmd.st-sent {
  border-left-color: var(--info);
}

.cmd.st-ok {
  border-left-color: var(--ok);
}

.cmd.st-timeout {
  border-left-color: var(--warn);
}

.cmd.st-error,
.cmd.st-rejected {
  border-left-color: var(--bad);
  background: var(--bad-soft);
}

.event.lv-debug {
  border-left-color: var(--border-strong);
}

.event.lv-info {
  border-left-color: var(--info);
}

.event.lv-warn {
  border-left-color: var(--warn);
  background: var(--warn-soft);
}

.event.lv-error {
  border-left-color: var(--bad);
  background: var(--bad-soft);
}

.event.fresh,
.log.fresh {
  animation: fresh 2s ease-out;
}

details.result {
  margin-top: 4px;
  min-width: 0;
}

details.result > summary {
  overflow: hidden;
  color: var(--muted);
  font: 12.5px/1.5 var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

pre.json,
.log-msg-full {
  margin: 6px 0 0;
  max-height: 420px;
  padding: 10px;
  overflow: auto;
  border-radius: 6px;
  background: var(--surface-3);
  font: 12.5px/1.45 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Network history */

.history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hist {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.hist-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.hist-body {
  margin-top: 4px;
  overflow-wrap: anywhere;
}

/* Logs */

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px 12px;
  align-items: end;
  margin-bottom: 10px;
}

.custom-range {
  display: contents;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  grid-column: 1 / -1;
}

.log-status {
  min-height: 18px;
  margin-bottom: 6px;
}

.log-list {
  min-height: 320px;
  max-height: calc(100vh - 230px);
  overflow: auto;
  overflow-anchor: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: 12.5px/1.45 var(--mono);
}

.log {
  border-bottom: 1px solid var(--border);
}

.log-line {
  display: grid;
  grid-template-columns: 148px 58px 50px minmax(70px, 110px) minmax(90px, 170px) minmax(0, 1fr);
  gap: 10px;
  padding: 3px 10px;
  white-space: nowrap;
  cursor: pointer;
}

.log-line > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-line:hover {
  background: var(--surface-2);
}

.log.open .log-line {
  background: var(--accent-soft);
}

.log-ts {
  color: var(--muted);
}

.log-lv {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  line-height: 18px;
}

.log-comp {
  color: var(--accent);
}

.log-app {
  color: var(--muted);
}

.log.lv-verbose,
.log.lv-debug {
  color: var(--muted);
}

.log.lv-verbose .log-comp,
.log.lv-debug .log-comp {
  color: var(--muted);
}

.log.lv-warn .log-lv {
  color: var(--warn);
}

.log.lv-error {
  background: var(--bad-soft);
}

.log.lv-error .log-lv {
  color: var(--bad);
}

.log-detail {
  padding: 4px 10px 10px;
  background: var(--surface-2);
  color: var(--text);
}

.log-empty {
  padding: 24px;
  text-align: center;
  font-family: var(--font);
}

@media (max-width: 760px) {
  .log-line {
    display: flex;
    flex-wrap: wrap;
    gap: 0 8px;
    padding: 5px 10px;
  }

  .log-msg {
    flex: 1 1 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .log-list {
    max-height: 70vh;
  }
}

/* Files */

.files {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.file {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--surface-3);
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.thumb-file {
  color: var(--muted);
  font: 700 13px/1 var(--mono);
  letter-spacing: 0.08em;
}

.file-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 10px;
}

.file-name {
  max-width: 100%;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Releases */

.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
}

.channel-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.channel-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
}

/* Settings */

.motion-state {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.motion-state p {
  margin: 0;
  flex: 1 1 260px;
}

.big-pill {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.big-pill-on {
  background: var(--warn-soft);
  color: var(--warn);
  box-shadow: inset 0 0 0 1.5px var(--warn);
}

.card-motion .form-actions {
  margin-top: 12px;
}

.settings-form .hint:empty {
  display: none;
}

.settings-form > .hint,
.settings-form > .notice {
  margin-top: 12px;
}

/* Enrolment code */

.enrol {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.enrol-card {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.enrol-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.enrol-code {
  padding: 10px 18px;
  border: 2px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--surface-2);
  font: 700 clamp(28px, 8vw, 46px)/1.1 var(--mono);
  letter-spacing: 0.18em;
  user-select: all;
  overflow-wrap: anywhere;
}

.enrol-exp {
  margin: 0;
}

.settings .enrol {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ------------------------------------------------------------------ animation */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

@keyframes flash {
  50% {
    box-shadow: 0 0 0 4px var(--warn-border);
  }
}

@keyframes fresh {
  from {
    box-shadow: inset 4px 0 0 var(--accent);
    background-color: var(--accent-soft);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition: none !important;
  }
}
