:root {
    --page-bg: #f0f0f3;
    --card-bg: #ffffff;
    --fg: #1a1a1a;
    --muted: #6b6b6b;
    --surface: #f2f2f2;
    --accent: #F85900;
    --grid: rgba(0, 0, 0, 0.12);
}

@media (prefers-color-scheme: dark) {
    :root {
        --page-bg: #0c0c0c;
        --card-bg: #161616;
        --fg: #ececec;
        --muted: #9a9a9a;
        --surface: #242424;
        --grid: rgba(255, 255, 255, 0.16);
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--page-bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Phone: full-width, chart edge-to-edge. */
#app {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    background: var(--card-bg);
}

/* Tablet / desktop: a centered card on the page background, so wide screens
   look deliberate rather than a stretched phone layout. The chart bleeds to
   the card's rounded edges. */
@media (min-width: 720px) {
    #app {
        margin: 24px auto;
        border-radius: 16px;
        overflow: hidden;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.10);
    }
}

/* Padded text blocks; the chart between them spans full width. */
.block { padding: 14px 16px; }

.status {
    padding: 48px 16px;
    text-align: center;
    color: var(--muted);
}

/* Location priming screen. */
.intro {
    max-width: 460px;
    margin: 0 auto;
    padding: 48px 24px;
    text-align: center;
}
.intro-title {
    font-size: 2rem;
    font-weight: 600;
    margin: 0 0 16px;
}
.intro-text {
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.5;
    margin: 0 0 12px;
}
.intro-btn {
    width: 100%;
    margin-top: 20px;
    padding: 13px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}
.intro-skip {
    display: block;
    margin: 14px auto 0;
    padding: 6px;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.9rem;
    text-decoration: underline;
    cursor: pointer;
}

.header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}
.header-text { min-width: 0; }

.gear {
    flex: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    padding: 4px;
    color: var(--muted);
    cursor: pointer;
}

.header .severity {
    font-size: clamp(2rem, 8vw, 2.75rem);
    font-weight: 600;
    line-height: 1.1;
}

.header .sub {
    color: var(--muted);
    font-size: 0.95rem;
    margin-top: 2px;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
}

.toggle { display: flex; }

.tab {
    border: 1px solid var(--grid);
    background: var(--surface);
    color: var(--fg);
    padding: 6px 14px;
    font-size: 0.9rem;
    cursor: pointer;
}
.tab:first-child { border-radius: 8px 0 0 8px; }
.tab:last-child { border-radius: 0 8px 8px 0; border-left: none; }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.field { display: flex; align-items: center; gap: 6px; }
.field-label { color: var(--muted); font-size: 0.85rem; }
.field select {
    background: var(--surface);
    color: var(--fg);
    border: 1px solid var(--grid);
    border-radius: 8px;
    padding: 5px 8px;
    font-size: 0.9rem;
}

/* Chart fills its width; height scales with the viewport but stays bounded so
   it's tall enough on a phone and not gigantic on a monitor. */
.chart-wrap {
    width: 100%;
    height: clamp(240px, 46vh, 440px);
}

.chart { display: block; width: 100%; height: 100%; }

/* Curve segments are coloured per-severity inline (stroke set in JS). */
.seg { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.grid { stroke: var(--grid); stroke-width: 1; }
.now { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 5; }
.now-dot { fill: var(--fg); }
.handle { stroke: var(--accent); stroke-width: 2; }
.handle-dot { fill: var(--accent); }
.axis { fill: var(--muted); font-size: 12px; text-anchor: middle; }

.readout {
    font-size: 1.05rem;
    font-weight: 500;
}

.legend {
    color: var(--muted);
    font-size: 0.8rem;
    margin-top: 6px;
}

#ios-hint {
    max-width: 760px;
    margin: 8px auto 0;
    padding: 10px 16px;
    color: var(--muted);
    font-size: 0.85rem;
    text-align: center;
}

/* Settings modal. */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}
.panel {
    background: var(--card-bg);
    color: var(--fg);
    border-radius: 16px;
    padding: 22px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}
.panel-title { margin: 0 0 10px; font-size: 1.25rem; }
.panel-text { margin: 0 0 16px; font-size: 0.95rem; line-height: 1.4; }
.panel-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}
.panel-note {
    margin: 16px 0 0;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--muted);
}
.panel-close {
    display: block;
    margin: 16px auto 0;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.9rem;
    text-decoration: underline;
    cursor: pointer;
}
