:root {
  color-scheme: light;
  --ink: #111;
  --paper: #fff;
  --ground: #f2f2f0;
  --muted: #606060;
  --shadow: #8a8a8a;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f5f5f5;
  --paper: #0d0d0d;
  --ground: #050505;
  --muted: #b5b5b5;
  --shadow: #666;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #f5f5f5;
    --paper: #0d0d0d;
    --ground: #050505;
    --muted: #b5b5b5;
    --shadow: #666;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.45 Arial, Helvetica, sans-serif;
}

.hidden { display: none !important; }

header {
  min-height: 64px;
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
  padding: 0 max(24px, calc((100vw - 1080px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.03em;
}

.header-actions,
#user-display,
.row {
  display: flex;
  align-items: center;
  gap: 12px;
}

main {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 64px 0 80px;
}

.panel {
  border: 2px solid var(--ink);
  background: var(--paper);
  padding: 22px;
  box-shadow: 6px 6px 0 var(--ink);
}

.panel-title {
  margin: -35px 0 22px;
  width: max-content;
  max-width: 100%;
  border: 2px solid var(--ink);
  background: var(--paper);
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.login-panel {
  max-width: 620px;
  margin: 0 auto;
}

label {
  display: block;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input {
  width: 100%;
  min-width: 0;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  padding: 11px 12px;
  font: inherit;
}

input:focus {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

input:read-only { background: var(--ground); }

button {
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--shadow);
  white-space: nowrap;
}

button:hover,
button.active {
  background: var(--paper);
  color: var(--ink);
}

button:active {
  box-shadow: 1px 1px 0 var(--shadow);
  transform: translate(2px, 2px);
}

button:focus-visible,
input:focus-visible {
  outline: 3px dashed var(--ink);
  outline-offset: 3px;
}

button.secondary,
button.danger,
nav button {
  background: var(--paper);
  color: var(--ink);
}

button.danger { border-style: dashed; }
button.compact { padding: 5px 9px; font-size: 12px; }
button.wide { width: 100%; margin-top: 16px; }
button:disabled { cursor: wait; opacity: .55; }

.muted {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.error { font-weight: 700; }
.success { font-weight: 700; }
.status { margin: 4px 0 0; }

nav {
  display: flex;
  width: max-content;
  max-width: 100%;
  margin-bottom: 30px;
  border: 2px solid var(--ink);
}

nav button {
  border: 0;
  border-right: 2px solid var(--ink);
  box-shadow: none;
}

nav button:last-child { border-right: 0; }
nav button.active { background: var(--ink); color: var(--paper); }

.action-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 26px;
  padding: 14px;
  box-shadow: 4px 4px 0 var(--ink);
}

.action-bar .status { flex-basis: 100%; }

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

.account,
.empty {
  border: 2px solid var(--ink);
  background: var(--paper);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border: 2px solid var(--ink);
  background: var(--ground);
  color: var(--ink);
  image-rendering: pixelated;
  object-fit: cover;
}

.avatar-fallback { font-weight: 800; }

.account-info {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 5px;
}

.account-info code {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
}

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

#users-list { list-style: none; padding: 0; margin: 0; }

#users-list button {
  width: 100%;
  border-width: 0 0 1px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: none;
  text-align: left;
}

#users-list button::before { content: "> "; }
.editor { display: grid; gap: 8px; }
.editor label:not(:first-child) { margin-top: 8px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; accent-color: var(--ink); }
.controls { margin-top: 14px; }

@media (max-width: 720px) {
  header {
    padding: 14px 16px;
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions { width: 100%; flex-wrap: wrap; }
  main { padding: 36px 0 64px; }
  .account-grid, .user-grid { grid-template-columns: 1fr; }
  .row { align-items: stretch; }
  .login-panel .row, .editor > .row { flex-direction: column; }
  .account { align-items: flex-start; flex-wrap: wrap; }
  .controls button { flex: 1; }
}
