:root {
  color-scheme: light dark;

  /* Ink & surfaces — cool, slightly blue-grey neutrals rather than pure
     grey, so the palette reads as chosen rather than default. */
  --ink: #10171a;
  --muted: #57696e;
  --paper: #f2f6f6;
  --surface: #ffffff;
  --surface-2: #e8eeee;
  --line: #d9e2e3;

  /* Brand accent: a pulse/signal teal instead of the generic SaaS blue this
     started with — ties the product's own name (a "pulse" check) to its
     one accent color, and matches the project's roadmap tracker. */
  --accent: #0e9594;
  --accent-strong: #0b7a79;
  --accent-bg: rgba(14, 149, 148, 0.10);
  --accent-ink: #ffffff;

  /* Status colors carry real meaning on a monitoring dashboard — kept
     separate from the brand accent so "this needs attention" never reads
     as "this is a link/button". */
  --up: #2f8f57;
  --up-bg: rgba(47, 143, 87, 0.12);
  --late: #b8791f;
  --late-bg: rgba(184, 121, 31, 0.14);
  --down: #c23f3f;
  --down-bg: rgba(194, 63, 63, 0.11);
  --new: #6b7b80;
  --new-bg: rgba(107, 123, 128, 0.12);
  --paused: #838f93;
  --paused-bg: rgba(131, 143, 147, 0.12);

  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  font-family: var(--font-body);
}

/* Light is the default for anyone with no saved preference — dark is
   opt-in via the theme toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e7edee;
    --muted: #93a5aa;
    --paper: #0c1315;
    --surface: #141d20;
    --surface-2: #192327;
    --line: #263134;

    --accent: #2dd4cf;
    --accent-strong: #6fe4e0;
    --accent-bg: rgba(45, 212, 207, 0.14);
    --accent-ink: #06282a;

    --up: #5fc78a;
    --up-bg: rgba(95, 199, 138, 0.14);
    --late: #e0a94a;
    --late-bg: rgba(224, 169, 74, 0.15);
    --down: #e97575;
    --down-bg: rgba(233, 117, 117, 0.14);
    --new: #8b9ca0;
    --new-bg: rgba(139, 156, 160, 0.14);
    --paused: #97a3a6;
    --paused-bg: rgba(151, 163, 166, 0.14);
  }
}

:root[data-theme="dark"] {
  --ink: #e7edee;
  --muted: #93a5aa;
  --paper: #0c1315;
  --surface: #141d20;
  --surface-2: #192327;
  --line: #263134;

  --accent: #2dd4cf;
  --accent-strong: #6fe4e0;
  --accent-bg: rgba(45, 212, 207, 0.14);
  --accent-ink: #06282a;

  --up: #5fc78a;
  --up-bg: rgba(95, 199, 138, 0.14);
  --late: #e0a94a;
  --late-bg: rgba(224, 169, 74, 0.15);
  --down: #e97575;
  --down-bg: rgba(233, 117, 117, 0.14);
  --new: #8b9ca0;
  --new-bg: rgba(139, 156, 160, 0.14);
  --paused: #97a3a6;
  --paused-bg: rgba(151, 163, 166, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
}

::selection { background: var(--accent-bg); }

h1, h2, h3 { text-wrap: balance; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

/* A small pulsing dot next to the wordmark — the one deliberate motion
   moment on the page, echoing the product's own name. Respects reduced
   motion by simply not animating; the dot still reads fine static. */
.brand::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-bg);
  animation: pulse-dot 2.4s ease-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(14, 149, 148, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(14, 149, 148, 0); }
  100% { box-shadow: 0 0 0 0 rgba(14, 149, 148, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .brand::before { animation: none; }
}

.topbar nav { display: flex; align-items: center; }
.topbar nav a, .topbar nav .muted {
  margin-left: 1.25rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.92rem;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
}

/* Logged-in app shell: sidebar + content, instead of the marketing top bar */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  padding: 0 0.5rem;
  margin-bottom: 1.75rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sidebar-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.5rem 0.6rem;
  border-radius: 7px;
  font-size: 0.9rem;
  font-weight: 500;
}

.sidebar-nav a:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0 0.5rem;
}

.sidebar-user {
  font-size: 0.78rem;
  word-break: break-all;
}

.sidebar-credit {
  padding: 0.85rem 0.5rem 0;
  margin-top: 0.85rem;
  border-top: 1px solid var(--line);
  font-size: 0.76rem;
}

.sidebar-credit .muted { font-size: 0.76rem; }

.credit-links {
  display: flex;
  gap: 0.7rem;
  margin-top: 0.3rem;
}

.credit-links a {
  color: var(--muted);
  text-decoration: none;
}

.credit-links a:hover { color: var(--accent-strong); }

.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.35rem 0.6rem;
  font-size: 0.95rem;
  align-self: flex-start;
  line-height: 1;
}

/* Without this, the generic button:hover rule further down (element +
   pseudo-class beats a single class) paints a solid teal box behind the
   theme icon on hover instead of the subtle highlight actually intended
   here. */
.theme-toggle:hover { background: var(--surface-2); }

.app-main {
  flex: 1;
  /* min-width: 0 is the actual fix here, not max-width — a flex item
     defaults to min-width: auto, which means it won't shrink below its
     content's intrinsic width no matter what max-width says. A long
     unbreakable ping URL or cron one-liner anywhere inside was enough to
     force this whole column (and the page) wider than the viewport;
     min-width: 0 lets flexbox actually shrink it, so the overflow-x:auto
     on individual code/pre blocks can do its job instead of being
     overridden by their ancestor's width. */
  min-width: 0;
  max-width: 920px;
  /* Without this, the leftover space on a wide screen (this column is
     capped at 920px for readability, same as GitHub/Linear/Notion) all
     piles up on the right, which reads as unfinished rather than
     intentional. Auto margins on a flex item absorb exactly that leftover
     space evenly on both sides — a flexbox behavior, not a hack. */
  margin: 0 auto;
  padding: 2.25rem 2rem;
}

@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 0.75rem 1rem;
    row-gap: 0.5rem;
    position: static;
    height: auto;
    overflow-y: visible;
  }
  .sidebar .brand { margin-bottom: 0; }
  /* Brand + footer controls share the first row (footer isn't last in the
     DOM, but "order" puts it there); nav wraps to its own full-width row
     below — four links plus brand plus controls all forced onto one row
     was overflowing the viewport on mobile. */
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    order: 3;
    width: 100%;
    justify-content: center;
    gap: 0.5rem 1rem;
  }
  .sidebar-footer { flex-direction: row; margin-top: 0; padding: 0; }
  .sidebar-user { display: none; }
  .sidebar-credit { display: none; }
  .app-main { padding: 1.5rem 1rem; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card.narrow {
  max-width: 380px;
  margin: 3rem auto;
}

h1 { margin-top: 0; font-weight: 700; letter-spacing: -0.01em; }

.header-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input, textarea {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.6rem 0.65rem;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
  font-family: inherit;
}

input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

textarea {
  resize: vertical;
}

.meta-row {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0.35rem 0 1.25rem;
}

.meta-row strong { color: var(--ink); font-weight: 600; }

.meta-sep {
  margin: 0 0.5rem;
  color: var(--line);
}

.tag-row { margin: -0.5rem 0 1.25rem; }
.tag-row .tag-pill { margin-left: 0; margin-right: 0.4rem; }

.ping-url-row {
  display: flex;
  gap: 0.6rem;
  align-items: stretch;
}

/* min-width: 0 overrides the flex default of min-width: auto — without it,
   a flex item won't shrink below its content's natural width, so this
   long, unbreakable URL string was pushing the Copy button off the edge
   of the page entirely (confirmed: caused real horizontal page overflow,
   not just a squeeze). */
.ping-url-row .ping-url { flex: 1; min-width: 0; margin: 0; }

.copy-btn {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  min-width: 5rem;
}

.tag-pill {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  margin-left: 0.4rem;
}

.inline-form {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.inline-form label { flex: 1; min-width: 150px; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font-size: 0.95rem;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  margin-top: 0;
}

.test-webhook-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.test-webhook-row button { font-size: 0.85rem; padding: 0.5rem 0.9rem; }

.template-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.template-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  border-radius: 999px;
}

/* background: none is doing real work here, not just resetting to the rest
   state — button:hover (element+pseudo-class, further down this file)
   otherwise beats a single-class selector like this one and paints a solid
   teal background under teal hover text, swallowing the label completely.
   Same root cause as the .link-button.danger fix below; this is the same
   bug hitting a different element. */
.template-btn:hover {
  background: none;
  border-color: var(--accent);
  color: var(--accent-strong);
}

button {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 7px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover { background: var(--accent-strong); }

.link-button {
  background: none;
  color: var(--accent-strong);
  padding: 0;
  font-size: 0.85rem;
  text-decoration: underline;
  font-weight: 500;
}

/* Real bug, not defensive paranoia: .link-button is a <button>, so it's
   also targeted by button:hover further down this file. That rule has
   higher specificity (element+pseudo-class beats a lone class) and sets a
   solid teal background, which combined with this element's teal text
   made "pause"/"resume"/"edit" links go fully unreadable on hover — the
   text wasn't just low-contrast, the background matched the text color. */
.link-button:hover { background: none; }

/* Explicit background here is load-bearing, not decoration: this element is
   a <button class="link-button danger">, and button.danger's red background
   (below) also matches it. .link-button.danger has higher CSS specificity
   (two classes vs. one class + one tag), so this wins — without it, the
   button.danger background would apply anyway and put red text on a red
   background, exactly the bug that was reported. */
.link-button.danger { color: var(--down); background: none; }
.link-button.danger:hover { background: none; }

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--down); }
.success { color: var(--up); }

.danger-card { border-color: color-mix(in srgb, var(--down) 35%, var(--line)); }

button.danger {
  background: var(--down);
}

button.danger:hover {
  background: color-mix(in srgb, var(--down) 82%, black);
}

.hero {
  text-align: center;
  padding: 2.5rem 0 1.5rem;
}

.hero h1 {
  font-size: 2.1rem;
  line-height: 1.25;
  margin: 0 0 1rem;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

.hero-sub {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 520px;
  margin: 0 auto 1.75rem;
}

.cta-row {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.cta-row button {
  padding: 0.7rem 1.5rem;
  font-size: 1rem;
}

button.secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

button.secondary:hover { background: var(--surface-2); }

.steps {
  padding-left: 1.2rem;
}

.steps li {
  margin-bottom: 0.75rem;
  color: var(--muted);
}

.steps li strong {
  color: var(--ink);
}

/* Dashboard status-summary strip — a scan-first overview (counts, not
   prose) above the monitor list, so the thing that needs attention is
   visible before you read a single row. */
.status-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--tile-color, var(--line));
  border-radius: 10px;
  padding: 0.85rem 1rem;
}

.stat-tile .stat-count {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--ink);
}

.stat-tile .stat-label {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.stat-tile.tile-up { --tile-color: var(--up); }
.stat-tile.tile-late { --tile-color: var(--late); }
.stat-tile.tile-down { --tile-color: var(--down); }
.stat-tile.tile-new { --tile-color: var(--new); }
.stat-tile.tile-paused { --tile-color: var(--paused); }

.uptime-pct {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timeline-bar {
  display: flex;
  height: 28px;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--line);
  margin: 0.75rem 0;
}

.timeline-segment {
  height: 100%;
  min-width: 2px;
}

.status-late-text { color: var(--late); }
.status-down-text { color: var(--down); }

.status-fill-up { background: var(--up); }
.status-fill-late { background: var(--late); }
.status-fill-down { background: var(--down); }
.status-fill-new { background: var(--new); }
.status-fill-paused { background: var(--paused); }

.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 0.35rem;
}

.table-scroll { overflow-x: auto; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.25rem;
  font-size: 0.9rem;
}

.pagination a { color: var(--accent-strong); text-decoration: none; font-weight: 500; }
.pagination a:hover { text-decoration: underline; }

.monitor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
  min-width: 480px;
}

.monitor-table th, .monitor-table td {
  text-align: left;
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--line);
}

.monitor-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.monitor-table td.mono, .monitor-table .mono {
  font-family: var(--font-mono);
  font-size: 0.87rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.monitor-table a { color: var(--ink); font-weight: 500; text-decoration: none; }
.monitor-table a:hover { color: var(--accent-strong); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.status-up { background: var(--up-bg); color: var(--up); }
.status-late { background: var(--late-bg); color: var(--late); }
.status-down { background: var(--down-bg); color: var(--down); }
.status-new { background: var(--new-bg); color: var(--new); }
.status-paused { background: var(--paused-bg); color: var(--paused); }
.badge-neutral { background: var(--accent-bg); color: var(--accent-strong); }
.badge-neutral::before { display: none; }

.ping-url {
  display: block;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.75rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

pre {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.75rem;
  overflow-x: auto;
  font-family: var(--font-mono);
}

.ping-list { list-style: none; padding: 0; margin: 0; font-family: var(--font-mono); font-size: 0.88rem; }
.ping-list li { padding: 0.4rem 0; border-bottom: 1px solid var(--line); }

.card h3 {
  font-size: 0.95rem;
  margin: 1.5rem 0 0.5rem;
}

.card h3:first-of-type { margin-top: 0; }

.card code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.card pre code {
  background: none;
  border: none;
  padding: 0;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}

.compare-table th, .compare-table td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.compare-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.verify-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--late-bg);
  border: 1px solid var(--late);
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.verify-banner form { flex-shrink: 0; }

.onboarding-guide {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.onboarding-guide h2 { margin-bottom: 1rem; }

.onboarding-steps {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
}

.onboarding-steps li {
  margin-bottom: 0.6rem;
  color: var(--ink);
}

.onboarding-steps li:last-child { margin-bottom: 0; }

.intro-panel {
  margin-bottom: 1.5rem;
}

.intro-panel summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.25rem 0;
}

.intro-panel[open] summary {
  margin-bottom: 1rem;
}

.intro-panel h3 {
  font-size: 0.95rem;
  margin: 1.25rem 0 0.4rem;
}

.intro-panel h3:first-of-type { margin-top: 0; }

.auth-intro {
  max-width: 380px;
  margin: 3rem auto 0;
  text-align: center;
}

.auth-intro h2 {
  font-size: 1.15rem;
  margin-bottom: 0.4rem;
}

.auth-intro ul {
  text-align: left;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 1rem 0 0;
  padding-left: 1.2rem;
}
