/* ==========================================================================
   MedNote — mobile-first styles. Phones get a bottom tab bar; screens
   900px and wider get a left sidebar.
   ========================================================================== */

:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-2: #f8fafb;
    --border: #e3e8ec;
    --text: #17212b;
    --muted: #64707d;
    --primary: #0f766e;
    --primary-strong: #0b5f58;
    --primary-soft: #e2f3f1;
    --danger: #c0352b;
    --danger-soft: #fdecea;
    --warn: #a15c07;
    --warn-soft: #fff4e0;
    --ok: #1d7a3e;
    --ok-soft: #e5f5ea;

    --k-appt: #2563eb;  --k-appt-soft: #e7eefe;
    --k-event: #c2410c; --k-event-soft: #fdeee6;
    --k-rx: #7c3aed;    --k-rx-soft: #f0e9fe;
    --k-sym: #b45309;   --k-sym-soft: #fdf2e1;
    --k-dx: #be185d;    --k-dx-soft: #fce8f1;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --tabbar-h: 64px;
    --topbar-h: 56px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1418;
        --surface: #182026;
        --surface-2: #1d262d;
        --border: #2a353e;
        --text: #e7edf2;
        --muted: #9aa7b3;
        --primary: #2bb5a8;
        --primary-strong: #4fd1c5;
        --primary-soft: #133a37;
        --danger: #f07167;
        --danger-soft: #3a1f1d;
        --warn: #f0b45a;
        --warn-soft: #3a2c15;
        --ok: #5fd08a;
        --ok-soft: #173323;
        --k-appt: #7aa2ff;  --k-appt-soft: #1c2742;
        --k-event: #ff9a66; --k-event-soft: #3a2418;
        --k-rx: #b89bff;    --k-rx-soft: #2a2142;
        --k-sym: #f5b25c;   --k-sym-soft: #3a2b16;
        --k-dx: #f58ab8;    --k-dx-soft: #3d1c2b;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
h1:focus { outline: none; }
.icon { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.optional { color: var(--muted); font-weight: 400; font-size: .85em; }
.nowrap { white-space: nowrap; }

/* ---------- App shell ---------- */

.app { min-height: 100dvh; }

.sidebar { display: none; }

.main { min-width: 0; }

.topbar {
    position: sticky; top: 0; z-index: 20;
    height: calc(var(--topbar-h) + var(--safe-t));
    padding: var(--safe-t) 16px 0;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(160%) blur(10px);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }

.patient-picker {
    display: inline-flex; align-items: center; gap: 6px;
    max-width: 60vw; min-height: 36px;
    padding: 4px 6px 4px 12px; border-radius: 999px;
    background: var(--primary-soft); color: var(--primary-strong); font-weight: 600; font-size: .9rem;
}
.patient-picker span { padding-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.patient-picker select {
    border: 0; background: transparent; color: inherit; font: inherit; padding: 4px 4px; max-width: 45vw;
    appearance: auto; min-height: 0;
}

.content {
    padding: 16px 16px calc(var(--tabbar-h) + var(--safe-b) + 88px);
    max-width: 960px; margin: 0 auto;
}

.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tabbar-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); font-size: .72rem; font-weight: 600;
}
.tabbar a:hover { text-decoration: none; }
.tabbar a.active { color: var(--primary); }
.tabbar a.active .icon { stroke-width: 2.4; }

@media (min-width: 900px) {
    .app { display: grid; grid-template-columns: 250px 1fr; }
    .tabbar, .brand-mobile { display: none; }
    .topbar { justify-content: flex-end; }
    .sidebar {
        display: flex; flex-direction: column;
        position: sticky; top: 0; height: 100dvh; overflow-y: auto;
        padding: 18px 14px; background: var(--surface); border-right: 1px solid var(--border);
    }
    .sidebar .brand { padding: 4px 10px 18px; }
    .side-nav { display: flex; flex-direction: column; gap: 2px; }
    .side-nav a {
        display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--radius-sm);
        color: var(--text); font-weight: 500;
    }
    .side-nav a:hover { background: var(--surface-2); text-decoration: none; }
    .side-nav a.active { background: var(--primary-soft); color: var(--primary-strong); font-weight: 650; }
    .side-heading { margin: 18px 12px 6px; font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
    .side-footer { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
    .content { padding: 28px 32px 120px; }
    .patient-picker { max-width: 360px; }
}

/* ---------- Page header ---------- */

.page-header { margin-bottom: 16px; }
.page-header .back {
    display: inline-flex; align-items: center; gap: 2px; margin: -4px 0 8px -6px; padding: 6px 8px 6px 2px;
    font-weight: 600; font-size: .95rem; min-height: 40px;
}
.page-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-title { min-width: 0; flex: 1 1 200px; }
.page-title h1 { margin: 0; overflow-wrap: anywhere; }
.subtitle { color: var(--muted); margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards & lists ---------- */

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.card > h2:first-child, .card > h3:first-child { margin-bottom: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-head h2, .card-head h3 { margin: 0; }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 22px 0 10px; }
.section-title h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.section-title a { font-weight: 600; font-size: .9rem; }

.list { display: flex; flex-direction: column; gap: 10px; }

.item {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 14px; color: var(--text); box-shadow: var(--shadow); min-height: 64px;
}
a.item:hover { text-decoration: none; border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
a.item:active { transform: scale(.995); }
.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 650; overflow-wrap: anywhere; }
.item-sub { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.item-meta { color: var(--muted); font-size: .85rem; text-align: right; white-space: nowrap; }
.item .chev { color: var(--muted); }
.item.muted-item { opacity: .65; }

.badge-icon {
    width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0;
    background: var(--primary-soft); color: var(--primary);
}
.k-appt .badge-icon, .badge-icon.k-appt { background: var(--k-appt-soft); color: var(--k-appt); }
.k-event .badge-icon, .badge-icon.k-event { background: var(--k-event-soft); color: var(--k-event); }
.k-rx .badge-icon, .badge-icon.k-rx { background: var(--k-rx-soft); color: var(--k-rx); }
.k-sym .badge-icon, .badge-icon.k-sym { background: var(--k-sym-soft); color: var(--k-sym); }
.k-dx .badge-icon, .badge-icon.k-dx { background: var(--k-dx-soft); color: var(--k-dx); }

.date-block {
    width: 52px; flex-shrink: 0; text-align: center; border-radius: 12px; padding: 6px 0;
    background: var(--k-appt-soft); color: var(--k-appt); line-height: 1.1;
}
.date-block .m { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.date-block .d { font-size: 1.35rem; font-weight: 750; }
.date-block.past { background: var(--surface-2); color: var(--muted); }

.pill {
    display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
    font-size: .78rem; font-weight: 650; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
    white-space: nowrap;
}
.pill-primary { background: var(--primary-soft); color: var(--primary-strong); border-color: transparent; }
.pill-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

/* Detail key/value rows */
.kv { display: grid; grid-template-columns: minmax(110px, 34%) 1fr; gap: 10px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: .9rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 420px) {
    .kv { grid-template-columns: 1fr; gap: 2px; }
    .kv dd { margin-bottom: 10px; }
}

/* Contact action buttons (call / map / portal) */
.actions-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin: 4px 0 14px; }
.action-tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    min-height: 64px; padding: 10px 6px; border-radius: var(--radius-sm);
    background: var(--primary-soft); color: var(--primary-strong); font-weight: 650; font-size: .85rem; text-align: center;
}
.action-tile:hover { text-decoration: none; filter: brightness(.97); }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 8px; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; color: var(--text); box-shadow: var(--shadow); }
.stat:hover { text-decoration: none; }
.stat .n { font-size: 1.6rem; font-weight: 750; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: .85rem; }

.quick-add { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .quick-add { grid-template-columns: repeat(4, 1fr); } }
.quick-add a {
    display: flex; align-items: center; gap: 10px; padding: 12px; min-height: 56px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600; box-shadow: var(--shadow);
}
.quick-add a:hover { text-decoration: none; }
.quick-add .badge-icon { width: 34px; height: 34px; border-radius: 10px; }

/* "More" menu */
.menu { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; box-shadow: var(--shadow); }
.menu a, .menu button {
    display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; min-height: 56px;
    color: var(--text); font: inherit; font-weight: 550; background: none; border: 0; text-align: left; cursor: pointer;
}
.menu > * + * { border-top: 1px solid var(--border); }
.menu a:hover, .menu button:hover { background: var(--surface-2); text-decoration: none; }
.menu .grow { flex: 1; }
.menu .chev { color: var(--muted); }
.menu form { margin: 0; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; font-weight: 650; cursor: pointer;
    text-decoration: none; white-space: nowrap; touch-action: manipulation;
}
.btn:hover { text-decoration: none; filter: brightness(.98); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-primary { color: #06201d; } }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost-danger { color: var(--danger); background: transparent; border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .9rem; border-radius: 10px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }

.fab {
    position: fixed; z-index: 25;
    right: 16px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 56px; min-width: 56px; padding: 0 16px; border-radius: 28px;
    background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(15, 118, 110, .35);
    font-weight: 700;
}
.fab:hover { text-decoration: none; filter: brightness(1.05); }
.fab-label { display: none; }
@media (prefers-color-scheme: dark) { .fab { color: #06201d; } }
@media (min-width: 900px) {
    .fab { bottom: 28px; right: 32px; padding: 0 22px 0 18px; }
    .fab-label { display: inline; }
}

/* ---------- Forms ---------- */

.form-card { max-width: 640px; }
.field { margin-bottom: 16px; }
.field > label, .field-label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=tel], input[type=url], input[type=number],
input[type=date], input[type=datetime-local], input[type=time], input[type=search], input:not([type]), select, textarea {
    width: 100%; min-height: 48px; padding: 10px 12px;
    font: inherit; font-size: 16px; /* 16px stops iOS from zooming in on focus */
    color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    appearance: none; -webkit-appearance: none;
}
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364707d' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}
.patient-picker select { background-image: none; padding-right: 4px; min-height: 0; width: auto; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 1px; border-color: var(--primary); }
input[type=date], input[type=datetime-local] { display: block; }
input::-webkit-date-and-time-value { text-align: left; }

.row-2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 560px) { .row-2 { grid-template-columns: 1fr 1fr; } }
.row-3 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (min-width: 560px) { .row-3 { grid-template-columns: 2fr 1fr 1fr; } .row-3 > :first-child { grid-column: auto; } }
.row-3 > :first-child { grid-column: 1 / -1; }

.check {
    display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 12px; margin-bottom: 16px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-weight: 550;
}
.check input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--primary); flex-shrink: 0; margin: 0; }

.duration-input { display: flex; gap: 10px; }
.duration-input label { display: flex; align-items: center; gap: 6px; flex: 1; }
.duration-input input { flex: 1; }

.form-actions {
    display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 8px;
}
.form-actions .btn-primary { flex: 1 1 160px; }
.form-actions .spacer { flex: 1; }
@media (max-width: 559px) {
    .form-actions { flex-direction: column-reverse; align-items: stretch; }
    .form-actions .btn, .form-actions .btn-primary { width: 100%; flex: none; }
    .form-actions .spacer { display: none; }
}

.validation-message { color: var(--danger); font-size: .875rem; margin-top: 4px; }
.invalid { border-color: var(--danger) !important; }
.validation-errors { color: var(--danger); padding-left: 18px; }

.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 2px; margin-bottom: 14px; max-width: 100%; overflow-x: auto; }
.segmented button {
    border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; font: inherit; font-weight: 600; color: var(--muted);
    cursor: pointer; white-space: nowrap; min-height: 38px;
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.search-box { position: relative; margin-bottom: 14px; }
.search-box .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 40px; }

/* ---------- Alerts / states ---------- */

.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; display: flex; gap: 10px; align-items: flex-start; }
.alert .icon { margin-top: 2px; }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-info { background: var(--primary-soft); color: var(--primary-strong); }
.alert b { color: inherit; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty h3 { color: var(--text); margin-top: 10px; }
.empty-icon { width: 60px; height: 60px; margin: 0 auto; border-radius: 18px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.empty .btn { margin-top: 8px; }

.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px 0; color: var(--muted); }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-screen { min-height: 60vh; display: grid; place-items: center; }

/* ---------- Timeline ---------- */

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; min-height: 38px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border); color: var(--muted); font: inherit; font-size: .88rem; font-weight: 600;
    white-space: nowrap; cursor: pointer;
}
.chip.on { color: var(--text); border-color: currentColor; }
.chip.on.k-appt { color: var(--k-appt); background: var(--k-appt-soft); }
.chip.on.k-event { color: var(--k-event); background: var(--k-event-soft); }
.chip.on.k-rx { color: var(--k-rx); background: var(--k-rx-soft); }
.chip.on.k-sym { color: var(--k-sym); background: var(--k-sym-soft); }
.chip.on.k-dx { color: var(--k-dx); background: var(--k-dx-soft); }

.tl-month { position: sticky; top: calc(var(--topbar-h) + var(--safe-t)); z-index: 5; margin: 18px 0 8px; padding: 6px 0; background: var(--bg); font-weight: 750; font-size: .95rem; color: var(--muted); }
.tl { position: relative; padding-left: 26px; }
.tl::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--border); border-radius: 2px; }
.tl-item { position: relative; margin-bottom: 10px; }
.tl-dot { position: absolute; left: -23px; top: 18px; width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--bg); background: var(--primary); }
.tl-item.k-appt .tl-dot { background: var(--k-appt); }
.tl-item.k-event .tl-dot { background: var(--k-event); }
.tl-item.k-rx .tl-dot { background: var(--k-rx); }
.tl-item.k-sym .tl-dot { background: var(--k-sym); }
.tl-item.k-dx .tl-dot { background: var(--k-dx); }
.tl-item .item { align-items: flex-start; }
.tl-when { font-size: .8rem; color: var(--muted); font-weight: 600; }
.tl-kind { font-size: .72rem; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; }
.k-appt .tl-kind { color: var(--k-appt); }
.k-event .tl-kind { color: var(--k-event); }
.k-rx .tl-kind { color: var(--k-rx); }
.k-sym .tl-kind { color: var(--k-sym); }
.k-dx .tl-kind { color: var(--k-dx); }
.tl-today { display: flex; align-items: center; gap: 8px; margin: 6px 0 12px -26px; color: var(--primary); font-weight: 700; font-size: .85rem; }
.tl-today::after { content: ""; flex: 1; height: 2px; background: var(--primary); opacity: .4; border-radius: 2px; }

/* ---------- Notes, tasks, info ---------- */

.note { padding: 12px 0; border-top: 1px solid var(--border); }
.note:first-of-type { border-top: 0; padding-top: 4px; }
.note-meta { color: var(--muted); font-size: .8rem; margin-bottom: 2px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.note p:last-child { margin-bottom: 0; }

.task { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.task:first-of-type { border-top: 0; }
.task-check {
    width: 28px; height: 28px; margin-top: 1px; border-radius: 8px; border: 2px solid var(--border); background: var(--surface);
    display: grid; place-items: center; color: transparent; cursor: pointer; flex-shrink: 0; padding: 0;
}
.task-check.done { background: var(--primary); border-color: var(--primary); color: #fff; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; overflow-wrap: anywhere; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-sub { font-size: .85rem; color: var(--muted); }
.task-sub.overdue { color: var(--danger); font-weight: 600; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.inline-form > :first-child { flex: 1 1 220px; }

.info-section { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.info-section:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.info-section h3 { font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.longtext { font-size: .95rem; overflow-wrap: anywhere; }
.longtext p { margin-bottom: .6rem; }
.longtext ul { padding-left: 20px; margin: 0 0 .6rem; }
.source { font-size: .8rem; color: var(--muted); margin-top: 12px; }

.interaction { border-left: 4px solid var(--warn); background: var(--warn-soft); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 10px; }
.interaction-title { font-weight: 700; color: var(--warn); margin-bottom: 4px; }
.interaction p { color: var(--text); font-size: .9rem; margin: 0; }

/* ---------- Sign-in & onboarding ---------- */

.auth-shell { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 28px 22px; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 1.4rem; margin-bottom: 18px; }
.onboarding { max-width: 520px; margin: 24px auto; padding: 24px 20px; }

/* ---------- Blazor error UI ---------- */

#blazor-error-ui {
    background: var(--warn-soft); color: var(--text);
    bottom: calc(var(--tabbar-h) + var(--safe-b)); box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none; left: 0; padding: 0.8rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.6rem; }
.blazor-error-boundary { background: var(--danger); padding: 1rem; color: white; border-radius: var(--radius-sm); }
.blazor-error-boundary::after { content: "Something went wrong on this part of the page."; }
