:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  --background: #202124;
  --panel: #292b2d;
  --input: #303236;
  --border: #55595d;
  --text: #eee;
  --muted: #b9bdc4;
  --accent: #9ac6fa;
  background: var(--background);
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; overflow-wrap: anywhere; }
h1 { font-size: 32px; line-height: 1.25; font-weight: 650; }
h2 { font-size: 24px; line-height: 1.35; font-weight: 650; }
h3, legend { font-size: 18px; font-weight: 600; }
button, input, textarea { font: inherit; color: inherit; }
button, .button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 24px; border: 1px solid #858b94; border-radius: 6px; background: transparent; font-weight: 550; text-align: center; cursor: pointer; overflow-wrap: anywhere; }
button:hover, .button:hover { border-color: var(--accent); background: #34383d; }
.primary { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input:not([type="hidden"]):not([type="checkbox"]), textarea { display: block; width: 100%; min-width: 0; padding: 10px 16px; border: 1px solid var(--border); border-radius: 6px; background: var(--input); }
textarea { resize: none; field-sizing: content; min-height: 44px; white-space: pre-wrap; overflow-wrap: anywhere; }
input:focus, textarea:focus { border-color: var(--accent); }
input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex: none; }
label { display: grid; gap: 6px; min-width: 0; color: var(--muted); font-weight: 550; }
label input, label textarea { color: var(--text); font-weight: 400; }
form { display: grid; gap: 16px; margin: 0; min-width: 0; }
.topbar { border-bottom: 1px solid var(--border); }
.header-inner { max-width: 1344px; padding: 0 32px; margin: auto; min-height: 58px; display: flex; gap: 24px; align-items: center; justify-content: space-between; }
.brand { font-size: 24px; font-weight: 650; white-space: nowrap; flex-shrink: 0; }
nav { display: flex; align-self: stretch; align-items: stretch; gap: 24px; flex-shrink: 0; }
nav a { display: flex; align-items: center; padding: 16px 8px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
nav a[aria-current="page"] { color: var(--text); border-color: var(--accent); font-weight: 650; }
.identity { display: flex; align-items: center; justify-content: flex-end; gap: 24px; min-width: 0; }
.identity span { color: var(--muted); min-width: 0; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity form { flex-shrink: 0; }
.identity button { padding: 7px 20px; white-space: nowrap; overflow-wrap: normal; }
.content { max-width: 1344px; margin: 0 auto; padding: 40px 32px 64px; }
.page-heading { display: flex; justify-content: space-between; gap: 24px; align-items: center; margin-bottom: 24px; }
.master-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 24px; align-items: stretch; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
.master-detail > .panel { min-height: 560px; }
.master { overflow: hidden; }
.panel-heading { padding: 20px 24px; border-bottom: 1px solid var(--border); font-size: 20px; }
.entries { margin: 0; padding: 0; list-style: none; }
.entry { display: flex; gap: 12px; align-items: center; justify-content: space-between; min-height: 72px; padding: 12px 20px; border-bottom: 1px solid var(--border); border-left: 4px solid transparent; }
.entry:hover { background: #303337; }
.entry[aria-current="true"] { background: #363e49; border-left-color: var(--accent); }
.entry:focus-visible { outline-offset: -3px; }
.entry-label { display: grid; gap: 2px; min-width: 0; }
.entry-label strong { font-weight: 600; overflow-wrap: anywhere; }
.short-id { font-size: 14px; letter-spacing: .025em; color: var(--muted); }
.state { color: var(--muted); font-size: 14px; flex: none; }
.state.enabled { color: var(--accent); }
.editor { padding: 24px; }
.editor > h2 { margin-bottom: 24px; }
.actions { display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.actions.start { justify-content: flex-start; }
.editor-section { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border); }
.editor-section > h3 { margin-bottom: 6px; }
.editor-section > label, .editor-section > form { margin-top: 16px; }
.editor-section > label:first-child { margin-top: 0; }
.hint { color: var(--muted); font-weight: 400; }
.address, .pair-code { font-family: ui-monospace, monospace; }
.pair-result { display: grid; gap: 12px; margin-top: 24px; }
.pair-code { font-size: 24px; letter-spacing: .12em; }
.error { color: #ffb5b5; }
fieldset { min-width: 0; border: 0; margin: 0; padding: 0; }
legend { margin-bottom: 12px; padding: 0; }
.grant { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.grant .entry-label { flex: 1; color: var(--text); }
.grant .state { font-weight: 400; }
.empty { padding: 24px; color: var(--muted); }
.login { width: calc(100% - 32px); max-width: 440px; margin: 80px auto; padding: 32px; }
.login h1 { font-size: 24px; margin-bottom: 24px; }
.login h2 { margin-bottom: 24px; }
.dashboard { display: grid; gap: 16px; }
.scale-link { display: flex; align-items: center; gap: 24px; justify-content: space-between; padding: 24px; }
.scale-link > div { min-width: 0; }
.scale-link h2 { font-size: 20px; }
@media (max-width: 840px) {
  .header-inner { padding: 12px 16px 0; flex-wrap: wrap; gap: 12px; }
  .brand { font-size: 22px; }
  .identity { margin-left: auto; gap: 12px; }
  .identity span { max-width: 90px; }
  .identity button { padding: 6px 12px; min-height: 38px; }
  nav { order: 3; width: 100%; gap: 16px; }
  nav a { padding: 10px 0 12px; }
  .content { padding: 28px 16px 48px; }
  .page-heading { align-items: flex-start; gap: 16px; flex-wrap: wrap; }
  .page-heading h1 { font-size: 28px; }
  .master-detail { grid-template-columns: minmax(0, 1fr); }
  .master-detail > .panel { min-height: 0; }
  .editor { padding: 20px; }
  .panel-heading { padding: 16px 20px; }
  .entry { padding: 12px 16px; }
  .scale-link { padding: 20px; flex-wrap: wrap; }
  .address { font-size: 13px; }
  .grant { flex-wrap: wrap; }
  .grant .entry-label { min-width: 100px; }
}
