*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--font-size);
  line-height: var(--line);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding:
    0
    max(var(--gap), env(safe-area-inset-right))
    max(2rem, env(safe-area-inset-bottom))
    max(var(--gap), env(safe-area-inset-left));
}

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

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 100;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}
.skip-link:focus { top: max(0.75rem, env(safe-area-inset-top)); }

/* ---- Header ---- */
.page-header {
  max-width: 90rem;
  margin: 0 auto;
  padding: max(2.5rem, calc(env(safe-area-inset-top) + 1.5rem)) 0 clamp(1.5rem, 4vw, 2.5rem);
}
.page-header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.page-header h1::after {
  content: "";
  display: block;
  width: 2.5rem;
  height: var(--rule);
  margin-top: 1rem;
  background: var(--accent);
}
.page-description {
  margin: 1rem 0 0;
  max-width: 60ch;
  color: var(--muted);
}

/* ---- Grid ----
   Sizes are stored for a 4-column layout. Fewer columns on narrower screens:
   blocks keep their width where they fit and shrink to full width where they don't. */
#dashboard {
  --cols: 1;
  max-width: 90rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-auto-rows: minmax(var(--row), auto);
  gap: var(--gap);
}
#dashboard:focus { outline: none; }

@media (min-width: 40rem) { #dashboard { --cols: 2; } }
@media (min-width: 64rem) { #dashboard { --cols: 4; } }

.tile {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tile > .tile-body { flex: 1; min-height: 0; }

/* Phone: one column, rows follow content */
.tile { grid-column: span 1; }

@media (min-width: 40rem) {
  .tile[data-w="2"], .tile[data-w="3"], .tile[data-w="4"] { grid-column: span 2; }
  .tile[data-h="2"] { grid-row: span 2; }
  .tile[data-h="3"] { grid-row: span 3; }
  .tile[data-h="4"] { grid-row: span 4; }
}
@media (min-width: 64rem) {
  .tile[data-w="3"] { grid-column: span 3; }
  .tile[data-w="4"] { grid-column: span 4; }
}

/* ---- Notices and the "config can't be read" panel ---- */
.notice, .empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: var(--pad);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.fatal {
  grid-column: 1 / -1;
  padding: var(--pad);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--danger);
  max-width: 50rem;
}
.fatal h2 { margin: 0 0 0.5rem; font-size: 1.25rem; font-weight: 600; color: var(--danger); }
.fatal p { margin: 0.5rem 0; }
.fatal ul { margin: 0.75rem 0; padding-left: 1.25rem; }
.fatal li + li { margin-top: 0.375rem; }
.fatal code, .issue-path {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875em;
}
.issue-path { color: var(--muted); }
.fatal pre {
  margin: 1rem 0 0;
  padding: 0.875rem 1rem;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.875rem;
  line-height: 1.45;
}
.fatal mark { background: var(--danger-bg); color: var(--danger); font-weight: 600; }

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
