    /* ── Reset & Tokens ──────────────────────────────────────── */
    * { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

    :root {
      --sage:         #7B9B8A;
      --sage-light:   #E7F4EF;
      --sage-dark:    #4A7C6B;
      --clay:         #C4956A;
      --clay-light:   #FDF3EB;
      --yellow:       #E8B563;
      --yellow-light: #FFF8E7;
      --bg:           #F9F7F4;
      --white:        #FFFFFF;
      --dark:         #2C2C2C;
      --mid:          #6B6B6B;
      --light:        #AAAAAA;
      --border:       #E8E4DF;
      --shadow:       0 2px 16px rgba(0,0,0,0.08);
      --red:          #A85751;
      --red-light:    #FFF5F5;
    }

    html { height: 100%; }
    body {
      font-family: 'Nunito', sans-serif;
      background: var(--bg);
      color: var(--dark);
      height: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
    }

    h1, h2, .brand { font-family: 'Comfortaa', sans-serif; }

    /* ── Page wrapper ────────────────────────────────────────── */
    .page {
      width: 100%;
      max-width: 420px;
      height: 100%;
      display: flex;
      flex-direction: column;
    }

    /* ── Status bar ──────────────────────────────────────────── */
    .status-bar {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 14px 20px 8px;
      font-size: 13px;
      font-weight: 700;
      color: var(--dark);
      flex-shrink: 0;
    }

    /* ── Panel system (messages screen only) ─────────────────── */
    .panel { display: none; flex: 1; min-height: 0; flex-direction: column; }
    .panel.active { display: flex; }

    /* ── Shared buttons ──────────────────────────────────────── */
    .btn {
      display: block;
      width: 100%;
      padding: 16px;
      border: none;
      border-radius: 14px;
      font-family: 'Nunito', sans-serif;
      font-size: 15px;
      font-weight: 700;
      cursor: pointer;
      text-align: center;
      text-decoration: none;
      transition: opacity .15s, transform .12s;
    }
    .btn:active { opacity: .82; transform: scale(.98); }
    .btn-sage  { background: var(--sage);  color: var(--white); box-shadow: 0 4px 14px rgba(123,155,138,.32); }
    .btn-ghost { background: var(--white); color: var(--mid);   border: 1.5px solid var(--border); }

    /* ── Error banner ────────────────────────────────────────── */
    .error-banner {
      background: var(--red-light);
      border: 1.5px solid var(--red);
      border-radius: 12px;
      padding: 12px 16px;
      font-size: 13px;
      color: var(--red);
      line-height: 1.5;
      margin: 0 20px 20px;
    }

    /* ── Toast ───────────────────────────────────────────────── */
    .toast {
      position: fixed;
      top: 60px;
      left: 50%;
      transform: translateX(-50%) translateY(-8px);
      width: calc(100% - 40px);
      max-width: 380px;
      background: var(--dark);
      color: white;
      padding: 14px 18px;
      border-radius: 14px;
      font-size: 14px;
      font-weight: 600;
      text-align: center;
      z-index: 9999;
      opacity: 0;
      transition: all 0.25s;
      pointer-events: none;
    }
    .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

    /* ════════════════════════════════════════════════════════
       SCREEN — CONNECT
    ════════════════════════════════════════════════════════ */
    .connect-body {
      flex: 1;
      display: flex;
      flex-direction: column;
      padding: 40px 24px 40px;
    }

    .connect-logo { margin-bottom: 48px; }

    .connect-logo .brand {
      font-size: 36px;
      font-weight: 700;
      color: var(--sage);
      letter-spacing: -0.5px;
    }

    .connect-logo .tagline {
      font-size: 13px;
      color: var(--light);
      margin-top: 6px;
    }

    .connect-hero {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: center;
      margin-bottom: 48px;
    }

    .connect-headline {
      font-family: 'Comfortaa', sans-serif;
      font-size: 28px;
      font-weight: 700;
      color: var(--dark);
      line-height: 1.3;
      margin-bottom: 16px;
      letter-spacing: -0.3px;
    }

    .connect-sub {
      font-size: 15px;
      color: var(--mid);
      line-height: 1.7;
    }

    .connect-actions { margin-top: auto; }

    .btn-connect {
      width: 100%;
      padding: 18px;
      background: #25D366;
      color: white;
      border: none;
      border-radius: 16px;
      font-family: 'Nunito', sans-serif;
      font-size: 16px;
      font-weight: 700;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      box-shadow: 0 6px 20px rgba(37,211,102,0.35);
      margin-bottom: 16px;
      text-decoration: none;
      transition: transform 0.15s, opacity 0.15s;
    }
    .btn-connect:active { transform: scale(0.98); opacity: 0.9; }

    .test-connect-btn { margin-bottom: 16px; }
    .test-connect-btn:disabled { opacity: .6; cursor: default; }

    .connect-note {
      text-align: center;
      font-size: 12px;
      color: var(--light);
      line-height: 1.6;
      padding: 0 8px;
    }

    /* ════════════════════════════════════════════════════════
       SCREEN — CONNECTED
    ════════════════════════════════════════════════════════ */
    .connected-wrap {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      padding: 40px 20px;
      text-align: center;
    }

    .connected-icon {
      width: 80px;
      height: 80px;
      background: var(--sage-light);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 24px;
      border: 2.5px solid var(--sage);
    }

    .connected-icon svg { width: 36px; height: 36px; stroke: var(--sage); }

    .connected-badge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      background: var(--sage-light);
      border: 1.5px solid var(--sage);
      border-radius: 20px;
      padding: 5px 14px;
      font-size: 13px;
      font-weight: 700;
      color: var(--sage-dark);
      margin-bottom: 16px;
    }

    .connected-badge .dot {
      width: 7px; height: 7px;
      background: var(--sage);
      border-radius: 50%;
    }

    .connected-wrap h1 {
      font-size: 26px;
      font-weight: 700;
      color: var(--dark);
      margin-bottom: 10px;
    }

    .connected-wrap p {
      font-size: 14px;
      color: var(--mid);
      line-height: 1.6;
      max-width: 280px;
      margin-bottom: 40px;
    }

    .connected-actions {
      width: 100%;
      padding: 0 20px;
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    /* ════════════════════════════════════════════════════════
       PANEL 1 — MESSAGES LIST (HOME)
    ════════════════════════════════════════════════════════ */
    .home-header {
      padding: 16px 20px 20px;
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
    }

    .home-greeting {
      font-size: 14px;
      color: var(--light);
      margin-bottom: 4px;
      font-weight: 600;
    }

    .home-header h1 {
      font-size: 28px;
      font-weight: 700;
      color: var(--dark);
      letter-spacing: -0.5px;
      line-height: 1.2;
    }

    .avatar {
      width: 42px;
      height: 42px;
      background: var(--sage);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      color: white;
      font-weight: 700;
      font-size: 17px;
      font-family: 'Comfortaa', sans-serif;
      flex-shrink: 0;
      margin-top: 4px;
    }

    .home-body { flex: 1; min-height: 0; padding: 0 20px 40px; overflow-y: auto; }

    .section-label {
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.8px;
      margin-bottom: 12px;
      color: var(--light);
      display: flex;
      align-items: center;
      gap: 8px;
    }

    /* Signal card */
    @keyframes slideIn {
      from { opacity: 0; transform: translateY(8px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    .signal-card {
      background: var(--white);
      border-radius: 18px;
      border-left: 4px solid var(--yellow);
      box-shadow: var(--shadow);
      overflow: hidden;
      cursor: pointer;
      transition: transform 0.15s;
      margin-bottom: 14px;
      animation: slideIn .25s ease;
    }
    .signal-card:active { transform: scale(0.99); }

    .signal-card-inner { padding: 16px 18px 14px; }

    .signal-card-top {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      margin-bottom: 8px;
    }

    .signal-name {
      font-size: 17px;
      font-weight: 700;
      color: var(--dark);
      margin-bottom: 2px;
    }

    .signal-meta { font-size: 12px; color: var(--mid); }

    .signal-summary {
      font-size: 13px;
      color: var(--mid);
      line-height: 1.6;
      margin-bottom: 12px;
      padding: 8px 12px;
      background: var(--bg);
      border-radius: 10px;
      overflow: hidden;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
    }

    .signal-cta {
      width: 100%;
      padding: 11px;
      background: var(--yellow);
      color: white;
      border: none;
      border-radius: 11px;
      font-family: 'Nunito', sans-serif;
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
      transition: opacity 0.15s;
    }
    .signal-cta:active { opacity: 0.85; }

    /* Empty state */
    .empty-state {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 60px 32px;
      text-align: center;
    }

    .empty-icon { font-size: 48px; margin-bottom: 20px; opacity: 0.8; }

    .empty-title {
      font-family: 'Comfortaa', sans-serif;
      font-size: 20px;
      font-weight: 700;
      color: var(--dark);
      margin-bottom: 10px;
    }

    .empty-sub { font-size: 14px; color: var(--mid); line-height: 1.7; }

    /* Live indicator */
    .live-indicator {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      font-size: 11px;
      font-weight: 700;
      color: var(--sage);
      text-transform: none;
      letter-spacing: 0;
    }

    .live-dot {
      width: 6px; height: 6px;
      background: var(--sage);
      border-radius: 50%;
      animation: pulse 1.5s infinite;
    }

    @keyframes pulse {
      0%, 100% { opacity: 1; }
      50%       { opacity: .3; }
    }

    /* ════════════════════════════════════════════════════════
       PANEL 2 — CONVERSATION DETAIL
    ════════════════════════════════════════════════════════ */
    .followup-header {
      background: var(--bg);
      padding: 16px 20px 18px;
      flex-shrink: 0;
      border-bottom: 1px solid var(--border);
    }

    .followup-header-top {
      display: flex;
      align-items: center;
      gap: 14px;
      margin-bottom: 12px;
    }

    .back-btn {
      width: 34px; height: 34px;
      background: rgba(0,0,0,0.08);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 18px;
      color: var(--dark);
      cursor: pointer;
      font-weight: 700;
      flex-shrink: 0;
      border: none;
      font-family: 'Nunito', sans-serif;
      transition: background 0.15s;
    }
    .back-btn:active { background: rgba(0,0,0,0.16); }

    .followup-name {
      font-family: 'Comfortaa', sans-serif;
      font-size: 20px;
      font-weight: 700;
      color: var(--dark);
    }

    .followup-sub { font-size: 13px; color: var(--mid); margin-top: 2px; }

    .followup-tags { display: flex; gap: 8px; flex-wrap: wrap; }

    .followup-tag {
      background: rgba(0,0,0,0.07);
      color: var(--dark);
      font-size: 11px;
      font-weight: 700;
      padding: 5px 12px;
      border-radius: 20px;
      border: none;
      font-family: 'Nunito', sans-serif;
    }

    .followup-body {
      flex: 1;
      min-height: 0;
      display: flex;
      flex-direction: column;
      padding: 16px 20px 20px;
    }

    .section-title {
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.9px;
      color: var(--light);
      margin-bottom: 10px;
    }

    /* Conversation block — fills the available space in convo-section */
    .convo-block {
      flex: 1;
      min-height: 0;
      background: var(--white);
      border-radius: 14px;
      border: 1.5px solid var(--border);
      overflow: hidden;
      margin-bottom: 12px;
      display: flex;
      flex-direction: column;
    }

    /* "↑ earlier" button — pinned above the scroll area, never scrolls away */
    .earlier-trigger {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      padding: 10px 16px;
      cursor: pointer;
      background: var(--sage-light);
      transition: background 0.15s;
      border: none;
      border-bottom: 1px solid var(--border); /* must come AFTER border:none */
      width: 100%;
      font-family: 'Nunito', sans-serif;
      flex-shrink: 0;
    }
    .earlier-trigger:active { background: #d4ebe3; }
    .earlier-trigger span { font-size: 12px; font-weight: 700; color: var(--sage-dark); }

    /* Scrollable message area — fills convo-block, no fixed height needed */
    .msg-scroll-area {
      flex: 1;
      min-height: 0;
      overflow-y: auto;
      scroll-behavior: smooth;
    }

    /* Message rows */
    @keyframes msgIn {
      from { opacity: 0; transform: translateY(-4px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    .msg {
      padding: 12px 16px;
      border-bottom: 1px solid var(--border);
      animation: msgIn 0.2s ease;
    }
    .msg:last-child { border-bottom: none; }

    .msg-who {
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      margin-bottom: 4px;
    }

    .msg-who.client { color: var(--sage); }
    .msg-who.chaya  { color: var(--sage-dark); }
    .msg-who.mua    { color: var(--clay); }

    .msg-text { font-size: 14px; color: var(--dark); line-height: 1.6; }
    .msg-time { font-size: 11px; color: var(--light); margin-top: 3px; }

    /* Chaya's Take */
    .chaya-take {
      background: var(--yellow-light);
      border: 1.5px solid var(--yellow);
      border-radius: 14px;
      padding: 14px 16px;
      margin-bottom: 20px;
      display: flex;
      gap: 10px;
      align-items: flex-start;
    }

    .chaya-take-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }

    .chaya-take-content strong {
      display: block;
      font-size: 11px;
      font-weight: 700;
      color: var(--dark);
      margin-bottom: 5px;
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }

    .chaya-take-content p { font-size: 13px; color: var(--dark); line-height: 1.7; }

    /* Action zone */
    .action-zone {
      background: var(--white);
      border-radius: 16px;
      border: 1.5px solid var(--border);
      overflow: hidden;
      margin-bottom: 12px;
      box-shadow: var(--shadow);
    }

    .message-box {
      padding: 14px 16px;
      font-size: 14px;
      line-height: 1.7;
      color: var(--dark);
      min-height: 76px;
      outline: none;
      border: none;
      width: 100%;
      font-family: 'Nunito', sans-serif;
      background: transparent;
      resize: none;
    }

    /* Send button */
    .open-wa-btn { margin-top: 12px; box-sizing: border-box; }
    .open-wa-note { text-align: center; font-size: 12px; color: var(--light); margin-top: 6px; line-height: 1.5; }

    .btn-send {
      width: 100%;
      padding: 16px;
      background: var(--sage);
      color: white;
      border: none;
      border-radius: 14px;
      font-family: 'Nunito', sans-serif;
      font-size: 16px;
      font-weight: 700;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      box-shadow: 0 4px 14px rgba(123,155,138,0.35);
      margin-bottom: 12px;
      transition: transform 0.15s, opacity 0.15s;
    }
    .btn-send:active { transform: scale(0.98); opacity: 0.9; }


    /* ── History import + disconnect ─────────────────────── */
    .info-banner {
      background: var(--yellow-light);
      border: 1px solid var(--yellow);
      color: var(--dark);
      border-radius: 12px;
      padding: 12px 14px;
      margin: 0 20px 14px;
      font-size: 13px;
      line-height: 1.5;
    }
    .connect-body .info-banner { margin: 0 0 16px; }
    .success-banner { background: var(--sage-light); border-color: var(--sage); }
    .info-banner a { color: var(--sage-dark); font-weight: 700; }
    .msg.historical { background: #F1F0EE; border-radius: 10px; padding: 6px 8px; opacity: 0.9; }
    .imported-tag {
      display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 6px;
      background: var(--border); color: var(--mid); font-size: 10px; font-weight: 700;
    }
    .send-tag {
      display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 6px;
      background: var(--red-light); color: var(--red); font-size: 10px; font-weight: 700;
    }
    .media-link { color: var(--sage-dark); font-weight: 700; }
    .media-img { display: block; max-width: 240px; max-height: 240px; border-radius: 8px; }
    .media-video { display: block; max-width: 100%; width: 280px; border-radius: 8px; }
    .media-player { display: block; width: 100%; max-width: 280px; }
    .media-note, .media-caption { font-size: 12px; color: var(--mid); margin-top: 3px; }
    .media-caption { font-size: 14px; color: var(--dark); }
    .media-missing { font-size: 12px; color: var(--mid); font-style: italic; }

    /* ── Gate screens: dev's passcode and the drop switches page (HOST.8) ── */
    .gate-input {
      display: block; width: 100%; margin-bottom: 12px; padding: 15px 16px;
      border: 1.5px solid var(--border); border-radius: 14px; background: var(--white);
      font-family: 'Nunito', sans-serif; font-size: 16px; color: var(--dark);
    }
    .gate-input:focus { outline: none; border-color: var(--sage); }
    .connect-body .gate-error { margin: 0 0 16px; }
