:root,
html[data-theme="light"] {
  color-scheme: light;
  --page: #efeff4;
  --bg: #efeff4;
  --chip: #e5e5ea;
  --card: #ffffff;
  --line: rgba(60, 60, 67, 0.12);
  --line-solid: rgba(60, 60, 67, 0.18);
  --text: #000000;
  --muted: #8e8e93;
  --subtitle: #6c6c70;
  --accent: #007aff;
  --accent-ink: #ffffff;
  --header: #f2f2f7;
  --warn: #c9892b;
  --danger: #ff3b30;
  --ok: #34c759;
  --shadow: none;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --page: #000000;
  --bg: #000000;
  --chip: #1c1c1e;
  --card: #1c1c1e;
  --line: rgba(255, 255, 255, 0.12);
  --line-solid: rgba(255, 255, 255, 0.16);
  --text: #ffffff;
  --muted: #8e8e93;
  --subtitle: #98989d;
  --accent: #0a84ff;
  --accent-ink: #ffffff;
  --header: #1c1c1e;
  --warn: #ffd60a;
  --danger: #ff453a;
  --ok: #32d74b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue",
    Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
}

body {
  padding: calc(12px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
}

.bg-grid {
  display: none;
}

.shell {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow.ok {
  color: var(--ok);
}

h1,
h2 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.03em;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 17px;
  margin-bottom: 10px;
}

.lede {
  color: var(--muted);
  margin: 6px 0 14px;
  max-width: 36em;
  font-size: 14px;
}

.who {
  text-align: right;
  padding: 6px 0;
}

.who-name {
  display: block;
  font-weight: 600;
  font-size: 14px;
}

.who-role {
  color: var(--muted);
  font-size: 12px;
}

.banner,
.card,
.stats {
  border: 0;
  border-radius: var(--radius);
  background: var(--card);
}

.banner {
  padding: 12px 14px;
  margin-bottom: 12px;
  color: #3b2d0c;
  background: #ffe8b0;
  font-size: 14px;
}

html[data-theme="dark"] .banner {
  color: #ffe8b0;
  background: #3b2d0c;
}

.banner code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  overflow: hidden;
  margin-bottom: 12px;
}

.stat {
  padding: 14px 12px 12px;
  border-right: 1px solid var(--line);
}

.stat:last-child {
  border-right: none;
}

.stat-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

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

.admin-period {
  grid-template-columns: repeat(2, 1fr);
  margin: 4px -16px 8px;
  background: transparent;
}

.admin-period .stat {
  padding: 8px 16px 10px;
}

.admin-ops {
  margin-top: 4px;
}

.admin-op {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.admin-op:first-child {
  border-top: 0;
}

.card {
  padding: 16px;
  margin-bottom: 12px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.field-label {
  margin: 14px 0 8px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.pills,
.squads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill,
.squad {
  appearance: none;
  border: 1px solid transparent;
  background: var(--chip);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
}

.squad {
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-width: 100%;
  flex: 1 1 100%;
  padding: 12px 14px;
  text-align: left;
}

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

.pill.active,
.squad.active {
  background: var(--card);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.hint,
.muted,
.foot {
  color: var(--muted);
  font-size: 13px;
}

.cta,
.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.cta {
  width: 100%;
  margin-top: 16px;
  padding: 13px 16px;
  background: var(--accent);
  color: var(--accent-ink);
}

.cta:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn {
  padding: 10px 12px;
  background: var(--chip);
  color: var(--text);
}

.btn.ghost {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.text-btn {
  appearance: none;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.url-box,
.client-msg {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  background: var(--chip);
  border-radius: 12px;
  padding: 12px;
  overflow-wrap: anywhere;
}

.client-msg {
  white-space: pre-wrap;
  color: var(--muted);
}

.meta {
  color: var(--muted);
  margin: 6px 0 12px;
}

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

.history-item,
.op-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.history-item:first-child,
.op-item:first-child {
  border-top: 0;
}

.history-item button,
.op-item button {
  appearance: none;
  border: 0;
  background: none;
  color: var(--danger);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.history-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.history-actions [data-bind] {
  color: var(--accent);
}

#bind-btn {
  width: 100%;
  margin: 12px 0 8px;
}

.dim {
  opacity: 0.5;
  text-decoration: line-through;
}

.ops-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-top: 12px;
}

input {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  width: 100%;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 5;
}

.lock-card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 16px;
  padding: 22px;
}

.hidden {
  display: none !important;
}

.skeleton {
  height: 54px;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--chip), var(--card), var(--chip));
  background-size: 200% 100%;
  animation: shine 1.2s infinite;
  flex: 1;
  min-width: 100%;
}

@keyframes shine {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}

.foot {
  text-align: center;
  margin: 8px 4px 0;
}

@media (max-width: 520px) {
  h1 {
    font-size: 20px;
  }

  .ops-form {
    grid-template-columns: 1fr;
  }
}
