:root {
    --bg: #0f1117;
    --bg2: #161820;
    --bg3: #1e2028;
    --border: rgba(255,255,255,0.07);
    --text: #e8eaf0;
    --text2: #8b8fa8;
    --text3: #5a5e72;
    --accent: #7c9ef8;
    --accent2: #f0a070;
    --green: #6ecb8a;
    --red: #f07070;
    --purple: #b07cf8;
    --yellow: #f0d060;

    /* Person colors */
    --steven: #7c9ef8;
    --stephanie: #f07cbc;
    --annabelle: #6ecb8a;
    --eric: #f0a070;
    --family: #b07cf8;

    --radius: 16px;
    --radius-sm: 10px;
    --header-h: 72px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  [data-theme="light"] {
    --bg: #f0f2f8;
    --bg2: #ffffff;
    --bg3: #e8eaf2;
    --border: rgba(0,0,0,0.08);
    --text: #1a1c28;
    --text2: #5a5e78;
    --text3: #9a9eb8;
    --accent: #4a72e8;
  }

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

  html, body {
    width: 100%; height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    overflow: hidden;
    user-select: none;
  }

  /* ── HEADER ────────────────────────────────────────────── */
  #header {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 28px;
    gap: 24px;
    z-index: 100;
    backdrop-filter: blur(12px);
  }

  #header-left {
    display: flex; flex-direction: column; gap: 1px;
    flex: 0 0 auto;
  }

  #clock {
    font-family: 'DM Serif Display', serif;
    font-size: 32px;
    letter-spacing: -0.5px;
    line-height: 1;
    color: var(--text);
  }

  #date-label {
    font-size: 12px;
    color: var(--text2);
    letter-spacing: 0.5px;
  }

  #header-weather {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 16px;
    background: var(--bg3);
    border-radius: 40px;
    border: 1px solid var(--border);
    flex: 0 0 auto;
  }

  #weather-icon { font-size: 22px; }
  #weather-temp { font-size: 22px; font-weight: 500; }
  #weather-desc { font-size: 12px; color: var(--text2); }
  #weather-astro {
    display: flex; flex-direction: column; gap: 2px;
    padding-left: 10px;
    border-left: 1px solid var(--border);
    font-size: 11px; color: var(--text3);
  }

  /* SensorPush outside pill — matches #header-weather size/shape */
  #header-sensorpush {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 16px;
    background: var(--bg3);
    border-radius: 40px;
    border: 1px solid var(--border);
    flex: 0 0 auto;
    font-size: 22px;  /* icon size */
    cursor: pointer;
    transition: border-color 0.15s;
  }
  #header-sensorpush:hover { border-color: var(--accent); }

  /* ── Sensor panel cards ─────────────────────────────────────── */
  #sp-content {
    display: flex; flex-wrap: wrap; gap: 10px;
    padding: 4px 0;
  }

  .sp-card {
    background: var(--bg3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 10px 14px;
    min-width: 140px;
    flex: 1 1 140px;
    display: flex; flex-direction: column; gap: 3px;
  }
  .sp-card.sp-outside {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 6%, var(--bg3));
  }
  .sp-name {
    font-size: 12px; font-weight: 600; color: var(--text2);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .sp-temp {
    font-size: 26px; font-weight: 600; color: var(--text);
    line-height: 1.1;
    cursor: pointer;
  }
  .sp-temp:hover { color: var(--accent); }
  .sp-meta {
    display: flex; gap: 10px;
    font-size: 12px; color: var(--text2);
  }
  .sp-age {
    font-size: 10px; color: var(--text3);
    margin-top: 2px;
  }
  .sp-id {
    font-size: 9px; color: var(--text3);
    font-family: monospace;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-top: 1px;
    opacity: 0.6;
  }

  /* ── SensorPush history modal ───────────────────────────────── */
  #sp-history-overlay {
    position: fixed; inset: 0; z-index: 600;
    background: rgba(0,0,0,0.55);
    display: none; align-items: center; justify-content: center;
  }
  #sp-history-overlay.open { display: flex; }

  #sp-history-modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    width: min(680px, 92vw);
    max-height: 80vh;
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 14px;
  }

  .sp-history-hdr {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  }
  .sp-history-hdr-left {
    display: flex; flex-direction: column; gap: 2px;
  }
  #sp-history-name {
    font-size: 17px; font-weight: 600; color: var(--text);
  }
  #sp-range-tabs {
    display: flex; gap: 4px; margin-top: 4px;
  }
  .sp-range-btn {
    background: none; border: 1px solid var(--border);
    border-radius: 4px; padding: 2px 10px;
    font-size: 12px; color: var(--text3); cursor: pointer;
  }
  .sp-range-btn:hover { color: var(--text); border-color: var(--text3); }
  .sp-range-btn.active {
    background: var(--accent); border-color: var(--accent);
    color: #fff;
  }
  .sp-history-close {
    background: none; border: none; color: var(--text3);
    font-size: 18px; cursor: pointer; padding: 2px 6px;
    flex-shrink: 0;
  }
  .sp-history-close:hover { color: var(--text); }

  #sp-history-chart svg { width: 100%; height: auto; overflow: visible; }
  .sp-chart-legend {
    display: flex; gap: 18px; font-size: 12px; color: var(--text2);
    align-items: center;
  }
  .sp-chart-legend-dot {
    display: inline-block; width: 24px; height: 2.5px;
    border-radius: 2px; vertical-align: middle; margin-right: 5px;
  }

  #leave-soon-banner {
    flex: 1;
    display: none;
    align-items: center; gap: 10px;
    background: linear-gradient(90deg, rgba(240,160,112,0.15), transparent);
    border: 1px solid rgba(240,160,112,0.3);
    border-radius: 40px;
    padding: 8px 20px;
    color: var(--accent2);
    font-size: 13px; font-weight: 500;
    animation: pulse-border 2s ease-in-out infinite;
  }
  #leave-soon-banner.visible { display: flex; }
  #leave-soon-banner.late {
    background: linear-gradient(90deg, rgba(220,50,50,0.22), transparent);
    border-color: rgba(220,50,50,0.5);
    color: #ff6b6b;
    font-size: 15px; font-weight: 700;
    animation: pulse-border-late 0.8s ease-in-out infinite;
  }

  @keyframes pulse-border {
    0%, 100% { border-color: rgba(240,160,112,0.3); }
    50% { border-color: rgba(240,160,112,0.7); }
  }
  @keyframes pulse-border-late {
    0%, 100% { border-color: rgba(220,50,50,0.4); background: linear-gradient(90deg, rgba(220,50,50,0.18), transparent); }
    50%       { border-color: rgba(220,50,50,0.85); background: linear-gradient(90deg, rgba(220,50,50,0.32), transparent); }
  }

  #header-right {
    margin-left: auto;
    display: flex; align-items: center; gap: 12px;
  }

  .header-chip {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 14px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 40px;
    font-size: 12px; color: var(--text2);
    cursor: pointer;
    transition: all 0.2s;
  }
  .header-chip:hover { background: var(--border); color: var(--text); }
  /* Status indicators — shape + color for color-blind accessibility
     ●  ok    = green circle  (connected)
     ■  error = red square    (network down)
     ◆  warn  = blue diamond  (server up, auth/config issue)
     ○  idle  = muted circle  (not configured / signed out)        */
  .header-chip .dot {
    width: 8px; height: 8px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--text3);
    opacity: 0.45;
    transition: background 0.3s, border-radius 0.3s, transform 0.3s, box-shadow 0.3s, opacity 0.3s;
  }
  .header-chip .dot[data-status="ok"] {
    background: var(--green); border-radius: 50%;
    box-shadow: 0 0 5px var(--green); transform: none; opacity: 1;
  }
  .header-chip .dot[data-status="error"] {
    background: var(--red); border-radius: 2px;
    box-shadow: none; transform: none; opacity: 1;
  }
  .header-chip .dot[data-status="warn"] {
    background: var(--accent); border-radius: 2px;
    box-shadow: none; transform: rotate(45deg); opacity: 1;
  }
  .header-chip .dot[data-status="idle"] {
    background: var(--text3); border-radius: 50%;
    box-shadow: none; transform: none; opacity: 0.45;
  }

  /* ── Services status popover ────────────────────────────── */
  #services-popover {
    position: absolute;
    top: 60px;
    right: 16px;
    min-width: 260px;
    max-width: 360px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    padding: 10px 12px;
    z-index: 999;
    font-size: 13px;
  }
  #services-popover .svc-pop-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text3);
    margin-bottom: 6px;
  }
  #services-popover ul { list-style: none; margin: 0; padding: 0; }
  .svc-pop-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 2px;
    border-bottom: 1px solid var(--border);
  }
  .svc-pop-row:last-child { border-bottom: none; }
  .svc-pop-clickable { cursor: pointer; }
  .svc-pop-clickable:hover { background: var(--bg3); }
  .svc-pop-dot {
    width: 8px; height: 8px; border-radius: 50%;
    flex-shrink: 0;
    background: var(--text3); opacity: 0.45;
  }
  .svc-pop-dot[data-status="ok"]    { background: var(--green); box-shadow: 0 0 5px var(--green); opacity: 1; }
  .svc-pop-dot[data-status="error"] { background: var(--red); border-radius: 2px; opacity: 1; }
  .svc-pop-dot[data-status="warn"]  { background: var(--accent); border-radius: 2px; transform: rotate(45deg); opacity: 1; }
  .svc-pop-dot[data-status="idle"]  { background: var(--text3); opacity: 0.45; }
  .svc-pop-label {
    color: var(--text);
    font-weight: 500;
    min-width: 80px;
  }
  .svc-pop-detail {
    color: var(--text3);
    font-size: 12px;
    flex: 1;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #theme-toggle {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--bg3);
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
  }
  #theme-toggle:hover { background: var(--border); transform: scale(1.05); }

  /* ── MAIN LAYOUT ───────────────────────────────────────── */
  #main {
    position: fixed;
    top: var(--header-h); left: 0; right: 0; bottom: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
  }

  /* ── CALENDAR SECTION ──────────────────────────────────── */
  #cal-section {
    flex: 1 1 0;
    min-height: 0;
    display: flex; flex-direction: column;
    padding: 16px 20px 6px;
    overflow: hidden;
  }

  #cal-nav {
    display: flex; align-items: center; gap: 16px;
    margin-bottom: 12px;
    flex-shrink: 0;
  }

  #cal-month-label {
    font-family: 'DM Serif Display', serif;
    font-size: 26px;
    color: var(--text);
    flex: 1;
    letter-spacing: -0.3px;
  }

  .cal-nav-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
  }
  .cal-nav-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
  .cal-nav-btn:active { transform: scale(0.93); }

  #cal-today-btn {
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text2);
    font-size: 12px; font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    font-family: 'DM Sans', sans-serif;
  }
  #cal-today-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }

  /* Legend — inline in #cal-nav, grows to fill space between month label and nav buttons */
  #cal-legend {
    display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
    flex: 1;
  }

  .legend-item {
    display: flex; align-items: center; gap: 5px;
    font-size: 11px; color: var(--text2);
    cursor: pointer;
    padding: 3px 8px 3px 5px;
    border-radius: 20px;
    border: 1px solid transparent;
    transition: opacity 0.18s, border-color 0.18s, background 0.18s;
    user-select: none;
  }
  .legend-item:hover {
    background: var(--bg3);
    border-color: var(--border);
  }
  .legend-item.muted {
    opacity: 0.32;
  }
  .legend-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  /* Calendar viewport — swipeable */
  #cal-viewport {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    position: relative;
  }

  #cal-slider {
    display: flex;
    width: 300%; /* prev + current + next */
    height: 100%;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .cal-month {
    width: calc(100% / 3);
    height: 100%;
    display: flex; flex-direction: column;
    flex-shrink: 0;
  }

  .cal-dow-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 4px;
    flex-shrink: 0;
  }

  .cal-dow {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.8px;
    color: var(--text3);
    padding: 2px 0;
    text-transform: uppercase;
  }

  .cal-grid {
    flex: 1 1 0;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    /* grid-template-rows set inline by renderMonth (5 or 6 weeks) */
    gap: 3px;
    position: relative; /* anchor for multiday overlay */
  }

  .cal-cell {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px 6px 4px;
    cursor: pointer;
    position: relative;
    display: flex; flex-direction: column;
    overflow: hidden;
    transition: background 0.15s, border-color 0.15s;
    min-height: 0;
  }
  .cal-cell:hover { background: var(--bg3); border-color: rgba(255,255,255,0.12); }
  .cal-cell:active { transform: scale(0.97); }

  .cal-cell.other-month { opacity: 0.35; }

  .cal-cell.today {
    border-color: var(--accent);
    background: rgba(124, 158, 248, 0.08);
  }

  .cal-cell.today .cal-day-num {
    color: var(--accent);
    font-weight: 600;
  }

  .cal-day-num {
    font-size: 12px;
    font-weight: 400;
    color: var(--text2);
    line-height: 1;
    margin-bottom: 3px;
    flex-shrink: 0;
  }

  .cal-events {
    display: flex; flex-direction: column; gap: 2px;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
  }

  /* Month pill — flex layout default: "Start  Title  End / more title..."
     order values resequence DOM (time, end, title) → visual (time, title, end).
     align-items: baseline keeps time and title text on the same baseline.
     Applies to: desktop Chrome (hover:hover), kiosk (overridden below). */
  .cal-event-pill {
    font-size: 9.5px;
    font-weight: 500;
    padding: 1.5px 5px;
    border-radius: 4px;
    overflow: hidden;
    line-height: 1.3;
    flex-shrink: 0;
    display: flex;
    align-items: baseline;
    gap: 0 3px;
  }
  .pill-time  { order: 1; flex-shrink: 0; font-size: 8.5px; opacity: 0.9;  white-space: nowrap; }
  .pill-end   { order: 3; flex-shrink: 0; font-size: 8px;   opacity: 0.75; white-space: nowrap; font-weight: 600; }
  .pill-title { order: 2; flex: 1; min-width: 0; overflow: visible; white-space: normal; text-overflow: clip; font-size: 8.5px; }

  /* Touch/no-hover devices (phones, tablets, kiosk — incl. iOS desktop mode):
     grid layout + header banner wrap. */
  @media (hover: none) {
    #header { flex-wrap: wrap; height: auto; min-height: var(--header-h); align-content: center; }
    #leave-soon-banner { flex: none; }
    #leave-soon-banner.visible { width: 100%; order: 10; margin-bottom: 6px; }
    .cal-event-pill { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; }
    .pill-time { float: none; grid-column: 1; grid-row: 1; font-size: 9px; opacity: 0.75; line-height: 1.3; margin: 0; }
    .pill-end  { float: none; grid-column: 2; grid-row: 1; font-size: 9px; opacity: 0.75; line-height: 1.3; text-align: right; font-weight: 600; margin: 0; }
    .pill-title { grid-column: 1 / -1; grid-row: 2; white-space: normal; overflow: hidden; text-overflow: ellipsis; }
  }

  /* Kiosk exception: hover:none but large display (≥1800px) → flex layout (same as desktop).
     Phone/tablet desktop mode tops out ~1600px; kiosk 4K is ~3840px. */
  @media (hover: none) and (min-width: 1800px) {
    .cal-event-pill { display: flex; align-items: baseline; gap: 0 3px; }
    .pill-time { font-size: 8.5px; opacity: 0.9; margin: 0; }
    .pill-end  { font-size: 8px;   opacity: 0.75; margin: 0; text-align: left; }
    .pill-title { overflow: visible; text-overflow: clip; }
  }

  /* JS-detected phones (incl. Android/iOS in desktop mode — hover:hover, pointer:fine to CSS).
     The <head> script adds .is-mobile to <html> when maxTouchPoints>0 && screen.width<=1024.
     These rules must come after the hover:none block to win the cascade. */
  html.is-mobile .cal-event-pill { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; }
  html.is-mobile .pill-time { float: none; grid-column: 1; grid-row: 1; font-size: 9px; opacity: 0.75; line-height: 1.3; margin: 0; }
  html.is-mobile .pill-end  { float: none; grid-column: 2; grid-row: 1; font-size: 9px; opacity: 0.75; line-height: 1.3; text-align: right; font-weight: 600; margin: 0; }
  html.is-mobile .pill-title { grid-column: 1 / -1; grid-row: 2; white-space: normal; overflow: hidden; text-overflow: ellipsis; }

  /* ── KIOSK (portrait large-screen: WebOS, Pi/mini-PC in portrait) ────────────
     Detected in <head> script: innerH > innerW && screen.width >= 800.
     Mutually exclusive with is-mobile. Must come after is-mobile to win cascade. */

  /* Header */
  html.is-kiosk #clock        { font-size: 48px; }
  html.is-kiosk #date-label   { font-size: 17px; }
  html.is-kiosk #weather-temp { font-size: 26px; }
  html.is-kiosk #weather-icon { font-size: 26px; }
  html.is-kiosk #weather-desc { font-size: 14px; }

  /* Calendar nav */
  html.is-kiosk #cal-month-label { font-size: 30px; }
  html.is-kiosk .cal-nav-btn     { width: 46px; height: 46px; font-size: 24px; }
  html.is-kiosk #cal-today-btn   { font-size: 15px; padding: 8px 16px; }
  html.is-kiosk .cal-view-btn    { font-size: 14px; padding: 7px 13px; }
  html.is-kiosk .cal-day-num     { font-size: 17px; }
  html.is-kiosk .legend-item     { font-size: 13px; }

  /* Pills: grid layout + bigger sizes (same structure as phone, larger text) */
  html.is-kiosk .cal-event-pill {
    font-size: 13px;
    padding: 3px 6px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }
  html.is-kiosk .pill-time  { float: none; grid-column: 1; grid-row: 1; font-size: 11px; opacity: 0.75; line-height: 1.3; margin: 0; }
  html.is-kiosk .pill-end   { float: none; grid-column: 2; grid-row: 1; font-size: 11px; opacity: 0.75; line-height: 1.3; text-align: right; font-weight: 600; margin: 0; }
  html.is-kiosk .pill-title { grid-column: 1 / -1; grid-row: 2; white-space: normal; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
  html.is-kiosk .cal-event-more { font-size: 11px; }

  /* Multiday bars — match pill text sizes exactly */
  html.is-kiosk .multiday-bar             { font-size: 12px; }
  html.is-kiosk .multiday-bar .bar-title  { font-size: 12px; }
  html.is-kiosk .multiday-bar .bar-time   { font-size: 11px; }
  html.is-kiosk .multiday-bar .bar-end-time { font-size: 11px; }

  /* Bottom section: taller default; separate localStorage key (bottomPaneH_kiosk) */
  html.is-kiosk #bottom-section { height: 380px; }

  /* Tabs + panel titles */
  html.is-kiosk .bottom-tab           { font-size: 15px; padding: 10px 15px; }
  html.is-kiosk .bottom-tab .tab-icon { font-size: 22px; }
  html.is-kiosk .panel-title          { font-size: 20px; }

  /* Multi-day overlay bars */
  .cal-grid-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
  }
  .multiday-bar {
    position: absolute;
    font-size: 8.5px;
    font-weight: 600;
    overflow: hidden;
    pointer-events: auto;
    cursor: pointer;
    display: flex;
    align-items: baseline;
    gap: 3px;
    padding: 0 5px;
    opacity: 0.88;
  }
  .multiday-bar .bar-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
  .multiday-bar .bar-time {
    flex-shrink: 0;
    opacity: 0.8;
    font-size: 0.94em;  /* scales with container: 8px@8.5px, ~9px@9.5px */
  }
  .multiday-bar .bar-end-time {
    flex-shrink: 0;
    opacity: 0.75;
    font-size: 0.94em;  /* scales with container */
    margin-left: auto;
    padding-left: 3px;
  }
  .multiday-bar:hover { opacity: 1; }
  /* Match pill container size on touch devices; kiosk stays at base 8.5px */
  @media (hover: none) and (max-width: 1799px) { .multiday-bar { font-size: 9.5px; } }

  .cal-event-more {
    font-size: 9px;
    color: var(--text3);
    padding-left: 4px;
  }

  /* ── BOTTOM PANELS ─────────────────────────────────────── */
  #resize-handle {
    flex: 0 0 44px;
    display: flex; align-items: center; justify-content: center;
    cursor: ns-resize;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    touch-action: none;
    user-select: none;
  }
  #resize-handle:hover .resize-pip,
  #resize-handle.dragging .resize-pip { background: var(--accent); }
  .resize-pip {
    width: 56px; height: 6px;
    border-radius: 3px;
    background: var(--text3);
    transition: background 0.2s;
  }

  #bottom-section {
    flex: 0 0 auto;
    height: 240px;
    background: var(--bg2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* Presets + split controls — sticky to bottom of the tab sidebar scroll area
     so they stay visible even when tabs overflow the panel height */
  .tab-controls {
    position: sticky;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 0;
    gap: 2px;
    border-top: 1px solid var(--border);
    background: var(--bg2);  /* cover scrolled tab content behind it */
    z-index: 1;
  }

  #bottom-presets-btn, #bottom-split-btn {
    width: 44px;
    height: 28px;
    background: none;
    border: none;
    color: var(--text3);
    font-size: 16px;
    cursor: pointer;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: auto;
    transition: color 0.15s, background 0.15s;
  }
  #bottom-presets-btn:hover, #bottom-split-btn:hover { color: var(--accent); background: var(--bg3); }
  #bottom-split-btn.active { color: var(--accent); }

  /* Presets floating menu */
  body.osk-active #layouts-menu {
    bottom: calc(var(--osk-h, 260px) + 8px) !important;
  }
  #layouts-menu {
    position: fixed;
    z-index: 1000;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
    min-width: 220px;
    max-width: 300px;
    overflow: hidden;
  }

  .layouts-empty {
    padding: 12px 16px;
    font-size: 12px;
    color: var(--text3);
    text-align: center;
  }

  .layouts-item {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
  }
  .layouts-item:last-child { border-bottom: none; }

  .layouts-load-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text1);
    font-size: 13px;
    padding: 12px 16px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
  }
  .layouts-load-btn:hover { background: var(--bg3); }

  .layouts-default-mark {
    font-size: 11px;
    color: var(--yellow);
    margin-left: 4px;
  }

  /* Columns wrapper (row layout within the section) */
  #bottom-columns {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
  }

  .bottom-col {
    display: flex;
    flex-direction: row;
    overflow: hidden;
    min-width: 0;
    flex: 1 1 0;
  }

  /* Vertical drag divider between left and right columns */
  #bottom-divider {
    flex-shrink: 0;
    width: 5px;
    background: var(--border);
    cursor: ew-resize;
    touch-action: none;
    display: none;
    transition: background 0.15s;
  }
  #bottom-divider:hover, #bottom-divider.dragging { background: var(--accent); }

  /* Right column — hidden until split mode */
  #bottom-right { display: none; }

  /* Tab nav on left edge — shared by both columns */
  #bottom-tabs, #bottom-right-tabs {
    display: flex; flex-direction: column;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    width: 52px;
    padding: 8px 0;
    gap: 2px;
    justify-content: flex-start;
    overflow-y: auto;
  }

  .bottom-tab {
    width: 52px; height: 52px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    cursor: pointer;
    border-right: 2px solid transparent;
    transition: all 0.2s;
    gap: 3px;
    font-size: 9px; color: var(--text3);
    font-weight: 500;
    letter-spacing: 0.3px;
  }
  .bottom-tab .tab-icon { font-size: 18px; }
  .bottom-tab.active {
    color: var(--accent);
    border-right-color: var(--accent);
    background: rgba(124,158,248,0.06);
  }
  .bottom-tab:hover:not(.active) { color: var(--text2); background: var(--bg3); }

  #bottom-content, #bottom-right-content {
    flex: 1;
    overflow: hidden;
    position: relative;
  }

  .bottom-panel {
    position: absolute; inset: 0;
    padding: 14px 20px;
    overflow-y: auto;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
    display: flex; flex-direction: column; gap: 8px;
  }
  .bottom-panel.active { opacity: 1; pointer-events: all; }

  /* Panel column-move button (shown in split mode) and order buttons (always) */
  .panel-move-btn, .panel-order-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text3);
    font-size: 11px;
    cursor: pointer;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 1px;
    line-height: 1;
    touch-action: auto;
    transition: color 0.15s, background 0.15s;
  }
  .panel-move-btn { display: none; } /* override to hidden; JS shows it in split mode */
  .panel-move-btn:hover, .panel-order-btn:hover { color: var(--accent); background: var(--bg3); }

  .panel-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text3);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .panel-loading {
    color: var(--text3);
    font-size: 13px;
    padding: 16px 0;
    text-align: center;
    animation: panel-loading-pulse 1.4s ease-in-out infinite;
  }
  @keyframes panel-loading-pulse {
    0%, 100% { opacity: 0.4; }
    50%       { opacity: 1;   }
  }
  .panel-title-actions {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
  }

  /* Chores panel */
  .person-group { display: flex; flex-direction: column; gap: 4px; }
  .person-label {
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.5px;
    margin-top: 4px;
    display: flex; align-items: center; gap: 5px;
    color: var(--text2);
  }
  .person-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  }
  .chore-row {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 12px;
    background: var(--bg3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
  }
  .chore-row:hover { border-color: rgba(255,255,255,0.1); }
  .chore-row.done { opacity: 0.4; }
  .chore-row.done .chore-name { text-decoration: line-through; }
  .chore-check {
    width: 32px; height: 32px; border-radius: 6px;
    border: 1.5px solid var(--text3);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0;
    transition: all 0.2s;
    /* Larger touch target so tapping the checkbox doesn't accidentally open the edit modal */
  }
  .chore-row.done .chore-check {
    background: var(--green); border-color: var(--green); color: var(--bg);
  }
  /* Undo state: yellow checkbox during 60s grace period after completing */
  .chore-check.undo {
    background: var(--yellow, #e6a817); border-color: var(--yellow, #e6a817); color: var(--bg);
  }
  .chore-name { font-size: 13px; flex: 1; }

  /* Add-chore collapsible form */
  .chore-form-wrap {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4,0,0.2,1), opacity 0.25s;
    opacity: 0;
    pointer-events: none;
  }
  .chore-form-wrap.open {
    max-height: 200px;
    opacity: 1;
    pointer-events: all;
  }
  .chore-form-inner {
    display: flex; flex-direction: column; gap: 8px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 10px;
  }
  .chore-form-row {
    display: flex; gap: 8px; align-items: center;
  }
  .chore-input {
    height: 36px;
    flex: 1;
    min-width: 0;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    padding: 0 10px;
    outline: none;
    -webkit-appearance: none;
  }
  .chore-input:focus { border-color: var(--accent); }
  .chore-submit-btn {
    height: 36px; padding: 0 16px;
    background: var(--accent); color: #fff;
    border: none; border-radius: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px; font-weight: 600;
    cursor: pointer; transition: opacity 0.15s;
  }
  .chore-submit-btn:hover { opacity: 0.85; }
  .chore-cancel-btn {
    height: 36px; padding: 0 12px;
    background: var(--bg2); color: var(--text2);
    border: 1px solid var(--border); border-radius: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px; cursor: pointer;
  }
  .chore-cancel-btn:hover { color: var(--text); border-color: rgba(255,255,255,0.12); }

  /* Meals panel */
  .meal-row {
    display: flex; align-items: center; gap: 12px;
    padding: 7px 12px;
    background: var(--bg3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer; transition: border-color 0.15s;
  }
  .meal-row:hover { border-color: rgba(255,255,255,0.15); }
  .meal-day { font-size: 11px; font-weight: 600; color: var(--text3); width: 28px; flex-shrink: 0; }
  .meal-name { font-size: 13px; flex: 1; }
  .meal-tag {
    font-size: 10px; padding: 2px 8px; border-radius: 20px;
    background: rgba(110,203,138,0.15); color: var(--green);
    font-weight: 500;
  }
  .meal-edit-btn {
    width: 22px; height: 22px; border-radius: 50%; border: none;
    background: transparent; color: var(--text3); font-size: 13px;
    cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
  }
  .meal-edit-btn:hover { background: var(--border); color: var(--text); }
  .meal-add-row {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border);
    cursor: pointer; transition: all 0.15s;
    margin-top: 2px;
  }
  .meal-add-row:hover { border-color: var(--accent); color: var(--accent); }
  .meal-add-row span { font-size: 12px; color: var(--text3); }
  .meal-add-row:hover span { color: var(--accent); }

  /* Meal edit modal */
  #meal-edit-overlay {
    position: fixed; inset: 0; z-index: 1500;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.2s;
  }
  #meal-edit-overlay.open { opacity: 1; pointer-events: all; }
  #meal-edit-dialog {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
    width: min(380px, 90vw);
    display: flex; flex-direction: column; gap: 16px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
    transform: scale(0.95); transition: transform 0.2s;
  }
  #meal-edit-overlay.open #meal-edit-dialog { transform: scale(1); }
  .med-title { font-size: 16px; font-weight: 600; }
  .med-types { display: flex; gap: 6px; flex-wrap: wrap; }
  .med-type {
    padding: 6px 14px; border-radius: 20px;
    border: 1.5px solid var(--border); font-size: 12px;
    cursor: pointer; transition: all 0.15s; background: var(--bg3);
  }
  .med-type.active { border-color: var(--accent); background: rgba(99,179,237,0.15); color: var(--accent); }
  .med-input {
    padding: 10px 14px; background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); font-size: 15px; outline: none;
  }
  .med-input:focus { border-color: var(--accent); }
  .med-actions { display: flex; gap: 8px; }
  .med-save { flex: 1; padding: 11px; background: var(--accent); color: white; border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; }
  .med-save:active { opacity: 0.8; }
  .med-del { padding: 11px 16px; background: rgba(255,80,80,0.15); color: var(--red); border: none; border-radius: var(--radius-sm); font-size: 14px; cursor: pointer; }
  .med-del:active { opacity: 0.8; }
  .med-cancel { padding: 11px 16px; background: var(--bg3); color: var(--text2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; cursor: pointer; }

  /* Shopping panel */
  .shop-add-row {
    display: flex; gap: 8px; margin-bottom: 8px;
  }
  .shop-add-input {
    flex: 1; padding: 8px 12px; font-size: 14px;
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    outline: none;
  }
  .shop-add-input:focus { border-color: var(--accent); }
  .shop-add-btn {
    padding: 8px 16px; background: var(--accent); color: white;
    border: none; border-radius: var(--radius-sm); font-size: 18px; font-weight: 600;
    cursor: pointer; flex-shrink: 0; line-height: 1;
  }
  .shop-add-btn:active { opacity: 0.8; }
  .shop-list-tab {
    padding: 4px 12px; font-size: 11px; font-weight: 600;
    border: 1.5px solid var(--border); border-radius: 20px;
    background: var(--bg3); color: var(--text2); cursor: pointer;
    transition: all 0.15s;
  }
  .shop-list-tab.active { border-color: var(--accent); background: rgba(99,179,237,0.12); color: var(--accent); }
  .shop-list-tab:hover:not(.active) { border-color: var(--text3); color: var(--text); }
  .shop-category { font-size: 10px; font-weight: 600; letter-spacing: 0.6px; color: var(--text3); text-transform: uppercase; margin-top: 4px; }
  .shop-item {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 12px;
    background: var(--bg3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
  }
  .shop-item:hover { border-color: rgba(255,255,255,0.1); }
  .shop-item.checked { opacity: 0.4; }
  .shop-item.checked .shop-item-name { text-decoration: line-through; }
  .shop-check {
    width: 16px; height: 16px; border-radius: 4px;
    border: 1.5px solid var(--text3); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 10px;
    transition: all 0.2s;
  }
  .shop-item.checked .shop-check { background: var(--accent); border-color: var(--accent); color: white; }
  .shop-item-name { font-size: 13px; flex: 1; }
  .shop-qty { font-size: 11px; color: var(--text3); }
  .shop-del {
    width: 24px; height: 24px; border-radius: 50%; border: none;
    background: transparent; color: var(--text3); font-size: 16px; line-height: 1;
    cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
  }
  .shop-del:hover, .shop-del:active { background: rgba(255,80,80,0.2); color: var(--red); }

  /* Weather detail panel */
  .weather-grid {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
  }
  .weather-card {
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 8px 6px;
    display: flex; flex-direction: column; gap: 3px; align-items: center;
    text-align: center; cursor: pointer; transition: border-color 0.15s, background 0.15s;
  }
  .weather-card:hover { border-color: var(--accent); background: var(--bg2); }
  .weather-card.today-card { border-color: var(--accent); }
  .weather-card-day { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
  .weather-card-date { font-size: 9px; color: var(--text3); }
  .weather-card-icon { font-size: 20px; }
  .weather-card-hi { font-size: 15px; font-weight: 600; }
  .weather-card-lo { font-size: 11px; color: var(--text3); }

  /* Hourly forecast overlay */
  #hourly-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center;
    z-index: 250;
  }
  #hourly-overlay.open { display: flex; }
  #hourly-modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px 28px;
    width: 520px;
    max-width: 92vw;
    max-height: 80vh;
    display: flex; flex-direction: column;
    box-shadow: 0 32px 80px rgba(0,0,0,0.5);
    animation: modal-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .hourly-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; flex-shrink: 0;
  }
  .hourly-title {
    font-family: 'DM Serif Display', serif;
    font-size: 20px;
  }
  .hourly-content {
    overflow-y: auto; flex: 1;
    display: flex; flex-direction: column; gap: 4px;
  }
  .hourly-row {
    display: grid; grid-template-columns: 70px 32px 1fr 50px 40px;
    align-items: center; gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg3);
  }
  .hourly-row.current-hour { background: var(--bg2); border: 1px solid var(--accent); }
  .hourly-time { font-size: 13px; font-weight: 600; color: var(--text2); }
  .hourly-icon { font-size: 18px; text-align: center; }
  .hourly-desc { font-size: 12px; color: var(--text3); }
  .hourly-temp { font-size: 16px; font-weight: 600; text-align: right; }
  .hourly-precip { font-size: 11px; color: #56B4E9; text-align: right; }
  .hourly-precip:empty { visibility: hidden; }

  /* ── WEATHER POP-OUT OVERLAY ────────────────────────────── */
  #weather-popout-overlay {
    position: fixed; inset: 0; z-index: 280;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center;
  }
  #weather-popout-overlay.open { display: flex; }
  #weather-popout-modal {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 20px; width: 95vw; max-width: 900px; max-height: 88vh;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 32px 80px rgba(0,0,0,0.5);
    animation: modal-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .wp-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; flex-shrink: 0; border-bottom: 1px solid var(--border);
  }
  .wp-title { font-family: 'DM Serif Display', serif; font-size: 20px; }
  .wp-day-strip {
    display: flex; overflow-x: auto; gap: 6px; padding: 10px 16px;
    border-bottom: 1px solid var(--border); flex-shrink: 0;
    scrollbar-width: none;
  }
  .wp-day-strip::-webkit-scrollbar { display: none; }
  .wp-day-chip {
    flex: 0 0 auto; display: flex; flex-direction: column; align-items: center;
    gap: 2px; padding: 8px 12px; border-radius: 12px; cursor: pointer;
    border: 1px solid transparent; transition: background 0.15s;
    min-width: 60px;
  }
  .wp-day-chip:hover { background: var(--bg3); }
  .wp-day-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
  .wp-day-chip.active .wp-chip-lo { color: rgba(255,255,255,0.7) !important; }
  .wp-chip-icon { font-size: 22px; }
  .wp-chip-day { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
  .wp-chip-date { font-size: 10px; color: var(--text3); }
  .wp-chip-hi { font-size: 13px; font-weight: 600; }
  .wp-chip-lo { font-size: 12px; }
  .wp-day-summary {
    display: flex; flex-wrap: wrap; gap: 10px 20px;
    padding: 10px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0;
  }
  .wp-sum-item { display: flex; align-items: center; gap: 5px; font-size: 13px; }
  .wp-sum-icon { font-size: 20px; }
  .wp-sum-lbl { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .04em; }
  .wp-hourly { overflow-y: auto; flex: 1; padding: 6px 12px; }
  .wp-hourly-row {
    display: grid;
    grid-template-columns: 62px 24px 1fr 42px 42px 56px 60px 44px;
    align-items: center; gap: 6px; padding: 7px 8px;
    border-radius: var(--radius-sm); font-size: 12px;
  }
  .wp-hourly-row:nth-child(even) { background: var(--bg3); }
  .wp-hourly-row.current-hour { background: rgba(30,100,220,0.15); border: 1px solid var(--accent); border-radius: 6px; }
  .wp-hr-time { font-size: 12px; font-weight: 600; color: var(--text2); }
  .wp-hr-icon { font-size: 16px; text-align: center; }
  .wp-hr-desc { font-size: 11px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .wp-hr-temp { font-size: 14px; font-weight: 600; text-align: right; }
  .wp-hr-feels { font-size: 11px; color: var(--text3); text-align: right; }
  .wp-hr-precip { font-size: 11px; color: #56B4E9; text-align: right; }
  .wp-hr-wind { font-size: 11px; color: var(--text3); text-align: right; }
  .wp-hr-humid { font-size: 11px; color: var(--text3); text-align: right; }

  /* ── TOYOTA POP-OUT OVERLAY ─────────────────────────────── */
  #toyota-popout-overlay {
    position: fixed; inset: 0; z-index: 280;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center;
  }
  #toyota-popout-overlay.open { display: flex; }
  #toyota-popout-modal {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 20px; width: 95vw; max-width: 600px; max-height: 88vh;
    overflow-y: auto; padding: 20px 24px;
    box-shadow: 0 32px 80px rgba(0,0,0,0.5);
    animation: modal-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .tp-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 16px;
  }
  .tp-title { font-family: 'DM Serif Display', serif; font-size: 22px; }
  .tp-vin { font-size: 11px; color: var(--text3); margin-top: 2px; }
  .tp-section { margin-bottom: 18px; }
  .tp-section-title {
    font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
    color: var(--text3); margin-bottom: 8px; font-weight: 600;
  }
  .tp-badges { display: flex; gap: 8px; flex-wrap: wrap; }
  .tp-badge { padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 600; }
  .tp-actions { display: flex; flex-wrap: wrap; gap: 10px; }
  .tp-actions .toyota-btn { min-height: 52px; min-width: 88px; font-size: 15px; flex: 1; }
  .tp-tire-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .tp-tire-cell {
    background: var(--bg3); border-radius: 8px; padding: 10px;
    text-align: center; border: 1px solid var(--border);
  }
  .tp-tire-cell.tc-warn { border-color: var(--red); }
  .tp-tire-pos { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
  .tp-tire-psi { font-size: 20px; font-weight: 700; }
  .tp-detail-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px;
  }
  .tp-detail-row:last-child { border-bottom: none; }
  .tp-detail-lbl { color: var(--text3); }
  .tp-caution-item { font-size: 13px; padding: 4px 0; color: var(--yellow); }
  .tp-charge-time { font-size: 12px; color: var(--text3); margin-top: 4px; }
  .tp-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
  .tp-vehicle-title { margin-bottom: 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
  .tp-edit-car-btn { background: none; border: none; cursor: pointer; font-size: 16px; color: var(--text3); padding: 2px 4px; border-radius: 4px; line-height: 1; flex-shrink: 0; }
  .tp-edit-car-btn:hover { color: var(--text1); background: var(--bg3); }
  .tp-car-edit { border-top: 1px solid var(--border); margin-top: 4px; }
  .tp-vehicle-block + .tp-vehicle-block { margin-top: 4px; }
  .tp-map { width: 100%; height: 200px; border: none; border-radius: 10px; display: block; margin-bottom: 6px; }
  .tp-location-addr { font-size: 12px; color: var(--text3); }
  .tc-popout-btn {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 6px; padding: 4px 8px;
    font-size: 15px; color: var(--text2);
    cursor: pointer; font-family: inherit;
    transition: color 0.15s, background 0.15s;
  }
  .tc-popout-btn:hover { color: var(--accent); background: var(--bg3); }

  /* ── MAP POP-OUT OVERLAY ──────────────────────────────── */
  #map-popout-overlay {
    position: fixed; inset: 0; z-index: 280;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center;
  }
  #map-popout-overlay.open { display: flex; }
  #map-popout-modal {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 20px; width: 96vw; max-width: 1400px;
    min-height: 60vh; max-height: 92vh;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 32px 80px rgba(0,0,0,0.5);
    animation: modal-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .mp-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
  }
  .mp-title { font-weight: 600; font-size: 15px; }
  .mp-header-actions { display: flex; align-items: center; gap: 8px; }
  .mp-reset-btn {
    background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
    color: var(--text2); font-size: 12px; padding: 4px 10px; cursor: pointer;
    font-family: 'DM Sans', sans-serif; transition: color 0.15s, background 0.15s;
  }
  .mp-reset-btn:hover { color: var(--accent); background: var(--bg2); }

  /* Side-by-side layout: sidebar left, map right */
  .mp-body {
    display: flex; flex: 1; overflow: hidden; min-height: 0;
  }
  #map-popout-sidebar {
    width: 240px; flex-shrink: 0; overflow-y: auto;
    border-right: 1px solid var(--border); padding: 10px 12px;
    display: flex; flex-direction: column; gap: 2px;
  }
  #map-popout-map { flex: 1; min-width: 0; }

  /* Sidebar rows */
  .mp-section-title {
    font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
    color: var(--text3); font-weight: 600; padding: 8px 0 4px;
  }
  .mp-section-title:first-child { padding-top: 2px; }
  .mp-sidebar-row {
    display: flex; align-items: flex-start; gap: 8px; padding: 6px 4px;
    border-radius: 8px;
  }
  .mp-sidebar-clickable { cursor: pointer; }
  .mp-sidebar-clickable:hover { background: var(--bg3); }

  /* Time pill — mirrors the map marker badge */
  .mp-sidebar-pill {
    flex-shrink: 0; color: #fff; font-size: 9px; font-weight: 700;
    padding: 2px 6px; border-radius: 10px; margin-top: 2px;
    white-space: nowrap; min-width: 24px; text-align: center;
  }
  /* Person circle — mirrors the map marker circle */
  .mp-sidebar-circle {
    flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 700; color: #fff; margin-top: 1px;
  }
  .mp-sidebar-icon { flex-shrink: 0; font-size: 16px; line-height: 1; margin-top: 2px; }

  .mp-sidebar-info { flex: 1; min-width: 0; }
  .mp-sidebar-name { font-size: 12px; font-weight: 600; line-height: 1.3; }
  .mp-sidebar-sub { font-size: 11px; color: var(--text3); margin-top: 1px; }
  .mp-sidebar-age { font-size: 10px; color: var(--text3); font-weight: 400; }
  .mp-sidebar-person { font-size: 10px; color: var(--text3); font-weight: 400; }

  @media (max-width: 640px) {
    #map-popout-overlay { align-items: flex-end; }
    #map-popout-modal {
      width: 100%; max-width: 100%;
      border-radius: 20px 20px 0 0; max-height: 90vh;
    }
    /* Stack: map on top, sidebar scrolls below */
    .mp-body { flex-direction: column; }
    #map-popout-sidebar {
      width: auto; max-height: 180px;
      border-right: none; border-top: 1px solid var(--border);
      flex-direction: row; flex-wrap: wrap; overflow-x: auto; overflow-y: hidden;
      padding: 8px 12px;
    }
    #map-popout-map { height: 280px; flex-shrink: 0; }
  }

  /* ── ADD EVENT MODAL ────────────────────────────────────── */
  #modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center;
    z-index: 200;
  }
  #modal-overlay.open { display: flex; }

  #modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px 32px;
    width: 1000px;
    max-width: 98vw;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 32px 80px rgba(0,0,0,0.5);
    animation: modal-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .modal-body {
    display: flex;
    gap: 0;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  .modal-left {
    flex: 0 0 420px;
    border-right: 1px solid var(--border);
    padding-right: 20px;
    margin-right: 20px;
    overflow-y: auto;
  }
  .modal-right {
    flex: 1;
    overflow-y: auto;
  }
  @keyframes modal-in { from { transform: scale(0.92) translateY(10px); opacity: 0; } }

  #modal h2 {
    font-family: 'DM Serif Display', serif;
    font-size: 22px; margin-bottom: 20px;
  }

  .modal-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
  .modal-field label { font-size: 11px; font-weight: 600; letter-spacing: 0.5px; color: var(--text3); text-transform: uppercase; }
  .modal-field input, .modal-field select {
    padding: 10px 14px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    outline: none;
    transition: border-color 0.2s;
  }
  .modal-field input:focus, .modal-field select:focus, .modal-field textarea:focus { border-color: var(--accent); }
  .modal-field textarea {
    padding: 10px 14px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    outline: none;
    transition: border-color 0.2s;
    resize: vertical;
    min-height: 72px;
  }
  /* PlaceAutocompleteElement inside modal */
  .modal-field gmp-place-autocomplete { display: block; width: 100%; color-scheme: light; }
  .modal-field gmp-place-autocomplete::part(input) {
    padding: 10px 14px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    outline: none;
    width: 100%;
    box-sizing: border-box;
  }
  .modal-field gmp-place-autocomplete:focus-within::part(input) { border-color: var(--accent); }

  .modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .modal-row-dates { grid-template-columns: 1fr 1fr auto; align-items: start; }

  /* Recurrence day picker */
  .modal-day-picker-row {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 14px;
  }
  .modal-day-label { font-size: 11px; font-weight: 600; letter-spacing: 0.5px; color: var(--text3); text-transform: uppercase; white-space: nowrap; }
  .modal-day-picker { display: flex; gap: 6px; flex-wrap: wrap; }
  .day-cb {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 10px; font-weight: 600; color: var(--text3);
    cursor: pointer; user-select: none;
  }
  .day-cb input[type=checkbox] {
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    accent-color: var(--accent);
    margin: 0;
  }
  .day-cb:has(input:checked) { color: var(--accent); }

  /* Recurrence scope radio */
  .modal-scope-btns { display: flex; flex-direction: column; gap: 8px; }
  .scope-opt {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--text2); cursor: pointer;
    padding: 8px 12px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s;
  }
  .scope-opt:has(input:checked) { border-color: var(--accent); color: var(--text); }
  .scope-opt input { accent-color: var(--accent); cursor: pointer; }

  .modal-actions { display: flex; gap: 10px; margin-top: 20px; }
  .btn {
    flex: 1; padding: 11px;
    border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'DM Sans', sans-serif;
    border: none;
  }
  .btn-primary { background: var(--accent); color: white; }
  .btn-primary:hover { filter: brightness(1.1); }
  .btn-secondary { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
  .btn-secondary:hover { background: var(--border); color: var(--text); }

  /* person color pills selector */
  .color-selector { display: flex; gap: 8px; flex-wrap: wrap; }
  .color-opt {
    width: 28px; height: 28px; border-radius: 50%;
    cursor: pointer; border: 2px solid transparent;
    transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; color: white; font-weight: 700;
    position: relative; flex-shrink: 0; user-select: none;
  }
  .color-opt.selected {
    border-color: white;
    box-shadow: 0 0 0 2px white, 0 0 0 4px rgba(0,0,0,0.4);
    transform: scale(1.18);
  }
  .color-opt.selected::after {
    content: '✓';
    position: absolute; inset: 0; border-radius: 50%;
    background: rgba(0,0,0,0.32);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 900; color: white;
    pointer-events: none;
  }

  /* scrollbar */
  ::-webkit-scrollbar { width: 4px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 2px; }

  /* ── LOCK BUTTON ───────────────────────────────────────── */
  #lock-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--bg3);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 17px;
    transition: all 0.2s;
    user-select: none;
  }
  #lock-btn:hover { background: var(--border); }
  body.locked #lock-btn { background: rgba(255,200,0,0.12); border-color: rgba(255,200,0,0.3); }

  /* ── READ-ONLY (locked) state ───────────────────────────── */
  body.locked [data-edit] { display: none !important; }
  body.locked .cal-cell   { pointer-events: none; cursor: default; }
  /* Keep nav buttons interactive when locked */
  body.locked .cal-nav-btn,
  body.locked #cal-today-btn,
  body.locked .cal-view-btn { pointer-events: auto !important; cursor: pointer !important; }
  body.locked .chore-row  { pointer-events: none; }
  body.locked .meal-row   { pointer-events: none; cursor: default; }
  body.locked .shop-check,
  body.locked .shop-item-name { pointer-events: none; cursor: default; }
  body.locked .toyota-actions { display: none; }
  body.locked #toyota-connect-btn,
  body.locked #toyota-otp-btn,
  body.locked #toyota-otp-input { pointer-events: none; opacity: 0.4; cursor: default; }

  /* ── LOCK MODAL ─────────────────────────────────────────── */
  #lock-modal {
    display: none;
    position: fixed; inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,0.65);
    align-items: center; justify-content: center;
  }
  #lock-modal.open { display: flex; }

  #lock-modal-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 36px 32px 28px;
    width: 300px;
    text-align: center;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  }
  .lock-modal-title { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
  .lock-modal-sub   { font-size: 13px; color: var(--text3); margin: 0 0 20px; }

  .lock-pin-input {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text1);
    font-size: 28px;
    text-align: center;
    letter-spacing: 10px;
    padding: 12px 16px;
    outline: none;
    margin-bottom: 20px;
    transition: border-color 0.15s;
  }
  .lock-pin-input:focus { border-color: var(--accent); }

  .lock-modal-btns { display: flex; gap: 10px; }
  .lock-cancel-btn, .lock-submit-btn {
    flex: 1; padding: 12px; border-radius: 10px; border: none;
    font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity 0.15s;
  }
  .lock-cancel-btn { background: var(--bg3); color: var(--text2); }
  .lock-submit-btn { background: var(--accent); color: #fff; }
  .lock-cancel-btn:hover { background: var(--border); }
  .lock-submit-btn:hover { opacity: 0.85; }

  @keyframes shake {
    0%,100% { transform: translateX(0); }
    20%      { transform: translateX(-10px); }
    40%      { transform: translateX(10px); }
    60%      { transform: translateX(-7px); }
    80%      { transform: translateX(7px); }
  }
  #lock-modal-card.shake { animation: shake 0.4s ease; }

  /* ── ADMIN BUTTON ──────────────────────────────────────── */
  #admin-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--bg3);
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px;
    transition: all 0.2s;
    color: var(--text3);
  }
  #admin-btn:hover { background: var(--border); color: var(--text); transform: rotate(30deg); }

  #ai-import-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--bg3);
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--text3);
    transition: all 0.2s;
    user-select: none;
  }
  #ai-import-btn:hover { background: var(--border); color: var(--text); transform: scale(1.05); }
  #ai-pending-badge {
    position: absolute; top: -4px; right: -4px;
    min-width: 16px; height: 16px; padding: 0 4px;
    background: #e55; color: #fff;
    border-radius: 8px; border: 2px solid var(--bg);
    font-size: 10px; font-weight: 700; line-height: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    pointer-events: none;
  }

  /* ── EMBED OVERLAY (iframe popup) ──────────────────────── */
  #embed-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 280;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
  }
  #embed-overlay.open { display: flex; }
  #embed-sheet {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%; height: 100%;
    max-width: 1400px;
    display: flex; flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  }
  #embed-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  #embed-title {
    font-size: 13px; font-weight: 600; color: var(--text2);
    letter-spacing: 0.4px;
  }
  #embed-close-btn, #embed-popout-btn {
    background: none; border: none; color: var(--text3);
    font-size: 18px; cursor: pointer; padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
  }
  #embed-close-btn:hover, #embed-popout-btn:hover { color: var(--text); background: var(--bg3); }
  #embed-header > span { flex: 1; }
  #embed-popout-btn { font-size: 16px; margin-right: 2px; }
  #embed-frame {
    flex: 1 1 0; border: none; width: 100%;
    background: #fff;
  }

  /* ── Panel title link button ─────────────────────────── */
  .panel-link-btn {
    display: inline-flex; align-items: center; justify-content: center;
    background: none; border: none;
    color: var(--text3);
    font-size: 11px; cursor: pointer;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 4px;
    vertical-align: middle;
    transition: color 0.15s, background 0.15s;
  }
  .panel-link-btn:hover { color: var(--accent); background: var(--bg3); }

  .panel-refresh-btn {
    display: inline-flex; align-items: center; justify-content: center;
    background: none; border: none;
    color: var(--text3);
    font-size: 14px; cursor: pointer;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 4px;
    vertical-align: middle;
    transition: color 0.15s, background 0.15s;
  }
  .panel-refresh-btn:hover { color: var(--accent); background: var(--bg3); }
  .panel-refresh-btn.spinning { animation: spin 1s linear infinite; color: var(--accent); pointer-events: none; }

  @keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
  }

  /* ── ADMIN OVERLAY ──────────────────────────────────────── */
  #admin-overlay {
    position: fixed; inset: 0;
    background: var(--bg);
    z-index: 300;
    display: none;
    flex-direction: column;
    overflow: hidden;
  }
  #admin-overlay.open { display: flex; }

  /* PIN view */
  #admin-pin-view {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 20px;
    padding: 40px 20px;
  }
  #admin-settings-view {
    flex: 1;
    min-height: 0;
    display: none;
    flex-direction: column;
    overflow: hidden;
  }
  #admin-settings-view.visible { display: flex; }

  .admin-logo {
    font-family: 'DM Serif Display', serif;
    font-size: 24px;
    color: var(--text2);
    letter-spacing: -0.3px;
    margin-bottom: 8px;
  }

  .pin-dots {
    display: flex; gap: 18px;
  }
  .pin-dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border);
    transition: all 0.15s cubic-bezier(0.34,1.56,0.64,1);
  }
  .pin-dot.filled {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(124,158,248,0.5);
    transform: scale(1.15);
  }
  .pin-dot.err { background: var(--red); border-color: var(--red); box-shadow: 0 0 10px rgba(240,112,112,0.5); }

  .pin-label {
    font-size: 13px;
    color: var(--text3);
    letter-spacing: 0.3px;
    height: 18px;
    transition: color 0.2s;
  }
  .pin-label.err { color: var(--red); }

  .pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 88px);
    gap: 14px;
  }
  .pin-btn {
    width: 88px; height: 88px;
    border-radius: 50%;
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 26px; font-weight: 400;
    font-family: 'DM Serif Display', serif;
    cursor: pointer;
    transition: background 0.1s, transform 0.1s, box-shadow 0.1s;
    display: flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent;
  }
  .pin-btn:active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    transform: scale(0.9);
    box-shadow: 0 0 20px rgba(124,158,248,0.35);
  }
  .pin-btn.pin-action {
    background: var(--bg3);
    font-family: 'DM Sans', sans-serif;
    font-size: 18px;
    color: var(--text2);
  }
  .pin-btn.pin-action:active { background: var(--bg3); border-color: var(--border); color: var(--text); box-shadow: none; transform: scale(0.93); }

  @keyframes pin-shake {
    0%,100% { transform: translateX(0); }
    15%     { transform: translateX(-10px); }
    30%     { transform: translateX(10px); }
    45%     { transform: translateX(-7px); }
    60%     { transform: translateX(7px); }
    75%     { transform: translateX(-4px); }
    90%     { transform: translateX(4px); }
  }
  #pin-dots.shake { animation: pin-shake 0.45s ease; }

  /* Settings form */
  .admin-header {
    display: flex; align-items: center; gap: 16px;
    padding: 16px 24px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .admin-close-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text2);
    font-size: 16px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
  }
  .admin-close-btn:hover { background: var(--border); color: var(--text); }
  .admin-title {
    font-family: 'DM Serif Display', serif;
    font-size: 22px;
    flex: 1;
  }
  .admin-save-btn {
    padding: 10px 22px;
    background: var(--accent);
    border: none;
    border-radius: 40px;
    color: white;
    font-size: 13px; font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
  }
  .admin-save-btn:hover { filter: brightness(1.12); }
  .admin-save-btn:disabled { opacity: 0.5; cursor: default; filter: none; }

  .hard-refresh-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text2);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
  }
  .hard-refresh-btn:hover { background: var(--border); color: var(--text); }
  .hard-refresh-btn:active { transform: scale(0.92); }

  .admin-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex; flex-direction: column; gap: 14px;
  }

  .admin-section {
    flex-shrink: 0;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: visible;
  }
  .admin-section-title {
    padding: 12px 18px;
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.8px; text-transform: uppercase;
    color: var(--text3);
    background: var(--bg3);
    border-bottom: 1px solid var(--border);
    cursor: pointer; user-select: none;
    display: flex; justify-content: space-between; align-items: center;
    transition: color 0.15s;
  }
  .admin-section-title:hover { color: var(--text2); }
  .admin-section-title::after {
    content: '▸';
    font-size: 13px; font-weight: 400;
    color: var(--text3); flex-shrink: 0;
    transition: transform 0.2s;
  }
  .admin-section--open .admin-section-title::after { content: '▾'; }
  .admin-section--open .admin-section-title { border-bottom: 1px solid var(--border); }
  .admin-section:not(.admin-section--open) .admin-section-title { border-bottom: none; }
  .admin-section:not(.admin-section--open) .admin-fields { display: none; }
  .admin-fields {
    padding: 16px 18px;
    display: flex; flex-direction: column; gap: 12px;
  }
  .admin-field-row { display: flex; gap: 12px; }
  .admin-field {
    display: flex; flex-direction: column; gap: 5px;
    flex: 1; min-width: 0;
  }
  .admin-field label {
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.5px; text-transform: uppercase;
    color: var(--text3);
  }
  .admin-field input {
    padding: 9px 12px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: 'DM Sans', sans-serif;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
  }
  .admin-field input:focus { border-color: var(--accent); }

  .admin-field-reveal {
    position: relative;
    display: flex; align-items: center;
  }
  .admin-field-reveal input { flex: 1; padding-right: 56px; }
  .reveal-toggle {
    position: absolute; right: 0;
    height: 100%;
    padding: 0 12px;
    background: none; border: none;
    color: var(--text3);
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.5px; text-transform: uppercase;
    cursor: pointer;
    transition: color 0.15s;
    font-family: 'DM Sans', sans-serif;
  }
  .reveal-toggle:hover { color: var(--accent); }

  /* Inline label note — smaller text alongside a label */
  .admin-field-label-note {
    font-size: 10px; font-weight: 400;
    color: var(--text3); text-transform: none; letter-spacing: 0;
    margin-left: 4px;
  }

  /* Sub-section header inside a larger section (e.g. Telegram sub-services) */
  .admin-subsection-title {
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.6px; text-transform: uppercase;
    color: var(--text3);
    margin-top: 8px; padding-top: 10px;
    border-top: 1px solid var(--border);
  }

  /* Status / result line below a section action */
  .admin-status-line {
    font-size: 12px; padding: 4px 2px; min-height: 18px;
    color: var(--text3);
  }

  /* Row of action buttons inside a section */
  .admin-action-row {
    display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px;
    align-items: center;
  }

  /* Hint paragraph below a field */
  .admin-field-hint {
    font-size: 10px; color: var(--text3); margin-top: 2px;
  }

  /* Discovery / scan result area */
  .admin-discover-result {
    font-size: 11px; color: var(--text3); margin-top: 4px; min-height: 16px;
  }

  /* PlaceAutocompleteElement (Places API New) — match admin input style */
  .admin-field gmp-place-autocomplete {
    display: block;
    width: 100%;
  }
  .admin-field gmp-place-autocomplete::part(input) {
    padding: 9px 12px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: 'DM Sans', sans-serif;
    outline: none;
    width: 100%;
    box-sizing: border-box;
  }
  .admin-field gmp-place-autocomplete:focus-within::part(input) { border-color: var(--accent); }

  /* Dynamic calendar row */
  .af-cal-row {
    display: flex; gap: 6px; align-items: center;
  }
  .af-cal-row .af-cal-name {
    flex: 0 0 100px;
  }
  .af-cal-row .af-cal-id {
    flex: 1;
  }
  .af-cal-del {
    width: 28px; height: 28px; flex-shrink: 0;
    border: none; border-radius: 50%;
    background: transparent; color: var(--text3);
    font-size: 18px; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
  }
  .af-cal-del:hover { background: rgba(255,80,80,0.2); color: var(--red); }

  /* Dynamic car row (model badge / nickname / colour picker) */
  .af-car-row {
    display: flex; gap: 6px; align-items: center; margin-bottom: 4px;
  }
  .af-car-model-badge {
    flex: 0 0 auto;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text2);
    white-space: nowrap;
  }
  .af-car-row .af-car-model {
    flex: 0 0 90px;
  }
  .af-car-row .af-car-nickname {
    flex: 1;
  }
  .af-car-row .af-car-color {
    flex: 0 0 38px; height: 36px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 2px; background: var(--bg2); cursor: pointer;
  }
  /* "Add vehicle" reuses af-add-btn class */
  .af-add-btn {
    margin-top: 6px; padding: 6px 14px;
    background: var(--bg3); border: 1px dashed var(--border);
    border-radius: var(--radius-sm); color: var(--text2);
    font-size: 12px; font-family: 'DM Sans', sans-serif;
    cursor: pointer; transition: all 0.2s; width: 100%;
  }
  .af-add-btn:hover { border-color: var(--accent); color: var(--accent); }

  /* ── Layout preset rows (admin panel) ─────────────────── */
  .af-preset-row {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    margin-bottom: 8px;
    background: var(--bg2);
  }
  .af-preset-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  }
  .af-preset-header .af-preset-name { flex: 1; }
  .af-preset-default-lbl {
    display: flex; align-items: center; gap: 4px;
    font-size: 11px; color: var(--text3); cursor: pointer;
    white-space: nowrap; padding: 4px 8px;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    transition: all 0.15s;
  }
  .af-preset-default-lbl.is-default {
    color: var(--yellow); border-color: var(--yellow);
  }
  .af-preset-default-lbl input { margin: 0; }

  /* ── Preset panel picker ───────────────────────────────── */
  .af-preset-panel-list {
    display: flex; flex-direction: column; gap: 3px; margin-top: 4px;
  }
  .af-preset-panel-row {
    display: flex; align-items: center; gap: 6px;
    background: var(--bg3); border-radius: var(--radius-sm);
    padding: 3px 6px; font-size: 12px;
  }
  .af-preset-move-btn {
    background: none; border: 1px solid var(--border); border-radius: 3px;
    color: var(--text2); font-size: 11px; padding: 0 4px; line-height: 1.6;
    cursor: pointer;
  }
  .af-preset-move-btn:hover { background: var(--bg4); }
  .af-preset-panel-icon { flex: 1; color: var(--text1); }
  .af-preset-right-lbl {
    display: flex; align-items: center; gap: 4px;
    font-size: 11px; color: var(--text3); cursor: pointer;
    white-space: nowrap;
  }
  .af-preset-right-lbl input { margin: 0; }

  .admin-test-btn {
    padding: 10px 18px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px; font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
  }
  .admin-test-btn:hover { border-color: var(--accent); color: var(--accent); }
  .admin-file-label { display: inline-block; }
  .test-result {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px; line-height: 1.5;
    background: var(--bg3);
    border: 1px solid var(--border);
    user-select: text;
  }
  .test-result .ti { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
  .test-result .td { color: var(--text2); user-select: text; word-break: break-all; }
  .test-result .td strong { color: var(--text); font-weight: 600; display: block; margin-bottom: 2px; user-select: text; }


  /* ── Modal event list ─────────────────────────────────── */
  .modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
  }
  .modal-header h2 { margin: 0; }
  .modal-close-btn {
    background: none; border: none;
    color: var(--text3); font-size: 18px; cursor: pointer;
    padding: 4px 8px; border-radius: var(--radius-sm);
    transition: color 0.15s;
    font-family: 'DM Sans', sans-serif;
  }
  .modal-close-btn:hover { color: var(--text); }

  #modal-event-list {
    display: flex; flex-direction: column; gap: 6px;
    margin-bottom: 4px;
  }
  .modal-evt-row {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 8px 10px;
    background: var(--bg3);
    border-radius: var(--radius-sm);
    border-left-width: 3px; border-left-style: solid;
  }
  .modal-evt-time {
    font-size: 11px; color: var(--text3); white-space: nowrap;
    padding-top: 1px; min-width: 80px;
  }
  .modal-evt-body { flex: 1; }
  .modal-evt-title { font-size: 13px; font-weight: 500; color: var(--text); }
  .modal-evt-loc { font-size: 11px; color: var(--text3); margin-top: 2px; }
  .modal-no-events { font-size: 12px; color: var(--text3); padding: 4px 0; }

  .modal-add-section { padding-top: 0; margin-top: 0; }
  .modal-add-label {
    font-size: 11px; font-weight: 600; letter-spacing: 0.5px;
    text-transform: uppercase; color: var(--text3); margin-bottom: 10px;
  }

  /* ── Toast notification ────────────────────────────────── */
  .cal-toast {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(12px);
    background: var(--bg2); border: 1px solid var(--border);
    color: var(--text); font-size: 13px; font-family: 'DM Sans', sans-serif;
    padding: 10px 20px; border-radius: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    opacity: 0; transition: opacity 0.3s, transform 0.3s;
    pointer-events: auto; user-select: text; cursor: text;
    z-index: 9999; white-space: nowrap;
  }
  .cal-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
  .cal-toast.warn { border-color: var(--yellow); color: var(--yellow); }

  /* ── Modal edit button on event rows ──────────────────── */
  .modal-evt-edit-btn {
    flex-shrink: 0; align-self: center;
    padding: 4px 10px;
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text2);
    font-size: 11px; font-weight: 600; font-family: 'DM Sans', sans-serif;
    cursor: pointer; transition: all 0.15s;
  }
  .modal-evt-edit-btn:hover { border-color: var(--accent); color: var(--accent); }

  /* ── Danger button ─────────────────────────────────────── */
  .btn-danger {
    background: rgba(220,60,60,0.15); border: 1px solid rgba(220,60,60,0.4);
    color: #e06060; border-radius: var(--radius-sm);
    padding: 10px 18px; font-size: 14px; font-weight: 500;
    font-family: 'DM Sans', sans-serif; cursor: pointer; transition: all 0.2s;
  }
  .btn-danger:hover { background: rgba(220,60,60,0.25); }

  /* ── All-day checkbox alignment ───────────────────────── */
  .modal-allday-field { flex: 0 0 auto; min-width: 64px; }


  /* ── Week / Day View ──────────────────────────────────── */
  #cal-week-view {
    flex: 1 1 0;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
  }

  /* Header + allday + grid all share the same column template */
  .wv-head, .wv-allday-row, .wv-grid {
    display: grid;
    grid-template-columns: 52px repeat(var(--wv-cols, 7), 1fr);
  }

  .wv-head {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
  }
  .wv-gutter { /* time-column spacer */ }

  .wv-day-hdr {
    padding: 6px 4px 8px;
    text-align: center;
    cursor: pointer;
    border-left: 1px solid var(--border);
    transition: background 0.15s;
  }
  .wv-day-hdr:hover { background: rgba(255,255,255,0.03); }
  .wv-day-hdr.wv-today { background: rgba(124,158,248,0.07); }
  .wv-day-hdr.wv-today .wv-dnum { color: var(--accent); }

  .wv-dow {
    display: block;
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.5px; text-transform: uppercase;
    color: var(--text3);
  }
  .wv-dnum {
    display: block;
    font-size: 26px;
    font-family: 'DM Serif Display', serif;
    color: var(--text); line-height: 1.1;
  }
  .wv-wx {
    display: block;
    font-size: 10px;
    color: var(--text2);
    margin-top: 1px;
    white-space: nowrap;
  }

  /* Meal blocks in the time grid */
  .wv-meal-block {
    position: absolute;
    right: 2px;
    width: 42%;
    border-radius: 0 4px 4px 0;
    padding: 2px 5px;
    overflow: hidden;
    z-index: 0;
    box-sizing: border-box;
    pointer-events: none;
  }
  .wv-meal-block-name {
    display: -webkit-box;
    font-size: 10px; font-weight: 600;
    color: var(--text);
    -webkit-line-clamp: 4; -webkit-box-orient: vertical;
    overflow: hidden; word-break: break-word;
  }

  /* Weather column — day view only */
  .wv-wx-col-hdr {
    padding: 6px 4px 8px;
    text-align: center;
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.5px; text-transform: uppercase;
    color: var(--text3);
    border-left: 1px solid var(--border);
  }
  .wv-weather-col {
    display: flex; flex-direction: column; height: auto;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    background: rgba(124,158,248,0.03);
  }
  .wv-wx-cell {
    flex: none; height: var(--wv-slot-h, 30px); box-sizing: border-box;
    display: flex; flex-direction: row;
    align-items: flex-start; justify-content: center;
    gap: 2px;
    padding-top: 2px;
    transform: translateY(-7px);
    overflow: hidden;
    white-space: nowrap;
  }
  .wv-wx-row { display: contents; }
  .wv-wx-half { flex: none; height: var(--wv-slot-h, 30px); }
  .wv-wx-icon { font-size: 13px; line-height: 1; flex-shrink: 0; }
  .wv-wx-temp {
    font-size: 10px; font-weight: 600;
    color: var(--text); line-height: 1; flex-shrink: 0;
  }
  .wv-wx-precip {
    font-size: 9px; color: var(--accent);
    line-height: 1; flex-shrink: 0;
  }

  /* All-day strip */
  .wv-allday-row {
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .wv-allday-lbl {
    font-size: 9px; letter-spacing: 0.3px;
    color: var(--text3); text-align: right;
    padding: 4px 6px 4px 0;
    align-self: center; text-transform: uppercase;
  }
  .wv-allday-cell {
    border-left: 1px solid var(--border);
    padding: 3px;
    display: flex; flex-direction: column; gap: 2px;
  }
  .wv-allday-pill {
    font-size: 11px; font-weight: 600;
    padding: 1px 6px; border-radius: 3px;
    color: #fff; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
    min-height: 14px;
  }

  /* Time grid — scrollable; height determined by fixed-px slots */
  .wv-scroll {
    flex: 1; min-height: 0;
    overflow-y: auto; overflow-x: hidden;
  }
  .wv-grid { height: auto; position: relative; }

  /* Time gutter */
  .wv-time-col {
    display: flex; flex-direction: column; height: auto;
    position: sticky; left: 0; z-index: 3;
    background: var(--bg2);
  }
  .wv-tlabel {
    flex: none; height: var(--wv-slot-h, 30px); box-sizing: border-box;
    display: flex; flex-direction: column;
    align-items: flex-end; justify-content: flex-start;
    padding: 2px 6px 0;
    font-size: 10px; color: var(--text3); letter-spacing: 0.2px;
    transform: translateY(-7px);
  }
  .wv-thalf {
    flex: none; height: var(--wv-slot-h, 30px);
    border-top: 1px solid rgba(255,255,255,0.04);
  }

  /* Day columns */
  .wv-day-col {
    display: flex; flex-direction: column; height: auto;
    position: relative;
    border-left: 1px solid var(--border);
  }
  .wv-slot {
    flex: none; height: var(--wv-slot-h, 30px);
    cursor: pointer; transition: background 0.1s;
    border-bottom: 1px solid rgba(255,255,255,0.04);
  }
  .wv-slot:nth-child(odd) { border-bottom-color: rgba(255,255,255,0.08); }
  .wv-slot:hover { background: rgba(255,255,255,0.04); }

  /* Event blocks */
  .wv-evt {
    position: absolute;
    border-radius: 6px;
    padding: 2px 6px;
    overflow: hidden; cursor: pointer;
    transition: filter 0.15s;
    z-index: 1; box-sizing: border-box;
  }
  .wv-evt:hover { filter: brightness(1.18); }
  .wv-evt-time {
    display: block; font-size: 9px; opacity: 0.8; white-space: nowrap;
  }
  .wv-evt-title {
    display: -webkit-box; font-size: 11px; font-weight: 600;
    line-height: 1.2; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
    overflow: hidden; word-break: break-word;
  }

  /* Current time indicator */
  .wv-now {
    position: absolute; left: 0; right: 0;
    height: 2px; background: var(--red);
    z-index: 2; pointer-events: none;
  }
  .wv-now-dot {
    position: absolute; left: -3px; top: -3px;
    width: 8px; height: 8px;
    border-radius: 50%; background: var(--red);
  }

  /* View toggle buttons */
  .cal-view-btns { display: flex; gap: 3px; }
  .cal-view-btn {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text2);
    font-family: 'DM Sans', sans-serif;
    font-size: 12px; font-weight: 500;
    padding: 5px 12px; border-radius: 8px;
    cursor: pointer; transition: all 0.15s;
  }
  .cal-view-btn.active {
    background: var(--accent); color: #fff; border-color: var(--accent);
  }
  .cal-view-btn:hover:not(.active) { background: var(--border); }

  /* ── On-screen keyboard ────────────────────────────────── */
  /* Push all fixed layers up when the OSK is open */
  body.osk-active #main {
    bottom: var(--osk-h, 260px);
  }
  body.osk-active #modal-overlay,
  body.osk-active #hourly-overlay,
  body.osk-active #embed-overlay,
  body.osk-active #meal-edit-overlay,
  body.osk-active #weather-popout-overlay,
  body.osk-active #toyota-popout-overlay,
  body.osk-active #map-popout-overlay,
  body.osk-active #lutron-popout-overlay {
    transform: translateY(calc(-0.5 * var(--osk-h, 260px)));
  }
  #main, #modal-overlay, #hourly-overlay, #embed-overlay, #meal-edit-overlay,
  #weather-popout-overlay, #toyota-popout-overlay, #map-popout-overlay, #lutron-popout-overlay {
    transition: top 0.2s ease, bottom 0.2s ease, transform 0.2s ease;
  }

  #osk {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    padding: 10px 8px 14px;
    /* Must sit above every modal backdrop (meal-edit=1500, lock=2000) so
       the on-screen keyboard isn't dimmed when a modal is open. */
    z-index: 2100;
    display: none;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
    touch-action: none;
    user-select: none;
  }
  #osk.osk-open { display: flex; }

  .osk-row {
    display: flex;
    justify-content: center;
    gap: 5px;
  }

  .osk-k {
    height: 52px;
    min-width: 52px;
    flex: 1;
    max-width: 80px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 16px;
    font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.1s, transform 0.08s;
    touch-action: manipulation;
  }
  .osk-k:active { background: var(--accent); color: #fff; transform: scale(0.93); }

  .osk-wide  { flex: 1.6; max-width: 120px; font-size: 14px; color: var(--text2); }
  .osk-space { flex: 5;   max-width: 400px; font-size: 13px; color: var(--text3); }
  .osk-close { background: rgba(240,112,112,0.12); border-color: rgba(240,112,112,0.25); color: var(--red); }
  .osk-close:active { background: var(--red); color: #fff; }

  /* ── Toyota Cars ────────────────────────────────────────── */
  #cars-content {
    /* flex: 1 0 auto lets #cars-content grow to fill leftover space in
       #panel-cars when the panel is taller than the cards' content
       (background reaches the bottom) AND lets it stay at content size
       when the cards are taller (panel scrolls vertically instead of
       clipping). flex: 1 + min-height: 0 previously clipped tall
       content because it allowed shrinking below content size. */
    flex: 1 0 auto;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  /* ── Map panel ─────────────────────────────────────────── */
  #map-jump-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
  }
  #map-jump-bar:empty { display: none; }
  .map-jump-btn {
    border: none;
    border-radius: 20px;
    padding: 5px 13px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    opacity: 0.88;
    transition: opacity 0.15s, transform 0.1s;
    font-family: inherit;
  }
  .map-jump-btn:hover  { opacity: 1; transform: scale(1.06); }
  .map-jump-btn:active { transform: scale(0.97); }
  .map-jump-all {
    background: var(--bg3) !important;
    color: var(--text2);
    border: 1px solid var(--border);
  }

  #map-content {
    flex: 1;
    min-height: 180px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg3);
    transition: opacity 0.3s;
  }
  #map-content.map-loading { opacity: 0; }
  .map-notice {
    color: var(--text3);
    font-size: 13px;
    padding: 16px 0;
  }

  .toyota-card {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    flex: 1 1 0;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .toyota-card.error { border-color: rgba(240,112,112,0.4); }
  /* Header: title+location left, lock icon right */
  .tc-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
  .toyota-title { font-weight: 700; font-size: 14px; color: var(--text); }
  .tc-location { font-size: 11px; color: var(--text3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
  .tc-lock { font-size: 22px; flex-shrink: 0; line-height: 1; }
  /* Alert pills */
  .tc-alerts { display: flex; flex-wrap: wrap; gap: 5px; }
  .tc-alert-item {
    font-size: 11px; font-weight: 600; padding: 2px 8px;
    border-radius: 10px; border: 1px solid currentColor;
  }
  .tc-alert-item.red { color: var(--red); background: rgba(240,112,112,0.1); }
  .tc-alert-item.yellow { color: var(--yellow); background: rgba(240,208,96,0.1); }
  .tc-caution-arrow { font-size: 9px; opacity: 0.8; }
  /* Expandable caution list */
  .tc-caution-list {
    display: none; margin-top: 4px; padding: 6px 8px;
    background: rgba(240,208,96,0.08); border-radius: 6px;
    border: 1px solid rgba(240,208,96,0.25);
  }
  .tc-caution-list.open { display: block; }
  .tc-caution-row { font-size: 11px; color: var(--yellow); padding: 2px 0; }
  /* Energy bar */
  .tc-energy { display: flex; flex-direction: column; gap: 4px; }
  .tc-energy-labels { display: flex; justify-content: space-between; align-items: baseline; }
  .tc-energy-main { font-size: 13px; font-weight: 600; color: var(--text2); }
  .tc-energy-sub { font-size: 11px; color: var(--text3); }
  .tc-bar { height: 7px; background: var(--bg2); border-radius: 4px; overflow: hidden; }
  .tc-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
  /* Stats grid */
  .tc-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
  .tc-stat { display: flex; flex-direction: column; background: var(--bg2); border-radius: 6px; padding: 5px 8px; }
  .tc-stat-k { font-size: 10px; color: var(--text3); font-weight: 500; }
  .tc-stat-v { font-size: 12px; color: var(--text2); font-weight: 600; }
  .tc-warn { color: var(--red); }
  /* Actions */
  .toyota-actions { display: flex; gap: 6px; flex-wrap: wrap; }
  .toyota-btn {
    flex: 1; min-width: 56px;
    padding: 8px 4px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    font-family: 'DM Sans', sans-serif;
  }
  .toyota-btn.lock-btn { background: rgba(124,158,248,0.12); color: var(--accent); border-color: rgba(124,158,248,0.2); }
  .toyota-btn.unlock-btn { background: rgba(230,159,0,0.12); color: #E69F00; border-color: rgba(230,159,0,0.3); }
  .toyota-btn.start-btn { background: rgba(110,203,138,0.12); color: var(--green); border-color: rgba(110,203,138,0.2); }
  .toyota-btn.horn-btn { background: rgba(176,124,248,0.12); color: var(--family); border-color: rgba(176,124,248,0.2); }
  .toyota-btn.lights-btn { background: rgba(240,160,112,0.12); color: var(--eric); border-color: rgba(240,160,112,0.2); }
  .toyota-btn.stop-btn { background: rgba(240,112,112,0.12); color: var(--red); border-color: rgba(240,112,112,0.2); }
  .toyota-btn:active:not(:disabled) { transform: scale(0.96); filter: brightness(0.9); }
  .toyota-btn:disabled { opacity: 0.5; cursor: not-allowed; }
  .toyota-error { font-size: 12px; color: var(--red); }

  /* ── RESPONSIVE / MOBILE ───────────────────────────────────
     Tablet: ≤1024px — tighten spacing
     Mobile: ≤640px  — scrollable layout, bottom-sheet modal, horizontal tabs
  ──────────────────────────────────────────────────────────── */

  @media (max-width: 1024px) {
    #header { padding: 0 16px; gap: 12px; }
    .header-chip span { display: none; }  /* icons only on tablet */
    .header-chip { padding: 6px 10px; }
    #cal-section { padding: 12px 14px 6px; }
  }

  @media (max-width: 640px) {
    /* ── Root tweaks ── */
    :root { --header-h: 58px; }

    /* Allow page to scroll on mobile */
    html, body {
      height: auto;
      min-height: 100%;
      overflow-x: hidden;
      overflow-y: auto;
    }

    /* ── Header ── */
    #header {
      padding: 0 14px;
      gap: 8px;
      height: var(--header-h);
      position: sticky;
      top: 0;
      z-index: 100;
    }
    #clock { font-size: 24px; }
    #date-label { display: none; }
    #header-weather { padding: 6px 10px; gap: 6px; }
    #weather-icon { font-size: 18px; }
    #weather-temp { font-size: 18px; }
    #weather-desc { display: none; }
    #weather-hilo { display: none; }
    #weather-astro { display: none; }
    /* Services chip stays but shrinks to just the dot on mobile */
    #chip-services span { display: none; }
    #chip-services { padding: 6px 10px; }
    /* Sensor chip hidden on mobile — sensor data is in the Sensors nav tab */
    #header-sensorpush { display: none; }
    #leave-soon-banner { font-size: 11px; padding: 6px 10px; }

    /* ── Main layout — switch from fixed to flow ── */
    #main {
      position: relative;
      top: 0; left: 0; right: 0; bottom: auto;
      min-height: calc(100dvh - var(--header-h));
      overflow: visible;
    }

    /* ── Calendar section — let cells grow and section scroll ── */
    #cal-section {
      flex: none;
      height: auto;
      padding: 10px 12px 6px;
      overflow: visible;
    }
    /* Break the fixed-height chain so cells can expand to show full titles */
    #cal-viewport { flex: none; height: auto; overflow: hidden; }
    #cal-slider   { height: auto; }
    .cal-month    { height: auto; }
    /* Override inline grid-template-rows:repeat(N,1fr) — auto rows size to content.
       Scoped away from mobile-nav-active where the height chain is constrained. */
    body:not(.mobile-nav-active) .cal-grid { grid-template-rows: repeat(6, auto) !important; }
    #cal-nav { gap: 8px; margin-bottom: 6px; }
    #cal-month-label { font-size: 20px; }
    #cal-legend { gap: 6px; }
    .legend-item { font-size: 10px; padding: 2px 6px 2px 4px; }
    .cal-nav-btn { width: 32px; height: 32px; font-size: 16px; }
    #cal-today-btn { padding: 5px 10px; font-size: 11px; }
    .cal-view-btn { padding: 4px 8px; font-size: 11px; }

    /* Cells: min height so empty days don't collapse, no overflow clip */
    .cal-cell {
      padding: 4px 5px 5px;
      min-height: 56px;
      overflow: visible;
    }
    .cal-day-num { font-size: 13px; margin-bottom: 3px; }

    /* Pills: grid layout on mobile — Start|End on row 1, Title on row 2 */
    .cal-event-pill {
      font-size: 11px; padding: 3px 5px;
      display: grid;
      grid-template-columns: 1fr 1fr;
      grid-template-rows: auto auto;
    }
    .pill-time { float: none; grid-column: 1; grid-row: 1; font-size: 9px; opacity: 0.75; line-height: 1.3; margin: 0; }
    .pill-end  { float: none; grid-column: 2; grid-row: 1; font-size: 9px; opacity: 0.75; line-height: 1.3; text-align: right; font-weight: 600; margin: 0; }
    .pill-title { grid-column: 1 / -1; grid-row: 2; white-space: normal; overflow: hidden; text-overflow: ellipsis; }
    /* Hide resize handle — bottom section is auto-height on mobile */
    #resize-handle { display: none; }
    /* Events container: no clipping, allow growth */
    .cal-events {
      overflow: visible;
      gap: 3px;
      flex: none;
    }
    /* Limit to 2 pills per cell — "+N more" still renders */
    .cal-events .cal-event-pill:nth-child(n+3) { display: none; }

    /* Week/day view — no horizontal scroll; all 7 days fit at equal width */
    #cal-week-view {
      overflow-x: hidden;
      overflow-y: hidden;
    }

    /* ── Bottom section ── */
    #bottom-section {
      flex: none;
      height: auto !important;
      min-height: 320px;
    }

    /* Hide split/presets controls on mobile */
    .tab-controls { display: none; }

    /* Stack column vertically on mobile */
    #bottom-columns { flex-direction: column; }
    .bottom-col { flex-direction: column; }

    /* Horizontal tab bar */
    #bottom-tabs {
      flex-direction: row;
      width: 100%;
      height: 46px;
      border-right: none;
      border-bottom: 1px solid var(--border);
      padding: 0;
      gap: 0;
      overflow-x: auto;
      white-space: nowrap;
    }
    .bottom-tab {
      flex: 1;
      width: auto;
      height: 46px;
      flex-direction: row;
      gap: 5px;
      font-size: 11px;
      padding: 0 6px;
      justify-content: center;
      border-left: none;
      border-bottom: 2px solid transparent;
      border-top: none;
    }
    .bottom-tab.active {
      border-bottom: 2px solid var(--accent);
      border-right-color: transparent;
    }
    .tab-icon { font-size: 15px; }

    /* Content area fills remaining space */
    #bottom-content {
      flex: 1;
      min-height: 274px;
      position: relative;
    }

    /* ── Modal — bottom sheet on mobile ── */
    #modal-overlay {
      align-items: flex-end;
      padding: 0;
    }
    #modal {
      width: 100%;
      max-width: 100%;
      max-height: 92dvh;
      border-radius: 20px 20px 0 0;
      margin: 0;
    }
    .modal-header { padding: 16px 18px 12px; }
    .modal-body {
      flex-direction: column;
      overflow-y: auto;
    }
    .modal-left {
      flex: none;
      width: 100%;
      max-height: 220px;
      border-right: none;
      border-bottom: 1px solid var(--border);
      padding-right: 0;
      margin-right: 0;
      padding-bottom: 12px;
      margin-bottom: 0;
    }
    .modal-right {
      flex: none;
      width: 100%;
      padding-top: 12px;
    }

    /* ── Overlays ── */
    #embed-overlay { padding: 0; align-items: flex-end; }
    #embed-sheet { border-radius: 20px 20px 0 0; height: 92dvh; }
    #hourly-overlay { align-items: flex-end; padding: 0; }
    #hourly-modal { border-radius: 20px 20px 0 0; max-height: 92dvh; width: 100%; margin: 0; }
  }

  /* ── Safe area insets (iPhone notch / home bar) ── */
  @supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 640px) {
      body:not(.mobile-nav-active) #bottom-section { padding-bottom: env(safe-area-inset-bottom); }
      #osk { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
    }
  }

  /* ════════════════════════════════════════════════════════════════
     AI IMPORT OVERLAY
     ════════════════════════════════════════════════════════════════ */

  #ai-import-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 16px;
  }
  #ai-import-overlay.open { display: flex; }

  #ai-import-modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px 32px 24px;
    width: 800px;
    max-width: 98vw;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: hidden;
    box-shadow: 0 32px 80px rgba(0,0,0,0.55);
    animation: modal-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .ai-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
  }
  .ai-modal-title { font-size: 17px; font-weight: 700; color: var(--text); }

  #ai-error-banner {
    background: rgba(240,112,112,0.1);
    border: 1px solid rgba(240,112,112,0.35);
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
  }
  .ai-error-label {
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.06em; color: var(--red); text-transform: uppercase;
  }
  .ai-error-text {
    font-family: 'DM Mono', 'Fira Code', monospace;
    font-size: 12px; color: var(--text);
    white-space: pre-wrap; word-break: break-word;
    user-select: text; cursor: text;
    margin: 0; max-height: 120px; overflow-y: auto;
  }

  #ai-drop-zone {
    border: 2px dashed rgba(124,158,248,0.35);
    border-radius: 16px; padding: 32px 24px;
    text-align: center; cursor: pointer;
    transition: all 0.2s; background: transparent;
  }
  #ai-drop-zone:hover, #ai-drop-zone.drag {
    border-color: var(--accent);
    background: rgba(124,158,248,0.06);
  }
  .ai-drop-icon  { font-size: 40px; margin-bottom: 10px; }
  .ai-drop-label { font-size: 15px; font-weight: 600; color: var(--text); }
  .ai-drop-sub   { font-size: 13px; color: var(--text3); margin-top: 4px; }

  .ai-divider {
    text-align: center; font-size: 12px; color: var(--text3);
    margin: 12px 0 8px; position: relative;
  }
  .ai-divider::before, .ai-divider::after {
    content: ''; position: absolute; top: 50%;
    width: calc(50% - 28px); height: 1px; background: var(--border);
  }
  .ai-divider::before { left: 0; }
  .ai-divider::after  { right: 0; }

  .ai-camera-btn { width: 100%; text-align: center; justify-content: center; }

  .ai-snap-btn {
    display: block; width: calc(100% - 32px);
    margin: 10px 16px 0; padding: 12px;
    background: var(--accent); color: var(--bg);
    border: none; border-radius: 12px;
    font-size: 15px; font-weight: 700; cursor: pointer;
    transition: opacity 0.15s; font-family: 'DM Sans', sans-serif;
  }
  .ai-snap-btn:hover { opacity: 0.88; }

  .ai-qr-wrap {
    display: flex; flex-direction: column;
    align-items: center; gap: 12px; padding: 8px 0;
  }
  .ai-qr-img {
    width: 200px; height: 200px; border-radius: 12px;
    border: 2px solid var(--border); background: var(--bg3);
  }
  .ai-qr-status { font-size: 13px; color: var(--text2); text-align: center; }

  .ai-processing {
    display: flex; flex-direction: column;
    align-items: center; gap: 14px; padding: 48px 0;
  }
  .ai-spinner {
    width: 44px; height: 44px;
    border: 3px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; animation: ai-spin 0.8s linear infinite;
  }
  @keyframes ai-spin { to { transform: rotate(360deg); } }
  .ai-processing-label { font-size: 16px; font-weight: 600; color: var(--text); }
  .ai-processing-sub   { font-size: 13px; color: var(--text3); }

  .ai-type-picker {
    display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap;
  }
  .ai-type-btn {
    flex: 1; min-width: 100px;
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text2);
    font-size: 13px; font-family: 'DM Sans', sans-serif;
    padding: 8px 12px; cursor: pointer; transition: all 0.15s;
  }
  .ai-type-btn:hover { border-color: var(--accent); color: var(--text); }
  .ai-type-btn.active {
    background: rgba(124,158,248,0.18);
    border-color: var(--accent);
    color: var(--text);
  }

  .ai-review-controls {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-shrink: 0; flex-wrap: wrap;
  }
  .ai-review-left { display: flex; align-items: center; gap: 10px; }
  .ai-review-label { font-size: 14px; font-weight: 600; color: var(--text2); }
  .ai-select-links { display: flex; gap: 4px; }
  .ai-link-btn {
    background: none; border: none; color: var(--accent);
    font-size: 12px; cursor: pointer; padding: 2px 6px;
    border-radius: 6px; font-family: 'DM Sans', sans-serif; transition: background 0.15s;
  }
  .ai-link-btn:hover { background: rgba(124,158,248,0.12); }

  .ai-review-right { display: flex; align-items: center; gap: 8px; }
  .ai-cal-label { font-size: 13px; color: var(--text2); white-space: nowrap; }
  .ai-cal-select {
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    font-size: 13px; font-family: 'DM Sans', sans-serif;
    padding: 6px 10px; outline: none; cursor: pointer; max-width: 180px;
  }
  .ai-cal-select:focus { border-color: var(--accent); }

  .ai-event-list {
    overflow-y: auto; flex: 1; max-height: 420px; min-height: 80px;
  }
  .ai-no-events { text-align: center; padding: 32px 16px; color: var(--text3); font-size: 14px; }

  .ai-grid-header { display: none; } /* replaced by 2-line layout */

  .ai-grid-row {
    display: flex; flex-direction: column; gap: 6px;
    padding: 10px 2px; border-bottom: 1px solid var(--border);
  }
  .ai-grid-row:last-child { border-bottom: none; }

  .ai-row-line1 { display: flex; align-items: center; gap: 8px; }
  .ai-row-line2 { display: flex; align-items: center; gap: 6px; padding-left: 24px; flex-wrap: wrap; }

  .ai-evt-check {
    accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; flex-shrink: 0;
  }
  .ai-edit {
    background: var(--bg3); border: 1px solid var(--border); border-radius: 6px;
    color: var(--text); font: inherit; font-size: 13px;
    padding: 5px 7px; box-sizing: border-box; min-width: 0;
  }
  .ai-edit:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(124,158,248,0.2); }
  .ai-edit-title  { flex: 1; font-weight: 500; min-width: 120px; }
  .ai-cal-pills   { flex-shrink: 0; gap: 5px; }
  .ai-cal-pills .color-opt { width: 24px; height: 24px; font-size: 10px; }
  .ai-edit-date,
  .ai-edit-enddate { width: 132px; flex-shrink: 0; }
  .ai-edit-stime,
  .ai-edit-etime  { width: 120px; flex-shrink: 0; font-size: 14px; padding: 6px 8px; }
  .ai-event-desc-display {
    padding-left: 24px; font-size: 12px; color: var(--text3); font-style: italic;
  }

  .ai-review-footer {
    display: flex; justify-content: space-between;
    align-items: center; flex-shrink: 0; padding-top: 4px;
  }

  @media (max-width: 640px) {
    #ai-import-modal { padding: 20px 16px 16px; gap: 16px; }
    .ai-review-controls { flex-direction: column; align-items: flex-start; }
    .ai-cal-select { max-width: 100%; width: 100%; }
    .ai-event-list { max-height: 260px; }
    .ai-row-line2 { padding-left: 0; }
  }

  /* ── Lutron Caseta panel ─────────────────────────────── */
  .lutron-scroll { overflow-y: auto; }

  .lutron-area { margin-bottom: 16px; }
  .lutron-area-name {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.6px; color: var(--text3); margin-bottom: 8px;
  }
  .lutron-devices { display: flex; flex-direction: column; gap: 6px; }

  .lutron-device {
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 10px 12px;
    transition: border-color 0.2s;
  }
  .lutron-device.on { border-color: rgba(124,158,248,0.35); }

  .lutron-device-row {
    display: flex; align-items: center; gap: 8px;
  }
  .lutron-device-name {
    flex: 1; font-size: 13px; font-weight: 500; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .lutron-device-pct {
    font-size: 11px; color: var(--text3);
    font-variant-numeric: tabular-nums; flex-shrink: 0;
  }
  .lutron-toggle {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text3);
    font-size: 11px; font-family: 'DM Sans', sans-serif; font-weight: 500;
    padding: 4px 12px; cursor: pointer; transition: all 0.15s;
    flex-shrink: 0;
  }
  .lutron-toggle.on {
    background: rgba(124,158,248,0.15);
    border-color: var(--accent); color: var(--accent);
  }
  .lutron-toggle:disabled { opacity: 0.5; cursor: default; }

  /* ── Brightness step buttons (replaces slider) ── */
  .lutron-bri-btns {
    display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px;
  }
  .lutron-bri-btn {
    flex: 1; min-width: 0;
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text2);
    font-size: 11px; font-family: 'DM Sans', sans-serif;
    padding: 5px 2px; cursor: pointer; transition: all 0.15s;
    white-space: nowrap; text-align: center;
  }
  .lutron-bri-btn:hover { border-color: var(--accent); color: var(--text); }
  .lutron-bri-btn.active {
    background: var(--accent); border-color: var(--accent);
    color: #fff; font-weight: 600;
  }

  .lutron-scenes-area { margin-top: 4px; }
  .lutron-scenes { display: flex; flex-wrap: wrap; gap: 6px; }
  .lutron-scene-group-label {
    width: 100%; font-size: 10px; color: var(--text3);
    text-transform: uppercase; letter-spacing: 0.5px;
    margin: 4px 0 2px;
  }
  .lutron-scene-btn {
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text2);
    font-size: 12px; font-family: 'DM Sans', sans-serif;
    padding: 6px 14px; cursor: pointer; transition: all 0.15s;
  }
  .lutron-scene-btn:hover { border-color: var(--accent); color: var(--text); }
  .lutron-scene-btn.activating { opacity: 0.55; }
  .lutron-scene-btn:disabled { cursor: default; }

  /* ── Fan speed buttons ── */
  .lutron-fan-speeds {
    display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px;
  }
  .lutron-fan-btn {
    flex: 1; min-width: 0;
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text2);
    font-size: 11px; font-family: 'DM Sans', sans-serif;
    padding: 5px 4px; cursor: pointer; transition: all 0.15s;
    white-space: nowrap;
  }
  .lutron-fan-btn:hover { border-color: var(--accent); color: var(--text); }
  .lutron-fan-btn.active {
    background: var(--accent); border-color: var(--accent);
    color: #fff; font-weight: 600;
  }

  /* ── Lutron pop-out overlay ── */
  #lutron-popout-overlay {
    position: fixed; inset: 0; z-index: 280;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center;
  }
  #lutron-popout-overlay.open { display: flex; }
  #lutron-popout-modal {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 20px; width: 95vw; max-width: 640px; max-height: 88vh;
    display: flex; flex-direction: column;
    box-shadow: 0 32px 80px rgba(0,0,0,0.5);
    animation: modal-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .lp-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px 12px; flex-shrink: 0;
    border-bottom: 1px solid var(--border);
  }
  .lp-title { font-family: 'DM Serif Display', serif; font-size: 20px; }
  #lutron-popout-content {
    overflow-y: auto; padding: 16px 20px 20px; flex: 1; min-height: 0;
  }
  #lutron-popout-content .lutron-scroll { overflow-y: unset; }
}

/* ══════════════════════════════════════════════════════════════════
   Whiteboard — drawing modal, panel, and calendar sticker overlay
   ══════════════════════════════════════════════════════════════════ */

/* cal-section needs position:relative so the sticker layer can anchor to it */
#cal-section { position: relative; }

/* ── Sticker layer ── */
#wb-sticker-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.wb-sticker {
  position: absolute;
  pointer-events: auto;
  user-select: none;
  min-width: 20px;
}

.wb-sticker img {
  display: block;
  width: 100%;
  border-radius: 6px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.35);
  pointer-events: none;
}

.wb-sticker-bar {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0,0,0,0.55);
  border-radius: 6px 6px 0 0;
  padding: 3px 6px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: auto;
  z-index: 3; /* above resize grips (z-index:2) so drag handle isn't blocked */
}
.wb-sticker:hover .wb-sticker-bar,
.wb-sticker:focus-within .wb-sticker-bar { opacity: 1; }

.wb-drag-handle {
  cursor: grab;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  touch-action: none;
}
.wb-drag-handle:active { cursor: grabbing; }

.wb-opacity-slider {
  flex: 1;
  min-width: 40px;
  max-width: 80px;
  accent-color: var(--accent);
}

.wb-sticker-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  line-height: 1;
}

.wb-resize-grip {
  position: absolute;
  width: 22px;
  height: 22px;
  touch-action: none;
  opacity: 0.25;
  transition: opacity 0.15s;
  background: rgba(0,0,0,0.5);
  border-radius: 3px;
  z-index: 2;
}
.wb-resize-br { bottom: 0; right: 0; cursor: se-resize; border-radius: 0 0 6px 0; }
.wb-resize-bl { bottom: 0; left:  0; cursor: sw-resize; border-radius: 0 0 0 6px; }
.wb-resize-tr { top:    0; right: 0; cursor: ne-resize; border-radius: 0 6px 0 0; }
.wb-resize-tl { top:    0; left:  0; cursor: nw-resize; border-radius: 6px 0 0 0; }
.wb-sticker:hover .wb-resize-grip,
.wb-sticker:focus-within .wb-resize-grip { opacity: 0.8; }

/* ── Drawing modal (full-screen) ── */
/* While the drawing modal is open, block the browser's edge-swipe back
   gesture and horizontal overscroll so stray swipes on the canvas don't
   navigate away and lose the in-progress drawing. `contain` stops the
   gesture from propagating to the browser chrome; `touch-action: none`
   on <html> kills any remaining default touch gestures. */
html.wb-modal-open { overscroll-behavior: none; touch-action: none; }
html.wb-modal-open body { overscroll-behavior: none; }

#wb-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  flex-direction: column;
  background: var(--bg);
  overscroll-behavior: none;
}

#wb-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  flex-shrink: 0;
}

#wb-colors {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}

.wb-color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s, border-color 0.1s;
}
.wb-color-swatch:hover { transform: scale(1.15); }
.wb-color-swatch.active {
  border-color: var(--accent);
  transform: scale(1.2);
  box-shadow: 0 0 0 2px var(--bg2);
}
/* BG palette lives inside the toolbar; a bit smaller so 20 swatches fit */
.wb-bg-swatches {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 3px;
  max-width: 220px;
  align-items: center;
}
.wb-bg-swatch {
  width: 20px;
  height: 20px;
}

.wb-toolbar-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 2px;
  flex-shrink: 0;
}

.wb-size-label, .wb-bg-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text2);
}
.wb-size-label input[type=range] { width: 70px; accent-color: var(--accent); }

.wb-bg-label input[type=color] {
  width: 26px;
  height: 26px;
  border: 2px solid var(--border);
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  background: none;
}
.wb-bg-label input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.wb-bg-label input[type=color]::-webkit-color-swatch { border: none; border-radius: 50%; }
#wb-bg-clear-btn { padding: 2px 6px; font-size: 11px; }

.wb-tool-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  padding: 4px 10px;
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.1s;
}
.wb-tool-btn:hover { filter: brightness(1.1); }
.wb-tool-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.wb-save-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}
.wb-save-primary:hover { opacity: 0.88; }

.wb-close-btn { margin-left: auto; }

#wb-layer-btns {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}
.wb-layer-btn {
  background: var(--bg2);
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 4px 10px;
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}
.wb-layer-btn + .wb-layer-btn { border-left: 1px solid var(--border); }
.wb-layer-btn.active {
  background: var(--accent);
  color: #fff;
}

#wb-name-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 4px 10px;
  min-width: 0;
  flex: 1 1 120px;
}
#wb-name-input:focus { outline: none; border-color: var(--accent); }

/* Checkerboard on the wrapper shows through wherever both layers are transparent */
#wb-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-color: #e8e8e8;
  background-image:
    linear-gradient(45deg, #fff 25%, transparent 25%),
    linear-gradient(-45deg, #fff 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #fff 75%),
    linear-gradient(-45deg, transparent 75%, #fff 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}
#wb-canvas-bg, #wb-canvas-draw {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#wb-canvas-draw {
  cursor: crosshair;
  touch-action: none;
  transition: opacity 0.2s;
}

/* PIN overlay inside the modal */
/* ── Whiteboard QR upload overlay ── */
#wb-qr-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 600;
}
#wb-qr-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.55);
  max-width: 300px;
  width: 90%;
}
#wb-qr-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}
#wb-qr-hint {
  font-size: 13px;
  color: var(--text2);
  text-align: center;
  line-height: 1.4;
}
#wb-qr-img {
  width: 200px;
  height: 200px;
  border-radius: 10px;
  background: var(--bg);
}
#wb-qr-status {
  font-size: 13px;
  color: var(--text2);
  text-align: center;
}

#wb-pin-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#wb-pin-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 240px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
#wb-pin-label { font-size: 15px; font-weight: 500; }
#wb-pin-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 18px;
  letter-spacing: 4px;
  padding: 8px 12px;
  text-align: center;
}
#wb-pin-input:focus { outline: none; border-color: var(--accent); }
#wb-pin-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
#wb-pin-btns button {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  padding: 6px 16px;
  font-size: 14px;
}

/* ── Drawings panel (bottom pane) ── */
#wb-panel-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.wb-panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  padding: 4px 2px 8px;
}

.wb-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-size: 12px;
  transition: box-shadow 0.15s;
}
.wb-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.2); }

.wb-card-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  display: block;
  background: #f4f4f4;
}

.wb-card-name {
  padding: 6px 8px 2px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.wb-card-date {
  padding: 0 8px 4px;
  color: var(--text2);
  font-size: 11px;
}

.wb-card-actions {
  display: flex;
  gap: 4px;
  padding: 0 6px 8px;
}

.wb-pin-btn {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 11px;
  padding: 4px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wb-pin-btn.active {
  background: rgba(0,114,178,0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.wb-edit-btn, .wb-del-btn, .wb-reset-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  padding: 4px 7px;
  font-size: 13px;
  color: var(--text2);
  flex-shrink: 0;
}
.wb-edit-btn:hover, .wb-reset-btn:hover { background: rgba(0,114,178,0.12); border-color: var(--accent); color: var(--accent); }
.wb-del-btn:hover { background: rgba(200,0,0,0.12); border-color: #c00; color: #c00; }

.wb-visibility-btn {
  display: block;
  width: calc(100% - 12px);
  margin: 0 6px 8px;
  padding: 5px 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text2);
  text-align: center;
}
.wb-visibility-btn:hover { background: rgba(0,0,0,0.08); color: var(--text); }
.wb-visibility-btn.is-hidden {
  background: rgba(0,114,178,0.1);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.wb-thumb-hidden { opacity: 0.35; }

.wb-sticker-hidden {
  visibility: hidden;
  pointer-events: none;
}

/* Locked layer — stickers become static decorations, fully transparent to interaction */
#wb-sticker-layer.wb-layer-locked {
  pointer-events: none;
  z-index: 1;
}
#wb-sticker-layer.wb-layer-locked .wb-sticker {
  pointer-events: none;
  /* Desaturate + dim locked stickers so calendar pills and text read cleanly
     over them. Multiplies with the sticker's own inline opacity rather than
     clobbering it, so per-sticker opacity choices are preserved. */
  filter: saturate(0.15) brightness(0.75) opacity(0.55);
  outline: none;
  cursor: default;
  transition: filter 0.2s;
}
/* Suppress all hover/focus effects on locked stickers */
#wb-sticker-layer.wb-layer-locked .wb-sticker:hover,
#wb-sticker-layer.wb-layer-locked .wb-sticker:focus-within {
  box-shadow: none;
  outline: none;
}
/* Hide every interactive control — toolbar, drag handle, resize grips */
#wb-sticker-layer.wb-layer-locked .wb-sticker-bar,
#wb-sticker-layer.wb-layer-locked .wb-resize-grip {
  display: none !important;
}
/* Also suppress grip visibility on hover (double-safe) */
#wb-sticker-layer.wb-layer-locked .wb-sticker:hover .wb-resize-grip,
#wb-sticker-layer.wb-layer-locked .wb-sticker:focus-within .wb-resize-grip {
  opacity: 0 !important;
  display: none !important;
}

.wb-loading, .wb-empty {
  padding: 16px;
  color: var(--text2);
  font-size: 13px;
  text-align: center;
}

/* ── Mobile bottom nav (PWA) ──────────────────────────────────────────────── */
@media (max-width: 640px) {

  /* Prevent document scrolling — everything lives in fixed/contained boxes */
  body.mobile-nav-active { overflow: hidden; height: 100dvh; }

  #mobile-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 56px;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    display: flex; align-items: stretch;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  #mobile-nav::-webkit-scrollbar { display: none; }

  /* #mnav-primary-tabs is a flex row; buttons don't compress */
  #mnav-primary-tabs { display: contents; }

  .mnav-btn {
    flex: 0 0 64px; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: none; border: none;
    color: var(--text3); cursor: pointer;
    gap: 3px; padding: 0 4px;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }
  .mnav-btn.active { color: var(--accent); }
  .mnav-icon { font-size: 20px; line-height: 1; }
  .mnav-label {
    font-size: 9px; font-weight: 500; letter-spacing: 0.3px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 58px;
  }

  /* Full-screen layout: #main fills the space between sticky header and fixed nav bar.
     An explicit height (not just min-height) is required so flex children can use flex:1. */
  body.mobile-nav-active #main {
    position: fixed; left: 0; right: 0; bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  /* ── Calendar tab: fills viewport, Google-style compact pills ── */
  body.mobile-nav-active.mnav-cal #cal-section {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
    padding: 6px 8px 4px;
  }
  /* Height propagation chain so 1fr rows resolve */
  body.mobile-nav-active.mnav-cal #cal-viewport { flex: 1; min-height: 0; overflow: hidden; }
  body.mobile-nav-active.mnav-cal #cal-slider   { height: 100%; }
  body.mobile-nav-active.mnav-cal .cal-month    { height: 100%; display: flex; flex-direction: column; }
  /* height:0 + flex-grow:1 gives a definite height so fr rows resolve correctly */
  body.mobile-nav-active.mnav-cal .cal-grid     { flex: 1; height: 0; min-height: 0; }

  /* Compact nav */
  body.mobile-nav-active.mnav-cal #cal-nav {
    gap: 5px; margin-bottom: 4px; flex-wrap: nowrap; align-items: center;
  }
  body.mobile-nav-active.mnav-cal #cal-month-label { font-size: 20px; flex: 1; }
  body.mobile-nav-active.mnav-cal #cal-today-btn   { padding: 4px 9px; font-size: 10px; }
  body.mobile-nav-active.mnav-cal .cal-nav-btn     { width: 28px; height: 28px; font-size: 14px; }
  body.mobile-nav-active.mnav-cal #cal-dow-row     { margin-bottom: 2px; }
  body.mobile-nav-active.mnav-cal .cal-dow         { font-size: 10px; }

  /* Legend toggle button hidden on desktop — CSS shows it only in mobile-nav-active */
  #cal-legend-toggle { display: none; }

  /* Legend hidden by default; toggle button shown; legend expands as second row when open */
  body.mobile-nav-active #cal-legend        { display: none; flex-wrap: wrap; flex-basis: 100%; order: 10; }
  body.mobile-nav-active.mobile-legend-open #cal-legend { display: flex; margin-top: 4px; }
  body.mobile-nav-active #cal-legend-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--bg3); border: 1px solid var(--border);
    color: var(--text2); font-size: 14px; cursor: pointer;
    flex-shrink: 0; -webkit-tap-highlight-color: transparent;
  }
  body.mobile-nav-active.mobile-legend-open #cal-legend-toggle { color: var(--accent); border-color: var(--accent); }

  /* Compact view switcher */
  body.mobile-nav-active .cal-view-btns { gap: 2px; }
  body.mobile-nav-active .cal-view-btn  { padding: 3px 7px; font-size: 10px; }

  /* Compact cells */
  body.mobile-nav-active.mnav-cal .cal-cell    { padding: 3px 2px 3px; overflow: hidden; }
  body.mobile-nav-active.mnav-cal .cal-day-num { font-size: 11px; margin-bottom: 1px; }
  body.mobile-nav-active.mnav-cal .cal-events  { gap: 2px; overflow: hidden; flex: 1; }

  /* Google-style pills: single line, title only, no times */
  body.mobile-nav-active.mnav-cal .cal-event-pill {
    display: block !important;
    font-size: 10px; padding: 2px 4px; border-radius: 3px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    min-width: 0;
  }
  body.mobile-nav-active.mnav-cal .pill-time,
  body.mobile-nav-active.mnav-cal .pill-end { display: none !important; }
  body.mobile-nav-active.mnav-cal .pill-title {
    display: block !important;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
  }

  body.mobile-nav-active.mnav-cal #bottom-section { display: none; }

  /* Panel tab active — bottom section fills #main */
  body.mobile-nav-active.mnav-panel #cal-section { display: none; }
  body.mobile-nav-active.mnav-panel #bottom-section {
    display: flex; flex: 1; height: auto !important; min-height: 0; overflow: hidden;
  }
  body.mobile-nav-active.mnav-panel #bottom-content {
    flex: 1; min-height: 0; overflow: hidden; position: relative;
  }

  /* ── Popout overlays: full-screen bottom sheets in mobile PWA ── */
  body.mobile-nav-active #weather-popout-overlay,
  body.mobile-nav-active #toyota-popout-overlay,
  body.mobile-nav-active #map-popout-overlay,
  body.mobile-nav-active #lutron-popout-overlay {
    align-items: flex-end;
  }
  body.mobile-nav-active #weather-popout-modal,
  body.mobile-nav-active #toyota-popout-modal,
  body.mobile-nav-active #map-popout-modal,
  body.mobile-nav-active #lutron-popout-modal {
    width: 100% !important; max-width: 100% !important;
    height: calc(100dvh - 44px);
    max-height: calc(100dvh - 44px) !important;
    border-radius: 20px 20px 0 0 !important;
    margin: 0;
  }
  /* Map: on top (order:1), fills remaining height; sidebar: compact strip below (order:2) */
  body.mobile-nav-active #map-popout-modal .mp-body { flex-direction: column; }
  body.mobile-nav-active #map-popout-map {
    order: 1; flex: 1; min-height: 0; height: auto !important;
  }
  body.mobile-nav-active #map-popout-sidebar {
    order: 2; flex-shrink: 0;
    width: auto; max-height: 200px; overflow-y: auto; overflow-x: hidden;
    flex-direction: column; flex-wrap: nowrap;
    border-right: none; border-top: 1px solid var(--border);
    padding: 8px 16px;
  }

  /* Meal add/edit modal: bottom sheet, scrollable so buttons survive keyboard */
  body.mobile-nav-active #meal-edit-overlay { align-items: flex-end; }
  body.mobile-nav-active #meal-edit-dialog {
    width: 100% !important; max-width: 100% !important;
    border-radius: 20px 20px 0 0;
    max-height: 85dvh; overflow-y: auto;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  /* Event modal: compact padding + remove the 220px cap so body scrolls as one unit */
  body.mobile-nav-active #modal { padding: 16px 16px 0; }
  body.mobile-nav-active .modal-header { padding: 0 2px 12px; }
  body.mobile-nav-active .modal-left { max-height: none; overflow-y: visible; }
  body.mobile-nav-active .modal-body { padding-bottom: 16px; }

  /* Event modal: "All Day" gets its own row so it's never clipped */
  body.mobile-nav-active .modal-row-dates {
    grid-template-columns: 1fr 1fr;
  }
  body.mobile-nav-active .modal-allday-field {
    grid-column: 1 / -1;
    flex-direction: row; align-items: center; gap: 12px;
    padding-top: 2px;
  }
  body.mobile-nav-active .modal-allday-field label { margin-bottom: 0; }

  /* Chores panel: 2-column grid on mobile */
  body.mobile-nav-active #chores-content {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    overflow-x: hidden; gap: 12px; align-items: start;
  }
  body.mobile-nav-active .person-group { min-width: 0 !important; }

  /* Toyota panel: stack cards vertically on mobile */
  body.mobile-nav-active #cars-content {
    flex-direction: column; flex-wrap: nowrap;
    overflow-x: hidden; gap: 12px;
  }
  body.mobile-nav-active .toyota-card { min-width: 0; flex: none; width: 100%; }

  /* Day view: no forced min-width — let the single column fill the viewport.
     The 560px min-width from the base mobile block is for week view only. */
  body.mobile-nav-active .wv-view-day .wv-grid,
  body.mobile-nav-active .wv-view-day .wv-head,
  body.mobile-nav-active .wv-view-day .wv-allday-row { min-width: 0; }
  body.mobile-nav-active .wv-view-day #cal-week-view { overflow-x: hidden; }

  /* Week / day view on mobile: tighter event blocks, wrapped titles */
  body.mobile-nav-active .wv-evt { padding: 1px 2px; border-radius: 3px; }
  body.mobile-nav-active .wv-evt-time { font-size: 7px; }
  body.mobile-nav-active .wv-evt-title { font-size: 8px; -webkit-line-clamp: 7; }
  /* Day column header: smaller day number, clip overflow so weather doesn't bleed */
  body.mobile-nav-active .wv-dnum { font-size: 15px; }
  body.mobile-nav-active .wv-dow  { font-size: 8px; }
  body.mobile-nav-active .wv-day-hdr { overflow: hidden; padding: 4px 2px 4px; }
  /* Week view column weather: wrap icon onto its own line, shrink font */
  body.mobile-nav-active .wv-view-week .wv-wx { white-space: normal; font-size: 8px; line-height: 1.2; }
  /* All-day cells: clip overflow so pills don't bleed into neighbours */
  body.mobile-nav-active .wv-allday-cell { overflow: hidden; }
  body.mobile-nav-active .wv-allday-pill { font-size: 8px; padding: 1px 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.mobile-nav-active .wv-meal-block-name { font-size: 8px; }

  /* Hide old horizontal tab bar when mobile-nav is active */
  body.mobile-nav-active #bottom-tabs { display: none; }
  body.mobile-nav-active #bottom-section { padding-bottom: 0; }

  /* ── More sheet ────────────────────────────────────────────────────── */
  #more-sheet-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 210; backdrop-filter: blur(2px);
    opacity: 0; transition: opacity 0.25s;
  }
  #more-sheet-backdrop.open { opacity: 1; }

  #more-sheet {
    position: fixed; left: 0; right: 0; bottom: 0;
    background: var(--bg2); border-radius: 20px 20px 0 0;
    border-top: 1px solid var(--border);
    padding: 10px 0 calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 220; max-height: 60dvh; overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
  #more-sheet.open { transform: translateY(0); }

  .more-sheet-handle {
    width: 40px; height: 5px; border-radius: 3px;
    background: var(--text3); margin: 0 auto 14px;
  }
  .more-sheet-title {
    font-size: 11px; font-weight: 600; letter-spacing: 0.8px;
    text-transform: uppercase; color: var(--text3); padding: 0 20px 10px;
  }
  .more-sheet-item {
    display: flex; align-items: center; gap: 14px; padding: 14px 20px;
    cursor: pointer; border-bottom: 1px solid var(--border);
    transition: background 0.15s; -webkit-tap-highlight-color: transparent;
  }
  .more-sheet-item:last-child { border-bottom: none; }
  .more-sheet-item:active { background: var(--bg3); }
  .more-sheet-item.active .more-item-label { color: var(--accent); }
  .more-item-icon { font-size: 22px; }
  .more-item-label { font-size: 15px; font-weight: 500; color: var(--text); }
}

/* ── Countdown panel ───────────────────────────────────── */
#countdowns-content {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 8px 4px; align-content: flex-start;
}

.cd-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg3); border-radius: var(--radius-sm);
  padding: 10px 14px; flex: 1 1 200px; max-width: 340px;
  border-left: 4px solid var(--accent);
  transition: opacity 0.15s;
}

.cd-number {
  font-size: 44px; font-weight: 600; line-height: 1;
  color: var(--text); min-width: 52px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.cd-today .cd-number { font-size: 32px; }

.cd-unit {
  font-size: 12px; color: var(--text3); min-width: 30px;
  line-height: 1.2; padding-top: 2px;
}

.cd-info { flex: 1; min-width: 0; }
.cd-title {
  font-size: 14px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cd-meta { font-size: 11px; color: var(--text3); margin-top: 2px; }

.cd-past { opacity: 0.5; }
.cd-past .cd-number { color: var(--text3); }

.cd-unpin {
  flex-shrink: 0; background: none; border: none;
  cursor: pointer; opacity: 0.3; font-size: 15px;
  padding: 4px; line-height: 1; border-radius: 4px;
  transition: opacity 0.15s, background 0.15s;
}
.cd-unpin:hover { opacity: 1; background: var(--bg); }

.cd-empty {
  color: var(--text3); font-size: 13px;
  padding: 20px 8px; line-height: 1.5;
}

/* Pin button inside calendar day modal */
.modal-evt-pin-btn {
  flex-shrink: 0; align-self: center;
  background: none; border: none;
  font-size: 15px; padding: 4px 6px;
  opacity: 0.3; cursor: pointer; border-radius: 4px;
  transition: opacity 0.15s, background 0.15s;
  line-height: 1;
}
.modal-evt-pin-btn:hover { opacity: 0.7; background: var(--bg); }
.modal-evt-pin-btn.pinned { opacity: 1; }

/* ── Screensaver ────────────────────────────────────────── */
#screensaver {
  position: fixed; inset: 0; z-index: 9999;
  background: #000;
  display: none;
  cursor: none;
}
#screensaver.ss-visible { display: block; }

.ss-photo {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.5s ease;
}

#ss-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding-bottom: 48px;
  background: linear-gradient(to top, rgba(0,0,0,0.55) 0%, transparent 50%);
  color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,0.8);
  text-align: center;
  pointer-events: none;
  user-select: none;
}
#ss-clock   { font-size: 80px; font-weight: 200; line-height: 1; }
#ss-date    { font-size: 22px; font-weight: 300; margin-bottom: 16px; }
#ss-event   { font-size: 20px; margin-bottom: 6px; }
#ss-weather { font-size: 18px; opacity: 0.85; }
#ss-leave   { font-size: 18px; margin-top: 8px; color: #ffd060; }

/* ── Pane host: settings modal + onboarding wizard + spinner ───────────── */
.pane-settings-overlay,
.pane-onb-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.pane-settings-dialog,
.pane-onb-dialog {
  background: var(--panel-bg, #1f242c);
  color: var(--text, #e8eaed);
  border-radius: 8px;
  width: min(520px, 92vw);
  max-height: 86vh;
  display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.pane-settings-head,
.pane-onb-progress {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-weight: 600;
}
.pane-settings-head h3 { margin: 0; font-size: 15px; }
.pane-settings-close {
  background: transparent; border: 0; color: inherit;
  font-size: 22px; line-height: 1; cursor: pointer;
}
.pane-settings-form,
.pane-onb-body {
  padding: 16px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.pane-settings-field {
  display: flex; flex-direction: column; gap: 4px;
}
.pane-settings-label {
  font-size: 12px; opacity: 0.8; font-weight: 500;
}
.pane-settings-input {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 6px 8px;
  color: inherit;
  font: inherit;
}
.pane-settings-help {
  font-size: 11px; opacity: 0.7;
}
.pane-settings-foot,
.pane-onb-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.pane-settings-cancel,
.pane-settings-save,
.pane-onb-back,
.pane-onb-next {
  padding: 6px 14px; border-radius: 4px; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.06);
  color: inherit; font: inherit;
}
.pane-settings-save,
.pane-onb-next {
  background: var(--accent, #4a90e2); border-color: var(--accent, #4a90e2); color: #fff;
}
.panel-refresh-btn.spinning {
  animation: pane-host-spin 0.6s linear;
  display: inline-block;
}
@keyframes pane-host-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.pane-error {
  padding: 12px;
  color: #f77;
}
.panel-settings-btn {
  background: transparent; border: 0; color: inherit; cursor: pointer;
  font-size: 14px; padding: 0 4px;
  opacity: 0.7;
}
.panel-settings-btn:hover { opacity: 1; }
