:root {
    color-scheme: dark;
    --bg: #1c1c1e;
    --surface: #2c2c2e;
    --text: #f5f5f7;
    --text-dim: #a0a0a6;
    --urgent: #d92d20;
    --urgent-text: #ffffff;
    --focus: #ffd60a;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    overscroll-behavior: none;
    user-select: none;
    -webkit-user-select: none;
}

#app {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding-top: var(--safe-top);
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    font-size: 1.5rem;
    color: var(--text-dim);
}

/* ---- Top bar: identity only, no controls (everything actionable
   lives in the bottom bar, in thumb reach) ------------------------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 0.75rem;
    background: var(--surface);
    flex-shrink: 0;
}

.topbar h1 {
    font-size: 1.1rem;
    margin: 0;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-dim);
}

/* ---- Scrollable content between the title strip and the bottom bar.
   The grid inside gets pushed down via margin-top:auto so it sits as
   close to the bottom bar (thumb zone) as the content allows. -------- */
.content-area {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.tile:active, .big-btn:active, .grid-option:active, .nav-btn:active, .role-chip:active {
    transform: scale(0.96);
    filter: brightness(1.15);
}

/* ---- Bottom navigation bar: everything reachable by thumb -------- */
.bottom-bar {
    flex-shrink: 0;
    background: var(--surface);
    padding: 0.6rem 0.75rem calc(0.6rem + var(--safe-bottom));
    border-top: 1px solid #3a3a3c;
}

.nav-row {
    display: flex;
    align-items: stretch;
    gap: 0.75rem;
}

.nav-btn {
    flex: 1 1 0;
    min-height: 3.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: 1rem;
    border: none;
    background: #3a3a3c;
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 600;
}

.nav-icon { font-size: 1.4rem; }

/* Grows to fill whatever's left: 100% alone, ~2/3 next to Back. */
.help-btn {
    flex: 2 1 0;
    min-height: 3.6rem;
    background: var(--urgent);
    color: var(--urgent-text);
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: 0.05em;
    border-radius: 1rem;
    border: none;
}

/* ---- Role filter (shown above the nav row, home screen only).
   Exactly three fixed-width chips — never wraps or scrolls. -------- */
.role-bar {
    display: flex;
    gap: 0.4rem;
    padding-bottom: 0.6rem;
}

.role-chip {
    flex: 1 1 0;
    min-width: 0;
    min-height: 2.8rem;
    padding: 0 0.5rem;
    border-radius: 999px;
    border: 2px solid #48484a;
    background: transparent;
    color: var(--text);
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.role-chip.active {
    background: #0a84ff;
    border-color: #0a84ff;
    font-weight: 700;
}

/* ---- Grids -------------------------------------------------------- */
.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.9rem;
    padding: 0.9rem;
    margin-top: auto;
}

.tile {
    min-height: 7.5rem;
    border-radius: 1.25rem;
    border: none;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.75rem;
    font-size: 1.15rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.15;
}

.tile .emoji { font-size: 2.4rem; }

.tile.urgent-tile {
    outline: 3px solid var(--urgent);
}

.grid-option {
    min-height: 5.5rem;
    border-radius: 1.1rem;
    border: 2px solid #48484a;
    background: var(--surface);
    color: var(--text);
    font-size: 1.2rem;
    font-weight: 600;
    padding: 0.75rem;
}

/* Severity scale gets a colour ramp, low (green) to high (red). */
.scale-0 { background: #2e7d32; border-color: #2e7d32; }
.scale-1 { background: #9e8a00; border-color: #9e8a00; }
.scale-2 { background: #b3541e; border-color: #b3541e; }
.scale-3 { background: #b3241e; border-color: #b3241e; }
.scale-4 { background: #8c1515; border-color: #8c1515; }

/* ---- Confirmation / spoken screen ---------------------------------- */
.spoken-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    gap: 1.5rem;
    text-align: center;
}

.spoken-phrase {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.3;
}

.spoken-actions {
    display: flex;
    gap: 1rem;
    width: 100%;
    max-width: 26rem;
}

.big-btn {
    flex: 1;
    min-height: 5rem;
    border-radius: 1.25rem;
    border: none;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    background: #0a84ff;
}

.big-btn.secondary {
    background: #3a3a3c;
}

/* ---- Focus visibility for switch control / external keyboards -- */
button:focus-visible {
    outline: 4px solid var(--focus);
    outline-offset: 2px;
}

.empty-state {
    padding: 2rem;
    text-align: center;
    color: var(--text-dim);
    font-size: 1.1rem;
}
