
  :root {
    --pico-font-size: 100%;
    --pico-spacing: 0.875rem;
    --pico-color: #181c20;
    --pico-muted-color: #4b5563;
    --pico-muted-border-color: #d0d7de;

    /* Deterministic Type Palette (IDE-style semantic colors) */
    --type-watch: #7e22ce;        /* Purple: Named setup ("Sourdough") */
    --type-watch-bg: #faf5ff;
    --type-watch-border: #d8b4fe;

    --type-action: #0172ad;       /* Blue: Clickable UI Buttons / Links ("Test", "Take photo") */
    --type-action-ref: #1e3a8a;   /* Darker Navy Blue: Non-clickable text referring to a blue button */
    --type-action-bg: #f0f7ff;
    --type-action-border: #bae6fd;

    --type-alert: #b45309;        /* Warm Amber: Notification address ONLY ("+12025550142") */
    --type-alert-bg: #fffbeb;
    --type-alert-border: #fcd34d;

    /* Three Distinct Shades of Red in the Iso-Lightness Band (OKLCH L ≈ 0.54–0.58):
       1. Alert Red (--type-trigger): Vivid Scarlet (#dc2626, L=0.577, H=27.3°) + #fef2f2 tinted callout surface
       2. Off Red (--type-off-red): Crisp True Red (#c92a2a, L=0.546, H=26.6°) on Pure White (#ffffff) un-shaded surface
       3. Cancel / Delete Red (--type-cancel-red): Bright Crimson-Rose (#e11d48, L=0.586, H=17.6°) + #fff1f2 surface */
    --type-trigger: #dc2626;      /* 1. Alert Red (Vivid Scarlet): "Alert sent:", "Alert triggered:", errors */
    --type-trigger-bg: #fef2f2;
    --type-trigger-border: #ef4444;

    --type-off-red: #c92a2a;      /* 2. Off Red (Crisp True Red on Pure White #ffffff): Stop, OFF switches, unselected days, Off selects */
    --type-off-red-bg: #ffffff;
    --type-off-red-border: #f03e3e;

    --type-cancel-red: #e11d48;   /* 3. Cancel / Delete Red (Bright Crimson-Rose, L=0.586): Cancel ×, Close ×, Delete, Clear all, Reset All */
    --type-cancel-red-bg: #fff1f2;
    --type-cancel-red-border: #f43f5e;

    --type-active: #15803d;       /* Green: Connected / Watching / "Message always" readout */
    --type-active-bg: #f0fdf4;
    --type-active-border: #86efac;
  }
  *, *::before, *::after {
    box-sizing: border-box;
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
  }
  [hidden] {
    display: none !important;
  }
  html {
    margin: 0;
    padding: 0;
    background: #ffffff;
    color: var(--pico-color);
    overflow-y: scroll;
  }
  body {
    margin: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    background: #ffffff;
    color: var(--pico-color);
    padding: 0.5rem 0.75rem 1.25rem;
  }

  /* Top bar: 1 row when space permits, cleanly wraps to 2+ rows when narrow */
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem 0.625rem;
    padding-top: 0 !important;
    padding-bottom: 0.45rem !important;
    margin-bottom: 0.6rem;
    border-bottom: 1px solid var(--pico-muted-border-color);
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
  }
  .brand-device {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    flex: 1 1 260px;
    min-width: 0;
    max-width: 100%;
  }
  .app-account-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
    flex: 0 0 auto;
  }
  .wordmark {
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pico-color);
  }
  .sep { color: var(--pico-muted-border-color); }
  .account-select-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
  }
  .account-select-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #ffffff;
    border: 1.5px solid #94a3b8;
    border-radius: 7px;
    padding: 0.28rem 0.6rem;
    min-height: 2.05rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--pico-color);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
  }
  .account-select-btn:hover {
    border-color: var(--type-action);
    color: var(--type-action);
    background: #f0f9ff;
  }
  .account-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    min-width: 225px;
    background: #ffffff;
    border: 1.5px solid var(--pico-muted-border-color);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
    padding: 0.45rem 0.55rem;
    z-index: 65;
    font-size: 0.76rem;
    color: var(--pico-color);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
  }

  /* Device Selector Dropdown (fills full available horizontal space so no empty whitespace remains) */
  .device-select-wrap {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .device-select-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    flex-wrap: nowrap;
    --pico-background-color: #ffffff;
    --pico-color: #181c20;
    background: #ffffff !important;
    border: 1.5px solid var(--pico-muted-border-color) !important;
    border-radius: 7px;
    padding: 0.28rem 0.65rem;
    margin: 0;
    width: 100%;
    max-width: 100%;
    cursor: pointer;
    color: #181c20 !important;
    box-shadow: none;
    user-select: none;
  }
  .device-select-btn:hover {
    border-color: var(--type-action) !important;
  }
  .cam-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    color: #181c20 !important;
  }
  .device-caret {
    font-size: 0.8rem;
    font-weight: 700;
    color: #181c20 !important;
    line-height: 1;
  }
  .badge-connected {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.1rem 0.42rem;
    border-radius: 5px;
    background: var(--type-active-bg);
    border: 1px solid var(--type-active-border);
    color: var(--type-active);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
  }
  .badge-searching {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.1rem 0.42rem;
    border-radius: 5px;
    background: var(--type-action-bg);
    border: 1px solid var(--type-action-border);
    color: var(--type-action);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
  }
  .device-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    min-width: 220px;
    background: #ffffff;
    border: 1.5px solid var(--pico-muted-border-color);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    padding: 0.3rem;
    z-index: 60;
  }
  .device-opt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.48rem 0.65rem;
    min-height: 2.35rem;
    margin-bottom: 0.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--pico-color);
  }
  .device-opt:hover {
    background: #f3f4f6;
  }
  .device-opt.active {
    background: var(--type-action-bg);
    color: var(--type-action);
    font-weight: 700;
  }
  .device-opt-status {
    font-size: 0.72rem;
    color: var(--type-active);
    font-weight: 700;
  }
  .device-opt-new {
    margin-top: 0.2rem;
    padding: 0.5rem 0.65rem;
    min-height: 2.35rem;
    display: flex;
    align-items: center;
    border-top: 1px solid var(--pico-muted-border-color);
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--type-action);
    cursor: pointer;
    border-radius: 0 0 6px 6px;
  }
  .device-opt-new:hover {
    background: var(--type-action-bg);
  }

  /* UF-01 Onboarding & Recovery Panel (Auto-opens when 0 cameras connected, or toggled via "+ Add device") */
  .onboarding-panel {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    border: 1.5px solid var(--type-action);
    border-radius: 10px;
    background: #f8fafc;
    padding: 0.95rem 1.1rem;
    margin-bottom: 1rem;
  }
  /* 3. Cancel Red (--type-cancel-red): Deep Claret/Burgundy #881337 — distinct from Alert Red (#dc2626) and Off Red (#9a2413) */
  .btn-cancel-red {
    --pico-background-color: var(--type-cancel-red-bg);
    --pico-color: var(--type-cancel-red);
    background: var(--type-cancel-red-bg) !important;
    color: var(--type-cancel-red) !important;
    border: 1.5px solid var(--type-cancel-red-border) !important;
  }
  .btn-cancel-red:hover {
    background: #f4e1e4 !important;
    color: var(--type-cancel-red) !important;
    border-color: var(--type-cancel-red) !important;
  }
  .onboarding-auto-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: #ffffff;
    border: 1px solid var(--type-action-border);
    border-left: 4px solid var(--type-action);
    border-radius: 6px;
    padding: 0.6rem 0.875rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
  }
  .auto-status {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
  }
  .pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--type-action);
    box-shadow: 0 0 0 4px rgba(1, 114, 173, 0.18);
    flex-shrink: 0;
  }
  .onboarding-subhead {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--pico-muted-color);
    margin-bottom: 0.5rem;
  }
  .fallback-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }
  @media (max-width: 900px) {
    .fallback-grid { grid-template-columns: 1fr; }
  }
  .fallback-card {
    background: #ffffff;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 8px;
    padding: 0.7rem 0.8rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.84rem;
    line-height: 1.4;
  }
  .fallback-card-title {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--pico-color);
    margin-bottom: 0.15rem;
  }
  .fallback-card p {
    margin: 0;
    color: var(--pico-muted-color);
    font-size: 0.81rem;
  }
  .code-row {
    display: flex;
    gap: 0.35rem;
    align-items: center;
  }
  .code-row input {
    margin: 0 !important;
    padding: 0.3rem 0.5rem !important;
    height: auto !important;
    font-size: 0.82rem !important;
    font-family: var(--pico-font-family-monospace);
    background: #fff !important;
  }
  .code-row button, .btn-fallback-action {
    margin: 0 !important;
    width: auto !important;
    padding: 0.32rem 0.7rem !important;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    white-space: nowrap;
    --pico-background-color: var(--type-action);
    --pico-color: #ffffff;
    background: var(--type-action) !important;
    border: 1.5px solid var(--type-action) !important;
    color: #ffffff !important;
  }
  .btn-fallback-outline {
    margin: 0 !important;
    width: 100% !important;
    padding: 0.32rem 0.65rem !important;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    --pico-background-color: #ffffff;
    --pico-color: var(--type-action);
    background: #ffffff !important;
    border: 1.5px solid var(--type-action) !important;
    color: var(--type-action) !important;
  }
  .mdns-details {
    margin: 0.25rem 0 0 0;
    padding: 0;
    border: none;
    font-size: 0.76rem;
  }
  .mdns-details summary {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 2.05rem;
    padding: 0.32rem 0.6rem;
    border-radius: 6px;
    background: #f0f9ff;
    border: 1.5px solid #93c5fd;
    color: var(--type-action);
    font-weight: 700;
    cursor: pointer;
    margin: 0;
    list-style: none;
  }
  .mdns-details summary::-webkit-details-marker {
    display: none;
  }
  .mdns-details summary:hover {
    background: #e0f2fe;
    border-color: var(--type-action);
  }
  .mdns-details code {
    display: block;
    margin-top: 0.25rem;
    padding: 0.25rem 0.4rem;
    background: #f1f5f9;
    border-radius: 4px;
    font-size: 0.73rem;
  }

  /* Upper-right compact boxes container */
  .corner-boxes {
    display: flex;
    align-items: stretch;
    gap: 0.45rem;
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
  }

  /* Compact Box 1: Named setup summary + Dropdown switcher ("Sourdough ▾" on top, cadence + alert target below) */
  .setup-box-wrap {
    position: relative;
    display: flex;
    min-width: 0;
    max-width: 100%;
  }
  .setup-box {
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--type-watch-bg);
    border: 1.5px solid var(--type-watch-border);
    border-radius: 7px;
    padding: 0.2rem 0.55rem;
    line-height: 1.15;
    cursor: pointer;
    user-select: none;
    min-width: 0;
    max-width: 100%;
  }
  .setup-box:hover {
    border-color: var(--type-watch);
  }
  .setup-box .setup-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--type-watch);
  }
  .setup-box .setup-caret {
    font-size: 0.75rem;
    opacity: 0.9;
  }
  .setup-box .setup-sub {
    font-size: 0.72rem;
    color: var(--pico-muted-color);
    margin-top: 0.1rem;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .setup-box .setup-sub strong { color: var(--pico-color); }
  .setup-box .setup-sub .alert-dest {
    color: var(--type-alert);
    font-weight: 700;
    font-family: var(--pico-font-family-monospace);
  }
  .setup-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    min-width: 230px;
    background: #ffffff;
    border: 1.5px solid var(--type-watch-border);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    padding: 0.3rem;
    z-index: 50;
  }
  .setup-opt {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0.48rem 0.65rem;
    min-height: 2.4rem;
    margin-bottom: 0.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    line-height: 1.25;
  }
  .setup-opt:hover {
    background: var(--type-watch-bg);
  }
  .setup-opt.active {
    background: var(--type-watch-bg);
    border: 1px solid var(--type-watch-border);
  }
  .setup-opt-name {
    font-weight: 700;
    color: var(--type-watch);
    display: flex;
    justify-content: space-between;
  }
  .setup-opt-meta {
    font-size: 0.72rem;
    color: var(--pico-muted-color);
  }
  .setup-opt-new {
    margin-top: 0.2rem;
    padding: 0.5rem 0.65rem;
    min-height: 2.35rem;
    display: flex;
    align-items: center;
    border-top: 1px solid var(--pico-muted-border-color);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--type-action);
    cursor: pointer;
    border-radius: 0 0 6px 6px;
  }
  .setup-opt-new:hover {
    background: var(--type-action-bg);
  }

  /* Compact Box 2: Watch Status on top, [Stop / -1h] and [+1h] buttons underneath
     Color Theory Fix (Chromatic Isolation): Neutral slate frame + white tray with a gap between
     [Stop] (Off Red hollow/light fill) and [+1h] (On Green solid fill) prevents complementary red/green edge clash! */
  .watch-box {
    display: flex;
    flex-direction: column;
    border: 1.5px solid #cbd5e1;
    border-radius: 7px;
    overflow: hidden;
    background: #ffffff;
    min-width: 0;
    max-width: 100%;
  }
  .watch-box.stopped {
    border-color: var(--type-action);
    background: var(--type-action);
    justify-content: center;
  }
  .watch-box .watch-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.2rem 0.5rem;
    font-size: 0.74rem;
    font-weight: 800;
    background: var(--type-active-bg);
    color: var(--type-active);
    border-bottom: 1px solid #cbd5e1;
    white-space: nowrap;
    line-height: 1.15;
  }
  .watch-box .watch-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.26rem;
    padding: 0.24rem;
    background: #ffffff;
  }
  .watch-box button {
    margin: 0;
    width: 100%;
    border-radius: 5px;
    padding: 0.32rem 0.55rem;
    font-size: 0.8rem;
    font-weight: 800;
    min-height: 1.95rem;
    cursor: pointer;
    box-shadow: none;
    line-height: 1.15;
  }
  .watch-box .btn-minus {
    --pico-background-color: #ffffff;
    --pico-color: var(--type-off-red);
    background: #ffffff !important;
    color: var(--type-off-red) !important;
    border: 1.5px solid var(--type-off-red-border) !important;
  }
  .watch-box .btn-minus:hover {
    /* Un-shaded #ffffff interior on hover (prevents simultaneous contrast clash next to green +1h) + crisp red ring */
    background: #ffffff !important;
    border-color: #b91c1c !important;
    color: #b91c1c !important;
    box-shadow: 0 0 0 2px rgba(240, 62, 62, 0.22) !important;
  }
  .watch-box .btn-minus.minus-hour {
    --pico-background-color: #f0f9ff;
    --pico-color: var(--type-action);
    background: #f0f9ff !important;
    color: var(--type-action) !important;
    border: 1.5px solid var(--type-action) !important;
  }
  .watch-box .btn-plus {
    --pico-background-color: #16a34a;
    --pico-color: #ffffff;
    background: #16a34a !important;
    color: #ffffff !important;
    border: 1.5px solid #15803d !important;
  }
  .watch-box .btn-plus:hover {
    background: #15803d !important;
  }
  .watch-box .btn-start {
    --pico-background-color: #0172ad;
    --pico-color: #ffffff;
    background: #0172ad !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem;
  }

  /* Surrounding Boxes for UI Elements OUTSIDE Text Chat */
  .box-watch {
    display: inline-block;
    background: var(--type-watch-bg);
    color: var(--type-watch);
    border: 1px solid var(--type-watch-border);
    border-radius: 5px;
    padding: 0.05rem 0.42rem;
    font-weight: 700;
    font-size: 0.88em;
  }
  .box-alert {
    display: inline-block;
    background: var(--type-alert-bg);
    color: var(--type-alert);
    border: 1px solid var(--type-alert-border);
    border-radius: 5px;
    padding: 0.05rem 0.42rem;
    font-weight: 700;
    font-size: 0.86em;
  }
  .btn-test .box-watch {
    background: #faf5ff;
    color: #6b21a8;
    border-color: #d8b4fe;
    margin-left: 0.35rem;
    padding: 0.02rem 0.4rem;
  }

  /* IDE-Style Colored Tokens INSIDE Text Chat (NO surrounding boxes!) */
  .chat-thread .t-watch {
    color: var(--type-watch);
    font-weight: 700;
  }
  .chat-thread .t-action {
    color: var(--type-action-ref);
    font-weight: 800;
  }
  .chat-thread .t-alert {
    color: var(--type-alert);
    font-weight: 700;
  }
  .chat-thread .t-cond {
    color: var(--pico-color);
    font-weight: 700;
  }

  /* Bottom Recent / Live Logs Console (UF-06 + UF-09):
     Shows both alerts that fired (Red/Green) and checks that ran and did nothing (Neutral) */
  .logs-section {
    margin-top: 1rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 8px;
    background: #fcfcfd;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
  }
  .logs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
    padding: 0.45rem 0.75rem;
    background: #f3f4f6;
    border-bottom: 1px solid var(--pico-muted-border-color);
    font-size: 0.82rem;
  }
  .logs-title {
    font-weight: 700;
    color: var(--pico-color);
    display: flex;
    align-items: center;
    gap: 0.45rem;
  }
  .logs-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--type-active);
    display: inline-block;
  }
  .logs-status-dot.paused {
    background: #9ca3af;
  }
  .logs-meta {
    color: var(--pico-muted-color);
    font-size: 0.76rem;
  }
  .log-list {
    display: flex;
    flex-direction: column;
    width: 100%;
  }
  .log-row {
    display: grid;
    grid-template-columns: 3.4rem minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #eef0f3;
    font-size: 0.85rem;
    line-height: 1.4;
    width: 100%;
    max-width: 100%;
  }
  .log-row:last-child {
    border-bottom: none;
  }
  /* Alert Fired Row (Red for conditional alert) */
  .log-row.fired {
    background: var(--type-trigger-bg);
    border-left: 4px solid var(--type-trigger);
  }
  /* Always-Message Fired Row (Green for continuous readout) */
  .log-row.always {
    background: var(--type-active-bg);
    border-left: 4px solid var(--type-active);
  }
  /* Checked & Did Nothing Row (Neutral) */
  .log-row.noop {
    background: #ffffff;
    border-left: 4px solid #cbd5e1;
  }
  .log-time {
    font-family: var(--pico-font-family-monospace);
    font-size: 0.78rem;
    color: var(--pico-muted-color);
    white-space: nowrap;
  }
  .log-body {
    color: var(--pico-color);
    min-width: 0;
  }
  .log-badge-fired {
    font-weight: 700;
    color: var(--type-trigger);
    margin-right: 0.25rem;
  }
  .log-badge-always {
    font-weight: 700;
    color: var(--type-active);
    margin-right: 0.25rem;
  }
  .log-badge-noop {
    font-weight: 700;
    color: var(--pico-muted-color);
    margin-right: 0.25rem;
  }
  .log-why {
    display: block;
    font-size: 0.79rem;
    color: var(--pico-muted-color);
    margin-top: 0.1rem;
  }
  .log-frame {
    font-family: var(--pico-font-family-monospace);
    font-size: 0.75rem;
    color: var(--pico-muted-color);
    white-space: nowrap;
  }

  /* Main P0 2-column workspace: Left = AI Chat (UF-03), Right = Photo + Aim + Test (UF-02, UF-04) */
  .workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
    padding-block: 0 !important;
    width: 100%;
    max-width: 100%;
  }

  /* Camera & Chat Columns — min-width: 0 prevents grid tracks from overflowing viewport */
  .col-camera, .col-chat {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }
  .photo-frame {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--pico-muted-border-color);
    background: #0d1117;
    width: 100%;
    max-width: 100%;
  }
  .photo-frame img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 360px;
    object-fit: cover;
    transition: transform 0.2s ease;
  }
  .photo-frame img.cropped-full {
    transform: scale(1.38) translate(-12%, -4%) !important;
  }
  /* Visual Crop Box Overlay on the top photo when "Crop" is active */
  .crop-overlay {
    position: absolute;
    inset: 0;
    overflow: clip;
    pointer-events: none;
  }
  .crop-box-rect {
    position: absolute;
    top: 10%;
    left: 44%;
    width: 48%;
    height: 82%;
    border: 2px dashed #38bdf8;
    border-radius: 4px;
    box-shadow: 0 0 0 400px rgba(0, 0, 0, 0.38);
    pointer-events: auto;
    cursor: move;
    touch-action: none;
    user-select: none;
  }
  .crop-handle {
    position: absolute;
    width: 26px;
    height: 26px;
    background: #ffffff;
    border: 2.5px solid #0172ad;
    border-radius: 6px;
    pointer-events: auto;
    touch-action: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  }
  .crop-handle.tl { top: -13px; left: -13px; cursor: nwse-resize; }
  .crop-handle.tr { top: -13px; right: -13px; cursor: nesw-resize; }
  .crop-handle.bl { bottom: -13px; left: -13px; cursor: nesw-resize; }
  .crop-handle.br { bottom: -13px; right: -13px; cursor: nwse-resize; }

  /* Visual Privacy Mask Overlay on the top photo when "Privacy Mask" is active */
  .mask-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
  }
  .mask-rect {
    position: absolute;
    background: rgba(15, 23, 42, 0.92);
    border: 1.5px dashed #f87171;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fca5a5;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    pointer-events: auto;
    cursor: move;
    touch-action: none;
    user-select: none;
  }
  .mask-del-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    border-radius: 5px;
    background: rgba(220, 38, 38, 0.95) !important;
    color: #ffffff !important;
    font-size: 0.9rem !important;
    font-weight: 800 !important;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1.5px solid #fecaca !important;
    padding: 0 !important;
    margin: 0 !important;
    z-index: 5;
  }
  .baseline-diff-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.48;
    mix-blend-mode: difference;
    pointer-events: none;
    z-index: 12;
  }
  .photo-stamp {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    max-width: calc(100% - 16px);
  }

  /* Camera actions: 1 single line ([Take photo] [Crop ▾] [Test Sourdough]) even at 360px */
  .cam-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    align-items: center;
    width: 100%;
    max-width: 100%;
  }
  .cam-actions button {
    margin: 0;
    padding: 0.36rem 0.55rem;
    font-size: 0.82rem;
    width: auto;
    max-width: 100%;
    white-space: nowrap;
  }
  .cam-actions .btn-outline {
    flex: 0 0 auto;
    --pico-background-color: #ffffff;
    --pico-color: var(--type-action);
    --pico-border-color: var(--type-action);
    background: #ffffff !important;
    color: var(--type-action) !important;
    border: 1.5px solid var(--type-action) !important;
    font-weight: 700;
  }
  .cam-actions .btn-test {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 700;
    --pico-background-color: var(--type-action);
    --pico-color: #ffffff;
    background: var(--type-action) !important;
    border: 1.5px solid var(--type-action) !important;
    color: #ffffff !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Compact inline Test Result card (UF-04) */
  .test-result {
    border: 1px solid var(--type-trigger-border);
    border-left: 4px solid var(--type-trigger);
    background: var(--type-trigger-bg);
    border-radius: 0 6px 6px 0;
    padding: 0.625rem 0.75rem;
    font-size: 0.88rem;
    width: 100%;
    max-width: 100%;
  }
  .test-result.always {
    border-color: var(--type-active-border);
    border-left-color: var(--type-active);
    background: var(--type-active-bg);
  }
  .test-result-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .verdict-pass {
    font-weight: 700;
    color: var(--type-trigger);
  }
  .test-result.always .verdict-pass {
    color: var(--type-active);
  }
  .test-time {
    font-size: 0.78rem;
    color: var(--pico-muted-color);
  }
  .test-why {
    margin: 0;
    color: var(--pico-color);
    line-height: 1.4;
  }

  /* P1 UF-07: Mode Switcher at top of Left Column (fills full horizontal width) */
  .left-mode-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    width: 100%;
  }
  .mode-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    flex: 1 1 auto;
    width: 100%;
    border: 1.5px solid var(--type-action);
    border-radius: 7px;
    overflow: hidden;
    background: #ffffff;
  }
  .mode-tab {
    margin: 0 !important;
    width: 100% !important;
    text-align: center !important;
    border: none !important;
    border-right: 1px solid #bae6fd !important;
    border-radius: 0 !important;
    padding: 0.36rem 0.25rem !important;
    min-height: 2.15rem !important;
    font-size: 0.78rem !important;
    font-weight: 800 !important;
    background: #f0f9ff !important;
    color: var(--type-action) !important;
    cursor: pointer;
    box-shadow: none !important;
    white-space: nowrap;
  }
  .mode-tab:last-child {
    border-right: none !important;
  }
  .mode-tab.active {
    background: var(--type-action) !important;
    color: #ffffff !important;
    box-shadow: none !important;
  }
  /* P1 UF-07: Manual Editor fields — full-width clean layout at 360px */
  .manual-editor {
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.7rem;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    font-size: 0.84rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .manual-field {
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
    min-width: 0;
    width: 100%;
  }
  .manual-field label {
    margin: 0;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--pico-muted-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
  }
  .manual-row-2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    gap: 0.45rem;
    align-items: start;
  }
  .manual-editor input[type="text"],
  .manual-editor input[type="number"],
  .manual-editor input[type="time"],
  .manual-editor select,
  .manual-editor textarea {
    margin: 0 !important;
    padding: 0.32rem 0.5rem !important;
    height: auto !important;
    font-size: 0.84rem !important;
    background: #ffffff !important;
    border-radius: 6px !important;
    width: 100% !important;
    min-width: 0 !important;
    color: var(--pico-color) !important;
    border: 1px solid var(--pico-muted-border-color) !important;
    box-shadow: none !important;
  }
  .manual-editor textarea.auto-expand {
    resize: none;
    overflow: hidden;
    line-height: 1.4;
    min-height: 2.6rem;
  }
  .manual-editor .input-watch-name {
    border: 1.5px solid var(--type-watch-border) !important;
    color: var(--type-watch) !important;
    font-weight: 700 !important;
  }
  .manual-editor .input-alert-dest {
    border: 1.5px solid var(--type-alert-border) !important;
    background: var(--type-alert-bg) !important;
    color: var(--type-alert) !important;
    font-weight: 700 !important;
    font-family: var(--pico-font-family-monospace);
  }

  /* Check Every / Watch Duration / Notifications before stop: clickable pill that splits into [number] + [units] */
  .check-every-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    background: #ffffff;
    border: 1.5px solid #94a3b8;
    border-radius: 6px;
    padding: 0.38rem 0.6rem;
    min-height: 2.2rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--pico-color);
    cursor: pointer;
    user-select: none;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
  }
  .check-every-display:hover {
    border-color: var(--type-action);
    background: #f8fafc;
    box-shadow: 0 1px 3px rgba(1, 114, 173, 0.15);
  }
  .check-every-display .click-caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--type-action-bg);
    border: 1px solid var(--type-action-border);
    border-radius: 4px;
    padding: 0.12rem 0.38rem;
    font-size: 0.78rem;
    font-weight: 900;
    color: var(--type-action);
    line-height: 1;
    flex-shrink: 0;
  }
  .check-every-display.stop-after-display {
    border-color: var(--type-off-red-border);
    background: var(--type-off-red-bg);
    color: var(--type-off-red);
  }
  .check-every-display.stop-after-display:hover {
    border-color: #b91c1c;
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(240, 62, 62, 0.18);
  }
  .check-every-display.stop-after-display .click-caret {
    background: #ffffff;
    border-color: var(--type-off-red-border);
    color: var(--type-off-red);
  }
  .check-every-split {
    display: grid;
    grid-template-columns: 3.8rem minmax(0, 1fr) auto;
    gap: 0.3rem;
    align-items: center;
  }
  .check-every-split.no-num {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .check-every-split input[type="number"] {
    text-align: center;
    font-weight: 700;
    padding: 0.3rem 0.25rem !important;
    min-height: 2.15rem !important;
  }
  .check-every-split select {
    padding: 0.3rem 0.35rem !important;
    font-weight: 600;
    min-height: 2.15rem !important;
  }
  .check-every-done-btn {
    margin: 0 !important;
    width: auto !important;
    min-width: 2.2rem !important;
    min-height: 2.15rem !important;
    padding: 0.25rem 0.55rem !important;
    font-size: 0.85rem !important;
    font-weight: 800 !important;
    border-radius: 6px !important;
    background: var(--type-action) !important;
    color: #ffffff !important;
    border: 1.5px solid var(--type-action) !important;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Help (?) badge for polymorphic Send To field (Fat-finger friendly on mobile) */
  .help-q {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #ffffff;
    border: 1.5px solid var(--type-action);
    color: var(--type-action);
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
    user-select: none;
  }
  .help-q:hover {
    background: var(--type-action);
    color: #ffffff;
  }
  .poly-help-box {
    font-size: 0.74rem;
    color: var(--pico-muted-color);
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.35rem 0.55rem;
    line-height: 1.35;
  }

  .alert-mode-pills {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.35rem;
  }
  .alert-mode-pill {
    margin: 0 !important;
    padding: 0.42rem 0.45rem !important;
    min-height: 2.2rem !important;
    font-size: 0.78rem !important;
    font-weight: 700 !important;
    border-radius: 6px !important;
    cursor: pointer;
    text-align: center;
    background: #f0f9ff !important;
    border: 1.5px solid #93c5fd !important;
    color: var(--type-action) !important;
    min-width: 0 !important;
    width: 100% !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .alert-mode-pill:hover {
    background: #e0f2fe !important;
    border-color: var(--type-action) !important;
  }
  .alert-mode-pill.cond-active,
  .alert-mode-pill.always-active {
    background: var(--type-action) !important;
    border-color: var(--type-action) !important;
    color: #ffffff !important;
  }

  /* P1 UF-08: Merged Crop / Tune Dropdown on the 1-line camera action bar */
  .cam-tool-wrap {
    position: relative;
    display: inline-flex;
  }
  .cam-tool-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 175px;
    background: #ffffff;
    border: 1.5px solid var(--type-action);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.14);
    padding: 0.3rem;
    z-index: 55;
  }
  .cam-tool-opt {
    padding: 0.48rem 0.65rem;
    min-height: 2.3rem;
    margin-bottom: 0.15rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--pico-color);
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .cam-tool-opt:hover, .cam-tool-opt.active {
    background: var(--type-action-bg);
    color: var(--type-action);
    font-weight: 700;
  }

  /* P1 UF-08: Image Tuning & Advanced Camera Drawer (Privacy Mask & Knobs)
     High-contrast sky-blue studio panel with centered controls and an upward connector arrow to the photo */
  @keyframes toolPanelPop {
    0% { transform: translateY(-4px); box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.35), 0 8px 20px rgba(1, 114, 173, 0.22); }
    100% { transform: translateY(0); box-shadow: 0 4px 14px rgba(1, 114, 173, 0.15); }
  }
  .tune-drawer {
    position: relative;
    border: 2px solid #94a3b8;
    border-top: 4px solid #334155;
    border-radius: 9px;
    background: #f8fafc;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.1);
    padding: 0.7rem 0.8rem;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: 100%;
    max-width: 100%;
    animation: toolPanelPop 0.28s ease-out;
  }
  /* Upward pointer in the center connecting the tool panel directly to the photo above */
  .tune-drawer::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-bottom: 8px solid #334155;
  }
  .tune-studio-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    text-align: center;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #cbd5e1;
  }
  .tune-studio-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: #1e293b;
    color: #ffffff;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
  }
  .tune-studio-sub {
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
  }
  .tune-top-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    flex-wrap: wrap;
  }
  .tune-btn-group {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
  }
  .tune-btn-sm {
    margin: 0 !important;
    width: auto !important;
    padding: 0.26rem 0.6rem !important;
    font-size: 0.76rem !important;
    font-weight: 700 !important;
    border-radius: 6px !important;
    --pico-background-color: #ffffff;
    --pico-color: #0172ad;
    background: #ffffff !important;
    color: var(--type-action) !important;
    border: 1.5px solid var(--type-action) !important;
    box-shadow: 0 1px 2px rgba(1, 114, 173, 0.1) !important;
    cursor: pointer;
    white-space: nowrap;
  }
  .tune-btn-sm:hover {
    background: #dbeafe !important;
    border-color: var(--type-action) !important;
    color: var(--type-action) !important;
  }
  .tune-btn-sm.primary-tool-btn {
    --pico-background-color: #0172ad;
    --pico-color: #ffffff;
    background: var(--type-action) !important;
    color: #ffffff !important;
  }
  .tune-btn-sm.primary-tool-btn:hover {
    background: #0369a1 !important;
    color: #ffffff !important;
  }
  /* 3. Cancel / Close / Delete Red (.btn-cancel-red) — placed AFTER .tune-btn-sm with higher specificity so it always wins over blue! */
  .tune-btn-sm.btn-cancel-red,
  button.btn-cancel-red,
  .btn-cancel-red {
    --pico-background-color: var(--type-cancel-red-bg);
    --pico-color: var(--type-cancel-red);
    background: var(--type-cancel-red-bg) !important;
    color: var(--type-cancel-red) !important;
    border: 1.5px solid var(--type-cancel-red-border) !important;
    box-shadow: 0 1px 2px rgba(225, 29, 72, 0.1) !important;
  }
  .tune-btn-sm.btn-cancel-red:hover,
  button.btn-cancel-red:hover,
  .btn-cancel-red:hover {
    background: #ffe4e6 !important;
    color: #be123c !important;
    border-color: var(--type-cancel-red) !important;
    box-shadow: 0 0 0 2px rgba(225, 29, 72, 0.16) !important;
  }
  .tune-sliders {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    gap: 0.45rem;
  }
  .tune-slider-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.32rem 0.5rem;
  }
  .tune-slider-item label {
    margin: 0;
    font-size: 0.73rem;
    font-weight: 700;
    color: var(--pico-color);
    display: flex;
    justify-content: space-between;
  }
  .tune-slider-item input[type="range"] {
    margin: 0 !important;
    height: 1.65rem !important;
  }
  /* Fat-finger Mobile Slider Track & 24px Thumb across all range inputs */
  input[type="range"] {
    height: 1.65rem !important;
    padding: 0.2rem 0 !important;
    cursor: pointer;
  }
  input[type="range"]::-webkit-slider-thumb {
    width: 24px !important;
    height: 24px !important;
    border-radius: 50% !important;
    background: var(--type-action) !important;
    border: 2.5px solid #ffffff !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35) !important;
    cursor: pointer;
  }
  input[type="range"]::-moz-range-thumb {
    width: 24px !important;
    height: 24px !important;
    border-radius: 50% !important;
    background: var(--type-action) !important;
    border: 2.5px solid #ffffff !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35) !important;
    cursor: pointer;
  }
  /* Slider turns Off Red when at 0 */
  input[type="range"].is-zero {
    accent-color: var(--type-off-red) !important;
  }
  input[type="range"].is-zero::-webkit-slider-runnable-track {
    background: #fee2e2 !important;
    border-radius: 999px !important;
  }
  input[type="range"].is-zero::-moz-range-track {
    background: #fee2e2 !important;
    border-radius: 999px !important;
  }
  input[type="range"].is-zero::-webkit-slider-thumb {
    background: var(--type-off-red) !important;
    border: 2.5px solid #ffffff !important;
    box-shadow: 0 0 0 1.5px var(--type-off-red-border), 0 1px 4px rgba(201, 42, 42, 0.35) !important;
  }
  input[type="range"].is-zero::-moz-range-thumb {
    background: var(--type-off-red) !important;
    border: 2.5px solid #ffffff !important;
    box-shadow: 0 0 0 1.5px var(--type-off-red-border), 0 1px 4px rgba(201, 42, 42, 0.35) !important;
  }
  .tune-slider-item select.tune-select {
    margin: 0 !important;
    padding: 0.24rem 0.4rem !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    height: auto !important;
    border-radius: 5px !important;
    border: 1.5px solid var(--type-action) !important;
    background: #ffffff !important;
    color: var(--type-action) !important;
    cursor: pointer;
  }
  /* 2. Off Red for any <select> currently set to "Off" (or "Nothing (skip sending)") AND the "Off" <option> in any dropdown list */
  .tune-slider-item select.tune-select.is-off,
  .manual-editor select.is-off,
  select.is-off {
    border: 1.5px solid var(--type-off-red-border) !important;
    background: #ffffff !important;
    color: var(--type-off-red) !important;
  }
  select option {
    color: var(--pico-color);
    background: #ffffff;
    font-weight: 600;
  }
  select option[value="off"],
  select option[value^="nothing"] {
    color: var(--type-off-red) !important;
    font-weight: 800 !important;
  }
  .val-off {
    color: var(--type-off-red) !important;
    font-weight: 800 !important;
  }
  /* Mobile-friendly Tactile Pill Switches (replaces tiny native checkboxes) */
  .pill-switch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
    gap: 0.38rem;
    padding-top: 0.35rem;
    border-top: 1px solid #cbd5e1;
  }
  .pill-switch {
    margin: 0 !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.35rem !important;
    padding: 0.36rem 0.6rem !important;
    min-height: 2.1rem !important;
    border-radius: 999px !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    cursor: pointer;
    user-select: none;
    background: var(--type-off-red-bg) !important;
    border: 1.5px solid var(--type-off-red-border) !important;
    color: var(--type-off-red) !important;
    box-shadow: none !important;
    transition: all 0.12s ease;
  }
  .pill-switch:hover {
    border-color: var(--type-action) !important;
  }
  .pill-switch .pill-state {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    /* 2. Off Red: light inside, warm brick-red border, warm brick-red text (no inner dot needed) */
    background: #ffffff;
    border: 1.5px solid var(--type-off-red-border);
    color: var(--type-off-red);
    white-space: nowrap;
  }
  .pill-switch.on {
    background: #f0fdf4 !important;
    border-color: #16a34a !important;
    color: #14532d !important;
  }
  .pill-switch.on .pill-state {
    /* Green ON: solid green fill, white text (no inner dot needed) */
    background: #16a34a;
    border-color: #15803d;
    color: #ffffff;
  }
  .knobs-section-title {
    font-size: 0.71rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #334155;
    margin-top: 0.15rem;
    padding-bottom: 0.15rem;
    border-bottom: 1px dashed #cbd5e1;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  /* Google Sheet access error / status box under polymorphic Send To */
  .sheet-error-box {
    border: 1.5px solid var(--type-trigger);
    background: var(--type-trigger-bg);
    border-radius: 6px;
    padding: 0.45rem 0.55rem;
    font-size: 0.75rem;
    color: var(--pico-color);
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
    line-height: 1.35;
  }
  .sheet-ok-box {
    border: 1.5px solid var(--type-active);
    background: var(--type-active-bg);
    border-radius: 6px;
    padding: 0.35rem 0.55rem;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--type-active);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.4rem;
  }
  /* P1 UF-16: Error status badge & top-level Error / Paging Banner */
  .badge-error {
    font-size: 0.72rem;
    font-weight: 800;
    padding: 0.1rem 0.45rem;
    border-radius: 5px;
    background: var(--type-trigger-bg);
    border: 1.5px solid var(--type-trigger);
    color: var(--type-trigger);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
  }
  .device-error-banner {
    border: 2px solid var(--type-trigger);
    background: var(--type-trigger-bg);
    color: var(--pico-color);
    border-radius: 8px;
    padding: 0.5rem 0.65rem;
    margin-bottom: 0.6rem;
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.45rem;
  }
  /* P1 UF-20: Baseline Reference Image overlay badge & separate side-by-side comparison card */
  .baseline-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(1, 114, 173, 0.92);
    color: #ffffff;
    border: 1.5px solid #bae6fd;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.18rem 0.5rem;
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    max-width: calc(100% - 16px);
    z-index: 15;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
  }
  .baseline-compare-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.45rem;
    background: #ffffff;
    border: 1.5px solid #93c5fd;
    border-radius: 7px;
    padding: 0.45rem;
  }
  .baseline-compare-slot {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
  }
  .baseline-compare-slot img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid #cbd5e1;
    display: block;
  }
  .baseline-compare-label {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--pico-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  /* P2 UF-22: 7 Day-of-Week Circle Buttons (The circle itself IS the filled green dot / hollow red circle!) */
  .day-btn-row {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.25rem;
    justify-items: center;
    width: 100%;
  }
  .day-btn {
    margin: 0 !important;
    width: 2.35rem !important;
    height: 2.35rem !important;
    min-width: 2.35rem !important;
    min-height: 2.35rem !important;
    padding: 0 !important;
    font-size: 0.84rem !important;
    font-weight: 800 !important;
    text-align: center !important;
    border-radius: 50% !important;
    /* 2. Off Red unselected: light inside, warm brick-red circle border, warm brick-red letters */
    background: var(--type-off-red-bg) !important;
    color: var(--type-off-red) !important;
    border: 2px solid var(--type-off-red-border) !important;
    cursor: pointer;
    box-shadow: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
    line-height: 1 !important;
    transition: all 0.12s ease;
  }
  .day-btn sub {
    position: relative;
    top: 0.34em;
    bottom: auto;
    font-size: 0.62em;
    line-height: 0;
    font-weight: 800;
    margin-left: 0.5px;
  }
  .day-btn.active {
    /* Green selected: solid green filled circle, light white letters */
    background: #16a34a !important;
    color: #ffffff !important;
    border-color: #15803d !important;
  }
  /* Prompt (Evaluated by AI) vs. Plain Text (Sent Literally) Color Coding */
  .badge-prompt {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.68rem;
    font-weight: 800;
    padding: 0.08rem 0.42rem;
    border-radius: 999px;
    background: #e0e7ff;
    color: #3730a3;
    border: 1px solid #a5b4fc;
    white-space: nowrap;
  }
  .badge-literal {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.68rem;
    font-weight: 800;
    padding: 0.08rem 0.42rem;
    border-radius: 999px;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    white-space: nowrap;
  }
  .field-prompt textarea {
    border: 2px solid #6366f1 !important;
    background: #f5f7ff !important;
    color: #1e1b4b !important;
  }
  .field-literal textarea {
    border: 2px solid #94a3b8 !important;
    background: #ffffff !important;
    color: #181c20 !important;
  }
  /* Camera Prefix Tag inside Config Name (e.g. KS-Sourdough / 3P-Sourdough) */
  .config-prefix-wrap {
    display: flex;
    align-items: stretch;
    border: 1.5px solid var(--type-watch-border);
    border-radius: 6px;
    overflow: hidden;
    background: var(--type-watch-bg);
  }
  .config-prefix-tag {
    display: inline-flex;
    align-items: center;
    padding: 0 0.55rem;
    font-family: var(--pico-font-family-monospace);
    font-size: 0.82rem;
    font-weight: 800;
    background: #ede9fe;
    color: var(--type-watch);
    border-right: 1.5px solid var(--type-watch-border);
    user-select: none;
    white-space: nowrap;
  }
  .config-prefix-wrap input.input-watch-name {
    border: none !important;
    border-radius: 0 !important;
    flex: 1 1 auto;
  }
  /* Persistent Cropped Indicator Button on Photo Viewer (Tap anywhere on button to delete crop) */
  .crop-active-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    margin: 0 !important;
    width: auto !important;
    background: rgba(1, 114, 173, 0.94) !important;
    color: #ffffff !important;
    border: 1.5px solid #bae6fd !important;
    font-size: 0.78rem !important;
    font-weight: 800 !important;
    padding: 0.32rem 0.65rem !important;
    min-height: 2.1rem !important;
    border-radius: 6px !important;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    z-index: 15;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28) !important;
  }
  .crop-active-badge:hover {
    background: #dc2626 !important;
    border-color: #fecaca !important;
  }
  /* Multi-Step Reversible Undo Toast Bar */
  .undo-toast-bar {
    border: 1.5px solid #cbd5e1;
    background: #f8fafc;
    color: var(--pico-color);
    border-radius: 7px;
    padding: 0.42rem 0.65rem;
    margin-bottom: 0.55rem;
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.45rem;
  }
  /* P1 UF-19 (Beta): Pin & Label Reference Photo ground-truth badge on log rows (Blue clickable — Purple is reserved strictly for Configs) */
  .pin-expect-btn {
    margin: 0 !important;
    width: auto !important;
    padding: 0.26rem 0.55rem !important;
    min-height: 1.95rem !important;
    font-size: 0.74rem !important;
    font-weight: 700 !important;
    border-radius: 6px !important;
    background: var(--type-action-bg) !important;
    color: var(--type-action) !important;
    border: 1.5px solid var(--type-action-border) !important;
    cursor: pointer;
    white-space: nowrap;
  }
  .pin-expect-btn:hover {
    background: #dbeafe !important;
    border-color: var(--type-action) !important;
  }

  /* P1 UF-09: Clickable Log Frame Link to inspect historical check photo */
  .log-frame-btn {
    margin: 0 !important;
    width: auto !important;
    padding: 0.26rem 0.55rem !important;
    min-height: 1.95rem !important;
    font-family: var(--pico-font-family-monospace);
    font-size: 0.74rem !important;
    font-weight: 700 !important;
    color: var(--type-action) !important;
    background: #ffffff !important;
    border: 1.5px solid var(--type-action-border) !important;
    border-radius: 6px !important;
    cursor: pointer;
    white-space: nowrap;
  }
  .log-frame-btn:hover {
    background: var(--type-action-bg) !important;
    border-color: var(--type-action) !important;
  }

  /* AI Chat Column (UF-03) */
  .chat-thread {
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    background: #fcfcfd;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .msg {
    padding: 0.55rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.45;
    min-width: 0;
  }
  .msg.user {
    background: #eef6fc;
    border: 1px solid #cce3f6;
    align-self: flex-end;
    max-width: 92%;
  }
  .msg.agent {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    align-self: flex-start;
    max-width: 98%;
  }
  .msg b.speaker {
    display: block;
    font-size: 0.75rem;
    color: var(--pico-muted-color);
    margin-bottom: 0.15rem;
  }
  .composer-box {
    display: flex;
    gap: 0.4rem;
    align-items: stretch;
    border: 2px solid var(--type-action);
    border-radius: 8px;
    padding: 0.35rem;
    background: #fff;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .composer-box textarea {
    margin: 0;
    border: none;
    box-shadow: none;
    resize: none;
    font-size: 0.9rem;
    padding: 0.3rem 0.4rem;
    min-height: 3.1rem;
    min-width: 0;
    width: 100%;
  }
  .composer-box button {
    margin: 0;
    width: auto;
    flex-shrink: 0;
    padding: 0 0.95rem;
    font-weight: 700;
    align-self: flex-end;
    height: 2.3rem;
    --pico-background-color: var(--type-action);
    --pico-color: #ffffff;
    background: var(--type-action) !important;
    border-color: var(--type-action) !important;
    color: #ffffff !important;
  }

  /* Visual Scroll & Boundary Affordances:
     1. Left & right vertical rails on body prove nothing is off-screen left/right.
     2. Single sticky top bar switches between "— Top of page · Nothing left or right —" and "↑ More above · Scroll up".
     3. Single sticky bottom bar switches between "↓ More below · Scroll down" and "— Bottom of page · Nothing below or left/right —". */
  body {
    border-left: 2px solid #cbd5e1;
    border-right: 2px solid #cbd5e1;
    min-height: 100vh;
    position: relative;
  }
  .scroll-status-bar {
    position: sticky;
    z-index: 80;
    padding: 0.24rem 0.5rem;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    user-select: none;
    transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  }
  .scroll-status-bar.top-bar {
    top: 0;
    margin: -0.4rem -0.5rem 0.35rem;
    border-bottom: 1.5px solid #cbd5e1;
  }
  .scroll-status-bar.bottom-bar {
    bottom: 0;
    margin: 0.45rem -0.5rem -1rem;
    border-top: 1.5px solid #cbd5e1;
  }
  .scroll-status-bar.at-boundary {
    background: #f8fafc;
    color: var(--pico-muted-color);
    border-color: #cbd5e1;
    cursor: default;
  }
  .scroll-status-bar.has-more {
    background: #eff6ff;
    color: var(--type-action);
    border-color: #93c5fd;
    cursor: pointer;
    box-shadow: 0 1px 6px rgba(1, 114, 173, 0.12);
  }
  .scroll-status-bar.has-more:hover {
    background: #dbeafe;
  }

  /* Responsive rules AT THE BOTTOM of <style> so they always win */
  @media (max-width: 860px) {
    /* 1-column layout from 581px to 860px: uses 100% of the screen width as it widens */
    body {
      max-width: 100%;
      padding: 0.5rem 0.75rem 1rem;
    }
    .brand-device .sep {
      display: none;
    }
    .workspace {
      grid-template-columns: minmax(0, 1fr);
      gap: 0.85rem;
    }
    .col-camera { order: 1; }
    .col-chat { order: 2; }
  }
  @media (max-width: 620px) {
    /* Only when pinned at Firefox's GTK min-width floor (with or without left vertical sidebar):
       fit cleanly inside 332px CSS so even a 535px physical window with a 60px sidebar has 0 clipping */
    body {
      max-width: 332px;
      padding: 0.4rem 0.45rem 1rem;
    }
    .brand-device .sep {
      display: none;
    }
    .app-account-row {
      width: 100%;
    }
    .device-select-wrap {
      width: 100%;
      flex: 1 1 100%;
    }
    .corner-boxes {
      width: 100%;
      display: grid;
      grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
      gap: 0.3rem;
      align-items: stretch;
    }
    .setup-box-wrap {
      min-width: 0;
    }
    .setup-box {
      width: 100%;
      height: 100%;
      padding: 0.2rem 0.42rem;
    }
    .setup-box .setup-sub {
      font-size: 0.68rem;
    }
    .watch-box {
      min-width: 0;
    }
    .watch-box .watch-top {
      white-space: normal;
      text-align: center;
      font-size: 0.68rem;
      padding: 0.18rem 0.3rem;
    }
    .watch-box button {
      padding: 0.36rem 0.35rem;
      font-size: 0.78rem;
    }
    .cam-actions {
      gap: 0.28rem;
    }
    .cam-actions button {
      padding: 0.34rem 0.42rem;
      font-size: 0.76rem;
    }
    .mode-tab {
      padding: 0.4rem 0.2rem !important;
      font-size: 0.76rem !important;
    }
    .day-btn {
      width: 2.15rem !important;
      height: 2.15rem !important;
      min-width: 2.15rem !important;
      min-height: 2.15rem !important;
      font-size: 0.78rem !important;
    }
    .setup-dropdown {
      left: 0;
      right: auto;
      min-width: min(230px, 100%);
    }
    .log-row {
      grid-template-columns: minmax(0, 1fr);
      gap: 0.2rem;
      padding: 0.45rem 0.6rem;
      font-size: 0.82rem;
    }
    .log-time, .log-frame {
      font-size: 0.72rem;
    }
  }
  .undo-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    font-size: 0.82rem;
    color: var(--pico-muted-color);
  }
  .undo-bar a { font-weight: 700; color: var(--type-action); text-decoration: none; }
  .undo-bar a:hover { text-decoration: underline; }
