:root {
    --navy: #232a6e;
    --navy-2: #2f3888;
    --bg: #f3f4f8;
    --card: #ffffff;
    --text: #1b1d29;
    --muted: #6b6f80;
    --line: #e3e5ee;
    --red: #d93025;
    --green: #1e8e3e;
    --t-vape: #7b3fe4;
    --t-aerosol: #d98200;
    --t-flame: #d93025;
    --t-cell: #00897b;
    --t-noise: #1a73e8;
    --radius: 14px;
    color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #101219;
        --card: #1b1e29;
        --text: #eceef5;
        --muted: #9aa0b4;
        --line: #2a2e3d;
    }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }

.topbar {
    position: sticky; top: 0; z-index: 5;
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 7px; }
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { font-size: 12px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.icon-btn {
    background: transparent; border: 0; color: #fff; padding: 8px; border-radius: 50%;
    cursor: pointer; display: grid; place-items: center;
}
.icon-btn:active { background: rgba(255,255,255,.15); }

.view { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.login-card { padding: 22px 20px; margin-top: 8vh; }
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card label { display: block; font-size: 14px; font-weight: 600; margin: 16px 0 6px; }
.login-card input {
    width: 100%; font-size: 17px; padding: 12px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.login-card .btn { width: 100%; margin-top: 20px; }
.error { color: var(--red); font-size: 14px; min-height: 1em; margin-top: 10px; }

.btn {
    font: inherit; font-weight: 600; font-size: 15px;
    border-radius: 10px; padding: 11px 16px; cursor: pointer;
    border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:active { background: var(--navy-2); }
.btn-danger { color: var(--red); }
.btn:disabled { opacity: .6; }

.banner {
    background: var(--card); border-left: 4px solid var(--navy); border-radius: var(--radius);
    padding: 14px 16px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.banner h2 { font-size: 16px; margin: 0 0 4px; }
.banner p { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.banner ol { margin: 6px 0 0; padding-left: 20px; font-size: 14px; }
.banner.warn { border-left-color: var(--red); }

.list-head { display: flex; align-items: baseline; justify-content: space-between; }
.list-head h1 { font-size: 22px; margin: 4px 0 8px; }
.day { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 4px 8px; }

.alarm {
    background: var(--card); border-radius: var(--radius); padding: 14px 14px 12px;
    margin-bottom: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.06);
    border-left: 5px solid var(--tc, var(--navy));
    transition: box-shadow .3s;
}
.alarm.highlight { box-shadow: 0 0 0 3px var(--tc, var(--navy)); }
.alarm-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chip {
    display: inline-block; font-size: 12px; font-weight: 700; color: #fff;
    background: var(--tc, var(--navy)); padding: 3px 9px; border-radius: 999px;
}
.alarm-time { font-size: 14px; color: var(--muted); white-space: nowrap; }
.alarm-where { font-size: 18px; font-weight: 650; margin: 8px 0 2px; }
.alarm-site { font-size: 14px; color: var(--muted); }
.alarm-foot { margin-top: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ack { font-size: 14px; color: var(--green); font-weight: 600; }
.ack-btn { padding: 8px 14px; font-size: 14px; }
.t-vape { --tc: var(--t-vape); }
.t-aerosol { --tc: var(--t-aerosol); }
.t-flame { --tc: var(--t-flame); }
.t-cell { --tc: var(--t-cell); }
.t-noise { --tc: var(--t-noise); }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty svg { opacity: .35; margin-bottom: 8px; }

.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.sheet-panel {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto;
    background: var(--card); border-radius: 18px 18px 0 0;
    padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
    max-width: 640px; margin: 0 auto;
}
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet-panel h2 { margin: 0; font-size: 20px; }
.sheet-panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 0 8px; }
.sheet-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.sheet-actions .btn { flex: 1 1 auto; }
.pref-list label {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 16px;
}
.pref-list input { width: 22px; height: 22px; accent-color: var(--navy); }

.toast {
    position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
    background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 30;
    max-width: calc(100% - 32px);
}
