/* =============================================
   MemoryCare — Patient Interface
   Design: warm, calm, cognitively accessible
   Font: Atkinson Hyperlegible (low-vision optimised)
   ============================================= */

/* =============================================
   CUSTOM PROPERTIES
   ============================================= */
:root {
    /* ── Palette ── */

    /* Sage Green — primary brand: header bar, buttons, avatars, CTAs */
    --sage:         #4A7C6F;
    --sage-light:   #E8F4F1;   /* soft tint for sage-themed elements */
    --sage-hover:   #3A6359;   /* hover / active state */

    /* Warm Linen — page background (avoids harsh pure-white glare) */
    --warm-50:      #F2ECE4;   /* = linen page background */
    --warm-100:     #E8E0D6;   /* slightly darker linen surfaces */
    --warm-200:     #D9D0C4;   /* frame border / divider */
    --warm-300:     #C9BFB0;   /* deeper linen accent */

    /* Deep Forest — primary text: headings, names */
    --ink-900:      #2D3A32;   /* = deep-forest for headings */
    --ink-700:      #4E5E55;   /* body text */
    --ink-500:      #7A8C85;   /* supporting / secondary text */
    --ink-300:      #A8B8B0;   /* disabled / placeholder */

    /* Calm Blue — secondary contacts (visual variety, no new meaning) */
    --blue-500:     #4A7C6F;   /* mapped to sage; use --calm-blue for blue */
    --blue-600:     #3A6359;
    --blue-100:     #E8F4F1;
    --calm-blue:    #3B6FAD;
    --calm-blue-hover: #2A5490;
    --calm-blue-light: #EAF1FA;

    /* Purple — removed from palette; scan button uses sage */
    --purple-500:   #4A7C6F;
    --purple-600:   #3A6359;

    /* Sunflower Amber — reminders, medication, time-sensitive only */
    --amber-500:    #E8A020;
    --amber-600:    #C87200;

    /* Sage reused for "done" / safe states */
    --green-500:    #4A7C6F;
    --green-600:    #3A6359;
    --green-100:    #E8F4F1;

    /* Alert Red — emergency ONLY: SOS button + emergency contacts header */
    --red-500:      #D94040;
    --red-600:      #BB3030;

    --white:     #FFFFFF;
    --border:    rgba(0,0,0,0.09);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.07);
    --shadow-md: 0 6px 24px rgba(0,0,0,0.11);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.15);

    /* ── Typography — Atkinson Hyperlegible ──
       Designed by the Braille Institute for people with low vision.
       Distinct letterforms eliminate 0/O, 1/l, b/d, p/q confusions.
       Tall x-height and generous letter-spacing aid at-a-glance reading. */
    --font-ui:      'Atkinson Hyperlegible', 'Helvetica Neue', Arial, sans-serif;
    --font-display: 'Atkinson Hyperlegible', 'Helvetica Neue', Arial, sans-serif;

    /* Strict 3-tier type scale */
    --text-xs:  15px;   /* absolute minimum — nothing smaller */
    --text-sm:  15px;   /* body / supporting text */
    --text-md:  17px;   /* elevated body / button labels */
    --text-lg:  19px;   /* card headings / section headings */
    --text-xl:  19px;   /* section headings */
    --text-2xl: 28px;   /* display: greeting, time (bold) */
    --text-3xl: 28px;   /* max display */

    /* Spacing */
    --sp-1: 6px;
    --sp-2: 12px;
    --sp-3: 20px;
    --sp-4: 28px;
    --sp-5: 40px;
    --sp-6: 56px;

    /* Shape */
    --r-sm: 14px;
    --r-md: 22px;
    --r-lg: 32px;
    --r-xl: 44px;
    --r-full: 9999px;

    /* Touch target */
    --touch: 64px;
}

/* =============================================
   RESET
   ============================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: var(--font-ui);
    font-size: var(--text-md);
    line-height: 1.55;
    color: var(--ink-700);
    background: var(--warm-50);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

/* Texture overlay on the body background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(74,124,111,0.08) 0%, transparent 60%),
        radial-gradient(ellipse 60% 80% at 80% 90%, rgba(232,160,32,0.06) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

img, video { max-width: 100%; display: block; }

button {
    font-family: var(--font-ui);
    cursor: pointer;
    border: none;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}
button:focus-visible { outline: 4px solid var(--sage); outline-offset: 4px; }

input {
    font-family: var(--font-ui);
    font-size: var(--text-md);
    border: 3px solid var(--border);
    border-radius: var(--r-sm);
    padding: var(--sp-2) var(--sp-3);
    background: var(--white);
    color: var(--ink-700);
    width: 100%;
}
input:focus { border-color: var(--sage); outline: none; box-shadow: 0 0 0 4px var(--sage-light); }

.hidden { display: none !important; }

/* =============================================
   ORIENTATION HEADER
   ============================================= */
#orientation-panel {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    background: var(--sage);
    border-bottom: 1.5px solid var(--sage-hover);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    min-height: 0;
}

.orient-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

#orient-day {
    font-size: var(--text-sm);
    font-weight: 700;
    color: rgba(255,255,255,0.8);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

#orient-time {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--white);
    line-height: 1;
    letter-spacing: -0.01em;
}

@media (min-width: 480px) {
    #orient-time { font-size: var(--text-2xl); }
    #orientation-panel { padding: var(--sp-2) var(--sp-4); }
}

.orient-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-1);
    text-align: center;
}

#orient-safety {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-sm);
    font-weight: 700;
    color: rgba(255,255,255,0.95);
    background: rgba(255,255,255,0.2);
    padding: 4px 14px;
    border-radius: var(--r-full);
}

.safety-dot {
    width: 10px;
    height: 10px;
    background: var(--white);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.3);
}

#orient-weather {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--text-sm);
    color: rgba(255,255,255,0.85);
}

.orient-right {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: 26px;
    opacity: 0.6;
}

/* =============================================
   MAIN DASHBOARD
   ============================================= */
#main-dashboard {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4) var(--sp-3);
}

/* =============================================
   ACTION BAR — 5 CARD BUTTONS
   ============================================= */
/* Mobile-first: 2 columns for handsets, scales up in media queries below */
.action-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 2.5vw;
    width: 100%;
    max-width: 700px;
    min-height: 320px;
    min-width: 0;
    align-items: stretch;
    justify-items: stretch;
    height: 40vh;
    margin: 0 auto;
    /* Always 2 rows, 3 columns for 6 buttons, fill space */
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px 12px 20px;
    border-radius: var(--r-md);
    border: none;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    min-height: 140px;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    color: var(--white);
    font-weight: 800;
    position: relative;
    overflow: hidden;
    transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.1s ease;
}

/* Soft sheen overlay */
.action-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(160deg, rgba(255,255,255,0.18) 0%, transparent 55%);
    border-radius: inherit;
    pointer-events: none;
}

.action-btn:active {
    transform: scale(0.95);
    box-shadow: var(--shadow-sm);
    filter: brightness(0.92);
}

.action-icon {
    font-size: 2.5rem;
    line-height: 1;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.action-label {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    text-align: center;
    line-height: 1.2;
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Individual button colours */
.action-call {
    background: linear-gradient(145deg, #4D84C8 0%, #2A5490 100%);
}
.action-scan {
    background: linear-gradient(145deg, #5A9282 0%, #3A6359 100%);
}
.action-reminders {
    background: linear-gradient(145deg, #F0A828 0%, #C87000 100%);
}
.action-camera {
    background: linear-gradient(145deg, #4A7C6F 0%, #2E5045 100%);
}
.action-emergency {
    background: linear-gradient(145deg, #E84848 0%, #A82828 100%);
    box-shadow: 0 6px 28px rgba(217,64,64,0.35);
}
.action-dnd {
    background: linear-gradient(145deg, #7B7B8E 0%, #4A4A58 100%);
}
.action-dnd.dnd-on {
    background: linear-gradient(145deg, #9B59B6 0%, #6C3483 100%);
    box-shadow: 0 6px 28px rgba(108,52,131,0.35);
}

/* ── Toggle pill inside the DND button ── */
.toggle-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}
.toggle-track {
    width: 38px;
    height: 20px;
    background: rgba(255,255,255,0.25);
    border-radius: 10px;
    position: relative;
    transition: background 0.25s;
    flex-shrink: 0;
}
.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.action-dnd.dnd-on .toggle-track {
    background: rgba(255,255,255,0.55);
}
.action-dnd.dnd-on .toggle-thumb {
    transform: translateX(18px);
}
.toggle-state-label {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: rgba(255,255,255,0.85);
}

/* ── Mobile-first default is 2 columns (set on .action-bar above) ── */

/* Remove media queries for action-bar grid, always 2x3 grid */

/* =============================================
   MODALS
   ============================================= */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    background: rgba(26,26,46,0.55);
    backdrop-filter: blur(4px);
}
.modal[aria-hidden="false"] {
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-content {
    background: var(--warm-50);
    width: 100%;
    max-width: 860px;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    display: flex;
    flex-direction: column;
    max-height: 100dvh;
    overflow: hidden;
}

.modal-full   { height: 100dvh; border-radius: 0; }
.modal-dialog { height: auto; max-height: 92dvh; }

.modal-header {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-4);
    background: rgba(255,255,255,0.95);
    border-bottom: 1.5px solid var(--border);
    flex-shrink: 0;
}

.modal-header h2 {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 700;
    flex: 1;
    color: var(--ink-900);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-4);
    -webkit-overflow-scrolling: touch;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn-back {
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--sage);
    background: none;
    padding: var(--sp-2) var(--sp-3);
    min-height: var(--touch);
    min-width: var(--touch);
    border-radius: var(--r-sm);
}
.btn-back:active { background: var(--warm-100); }

.btn-primary {
    background: var(--sage);
    color: var(--white);
    font-weight: 700;
    border-radius: var(--r-md);
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--text-md);
    min-height: var(--touch);
    box-shadow: 0 4px 14px rgba(74,124,111,0.3);
}
.btn-primary:active { background: var(--sage-hover); box-shadow: none; }

.btn-secondary {
    background: var(--white);
    color: var(--ink-700);
    font-weight: 700;
    border-radius: var(--r-md);
    border: 2px solid var(--border);
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--text-md);
    min-height: var(--touch);
}
.btn-secondary:active { background: var(--warm-100); }

.btn-large {
    font-size: var(--text-lg);
    padding: var(--sp-3) var(--sp-5);
    min-height: 72px;
}

.btn-full { display: block; width: 100%; text-align: center; }

/* Done button in reminders */
.btn-done {
    background: var(--sage);
    color: var(--white);
    font-size: var(--text-md);
    font-weight: 700;
    border-radius: var(--r-md);
    padding: var(--sp-2) var(--sp-4);
    min-height: var(--touch);
    min-width: 110px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(74,124,111,0.28);
}
.btn-done:active { background: var(--sage-hover); box-shadow: none; }

/* Add-reminder dashed button */
.btn-add-reminder {
    display: block;
    width: 100%;
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--amber-500);
    background: transparent;
    border: 3px dashed var(--amber-500);
    border-radius: var(--r-md);
    padding: var(--sp-3);
    min-height: 80px;
    text-align: center;
    margin-top: var(--sp-3);
    opacity: 0.8;
}
.btn-add-reminder:active { background: var(--amber-light, #FDF3E4); opacity: 1; }

/* =============================================
   CONTACT LIST
   ============================================= */
.contact-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.contact-card {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-3);
    background: var(--white);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    border: 1.5px solid var(--border);
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-size: var(--text-md);
    min-height: 96px;
}
.contact-card:active { background: var(--warm-100); }

.contact-avatar {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--sage);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    color: var(--white);
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
    border: 3px solid var(--white);
    box-shadow: var(--shadow-sm);
}
.contact-avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.contact-card-info { flex: 1; }

.contact-card-name {
    font-size: var(--text-md);
    font-weight: 800;
    color: var(--ink-900);
}

.contact-card-rel {
    font-size: var(--text-sm);
    color: var(--ink-500);
    margin-top: 2px;
}

.contact-card-action { font-size: 32px; }

/* Small variant */
.contact-list-small .contact-card { min-height: 72px; padding: var(--sp-2) var(--sp-3); }
.contact-list-small .contact-avatar { width: 52px; height: 52px; font-size: 22px; }

.contact-card.selected {
    border-color: var(--sage);
    border-width: 3px;
    background: var(--sage-light);
}

/* =============================================
   REMINDERS
   ============================================= */
.reminders-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
}

.reminder-card {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--white);
    border-radius: var(--r-md);
    border: 1.5px solid var(--border);
    box-shadow: var(--shadow-sm);
    min-height: 96px;
}
.reminder-card.completed { opacity: 0.45; }

.reminder-info { flex: 1; }

.reminder-title {
    font-size: var(--text-md);
    font-weight: 800;
    color: var(--ink-900);
}

.reminder-desc {
    font-size: var(--text-sm);
    color: var(--ink-500);
    margin-top: 3px;
}

.reminder-time {
    font-size: var(--text-sm);
    color: var(--amber-500);
    font-weight: 700;
    margin-top: 4px;
}

.empty-state {
    text-align: center;
    padding: var(--sp-6);
    font-size: var(--text-xl);
    color: var(--ink-300);
}

/* =============================================
   FORM
   ============================================= */
.form-group {
    margin-bottom: var(--sp-4);
    position: relative;
}

.form-group label {
    display: block;
    font-size: var(--text-md);
    font-weight: 700;
    margin-bottom: var(--sp-2);
    color: var(--ink-700);
}

.input-large {
    font-size: var(--text-lg);
    padding: var(--sp-3) var(--sp-4);
    padding-right: 72px;
    min-height: var(--touch);
    border-radius: var(--r-md);
    border-width: 2px;
}

.btn-voice {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--sage);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(74,124,111,0.3);
}
.btn-voice:active { background: var(--sage-hover); }
.btn-voice.listening { background: var(--red-500); }

/* =============================================
   FACE / CAMERA
   ============================================= */
.facescan-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: var(--sp-4);
}

.camera-container {
    position: relative;
    width: 100%;
    max-width: 620px;
    background: #000;
    border-radius: var(--r-md);
    overflow: hidden;
}

.camera-container video {
    width: 100%;
    max-height: 58dvh;
    object-fit: cover;
    display: block;
}

.camera-instruction {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.72);
    color: var(--white);
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--r-full);
    font-size: var(--text-sm);
    white-space: nowrap;
}

.scanning-indicator {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0,0,0,0.7);
    color: var(--sage-light);
    padding: 6px 14px;
    border-radius: var(--r-full);
    font-size: var(--text-xs);
    display: flex;
    align-items: center;
    gap: 8px;
}

.scanning-dot {
    width: 10px;
    height: 10px;
    background: var(--sage-light);
    border-radius: 50%;
    display: inline-block;
}

.facescan-result,
.facescan-no-match {
    text-align: center;
    padding: var(--sp-5);
}

.result-avatar {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: var(--sage);
    margin: 0 auto var(--sp-4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    color: var(--white);
    font-weight: 700;
    overflow: hidden;
    border: 5px solid var(--white);
    box-shadow: var(--shadow-md);
}

.facescan-result h3 {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-bottom: var(--sp-1);
}

.facescan-result p,
.facescan-no-match p { font-size: var(--text-md); margin-bottom: var(--sp-3); }

.result-trust-msg {
    color: var(--sage);
    font-weight: 700;
    font-size: var(--text-md) !important;
}

.no-match-msg {
    font-size: var(--text-xl) !important;
    font-weight: 700;
    color: var(--amber-500);
}

.no-match-actions {
    display: flex;
    gap: var(--sp-3);
    justify-content: center;
    flex-wrap: wrap;
    margin-top: var(--sp-3);
}

/* =============================================
   INTERACTION LOGS — face-scan overlay
   ============================================= */
.ilog-scan-wrapper {
    text-align: left;
    margin: var(--sp-3) 0;
    max-height: 260px;
    overflow-y: auto;
}

.ilog-not-trusted {
    font-size: var(--text-lg) !important;
    font-weight: 700;
    color: var(--coral, #D94040);
    margin-bottom: var(--sp-2) !important;
    text-align: center;
}

.ilog-scan-subheader {
    font-size: var(--text-sm, 13px) !important;
    color: var(--text-muted, #7A8C85);
    margin-bottom: var(--sp-2) !important;
    text-align: center;
}

.ilog-scan-loading {
    font-size: var(--text-sm, 13px) !important;
    color: var(--text-muted, #7A8C85);
    text-align: center;
}

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

.ilog-scan-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px;
    background: rgba(255,255,255,0.12);
    border-radius: 10px;
}

.ilog-scan-photo {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.ilog-scan-photo--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: rgba(255,255,255,0.2);
}

.ilog-scan-details {
    flex: 1;
    min-width: 0;
}

.ilog-scan-details strong {
    display: block;
    font-size: 15px;
    font-weight: 700;
}

.ilog-scan-details p {
    font-size: 13px !important;
    margin-bottom: 2px !important;
    opacity: 0.85;
}

.ilog-scan-time {
    font-size: 12px;
    opacity: 0.7;
}

/* Seen-before (visible but not trusted) — full card layout */
.ilog-scan-wrapper--seen-before {
    max-height: none;
    overflow: visible;
    text-align: center;
    margin: 0 0 var(--sp-3) 0;
}

.ilog-seen-before-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-2);
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: var(--sp-4) var(--sp-3);
    width: 100%;
    box-sizing: border-box;
}

.ilog-seen-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 44px;
    border: 3px solid rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
    margin-bottom: var(--sp-1);
}

.ilog-seen-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ilog-seen-before-heading {
    font-size: var(--text-md, 16px) !important;
    font-weight: 600;
    opacity: 0.85;
    margin: 0 !important;
}

.ilog-seen-name {
    font-size: var(--text-2xl, 26px) !important;
    font-weight: 700;
    display: block;
    margin: 0;
    line-height: 1.2;
}

.ilog-seen-summary {
    font-size: var(--text-md, 16px) !important;
    opacity: 0.85;
    margin: 0 !important;
    padding: 0 var(--sp-2);
}

.ilog-not-trusted-warning {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: var(--text-md, 16px) !important;
    font-weight: 700;
    color: #E07B00;
    background: rgba(224, 123, 0, 0.15);
    border: 2px solid #E07B00;
    border-radius: 10px;
    padding: 12px 14px;
    margin-top: var(--sp-2) !important;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
}

.ilog-not-trusted-warning span:first-child {
    font-size: 20px;
    flex-shrink: 0;
    line-height: 1.3;
}

@media (max-width: 480px) {
    .ilog-seen-avatar {
        width: 80px;
        height: 80px;
        font-size: 36px;
    }
    .ilog-seen-name {
        font-size: var(--text-xl, 22px) !important;
    }
    .facescan-no-match {
        padding: var(--sp-3) var(--sp-2);
    }
    .no-match-actions {
        flex-direction: column;
    }
    .no-match-actions button {
        width: 100%;
    }
}

/* =============================================
   CAMERA / PHOTO MODAL
   ============================================= */
.camera-modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-3);
}

.btn-capture {
    display: block;
    width: 80%;
    max-width: 400px;
    margin: var(--sp-3) auto;
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--white);
    background: var(--sage);
    border-radius: var(--r-xl);
    padding: var(--sp-3);
    min-height: 80px;
    text-align: center;
    box-shadow: 0 6px 20px rgba(74,124,111,0.3);
}
.btn-capture:active { background: var(--sage-hover); }

.photo-preview { width: 100%; max-width: 620px; }
.photo-preview img { width: 100%; border-radius: var(--r-md); margin-bottom: var(--sp-3); }

.send-label {
    font-size: var(--text-md);
    font-weight: 700;
    margin-bottom: var(--sp-2);
}

.photo-actions {
    display: flex;
    gap: var(--sp-3);
    margin-top: var(--sp-3);
    justify-content: center;
    flex-wrap: wrap;
}

/* =============================================
   NOTIFICATION POPUP
   ============================================= */
.notification-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 300;
    background: var(--amber-500);
    color: var(--white);
    box-shadow: var(--shadow-lg);
}

.notification-content {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    max-width: 860px;
    margin: 0 auto;
}

.notification-icon { font-size: 44px; flex-shrink: 0; }

.notification-text { flex: 1; }
.notification-text h3 { font-size: var(--text-md); font-weight: 800; }
.notification-text p  { font-size: var(--text-sm); opacity: 0.9; }

#notification-done-btn {
    background: var(--sage);
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(74,124,111,0.3);
}

/* =============================================
   MANAGE TRUSTED PEOPLE
   ============================================= */
.manage-trusted-actions { margin-bottom: var(--sp-4); }

.trusted-manage-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.trusted-manage-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3);
    background: var(--white);
    border-radius: var(--r-md);
    border: 1.5px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.trusted-manage-avatar {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--white);
    flex-shrink: 0;
    overflow: hidden;
    background: var(--sage);
}
.trusted-manage-avatar img { width: 100%; height: 100%; object-fit: cover; }

.trusted-manage-info { flex: 1; min-width: 0; }
.trusted-manage-info strong { display: block; font-size: var(--text-md); font-weight: 800; }
.trusted-manage-info span  { font-size: var(--text-sm); color: var(--ink-500); }

.trusted-manage-actions { display: flex; gap: 8px; }
.trusted-manage-actions button {
    width: 46px;
    height: 46px;
    border-radius: var(--r-sm);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.trusted-manage-actions button:active { background: var(--warm-200); }

/* =============================================
   FACE SCAN LINK UI
   ============================================= */
.face-link-scan-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) 0;
}

.face-link-scan-body .camera-container {
    width: 100%;
    max-width: 360px;
    aspect-ratio: 4/3;
    border-radius: var(--r-md);
}

.face-link-scan-body .camera-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.face-link-result {
    width: 100%;
    text-align: center;
    padding: var(--sp-3);
    border-radius: var(--r-md);
    margin-top: var(--sp-2);
}

.face-link-result .link-success { color: var(--green-500); font-size: var(--text-md); font-weight: 700; }
.face-link-result .link-fail    { color: var(--amber-500); font-size: var(--text-sm); }

.modal-desc {
    text-align: center;
    color: var(--ink-500);
    font-size: var(--text-sm);
    margin-bottom: var(--sp-2);
}

.face-scan-hint {
    text-align: center;
    color: var(--ink-500);
    font-size: var(--text-xs);
}

/* Divider */
.divider-or {
    text-align: center;
    margin: var(--sp-3) 0;
    position: relative;
}
.divider-or::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: var(--border);
}
.divider-or span {
    position: relative;
    background: var(--warm-50);
    padding: 0 14px;
    font-size: var(--text-sm);
    color: var(--ink-500);
}

/* Form stacks */
.form-actions-stack {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    margin-top: var(--sp-4);
}

/* Search results */
.search-result-row {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    margin-bottom: 8px;
    background: var(--white);
}
.search-result-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--sage);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    overflow: hidden;
}
.search-result-avatar img { width: 100%; height: 100%; object-fit: cover; }
.search-result-info { flex: 1; min-width: 0; }
.search-result-info strong { display: block; font-size: var(--text-sm); font-weight: 700; }
.search-result-role { font-size: var(--text-xs); color: var(--ink-500); }
.search-selected { font-size: var(--text-xs); color: var(--sage); font-weight: 700; padding: 6px 0; }

.btn-sm {
    font-size: var(--text-xs);
    padding: 6px 14px;
    border-radius: var(--r-sm);
    border: none;
    cursor: pointer;
    font-weight: 700;
}

/* =============================================
   UTILITY: CAREGIVER LINK & LOGOUT
   ============================================= */
.caregiver-link {
    position: fixed;
    bottom: var(--sp-2);
    right: var(--sp-2);
    font-size: 18px;
    opacity: 0.25;
    text-decoration: none;
    z-index: 50;
    padding: 6px;
}
.caregiver-link:hover { opacity: 0.55; }

.patient-logout-btn {
    position: fixed;
    top: var(--sp-2);
    right: var(--sp-2);
    background: rgba(0,0,0,0.06);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 20px;
    cursor: pointer;
    z-index: 100;
    opacity: 0.4;
    display: flex;
    align-items: center;
    justify-content: center;
}
.patient-logout-btn:hover { opacity: 0.9; background: rgba(0,0,0,0.12); }

/* =============================================
   LOGOUT PIN MODAL
   ============================================= */
.modal-logout-pin-content {
    max-width: 360px;
    margin: auto;
}

.modal-logout-pin-body {
    text-align: center;
    padding: var(--sp-5) var(--sp-4);
}

.logout-pin-prompt {
    font-size: var(--text-sm);
    color: var(--ink-500);
    margin-bottom: var(--sp-4);
}

.logout-pin-input {
    font-size: 2.5rem;
    letter-spacing: 0.4em;
    text-align: center;
    width: 100%;
    padding: var(--sp-3);
    border: 3px solid var(--ink-300);
    border-radius: var(--r-md);
    margin-bottom: var(--sp-2);
    font-family: var(--font-display);
}
.logout-pin-input:focus {
    border-color: var(--blue-500);
    outline: none;
    box-shadow: 0 0 0 4px var(--blue-100);
}

.logout-pin-error {
    color: var(--red-500);
    font-size: var(--text-xs);
    min-height: 28px;
    margin-bottom: var(--sp-3);
    font-weight: 700;
}

.logout-pin-actions {
    display: flex;
    gap: var(--sp-2);
}

.logout-pin-actions .btn-secondary,
.logout-pin-actions .btn-primary {
    flex: 1;
}

/* =============================================
   HIGH CONTRAST MODE
   ============================================= */
body.high-contrast {
    --warm-50:  #FFFFFF;
    --warm-100: #F0F0F0;
    --ink-700:  #000000;
    --ink-500:  #333333;
    --blue-500: #0050B3;
    --border:   rgba(0,0,0,0.3);
}

/* =============================================
   RESPONSIVE TYPOGRAPHY
   ============================================= */
@media (max-width: 580px) {
    :root {
        --text-2xl: 36px;
        --text-xl:  28px;
        --text-lg:  24px;
        --text-md:  20px;
        --text-sm:  17px;
        --text-xs:  14px;
    }
    #orientation-panel {
        flex-wrap: wrap;
        padding: var(--sp-2);
    }
    .orient-center { order: 3; flex-basis: 100%; }
}