/* ═══════════════════════════════════════════════════════════════════════════
   ลงเวลาปฏิบัติงานด้วยตำแหน่ง — qr_checkin_v2.php
   2026-09-25 first version · 2026-10-02 site language (blue header, Sarabun + display font)
   2026-10-07 commercial-grade time clock:
     a round time-clock button whose ring shows the location state (body[data-loc]),
     a small radar of the school's radius, today's work line with hours worked so far,
     this week Mon–Fri and this month's totals, and a two-pane layout on wide screens.
   Every selector is prefixed ci- so this sheet cannot collide with the rest of the module.
   Mobile first. Text colours meet 4.5:1 (large text 3:1) in light and dark.
   tb1-app.css swaps --ci-sans/--ci-serif to Sukhumvit Set inside the TB1 app and gives
   .ci-clock, .ci-sched b and .ci-t dd a system font with even digits: keep those class names.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --ci-sans: var(--tb1-font-body, "Sarabun", system-ui, sans-serif);
    --ci-serif: var(--tb1-font-display, "Noto Sans Thai Looped", "Sarabun", sans-serif);

    /* hero: white text is 5.8:1 or more on every stop */
    --ci-hero-a: #081a52;
    --ci-hero-b: #1d4ed8;
    --ci-hero-c: #1e4fc0;
    --ci-on-hero: #ffffff;
    --ci-on-hero-2: #dfe7ff;   /* 5.7:1 on the lightest hero stop, 4.8:1 inside the glass pills */
    --ci-brand: #1d4ed8;
    --ci-brand-ink: #1e40af;

    --ci-bg: #eef2f9;
    --ci-surface: #ffffff;
    --ci-surface-2: #f6f8fc;
    --ci-ink: #0f172a;
    --ci-ink-2: #475569;
    --ci-muted: #5a697f;       /* 5.4:1 on white, 4.9:1 on the page */
    --ci-line: #e3e8f1;
    --ci-soft: #f1f5fb;

    --ci-ok: #047857;          /* 5.5:1 on white */
    --ci-ok-bg: #e7f6ef;
    --ci-ok-ring: #10b981;
    --ci-warn: #92400e;        /* 7.1:1 on white */
    --ci-warn-bg: #fff4e0;
    --ci-warn-ring: #f59e0b;
    --ci-bad: #b91c1c;         /* 6.5:1 on white */
    --ci-bad-bg: #fdecec;
    --ci-bad-ring: #ef4444;
    --ci-info: #1e40af;
    --ci-info-bg: #e8efff;
    --ci-info-ring: #3b82f6;
    --ci-leave: #6d28d9;
    --ci-leave-bg: #f1ebff;
    --ci-travel: #0e7490;
    --ci-travel-bg: #e2f6fa;

    /* the dial: white label 5.5:1 / 5.0:1 / 4.8:1 on the lighter stop */
    --ci-go-in-a: #047857;
    --ci-go-in-b: #064e3b;
    --ci-go-out-a: #b45309;
    --ci-go-out-b: #7c2d12;
    --ci-go-off-a: #64748b;
    --ci-go-off-b: #475569;
    --ci-dial: 200px;
    --ci-go: 164px;

    --ci-radius: 26px;
    --ci-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 10px 24px -6px rgba(15, 23, 42, .08), 0 28px 56px -28px rgba(15, 23, 42, .18);
    --ci-ease: cubic-bezier(.22, 1, .36, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --ci-hero-a: #030a1f;
        --ci-hero-b: #11307e;
        --ci-hero-c: #173a9c;
        --ci-on-hero-2: #c9d6ff;
        --ci-brand: #4f7bf3;
        --ci-brand-ink: #a5b8ff;

        --ci-bg: #070d1b;
        --ci-surface: #0f182c;
        --ci-surface-2: #131e36;
        --ci-ink: #e8edf7;
        --ci-ink-2: #b9c4d8;
        --ci-muted: #97a5bb;
        --ci-line: #223050;
        --ci-soft: #15203a;

        --ci-ok: #6ee7b7;
        --ci-ok-bg: #0c2a21;
        --ci-warn: #fcd34d;
        --ci-warn-bg: #2f240b;
        --ci-bad: #fca5a5;
        --ci-bad-bg: #3a1517;
        --ci-info: #a5b8ff;
        --ci-info-bg: #18234f;
        --ci-leave: #c4b5fd;
        --ci-leave-bg: #24184a;
        --ci-travel: #67e8f9;
        --ci-travel-bg: #0b2a33;

        --ci-shadow: 0 1px 0 rgba(255, 255, 255, .03), 0 18px 40px -12px rgba(0, 0, 0, .55);
    }
}

* {
    box-sizing: border-box;
}

/* Components below set display:flex/grid; without this the hidden attribute would lose. */
[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
}

.ci-body {
    margin: 0;
    min-height: 100vh;
    background: var(--ci-bg);
    color: var(--ci-ink);
    font-family: var(--ci-sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

.ci-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.ci-body :focus-visible {
    outline: 3px solid var(--ci-brand);
    outline-offset: 3px;
}

.ci-hero :focus-visible {
    outline-color: #ffffff;
}

/* ═══ Header ════════════════════════════════════════════════════════════════ */

.ci-hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    color: var(--ci-on-hero);
    /* solid colour under the gradient: what a contrast checker reads */
    background-color: var(--ci-hero-b);
    background-image: linear-gradient(150deg, var(--ci-hero-a) 0%, var(--ci-hero-b) 60%, var(--ci-hero-c) 100%);
    padding: calc(12px + env(safe-area-inset-top)) 0 88px;
    border-radius: 0 0 32px 32px;
}

/* fine grid + two soft lights, nothing to download */
.ci-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
    background-size: 28px 28px;
    -webkit-mask-image: radial-gradient(120% 90% at 50% 0%, #000000 30%, transparent 75%);
    mask-image: radial-gradient(120% 90% at 50% 0%, #000000 30%, transparent 75%);
}

.ci-hero-glow {
    position: absolute;
    z-index: -1;
    border-radius: 50%;
    pointer-events: none;
}

.ci-hero-glow.is-a {
    width: 360px;
    height: 360px;
    top: -170px;
    right: -120px;
    background: radial-gradient(circle, rgba(125, 211, 252, .35) 0%, rgba(125, 211, 252, 0) 68%);
}

.ci-hero-glow.is-b {
    width: 300px;
    height: 300px;
    bottom: -160px;
    left: -110px;
    background: radial-gradient(circle, rgba(129, 140, 248, .32) 0%, rgba(129, 140, 248, 0) 68%);
}

.ci-hero-in {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 18px;
}

.ci-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 48px;
}

.ci-app {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ci-app-logo,
.ci-app-ic {
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 12px;
}

.ci-app-logo {
    padding: 3px;
    object-fit: contain;
    background: #ffffff;
    box-shadow: 0 6px 16px -6px rgba(2, 6, 23, .6);
}

.ci-app-ic {
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    background: rgba(255, 255, 255, .16);
    border: 1px solid rgba(255, 255, 255, .25);
}

.ci-app-txt {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.ci-app-txt b {
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: .01em;
}

.ci-app-txt span {
    overflow: hidden;
    font-size: .76rem;
    color: var(--ci-on-hero-2);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ci-topbtn {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    font-size: 1.15rem;
    color: #ffffff;
    text-decoration: none;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .24);
    border-radius: 14px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: background-color .2s var(--ci-ease);
}

.ci-topbtn:hover {
    background: rgba(2, 6, 23, .22);
}

/* person */
.ci-person {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
}

.ci-avatar {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    overflow: hidden;
    font-family: var(--ci-serif);
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(140deg, rgba(255, 255, 255, .28), rgba(255, 255, 255, .1));
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .85), 0 0 0 7px rgba(255, 255, 255, .12), 0 14px 26px -10px rgba(2, 6, 23, .8);
}

.ci-avatar-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 22%;
    background: #ffffff;
}

.ci-avatar.has-photo .ci-avatar-ini {
    visibility: hidden;
}

.ci-person-txt {
    min-width: 0;
}

.ci-hello,
.ci-dept {
    margin: 0;
    font-size: .84rem;
    line-height: 1.4;
    color: var(--ci-on-hero-2);
}

.ci-name {
    margin: 1px 0 1px;
    font-family: var(--ci-serif);
    font-size: 1.32rem;
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

/* clock */
.ci-clockbox {
    margin-top: 18px;
    text-align: center;
}

.ci-clock {
    font-family: var(--ci-sans);
    font-size: clamp(3.5rem, 2.4rem + 7vw, 4.6rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    letter-spacing: -.02em;
    text-shadow: 0 6px 30px rgba(2, 6, 23, .35);
}

.ci-clock span {
    margin-left: 2px;
    font-size: .38em;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--ci-on-hero-2);
    vertical-align: .9em;
}

.ci-date {
    margin: 8px 0 0;
    font-size: .9rem;
    color: var(--ci-on-hero-2);
}

.ci-sched {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
}

.ci-sched li {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 8px 4px;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 16px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.ci-sched-k {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .76rem;
    line-height: 1.3;
    color: var(--ci-on-hero-2);
}

.ci-sched b {
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

/* signed-out header */
.ci-school {
    margin-top: 22px;
    text-align: center;
}

.ci-school-ic {
    display: inline-grid;
    place-items: center;
    width: 72px;
    height: 72px;
    margin-bottom: 10px;
    font-size: 2rem;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .26);
    border-radius: 24px;
    box-shadow: 0 18px 36px -16px rgba(2, 6, 23, .8);
}

/* signed out: the school's name is already the headline */
.is-guest .ci-app-txt span {
    display: none;
}

.ci-name--school {
    font-size: 1.45rem;
}

.ci-school .ci-dept {
    text-wrap: balance;
    max-width: 22rem;
    margin: 6px auto 0;
}

/* ═══ Page column ═══════════════════════════════════════════════════════════ */

.ci-shell {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 480px;
    margin: -64px auto 0;
    padding: 0 14px calc(28px + env(safe-area-inset-bottom));
}

.ci-card {
    padding: 18px;
    background: var(--ci-surface);
    border: 1px solid var(--ci-line);
    border-radius: var(--ci-radius);
    box-shadow: var(--ci-shadow);
}

.ci-title {
    margin: 0 0 8px;
    font-family: var(--ci-serif);
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.35;
}

.ci-title--sm {
    margin: 0;
    font-size: 1.04rem;
}

.ci-lead {
    margin: -4px 0 14px;
    color: var(--ci-ink-2);
}

.ci-fine {
    margin: 10px 0 0;
    font-size: .84rem;
    line-height: 1.55;
    color: var(--ci-muted);
}

.ci-fine i {
    margin-right: 4px;
}

/* ═══ Today: head, dial, location, work line ════════════════════════════════ */

.ci-main-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.ci-main-title {
    margin: 0;
    font-family: var(--ci-serif);
    font-size: 1.08rem;
    font-weight: 600;
}

.ci-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 12px;
    font-size: .86rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--ci-ink-2);
    white-space: nowrap;
    background: var(--ci-soft);
    border-radius: 999px;
}

.ci-chip::before {
    content: "";
    width: 8px;
    height: 8px;
    background: currentColor;
    border-radius: 50%;
}

.ci-chip[data-status="present"] {
    color: var(--ci-ok);
    background: var(--ci-ok-bg);
}

.ci-chip[data-status="late"],
.ci-chip[data-status="early_leave"] {
    color: var(--ci-warn);
    background: var(--ci-warn-bg);
}

.ci-chip[data-status="absent"] {
    color: var(--ci-bad);
    background: var(--ci-bad-bg);
}

.ci-chip[data-status="leave"] {
    color: var(--ci-leave);
    background: var(--ci-leave-bg);
}

.ci-chip[data-status="travel"],
.ci-chip[data-status="half_day"] {
    color: var(--ci-info);
    background: var(--ci-info-bg);
}

.ci-note {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 12px;
    padding: 10px 14px;
    font-size: .9rem;
    line-height: 1.55;
    color: var(--ci-info);
    background: var(--ci-info-bg);
    border-radius: 16px;
}

.ci-note a {
    font-weight: 700;
    color: inherit;
}

/* ── the dial ── */
.ci-action {
    position: relative;
    display: grid;
    place-items: center;
    width: var(--ci-dial);
    height: var(--ci-dial);
    margin: 18px auto 0;
}

.ci-ring {
    position: absolute;
    inset: 0;
    border: 3px dashed var(--ci-info-ring);
    border-radius: 50%;
    opacity: .75;
    transition: border-color .3s ease, box-shadow .3s ease, opacity .3s ease;
}

.ci-ring-in {
    position: absolute;
    inset: 9px;
    background: radial-gradient(circle, transparent 58%, rgba(59, 130, 246, .14) 100%);
    border-radius: 50%;
}

body[data-loc="acquiring"] .ci-ring,
body[data-loc="idle"] .ci-ring {
    animation: ci-spin 14s linear infinite;
}

body[data-loc="inside"] .ci-ring {
    border-style: solid;
    border-color: var(--ci-ok-ring);
    opacity: 1;
    box-shadow: 0 0 0 6px rgba(16, 185, 129, .16), 0 0 34px rgba(16, 185, 129, .35);
    animation: ci-breathe 2.8s ease-in-out infinite;
}

body[data-loc="inside"] .ci-ring-in {
    background: radial-gradient(circle, transparent 58%, rgba(16, 185, 129, .18) 100%);
}

body[data-loc="weak"] .ci-ring {
    border-color: var(--ci-warn-ring);
    opacity: 1;
    animation: ci-spin 22s linear infinite;
}

body[data-loc="outside"] .ci-ring,
body[data-loc="denied"] .ci-ring,
body[data-loc="unavailable"] .ci-ring {
    border-style: solid;
    border-color: var(--ci-bad-ring);
    opacity: .9;
}

body[data-busy="1"] .ci-ring {
    border-style: dashed;
    border-color: var(--ci-info-ring);
    opacity: 1;
    animation: ci-spin 1.4s linear infinite;
}

body[data-act="off"] .ci-ring {
    border-style: solid;
    border-color: var(--ci-line);
    box-shadow: none;
    opacity: 1;
    animation: none;
}

body[data-act="off"][data-next="done"] .ci-ring {
    border-color: var(--ci-ok-ring);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, .14);
}

.ci-go {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: var(--ci-go);
    height: var(--ci-go);
    padding: 18px;
    font: inherit;
    color: #ffffff;
    text-align: center;
    cursor: pointer;
    background-color: var(--ci-go-in-a);
    background-image: radial-gradient(120% 90% at 30% 15%, rgba(255, 255, 255, .22) 0%, transparent 45%), linear-gradient(160deg, var(--ci-go-in-a) 0%, var(--ci-go-in-b) 100%);
    border: 0;
    border-radius: 50%;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, .28), inset 0 -10px 22px rgba(0, 0, 0, .22), 0 22px 40px -16px rgba(4, 120, 87, .9);
    transition: transform .18s var(--ci-ease), box-shadow .2s ease, filter .2s ease;
    touch-action: manipulation;
}

.ci-go:hover:not(:disabled) {
    filter: brightness(1.06);
}

.ci-go:active:not(:disabled) {
    transform: scale(.955);
}

.ci-go[data-next="checkout"] {
    background-color: var(--ci-go-out-a);
    background-image: radial-gradient(120% 90% at 30% 15%, rgba(255, 255, 255, .22) 0%, transparent 45%), linear-gradient(160deg, var(--ci-go-out-a) 0%, var(--ci-go-out-b) 100%);
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, .28), inset 0 -10px 22px rgba(0, 0, 0, .22), 0 22px 40px -16px rgba(180, 83, 9, .9);
}

.ci-go:disabled {
    cursor: default;
    background-color: var(--ci-go-off-a);
    background-image: linear-gradient(160deg, var(--ci-go-off-a) 0%, var(--ci-go-off-b) 100%);
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, .2), 0 16px 30px -18px rgba(15, 23, 42, .7);
}

.ci-go[aria-busy="true"] {
    background-color: var(--ci-go-in-a);
    background-image: linear-gradient(160deg, var(--ci-go-in-a) 0%, var(--ci-go-in-b) 100%);
}

.ci-go[data-next="checkout"][aria-busy="true"] {
    background-color: var(--ci-go-out-a);
    background-image: linear-gradient(160deg, var(--ci-go-out-a) 0%, var(--ci-go-out-b) 100%);
}

/* done for today: a calm green medal instead of a grey button */
.ci-go[data-next="done"]:disabled {
    color: var(--ci-ok);
    background-color: var(--ci-ok-bg);
    background-image: none;
    box-shadow: inset 0 0 0 2px rgba(16, 185, 129, .45);
}

.ci-go-ic {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    font-size: 1.75rem;
    background: rgba(255, 255, 255, .17);
    border-radius: 50%;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}

.ci-go[data-next="done"]:disabled .ci-go-ic {
    color: #ffffff;
    background: var(--ci-ok);
}

.ci-go[aria-busy="true"] .ci-go-ic i {
    animation: ci-spin 1s linear infinite;
}

.ci-go-label {
    text-wrap: balance;
    font-size: 1.12rem;
    font-weight: 700;
    line-height: 1.3;
}

.ci-go[data-next="done"]:disabled .ci-go-label {
    font-size: 1rem;
}

.ci-go-sub {
    text-wrap: balance;
    max-width: 22rem;
    min-height: 1.5em;
    margin: 12px auto 0;
    font-size: .92rem;
    font-weight: 600;
    line-height: 1.5;
    color: var(--ci-ink-2);
    text-align: center;
}

body[data-loc="inside"] .ci-go-sub {
    color: var(--ci-ok);
}

body[data-loc="outside"] .ci-go-sub,
body[data-loc="denied"] .ci-go-sub,
body[data-loc="unavailable"] .ci-go-sub {
    color: var(--ci-bad);
}

body[data-loc="weak"] .ci-go-sub {
    color: var(--ci-warn);
}

/* ── result ── */
.ci-result {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: 20px;
    animation: ci-pop .45s var(--ci-ease) both;
}

.ci-result[data-kind="ok"] {
    color: var(--ci-ok);
    background: var(--ci-ok-bg);
    border: 1px solid rgba(16, 185, 129, .35);
}

.ci-result[data-kind="bad"] {
    color: var(--ci-bad);
    background: var(--ci-bad-bg);
    border: 1px solid rgba(239, 68, 68, .35);
}

.ci-result-ic {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    font-size: 1.35rem;
    color: #ffffff;
    background: var(--ci-ok);
    border-radius: 50%;
}

.ci-result[data-kind="bad"] .ci-result-ic {
    background: var(--ci-bad);
}

@media (prefers-color-scheme: dark) {
    .ci-result-ic {
        color: #06281d;
    }

    .ci-result[data-kind="bad"] .ci-result-ic {
        color: #3a1517;
    }
}

.ci-result[data-kind="ok"] .ci-result-ic {
    animation: ci-check .5s var(--ci-ease) .1s both;
}

.ci-result-body {
    min-width: 0;
}

.ci-result strong {
    display: block;
    font-size: 1rem;
    line-height: 1.4;
}

.ci-result-time {
    display: block;
    margin-top: 2px;
    font-size: 1.6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
    color: var(--ci-ink);
}

.ci-result-msg {
    display: block;
    margin-top: 2px;
    font-size: .9rem;
    line-height: 1.5;
    color: var(--ci-ink);
}

.ci-result-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.ci-result-tag {
    padding: 2px 10px;
    font-size: .8rem;
    font-weight: 700;
    line-height: 1.5;
    color: var(--ci-ink);
    background: var(--ci-surface);
    border-radius: 999px;
}

/* ── location ── */
.ci-loc {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: center;
    gap: 14px;
    margin-top: 16px;
    padding: 12px 14px 12px 12px;
    background: var(--ci-surface-2);
    border: 1px solid var(--ci-line);
    border-radius: 20px;
    transition: background-color .3s ease, border-color .3s ease;
}

.ci-loc[data-state="inside"] {
    background: var(--ci-ok-bg);
    border-color: rgba(16, 185, 129, .35);
}

.ci-loc[data-state="outside"],
.ci-loc[data-state="denied"],
.ci-loc[data-state="unavailable"] {
    background: var(--ci-bad-bg);
    border-color: rgba(239, 68, 68, .3);
}

.ci-loc[data-state="weak"] {
    background: var(--ci-warn-bg);
    border-color: rgba(245, 158, 11, .35);
}

/* nothing to tap today: the GPS is off and the panel steps aside (it comes back with "update departure") */
body[data-act="off"] .ci-loc[data-state="idle"] {
    display: none;
}

.ci-radar {
    display: block;
    width: 72px;
    height: 72px;
}

.ci-radar svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.ci-radar-bg {
    fill: var(--ci-surface);
    stroke: var(--ci-line);
    stroke-width: 1.5;
}

.ci-radar-grid {
    fill: none;
    stroke: var(--ci-line);
    stroke-width: 1;
    stroke-dasharray: 2 3;
}

.ci-radar-fence {
    fill: rgba(16, 185, 129, .14);
    stroke: var(--ci-ok-ring);
    stroke-width: 1.5;
    stroke-dasharray: 4 3;
}

.ci-radar-school {
    fill: var(--ci-ink-2);
}

.ci-radar-sweep {
    fill: rgba(59, 130, 246, .22);
    transform-origin: 60px 60px;
    opacity: 0;
}

.ci-loc[data-state="acquiring"] .ci-radar-sweep,
.ci-loc[data-state="idle"] .ci-radar-sweep {
    opacity: 1;
    animation: ci-spin 2.4s linear infinite;
}

.ci-radar-acc {
    fill: rgba(59, 130, 246, .2);
    transition: cx .6s var(--ci-ease), cy .6s var(--ci-ease), r .6s var(--ci-ease);
}

.ci-radar-dot {
    fill: #2563eb;
    stroke: #ffffff;
    stroke-width: 2.5;
    transition: cx .6s var(--ci-ease), cy .6s var(--ci-ease);
}

.ci-loc:not(.has-fix) .ci-radar-dot,
.ci-loc:not(.has-fix) .ci-radar-acc {
    opacity: 0;
}

.ci-loc[data-state="outside"] .ci-radar-dot {
    fill: var(--ci-bad-ring);
}

.ci-loc[data-state="inside"] .ci-radar-dot {
    fill: #059669;
}

.ci-loc-txt {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ci-loc-head {
    display: flex;
    align-items: baseline;
    gap: 7px;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--ci-ink);
}

.ci-loc[data-state="inside"] .ci-loc-head {
    color: var(--ci-ok);
}

.ci-loc[data-state="outside"] .ci-loc-head,
.ci-loc[data-state="denied"] .ci-loc-head,
.ci-loc[data-state="unavailable"] .ci-loc-head {
    color: var(--ci-bad);
}

.ci-loc[data-state="weak"] .ci-loc-head {
    color: var(--ci-warn);
}

.ci-loc-sub {
    display: flex;
    flex-wrap: wrap;
    gap: 0 12px;
    margin-top: 2px;
    font-size: .84rem;
    line-height: 1.5;
    color: var(--ci-ink-2);
}

/* ── today's work line ── */
.ci-day {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--ci-line);
}

.ci-times {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
}

.ci-t {
    min-width: 0;
    margin: 0;
    text-align: center;
}

.ci-t--in {
    text-align: left;
}

.ci-t--out {
    text-align: right;
}

.ci-t dt {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .8rem;
    line-height: 1.4;
    color: var(--ci-muted);
}

.ci-t dd {
    margin: 2px 0 0;
    font-size: 1.4rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
    color: var(--ci-muted);
}

.ci-t.is-set dd {
    color: var(--ci-ink);
}

.ci-t--dur dd {
    font-size: 1.02rem;
    line-height: 1.7;
    color: var(--ci-ink-2);
}

.ci-track {
    display: block;
    margin-top: 12px;
}

.ci-track-bar {
    position: relative;
    display: block;
    height: 10px;
    background: var(--ci-soft);
    border: 1px solid var(--ci-line);
    border-radius: 999px;
}

.ci-track-fill {
    position: absolute;
    top: -1px;
    bottom: -1px;
    left: 0;
    width: 0;
    background: linear-gradient(90deg, #10b981, #2563eb);
    border-radius: 999px;
    transition: left .6s var(--ci-ease), width .6s var(--ci-ease);
}

.ci-track-now {
    position: absolute;
    top: 50%;
    left: 0;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    background: var(--ci-surface);
    border: 3px solid #2563eb;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .18);
    transition: left .6s var(--ci-ease);
}

.ci-track-scale {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: .76rem;
    font-variant-numeric: tabular-nums;
    color: var(--ci-muted);
}

/* ═══ This week ═════════════════════════════════════════════════════════════ */

.ci-week-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.ci-week-more {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    min-height: 44px;
    padding: 0 4px;
    font-size: .88rem;
    font-weight: 700;
    color: var(--ci-brand-ink);
    text-decoration: none;
}

.ci-week-days {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
}

.ci-wd {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 0;
    padding: 8px 2px 9px;
    background: var(--ci-surface-2);
    border: 1px solid var(--ci-line);
    border-radius: 18px;
}

.ci-wd.is-today {
    background: var(--ci-surface);
    border: 2px solid var(--ci-brand);
    box-shadow: 0 8px 18px -12px var(--ci-brand);
}

.ci-wd-d {
    font-size: .76rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--ci-muted);
}

.ci-wd-n {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--ci-ink);
}

.ci-wd-ic {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    margin: 3px 0 1px;
    font-size: .95rem;
    color: var(--ci-muted);
    background: var(--ci-soft);
    border-radius: 50%;
}

.ci-wd-t {
    max-width: 100%;
    overflow: hidden;
    font-size: .74rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
    color: var(--ci-ink-2);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ci-wd.is-present .ci-wd-ic {
    color: #ffffff;
    background: var(--ci-ok);
}

.ci-wd.is-late .ci-wd-ic {
    color: var(--ci-warn);
    background: var(--ci-warn-bg);
}

.ci-wd.is-late .ci-wd-t {
    color: var(--ci-warn);
}

.ci-wd.is-leave .ci-wd-ic {
    color: var(--ci-leave);
    background: var(--ci-leave-bg);
}

.ci-wd.is-travel .ci-wd-ic {
    color: var(--ci-travel);
    background: var(--ci-travel-bg);
}

.ci-wd.is-absent .ci-wd-ic {
    color: var(--ci-bad);
    background: var(--ci-bad-bg);
}

.ci-wd.is-pending .ci-wd-ic {
    color: var(--ci-brand-ink);
    background: transparent;
    border: 2px dashed var(--ci-brand);
}

.ci-wd.is-future .ci-wd-ic {
    background: transparent;
    border: 2px dashed var(--ci-line);
}

@media (prefers-color-scheme: dark) {
    .ci-wd.is-present .ci-wd-ic {
        color: #06281d;
    }
}

.ci-month {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    margin: 12px 0 0;
    padding-top: 12px;
    font-size: .86rem;
    line-height: 1.5;
    color: var(--ci-ink-2);
    border-top: 1px solid var(--ci-line);
}

.ci-month-k {
    font-weight: 700;
    color: var(--ci-ink);
}

.ci-month-v {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.ci-month-v::before {
    content: "";
    width: 8px;
    height: 8px;
    background: var(--ci-muted);
    border-radius: 50%;
}

.ci-month-v.is-present::before {
    background: var(--ci-ok-ring);
}

.ci-month-v.is-late::before {
    background: var(--ci-warn-ring);
}

.ci-month-v.is-leave::before {
    background: #8b5cf6;
}

.ci-month-v.is-travel::before {
    background: #06b6d4;
}

.ci-month-v.is-absent::before {
    background: var(--ci-bad-ring);
}

.ci-month-v b {
    color: var(--ci-ink);
    font-variant-numeric: tabular-nums;
}

/* ═══ Device ════════════════════════════════════════════════════════════════ */

.ci-dev-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.ci-badge {
    flex: none;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    font-size: 1.3rem;
    color: var(--ci-brand-ink);
    background: var(--ci-info-bg);
    border-radius: 16px;
}

.ci-badge--warn {
    margin: 0 auto 10px;
    color: var(--ci-warn);
    background: var(--ci-warn-bg);
}

.ci-dev-text {
    margin: 4px 0 0;
    font-size: .9rem;
    line-height: 1.55;
    color: var(--ci-ink-2);
}

.ci-dev-remember .ci-btn {
    margin-top: 14px;
}

.ci-dev-known {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 12px;
}

.ci-device-line {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: .92rem;
    line-height: 1.5;
    color: var(--ci-ink-2);
}

.ci-device-ic {
    flex: none;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    font-size: 1.05rem;
    color: var(--ci-ok);
    background: var(--ci-ok-bg);
    border-radius: 12px;
}

.ci-device-line strong {
    color: var(--ci-ink);
}

.ci-dev-session .ci-fine {
    margin: 0;
}

.ci-tips {
    margin-top: 12px;
    border-top: 1px solid var(--ci-line);
}

.ci-tips summary {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding-top: 6px;
    font-size: .92rem;
    font-weight: 600;
    color: var(--ci-ink-2);
    cursor: pointer;
    list-style: none;
}

.ci-tips summary::-webkit-details-marker {
    display: none;
}

.ci-tips summary::after {
    content: "\F282";
    margin-left: auto;
    font-family: "bootstrap-icons";
    font-size: .85rem;
    transition: transform .2s ease;
}

.ci-tips[open] summary::after {
    transform: rotate(180deg);
}

.ci-tips ul {
    display: grid;
    gap: 8px;
    margin: 4px 0 4px;
    padding: 0 0 0 18px;
    font-size: .88rem;
    line-height: 1.6;
    color: var(--ci-ink-2);
}

/* ═══ Buttons, links, alerts ════════════════════════════════════════════════ */

.ci-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 52px;
    padding: 10px 18px;
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border: 0;
    border-radius: 16px;
    transition: transform .15s var(--ci-ease), filter .2s ease, background-color .2s ease;
}

.ci-btn:active {
    transform: scale(.98);
}

.ci-btn--primary {
    color: #ffffff;
    background-color: var(--ci-brand);
    background-image: linear-gradient(160deg, #1d4ed8, #1e3a8a);
    box-shadow: 0 14px 28px -14px rgba(29, 78, 216, .9);
}

.ci-btn--primary:hover {
    filter: brightness(1.08);
}

.ci-btn--soft {
    color: var(--ci-brand-ink);
    background: var(--ci-info-bg);
    border: 1px solid rgba(59, 130, 246, .3);
}

.ci-btn--soft:hover {
    background: rgba(59, 130, 246, .18);
}

.ci-btn:disabled {
    cursor: wait;
    opacity: .7;
}

.ci-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    min-height: 44px;
    margin-top: 6px;
    padding: 6px 10px;
    font: inherit;
    font-size: .92rem;
    font-weight: 700;
    color: var(--ci-brand-ink);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    background: none;
    border: 0;
    border-radius: 12px;
}

.ci-link--quiet {
    width: auto;
    margin: 0;
    padding: 6px 4px;
    font-weight: 600;
    color: var(--ci-muted);
}

.ci-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 12px;
    padding: 12px 14px;
    font-size: .92rem;
    line-height: 1.55;
    border-radius: 16px;
}

.ci-alert i {
    margin-top: 2px;
    font-size: 1.1rem;
}

.ci-alert--warn {
    color: var(--ci-warn);
    background: var(--ci-warn-bg);
}

.ci-alert--bad {
    color: var(--ci-bad);
    background: var(--ci-bad-bg);
}

.ci-device .ci-alert {
    margin: 12px 0 0;
}

/* ═══ Signed out: first steps ═══════════════════════════════════════════════ */

.ci-welcome {
    text-align: left;
}

.ci-welcome .ci-title {
    font-size: 1.3rem;
}

.ci-steps {
    position: relative;
    display: grid;
    gap: 14px;
    margin: 0 0 18px;
    padding: 0;
    list-style: none;
}

.ci-steps::before {
    content: "";
    position: absolute;
    top: 22px;
    bottom: 22px;
    left: 21px;
    width: 2px;
    background: linear-gradient(var(--ci-info-ring), var(--ci-ok-ring));
    opacity: .35;
}

.ci-steps li {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
}

.ci-step-n {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    font-size: 1.15rem;
    color: var(--ci-brand-ink);
    background: var(--ci-info-bg);
    border: 2px solid var(--ci-surface);
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--ci-line);
}

.ci-steps li:last-child .ci-step-n {
    color: var(--ci-ok);
    background: var(--ci-ok-bg);
}

.ci-step-t {
    text-wrap: balance;
    font-size: .95rem;
    line-height: 1.55;
    color: var(--ci-ink-2);
}

.ci-step-t strong {
    color: var(--ci-ink);
}

/* ═══ Footer ════════════════════════════════════════════════════════════════ */

.ci-foot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 6px 0 4px;
    text-align: center;
}

.ci-foot-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.ci-foot-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 16px;
    font-size: .9rem;
    font-weight: 600;
    color: var(--ci-ink-2);
    text-decoration: none;
    background: var(--ci-surface);
    border: 1px solid var(--ci-line);
    border-radius: 999px;
    box-shadow: 0 6px 16px -12px rgba(15, 23, 42, .5);
}

.ci-foot-link:hover {
    color: var(--ci-brand-ink);
    border-color: var(--ci-brand);
}

.ci-foot-school {
    text-wrap: balance;
    max-width: 22rem;
    margin: 0;
    font-size: .8rem;
    line-height: 1.5;
    color: var(--ci-muted);
}

.ci-foot-name {
    display: block;
    margin-top: 2px;
    font-weight: 600;
}

/* ═══ Motion ════════════════════════════════════════════════════════════════ */

@keyframes ci-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes ci-breathe {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.025);
    }
}

@keyframes ci-pop {
    from {
        transform: translateY(8px) scale(.98);
    }

    to {
        transform: none;
    }
}

@keyframes ci-check {
    from {
        transform: scale(.4) rotate(-20deg);
    }

    to {
        transform: none;
    }
}

@keyframes ci-rise {
    from {
        transform: translateY(14px);
    }

    to {
        transform: none;
    }
}

.ci-shell > .ci-card {
    animation: ci-rise .6s var(--ci-ease) both;
}

.ci-shell > .ci-card:nth-child(2) {
    animation-delay: .06s;
}

.ci-shell > .ci-card:nth-child(3) {
    animation-delay: .12s;
}

/* ═══ Small phones ══════════════════════════════════════════════════════════ */

@media (max-width: 359px) {
    :root {
        --ci-dial: 172px;
        --ci-go: 140px;
    }

    .ci-hero-in {
        padding: 0 14px;
    }

    .ci-shell {
        padding: 0 10px calc(24px + env(safe-area-inset-bottom));
    }

    .ci-card {
        padding: 14px;
    }

    .ci-app-txt span {
        display: none;
    }

    .ci-sched-k i {
        display: none;
    }

    .ci-go-ic {
        width: 46px;
        height: 46px;
        font-size: 1.45rem;
    }

    .ci-go-label {
        font-size: 1rem;
    }

    .ci-loc {
        grid-template-columns: 56px minmax(0, 1fr);
        gap: 10px;
    }

    .ci-radar {
        width: 56px;
        height: 56px;
    }

    .ci-t dd {
        font-size: 1.2rem;
    }

    .ci-t--dur dd {
        font-size: .9rem;
    }

    .ci-week-days {
        gap: 5px;
    }

    .ci-wd-ic {
        width: 26px;
        height: 26px;
    }
}

/* ═══ Wide screens: blue panel on the left, cards on the right ══════════════ */

@media (min-width: 980px) {
    .ci-body {
        display: grid;
        grid-template-columns: minmax(400px, 42%) minmax(0, 1fr);
        align-items: start;
    }

    .ci-hero {
        position: sticky;
        top: 0;
        display: flex;
        align-items: center;
        min-height: 100vh;
        padding: 40px 0;
        border-radius: 0 40px 40px 0;
    }

    .ci-hero-in {
        width: 100%;
        max-width: 460px;
        padding: 0 36px;
    }

    .ci-topbar {
        position: absolute;
        top: 28px;
        left: 36px;
        right: 36px;
    }

    .ci-person {
        margin-top: 0;
    }

    .ci-avatar {
        width: 72px;
        height: 72px;
        font-size: 1.4rem;
    }

    .ci-name {
        font-size: 1.6rem;
    }

    .ci-clockbox {
        margin-top: 34px;
        text-align: left;
    }

    .ci-clock {
        font-size: 5.6rem;
    }

    .ci-sched {
        margin-top: 22px;
    }

    .ci-school {
        text-align: left;
    }

    .ci-school .ci-dept {
        margin-left: 0;
    }

    .ci-shell {
        width: 100%;
        max-width: 560px;
        margin: 0 auto;
        padding: 40px 32px 48px;
    }
}

/* ═══ Accessibility preferences ═════════════════════════════════════════════ */

@media (prefers-contrast: more) {
    :root {
        --ci-muted: #334155;
        --ci-ink-2: #1e293b;
        --ci-line: #94a3b8;
    }

    .ci-card,
    .ci-loc,
    .ci-wd {
        border-width: 2px;
    }

    .ci-hero::after,
    .ci-hero-glow {
        display: none;
    }
}

@media (forced-colors: active) {
    .ci-ring {
        border-color: CanvasText;
    }

    .ci-go {
        border: 3px solid ButtonText;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* PWA version and safe automatic updates. */
.ci-update-release { margin: 4px 0 8px; font-size: .85rem; color: var(--ci-muted); }
.ci-update-status { margin: 0 0 10px; font-size: .94rem; color: var(--ci-ink-2); line-height: 1.6; }
.ci-update-auto { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: .94rem; color: var(--ci-ink); }
.ci-update-auto input { width: 20px; height: 20px; accent-color: var(--ci-brand); flex: none; }
.ci-update-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ci-update-actions .ci-btn { width: auto; min-height: 44px; padding: 9px 14px; font-size: .94rem; }
.ci-updates [hidden] { display: none !important; }

.ci-update-banner {
    position: fixed; z-index: 100; bottom: calc(12px + env(safe-area-inset-bottom)); left: 50%;
    transform: translateX(-50%); width: min(calc(100% - 24px), 480px); display: flex;
    align-items: center; gap: 12px; padding: 12px 14px; color: var(--ci-ink);
    background: var(--ci-surface); border: 1px solid var(--ci-line); border-radius: 14px;
    box-shadow: 0 8px 28px rgba(0,0,0,.2); font-size: .94rem;
}
.ci-update-banner .ci-btn { flex: none; width: auto; min-height: 44px; padding: 8px 12px; }

/* A labelled bottom menu keeps the three everyday destinations within thumb reach. */
.ci-app-nav { display: none; }
.ci-install-intro { margin: 6px 0 12px; color: var(--ci-ink-2); line-height: 1.6; }
.ci-install-guide { margin-bottom: 14px; }
.ci-install-guide summary { min-height: 48px; display: flex; cursor: pointer; padding-block: 10px; font-size: 1rem; font-weight: 500; }
.ci-install-guide ol { padding-left: 24px; line-height: 1.7; font-size: 1rem; }
.ci-install-guide li + li { margin-top: 10px; }
.ci-body :is(#ci-clock-panel, #ci-updates) { scroll-margin-top: 16px; }
@media screen and (max-width: 979px) {
    .ci-body .ci-shell { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
    .ci-body .ci-app-nav {
        display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
        position: fixed; bottom: 0; left: 0; right: 0; z-index: 90;
        padding: 6px max(10px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom));
        background: var(--ci-surface); border-top: 1px solid var(--ci-line);
        box-shadow: 0 -4px 20px rgba(15, 23, 42, .08); gap: 6px;
    }
    .ci-app-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px; padding: 4px; border-radius: 12px; text-decoration: none; color: var(--ci-ink-2); font-size: .94rem; font-weight: 400; line-height: 1.4; }
    .ci-app-nav i { font-size: 1.4rem; }
    .ci-app-nav a[aria-current] { color: var(--ci-brand-ink); background: var(--ci-info-bg); font-weight: 500; }
    .ci-body .ci-update-banner { bottom: calc(86px + env(safe-area-inset-bottom)); }
    .ci-body :is(.ci-btn, .ci-link, .ci-foot-link, .ci-tips summary) { min-height: 48px; }
    .ci-body :is(.ci-fine, .ci-update-status, .ci-update-auto, .ci-install-intro) { font-size: 1rem; line-height: 1.65; }
}
@media print { .ci-app-nav, .ci-update-banner { display: none !important; } }
