/* Critical: any author rule that sets `display` outranks the UA `[hidden]`
 * rule, which would un-hide the login form, logout button and pairing panel
 * that the script toggles through the `hidden` property. Keep this first. */
[hidden] { display: none !important; }

:root {
  color-scheme: light dark;

  /* environment layer: cold near-white, never pure #fff */
  --canvas: #FAFBFC;
  --raised: #F3F5F8;
  --sheet: #F7F9FC;
  --base: #EDF1F6;

  --ink: #1A1D21;
  --ink-soft: #525660;
  --ink-fade: #878B95;
  --ink-mute: #B0B4BC;

  --hairline: #DCE0E8;
  --hairline-soft: #E8ECF1;

  --seal: #3B7FAB;

  --state-success: #3E7A6B;
  --state-warn: #3B6FAB;
  --state-danger: #7A3E50;

  --radius: 12px;
  --radius-sm: 6px;
  --focus: rgba(59, 127, 171, 0.32);

  --font-sans: "Inter", -apple-system, "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #11141A;
    --raised: #181C24;
    --sheet: #1E232C;
    --base: #1A1E26;

    --ink: #EDF1F6;
    --ink-soft: #B0B4BC;
    --ink-fade: #7B7F8A;
    --ink-mute: #494D58;

    --hairline: #2A303B;
    --hairline-soft: #222834;

    --seal: #5D9CBF;

    --state-success: #6EAA9B;
    --state-warn: #6B9FCB;
    --state-danger: #AA6E80;

    --focus: rgba(93, 156, 191, 0.38);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.shell {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(28px, 6vw, 60px) clamp(20px, 5vw, 32px) clamp(36px, 7vw, 64px);
  display: grid;
  gap: clamp(18px, 3vw, 26px);
  align-content: start;
}

.masthead { display: grid; gap: 18px; }

.brand { display: flex; align-items: flex-start; gap: 13px; }

/* Restrained brand mark: a small seal, not a logo. */
.seal {
  flex: none;
  width: 10px;
  height: 10px;
  margin-top: 15px;
  border-radius: 3px;
  background: var(--seal);
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4.6vw, 36px);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.012em;
}

.lede { margin: 6px 0 0; color: var(--ink-soft); font-size: 14px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

button {
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  background: var(--sheet);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

button:hover { background: var(--raised); border-color: var(--ink-mute); }

button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

button:disabled { opacity: 0.5; cursor: default; }

/* Red line 1: the primary control is graphite-on-paper; azure never sits on a
 * CTA. In dark mode the graphite/paper pair inverts with the tokens. */
.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--canvas);
}

.btn-primary:hover { background: var(--ink-soft); border-color: var(--ink-soft); }

.btn-quiet { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
}

.status {
  margin: 0;
  padding: 11px 14px;
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-sm);
  background: var(--sheet);
  color: var(--ink-soft);
  font-size: 13.5px;
}

/* Tone is decoration on top of the sentence, never the message itself. */
.status-ok { border-color: var(--state-success); }

.status-alert { border-color: var(--state-danger); color: var(--ink); }

.devices { display: grid; gap: 12px; }

/* An emptied list should not leave a gap in the column. */
.devices:empty { display: none; }

.device {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--sheet);
}

.device-revoked { background: var(--base); }

.device-name {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  /* Device names are user-supplied; let long ones wrap instead of overflowing. */
  overflow-wrap: anywhere;
}

.device-state {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 13.5px;
}

/* Red line 6: the dot only reinforces the sentence next to it, so the state
 * still reads when colour is unavailable. */
.device-state::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  /* 50% rather than a large px value: keeps every numeric radius in the file
   * within the "radius <= 16px" red line, which is checked by a test. */
  border-radius: 50%;
  background: var(--ink-mute);
}

.state-online::before { background: var(--state-success); }
.state-offline::before { background: var(--state-warn); }
.state-revoked::before { background: var(--state-danger); }

.panel {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--sheet);
}

.panel h2 { margin: 0; font-size: 17px; font-weight: 600; }

.panel-note { margin: 0; color: var(--ink-soft); font-size: 13.5px; }

.field { display: grid; gap: 5px; }

.field label { font-size: 12.5px; font-weight: 550; color: var(--ink-soft); }

input {
  font: inherit;
  font-size: 14px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--canvas);
  color: var(--ink);
}

input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* Native select styled to match the text fields; the OS keeps the menu. */
select {
  font: inherit;
  font-size: 14px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--canvas);
  color: var(--ink);
}

select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.pairing-status { margin: 0; color: var(--ink-soft); font-size: 13px; }

.pairing-status:empty { display: none; }

.task-result { margin: 0; color: var(--ink-soft); font-size: 13px; overflow-wrap: anywhere; }

.task-result:empty { display: none; }

/* Tone reinforces the sentence; the sentence itself always states the outcome. */
.task-result-ok { color: var(--ink); }

.task-result-alert { color: var(--ink); border-left: 2px solid var(--state-danger); padding-left: 8px; }

.footnote {
  margin: 0;
  padding-top: 18px;
  border-top: 1px solid var(--hairline-soft);
  color: var(--ink-fade);
  font-size: 12.5px;
}
