:root {
  color-scheme: light dark;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --text: #1c2523;
  --muted: #5d6b67;
  --border: #d5dcda;
  --accent: #2f6f62;
  --accent-text: #ffffff;
  --ok: #1f7a4d;
  --warn: #a4501b;
  --chart-bar: #00856a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111615;
    --surface: #1b2220;
    --text: #e8eeec;
    --muted: #9aa8a4;
    --border: #33403c;
    --accent: #5fb3a0;
    --accent-text: #0d1513;
    --ok: #5dd39e;
    --warn: #f0a56b;
    --chart-bar: #19ad8c;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif;
}

h1 {
  margin: 0;
  font-size: 18px;
}

h2 {
  margin: 24px 0 8px;
  font-size: 16px;
}

button,
select,
input {
  font: inherit;
  color: inherit;
}

button {
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

button[aria-pressed="true"],
.login-card button {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

select,
input {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.version {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.status {
  font-size: 14px;
  font-weight: 600;
}

.status-on {
  color: var(--ok);
}

.status-off {
  color: var(--warn);
}

main {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}

.stage {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
  aspect-ratio: 16 / 9;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 16px;
  background: rgb(0 0 0 / 0.6);
  color: #fff;
  text-align: center;
}

.stage:fullscreen,
.stage-maximized {
  width: 100%;
  height: 100%;
  border-radius: 0;
  aspect-ratio: auto;
}

.stage-maximized {
  position: fixed;
  inset: 0;
  z-index: 10;
  height: 100dvh;
}

.stage-button {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 1;
  border-color: transparent;
  background: rgb(0 0 0 / 0.6);
  color: #fff;
}

.meta {
  margin: 8px 0;
  color: var(--muted);
  font-size: 14px;
}

.battery-low {
  color: var(--warn);
  font-weight: 700;
}

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

.field {
  display: block;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--muted);
}

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

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

.shot a {
  color: inherit;
  font-size: 13px;
  text-align: center;
  text-decoration: none;
}

.shot button {
  min-height: 40px;
  padding: 4px 8px;
  border-width: 1px 0 0;
  border-radius: 0;
  font-size: 13px;
}

.chart {
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.chart figcaption {
  font-weight: 700;
}

.chart-readout {
  min-height: 1.6em;
  margin: 2px 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.chart-bars {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  height: 96px;
  border-bottom: 1px solid var(--border);
}

.chart-slot {
  display: flex;
  align-items: flex-end;
  justify-content: stretch;
  min-width: 0;
  min-height: 0;
  padding: 0 1px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.chart-slot:hover,
.chart-slot:focus-visible {
  background: var(--border);
}

.chart-bar {
  display: block;
  width: 100%;
  border-radius: 4px 4px 0 0;
  background: var(--chart-bar);
}

.chart-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.chart-table {
  margin-top: 8px;
  font-size: 14px;
}

.chart-table summary {
  min-height: 32px;
  color: var(--muted);
  cursor: pointer;
}

.chart-table table {
  width: 100%;
  border-collapse: collapse;
}

.chart-table th,
.chart-table td {
  padding: 2px 4px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.hidden-username {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
}

.grid img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list li + li {
  margin-top: 8px;
}

.list button {
  width: 100%;
  text-align: left;
}

video {
  width: 100%;
  margin-bottom: 16px;
  border-radius: 8px;
  background: #000;
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.tabbar button {
  min-height: 56px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.tabbar button[aria-current="page"] {
  color: var(--accent);
  font-weight: 700;
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.login-card h1 {
  margin-bottom: 16px;
}

.login-card button {
  width: 100%;
}

.hint {
  display: block;
  margin-top: 4px;
  font-size: 13px;
}

.card-link {
  margin: 16px 0 0;
  font-size: 14px;
  text-align: center;
}

.card-link a {
  color: var(--accent);
}

code {
  overflow-wrap: anywhere;
  font-size: 18px;
  font-weight: 700;
}

.log-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.log-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.name-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 8px;
}

.name-form .field {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.name-form button {
  flex: none;
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.list .account-row button {
  flex: none;
  width: auto;
}

.error {
  margin: 12px 0 0;
  color: var(--warn);
  font-size: 14px;
}
