:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --line: #d8e1e5;
  --text: #14201c;
  --muted: #60706b;
  --accent: #0f766e;
  --danger: #ba3b35;
  --warn: #9a6700;
  --ok: #16794b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

[hidden] {
  display: none !important;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-form {
  width: min(360px, 100%);
  display: grid;
  gap: 12px;
}

.auth-form h1 {
  font-size: 26px;
  margin: 0 0 8px;
}

.auth-form label {
  color: var(--muted);
  font-size: 14px;
}

.auth-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
}

.auth-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 14px;
  margin: 0;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}

a.button,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

a.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.file-button input {
  display: none;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 28px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow {
  color: var(--accent);
  font-weight: 700;
  margin: 0 0 6px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(28px, 5vw, 44px);
  margin-bottom: 0;
}

h2 {
  font-size: 20px;
}

section {
  margin-top: 26px;
}

.status-pill,
.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--muted);
  background: #fff;
}

.status-pill.ok,
.tag.ok {
  color: var(--ok);
  border-color: #b8dec9;
}

.status-pill.bad,
.tag.bad {
  color: var(--danger);
  border-color: #efc1bd;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.card h3 {
  margin-bottom: 10px;
}

.meta {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 10px;
  font-size: 14px;
}

.meta dt {
  color: var(--muted);
}

.meta dd {
  margin: 0;
  font-weight: 650;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.notice-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  font-size: 14px;
}

.notice.ok {
  border-color: #b8dec9;
  color: var(--ok);
}

.notice.warn {
  border-color: #efd48a;
  color: var(--warn);
}

.notice.bad {
  border-color: #efc1bd;
  color: var(--danger);
}

.transfer-progress {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  color: var(--text);
}

.lan-transfer-panel {
  display: grid;
  gap: 8px;
  min-height: 52px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
}

.lan-transfer-panel.is-offline,
.lan-transfer-panel.is-failed {
  border-left-color: var(--danger);
}

.lan-transfer-panel.is-complete,
.lan-transfer-panel.is-idle {
  border-left-color: var(--ok);
}

.transfer-status-head,
.queue-status-head,
.queue-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.transfer-status-head span,
.queue-status-head span,
.queue-stats {
  color: var(--muted);
}

.queue-status {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.queue-status.ok .progress-bar span {
  background: var(--ok);
}

.queue-status.warn .progress-bar span {
  background: var(--warn);
}

.queue-status.bad .progress-bar span {
  background: var(--danger);
}

.queue-stats {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.transfer-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.transfer-line strong,
.transfer-line span {
  overflow-wrap: anywhere;
}

.progress-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef0;
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 160ms ease;
}

.record-settings {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

.record-settings label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.record-settings .toggle-setting {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding-bottom: 9px;
  color: var(--text);
}

.record-settings .toggle-setting input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.record-settings select {
  min-width: 240px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  font-size: 14px;
}

.setting-note {
  color: var(--muted);
  font-size: 13px;
  padding-bottom: 9px;
}

.frame-counter {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.frame-counter span {
  color: var(--muted);
  font-size: 13px;
}

.frame-counter strong {
  font-size: 28px;
  line-height: 1;
}

.frame-counter.recording {
  border-color: #b8dec9;
  background: #f1faf5;
}

.device-row {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 10px;
}

.events {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 360px;
  overflow: auto;
}

.operation-log {
  display: grid;
  gap: 10px;
}

.operation-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}

.operation-row.ok {
  border-color: #b8dec9;
}

.operation-row.bad {
  border-color: #efc1bd;
}

.operation-row.warn,
.operation-row.pending {
  border-color: #efd48a;
}

.operation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.operation-head span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  font-size: 12px;
}

.operation-meta {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 6px 10px;
  margin: 0;
  color: var(--text);
  font-size: 13px;
}

.operation-meta dt {
  color: var(--muted);
}

.operation-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.data-list {
  display: grid;
  gap: 10px;
}

.data-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

.subtle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin-top: 4px;
}

.preview-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.preview-summary {
  margin-bottom: 14px;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.thumb-grid figure {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.thumb-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #edf2f4;
}

.thumb-grid figcaption {
  overflow: hidden;
  padding: 7px 8px;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

.empty {
  color: var(--muted);
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

/* Minimal responsive control layout */
:root {
  --bg: #f7f8f8;
  --panel: #ffffff;
  --line: #dfe5e4;
  --line-strong: #cbd5d3;
  --text: #17211e;
  --muted: #697773;
  --accent: #0b756b;
  --accent-soft: #eef8f6;
  --danger: #b73532;
  --danger-soft: #fff3f2;
  --warn: #8a6500;
  --warn-soft: #fff9e8;
  --ok: #18754b;
  --ok-soft: #f0faf4;
}

html {
  -webkit-text-size-adjust: 100%;
}

html,
body {
  min-width: 0;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  line-height: 1.45;
}

button,
a.button,
.file-button {
  min-height: 38px;
  border-radius: 7px;
  padding: 8px 13px;
  font-weight: 650;
  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

button:hover:not(:disabled),
a.button:hover,
.file-button:hover {
  border-color: var(--line-strong);
  background: #f8fbfa;
}

button:focus-visible,
a.button:focus-visible,
.file-button:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(11, 117, 107, 0.35);
  outline-offset: 2px;
}

button.primary:hover:not(:disabled) {
  background: #09665e;
  border-color: #09665e;
}

button.danger:hover:not(:disabled) {
  background: #9f302d;
  border-color: #9f302d;
}

.shell {
  width: min(1240px, calc(100vw - 32px));
  padding: 22px 0 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: 0 -16px 18px;
  padding: 14px 16px;
  background: rgba(247, 248, 248, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.eyebrow {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  font-size: 24px;
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 16px;
  line-height: 1.25;
}

h3 {
  font-size: 16px;
  line-height: 1.3;
}

.panel-section {
  margin-top: 18px;
}

.section-title {
  min-height: 38px;
  margin-bottom: 8px;
}

.status-pill,
.tag {
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.ok,
.tag.ok {
  background: var(--ok-soft);
}

.status-pill.bad,
.tag.bad {
  background: var(--danger-soft);
}

.grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.card,
.record-settings,
.notice,
.data-row,
.preview-panel,
.events,
.operation-row,
.empty {
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(18, 32, 28, 0.04);
}

.card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 8px 24px rgba(18, 32, 28, 0.07);
  transform: translateY(-1px);
}

.card h3 {
  margin-bottom: 0;
  overflow-wrap: anywhere;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edf1f0;
}

.card-kicker {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.state-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8faf9;
  color: var(--muted);
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.metric-strip {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr 0.8fr;
  gap: 8px;
}

.metric-tile {
  min-width: 0;
  border: 1px solid #e6ecea;
  border-radius: 8px;
  background: #fbfcfc;
  padding: 9px 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.metric-tile span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.metric-tile strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 17px;
  line-height: 1.1;
}

.primary-metric {
  border-color: #cfe3df;
  background: linear-gradient(180deg, #f4fbfa 0%, #ffffff 100%);
}

.primary-metric strong {
  color: var(--accent);
  font-size: 30px;
}

.health-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.health-line span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--warn);
}

.health-line.ok span {
  background: var(--ok);
}

.health-line strong {
  font-weight: 700;
}

.diagnostic-meta {
  border-top: 1px dashed #dfe7e5;
  padding-top: 10px;
}

.device-card.is-recording {
  border-color: #badbd4;
}

.meta {
  grid-template-columns: minmax(88px, 0.45fr) minmax(0, 1fr);
  gap: 6px 10px;
  font-size: 13px;
}

.meta dd {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
}

.actions {
  border-top: 1px solid #edf1f0;
  gap: 8px;
  margin-top: 2px;
  padding-top: 12px;
}

.actions + .actions {
  border-top: 0;
  padding-top: 0;
}

.actions button,
.actions .button {
  flex: 1 1 132px;
  min-width: 0;
}

.record-settings {
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) auto minmax(220px, 1fr);
  align-items: end;
  gap: 12px;
  padding: 12px;
}

.record-settings label {
  min-width: 0;
}

.record-settings select {
  width: 100%;
  min-width: 0;
  min-height: 38px;
}

.record-settings .toggle-setting {
  min-height: 38px;
  padding: 0 2px;
  white-space: nowrap;
}

.setting-note {
  padding-bottom: 8px;
  color: var(--muted);
}

.frame-counter {
  margin-bottom: 0;
  background: #fbfdfc;
  padding: 10px 12px;
}

.frame-counter strong {
  font-size: 30px;
}

.frame-counter.recording {
  background: var(--ok-soft);
}

.notice-list {
  margin-bottom: 12px;
}

.notice {
  padding: 9px 11px;
}

.notice.ok {
  background: var(--ok-soft);
}

.notice.warn {
  background: var(--warn-soft);
}

.notice.bad {
  background: var(--danger-soft);
}

.data-row {
  align-items: flex-start;
  border-left: 3px solid var(--line-strong);
  padding: 12px;
}

.data-row strong {
  overflow-wrap: anywhere;
}

.subtle,
.error-text {
  overflow-wrap: anywhere;
}

.events,
.operation-log {
  max-height: 420px;
  overflow: auto;
}

.event {
  padding: 9px 11px;
  font-size: 11px;
}

.operation-row {
  border-left-width: 3px;
  padding: 11px;
  min-width: 0;
}

.operation-row.ok {
  border-left-color: var(--ok);
}

.operation-row.bad {
  border-left-color: var(--danger);
}

.operation-row.warn,
.operation-row.pending {
  border-left-color: var(--warn);
}

.operation-head {
  margin-bottom: 8px;
}

.operation-head > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.operation-head small {
  color: var(--muted);
  font-size: 11px;
}

.operation-meta {
  grid-template-columns: 80px minmax(0, 1fr);
  font-size: 12px;
}

.thumb-grid {
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
}

@media (max-width: 760px) {
  .shell {
    width: min(100vw - 20px, 100%);
    padding: 12px 0 28px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    margin: 0 -10px 14px;
    padding: 12px 10px;
  }

  h1 {
    font-size: 20px;
  }

  .section-title {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .section-title button,
  .section-title .file-button {
    width: 100%;
  }

  select {
    font-size: 16px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .card:hover {
    box-shadow: 0 1px 2px rgba(18, 32, 28, 0.04);
    transform: none;
  }

  .chip-row {
    justify-content: flex-start;
  }

  .record-settings {
    grid-template-columns: 1fr;
  }

  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .record-settings .toggle-setting,
  .setting-note {
    padding: 0;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .actions button,
  .actions .button,
  button,
  a.button,
  .file-button {
    width: 100%;
  }

  .meta,
  .operation-meta {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .data-row,
  .transfer-line,
  .transfer-status-head,
  .queue-status-head,
  .operation-head {
    align-items: stretch;
    flex-direction: column;
  }

  .events,
  .operation-log {
    max-height: 360px;
  }
}

@media (max-width: 420px) {
  .shell {
    width: min(100vw - 14px, 100%);
  }

  .topbar {
    gap: 10px;
  }

  .status-pill {
    align-self: flex-start;
  }

  h1 {
    font-size: 18px;
  }

  .card,
  .record-settings,
  .preview-panel,
  .empty {
    padding: 12px;
  }

  .meta,
  .operation-meta {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .metric-strip {
    grid-template-columns: 1fr;
  }

  .meta dt,
  .operation-meta dt {
    margin-top: 6px;
  }
}
