:root {
    color-scheme: light;
    --surface-1: #fcfcfb;
    --page: #f9f9f7;
    --text-primary: #0b0b0b;
    --text-secondary: #52514e;
    --muted-ink: #898781;
    --hairline: #e1e0d9;
    --border: rgba(11, 11, 11, 0.10);
    --good: #0ca30c;
    --warning: #fab219;
    --critical: #d03b3b;
    --gap: #898781;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --surface-1: #1a1a19;
        --page: #0d0d0d;
        --text-primary: #ffffff;
        --text-secondary: #c3c2b7;
        --muted-ink: #898781;
        --hairline: #2c2c2a;
        --border: rgba(255, 255, 255, 0.10);
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--page);
    color: var(--text-primary);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 14px;
}

.page { max-width: 960px; margin: 0 auto; padding: 16px; }

.header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.header h1 { font-size: 1.4rem; margin: 8px 0; }

.error-banner {
    background: color-mix(in srgb, var(--critical) 12%, var(--surface-1));
    border: 1px solid var(--critical);
    border-radius: 8px;
    padding: 8px 12px;
    margin: 8px 0;
}

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.tile {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
}
.tile-head { color: var(--text-secondary); font-weight: 600; letter-spacing: 0.04em; }
.tile-state { font-size: 2rem; font-weight: 700; margin: 4px 0; }
.tile-since { color: var(--muted-ink); font-size: 0.85rem; }
.tile-up .tile-state { color: var(--good); }
.tile-down .tile-state { color: var(--critical); }

.card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    margin: 12px 0;
}
.card h2 { font-size: 1rem; margin: 0 0 10px; }

.toolbar { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.ranges { display: flex; gap: 6px; }

.btn {
    background: var(--surface-1);
    color: var(--text-primary);
    border: 1px solid var(--hairline);
    border-radius: 8px;
    padding: 5px 12px;
    cursor: pointer;
    font: inherit;
}
.btn:hover { border-color: var(--muted-ink); }
.btn-on { border-color: var(--text-primary); font-weight: 600; }

.timeline { position: relative; touch-action: pan-y; cursor: grab; user-select: none; }
.timeline:active { cursor: grabbing; }

.lane-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.lane-label { width: 64px; color: var(--text-secondary); font-size: 0.85rem; text-align: right; flex: none; }
.lane {
    position: relative;
    flex: 1;
    height: 34px;
    background: var(--page);
    border-radius: 6px;
    overflow: hidden;
}
.seg {
    position: absolute;
    top: 0;
    bottom: 0;
    border-right: 2px solid var(--surface-1);
    border-radius: 3px;
}
.seg.good { background: var(--good); }
.seg.warning { background: var(--warning); }
.seg.critical { background: var(--critical); }
.seg.muted { background: var(--gap); }
.seg.provisional {
    background-image: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.35) 0 4px,
        transparent 4px 9px);
}

.axis { position: relative; height: 20px; margin-left: 74px; }
.tick {
    position: absolute;
    transform: translateX(-50%);
    color: var(--muted-ink);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tooltip {
    position: absolute;
    top: -8px;
    transform: translate(-50%, -100%);
    background: var(--text-primary);
    color: var(--page);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 0.8rem;
    white-space: nowrap;
    pointer-events: none;
    z-index: 5;
}

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; color: var(--text-secondary); font-size: 0.8rem; }
.legend .sw {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    vertical-align: -2px;
    margin-right: 4px;
}
.sw.good { background: var(--good); }
.sw.warning { background: var(--warning); }
.sw.critical { background: var(--critical); }
.sw.muted { background: var(--gap); }
.sw.provisional {
    background-image: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.35) 0 3px,
        transparent 3px 6px);
}

.events { width: 100%; border-collapse: collapse; }
.events th {
    text-align: left;
    color: var(--muted-ink);
    font-weight: 500;
    border-bottom: 1px solid var(--hairline);
    padding: 4px 8px 6px 0;
}
.events td {
    padding: 6px 8px 6px 0;
    border-bottom: 1px solid var(--hairline);
    font-variant-numeric: tabular-nums;
}

.muted { color: var(--muted-ink); }
.footer { margin: 16px 0; font-size: 0.8rem; }

#blazor-error-ui { display: none; }

@media (max-width: 560px) {
    .tiles { grid-template-columns: 1fr; }
    .tile-state { font-size: 1.5rem; }
}
