  :root {
    /* Support Human brand colors */
    --cream: #fdfdfd;
    --ink: #030203;
    --blue: #69a3ff;
    --blue-light: #e8f0ff;
    --salmon: #ee897c;
    --salmon-light: #fce9e7;
    --pink: #eda7e3;
    --pink-light: #faeef8;
    --peach: #fed5b7;
    --peach-light: #fff3eb;
    --hotpink: #fa5791;
    --hotpink-light: #ffe0ed;
    --purple: #7a2e82;
    --purple-light: #f0ddf2;

    /* Functional flag colors */
    --red: #C8392B;
    --red-light: #fce4e1;
    --yellow: #b86e00;
    --yellow-light: #fef3d8;
    --stop: #8B1A1A;
    --stop-light: #f5d5d2;

    /* UI colors from brand */
    --muted: #7a7a8a;
    --border: #e2dff0;
    --white: #fdfdfd;

    /* Verdict greens */
    --green: #1a6645;
    --green-light: #d4f0e4;

    --surface: #ffffff;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  html, body { height: 100%; }
  body {
    font-family: 'DM Sans', sans-serif;
    background: #f4f2fb;
    color: var(--ink);
    display: flex;
    flex-direction: column;
  }

  .container {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 16px 60px;
    position: relative;
    z-index: 1;
  }

  /* JOB NAME INPUT (in toolbar) */
  .job-name-input {
    flex: 1;
    font-family: 'Playfair Display', serif;
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
    background: transparent;
    border: none;
    outline: none;
  }
  .job-name-input::placeholder { color: var(--hotpink); opacity: 0.55; font-style: italic; font-weight: 400; }

  /* STATUS BAR */
  .status-bar {
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
  }
  .flag-counts { display: flex; gap: 14px; align-items: center; }
  .flag-count-item { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
  .flag-count-item strong { font-size: 18px; font-family: 'Playfair Display', serif; }
  .flag-count-item.red strong { color: var(--red); }
  .flag-count-item.yellow strong { color: var(--yellow); }
  .divider-v { width: 1px; height: 20px; background: var(--border); }

  .verdict {
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 100px;
    white-space: nowrap;
    transition: all 0.3s;
  }
  .verdict.green  { background: var(--green-light);  color: var(--green); }
  .verdict.yellow { background: var(--yellow-light); color: #8a6010; }
  .verdict.orange { background: #FDE8D0; color: #9a4a10; }
  .verdict.red    { background: var(--red-light);    color: var(--red); }

  /* BINGO BANNER */
  .bingo-banner {
    display: none;
    background: #b5175e;
    color: white;
    border-radius: 12px;
    padding: 20px 22px;
    margin-bottom: 16px;
    animation: slide-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
  }

  .bingo-banner.visible { display: block; }
  @keyframes slide-in {
    from { opacity: 0; transform: translateY(-14px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }
  .bingo-banner::before {
    content: '🚩';
    position: absolute;
    font-size: 70px;
    right: 20px; top: 50%;
    transform: translateY(-50%);
    opacity: 0.55;
    pointer-events: none;
    background: rgba(255,255,255,0.25);
    width: 90px; height: 90px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    line-height: 1;
  }
  .bingo-banner h2 { font-family: 'Playfair Display', serif; font-size: 1.4rem; font-weight: 900; margin-bottom: 5px; }

  .bingo-banner p  { font-size: 13px; opacity: 0.9; line-height: 1.55; max-width: 430px; }
  .bingo-flags     { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 5px; }
  .flag-tag {
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.3);
    font-size: 10.5px; font-weight: 600;
    padding: 3px 9px; border-radius: 100px; color: white;
  }

  /* Share modal buttons */
  .btn {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px; font-weight: 600;
    padding: 8px 15px;
    border-radius: 6px;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
  }
  /* Share modal overlay */
  .share-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26, 18, 8, 0.55);
    z-index: 100;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    backdrop-filter: blur(3px);
  }
  .share-overlay.visible { display: flex; }

  .share-modal {
    background: var(--surface);
    border-radius: 16px;
    padding: 28px 28px 24px;
    max-width: 520px;
    width: 100%;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    animation: modal-in 0.3s cubic-bezier(0.34,1.56,0.64,1);
    position: relative;
    margin: auto;
  }
  @keyframes modal-in {
    from { opacity: 0; transform: scale(0.93) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
  }

  .share-modal h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem; font-weight: 900;
    margin-bottom: 18px;
    color: var(--purple);
  }

  .share-preview {
    border: 1.5px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 16px;
    background: var(--white);
  }
  .share-preview img {
    width: 100%;
    display: block;
  }
  .share-preview-placeholder {
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 13px;
    font-style: italic;
  }

  .share-text-box {
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--ink);
    margin-bottom: 16px;
    white-space: pre-wrap;
    word-break: break-word;
  }

  .share-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  .btn-copy {
    background: var(--purple); color: white; border-color: var(--purple);
    flex: 1;
  }
  .btn-copy:hover { background: #5e2063; }
  .btn-copy.copied { background: var(--green); border-color: var(--green); color: white; }

  .btn-download {
    background: var(--white); color: var(--ink); border-color: var(--border);
    flex: 1;
  }
  .btn-download:hover { background: var(--border); }

  .btn-close-modal {
    background: transparent; color: var(--muted); border-color: var(--border);
  }
  .btn-close-modal:hover { background: var(--border); }

  .share-modal-close {
    position: absolute;
    top: 14px; right: 16px;
    background: none; border: none;
    font-size: 20px; cursor: pointer;
    color: var(--muted); line-height: 1;
    padding: 4px;
  }
  .share-modal-close:hover { color: var(--ink); }

  /* EDIT HINT */
  .edit-hint {
    display: none;
    background: var(--purple-light);
    border: 1.5px solid var(--purple);
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 12.5px; color: #6b2475;
    margin-bottom: 10px;
  }
  .edit-hint.visible { display: block; }

  /* BINGO COLUMN HEADERS */
  .bingo-header {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    margin-bottom: 5px;
  }
  .col-header {
    font-family: 'Playfair Display', serif;
    font-size: 32px; font-weight: 900;
    text-align: center; padding: 2px 0;
    color: var(--purple);
  }

  /* GRID */
  .bingo-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    margin-bottom: 18px;
  }

  .bingo-cell {
    aspect-ratio: 1;
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px;
    cursor: pointer;
    position: relative;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.15s;
    user-select: none;
    overflow: hidden;
  }
  .bingo-cell:hover:not(.free-space) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: var(--blue);
  }

  /* Small rating dot in corner */
  .rating-dot {
    position: absolute;
    top: 5px; left: 6px;
    width: 10px; height: 10px;
    border-radius: 50%;
    opacity: 0.85;
    flex-shrink: 0;
  }
  .rating-dot.red    { background: var(--red); }
  .rating-dot.yellow { background: var(--yellow); }

  .cell-text {
    font-size: clamp(8px, 1.9vw, 13px);
    text-align: center;
    line-height: 1.3;
    color: var(--ink);
    font-weight: 500;
  }

  /* Marked */
  .bingo-cell.marked {
    background: var(--red-light);
    border-color: var(--red);
  }
  .bingo-cell.marked .cell-text { color: var(--red); font-weight: 600; }
  .bingo-cell.marked::after {
    content: '✗';
    position: absolute;
    top: 3px; right: 5px;
    font-size: 10px; color: var(--red);
    font-weight: 900; opacity: 0.5;
  }

  /* Winning line */
  .bingo-cell.winner {
    background: var(--red-light);
    border-color: var(--red);
    animation: winner-pop 0.45s ease;
  }
  .bingo-cell.winner .cell-text { color: var(--red); }
  @keyframes winner-pop {
    0%  { transform: scale(1); }
    50% { transform: scale(1.07); }
    100%{ transform: scale(1); }
  }

  /* Free space */
  .bingo-cell.free-space {
    background: #f5bfb5;
    border-color: #ee897c;
    cursor: default;
  }
  .bingo-cell.free-space:hover { transform: none; box-shadow: none; }
  .free-label {
    font-family: 'Playfair Display', serif;
    font-size: clamp(10px, 1.9vw, 14px); font-weight: 900;
    color: var(--purple);
    text-align: center; line-height: 1.3;
  }

  /* Edit mode */
  .bingo-cell.edit-mode {
    border-style: dashed;
    border-color: var(--purple);
    background: var(--purple-light);
  }
  .cell-edit-input {
    width: 100%; height: 100%;
    border: none; background: transparent;
    text-align: center;
    font-family: 'DM Sans', sans-serif;
    font-size: clamp(8px, 1.9vw, 13px);
    font-weight: 500; color: var(--ink);
    resize: none; outline: none;
    cursor: text; padding: 4px; line-height: 1.3;
  }

  /* LEGEND */
  .legend {
    display: flex; gap: 14px; flex-wrap: wrap;
    margin-bottom: 16px;
    font-size: 12px; color: var(--muted); align-items: center;
  }
  .legend-item { display: flex; align-items: center; gap: 5px; }
  .legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

  /* FOOTER */
  .footer-note {
    font-size: 12px; color: var(--muted);
    line-height: 1.8;
    border-top: 1px solid var(--border);
    padding: 14px 16px;
  }
  .footer-note a { color: var(--purple); text-decoration: none; }
  .footer-note a:hover { text-decoration: underline; }
  .footer-note-inner {
    display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap;
  }
  .footer-note-text { text-align: center; }
  .footer-note a.footer-coffee {
    display: inline-block; font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 700;
    color: white; background: var(--purple); padding: 6px 16px; border-radius: 8px;
    text-decoration: none; transition: background 0.12s; white-space: nowrap; flex-shrink: 0;
  }
  .footer-note a.footer-coffee:hover { background: #621870; color: white; text-decoration: none; }

  /* ── TOOLTIP ── */
  /* Small "?" info button on each cell */
  .info-btn {
    position: absolute;
    bottom: 4px; right: 4px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--border);
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
    cursor: pointer;
    border: none;
    padding: 0;
    transition: background 0.15s, color 0.15s;
    z-index: 2;
    font-family: 'DM Sans', sans-serif;
  }
  .info-btn:hover { background: var(--purple); color: white; }
  .bingo-cell.marked .info-btn { background: rgba(200,57,43,0.2); color: var(--red); }
  .bingo-cell.marked .info-btn:hover { background: var(--red); color: white; }

  /* Tooltip popup — positioned via JS */
  #tooltip {
    display: none;
    position: fixed;
    z-index: 999;
    max-width: 260px;
    background: #1a1535;
    color: #f5f3ff;
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.22);
    pointer-events: none;
    animation: tooltip-in 0.18s ease;
  }
  #tooltip.visible { display: block; }
  @keyframes tooltip-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  #tooltip .tt-rating {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 5px;
    opacity: 0.7;
  }
  #tooltip .tt-why {
    font-size: 12.5px;
    line-height: 1.55;
    color: #e8e4ff;
  }
  /* Arrow pointer */
  #tooltip::before {
    content: '';
    position: absolute;
    width: 0; height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
  }
  #tooltip.arrow-up::before {
    top: -6px; left: 18px;
    border-bottom: 6px solid #1a1535;
  }
  #tooltip.arrow-down::before {
    bottom: -6px; left: 18px;
    border-top: 6px solid #1a1535;
  }

  /* Update legend to mention the ? button */
  .legend-info { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
  /* btn-auth, auth-modal: injected by sh-auth-ui.js */

  .bjb-scroll { flex: 1; overflow-y: auto; }

  /* ── TOOLBAR ─────────────────────────────────────────────────── */
  .toolbar {
    background: var(--cream);
    border-bottom: 1.5px solid var(--border);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
  }
  .toolbar-sep { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; }
  .toolbar-job-wrap {
    display: flex; align-items: baseline; gap: 8px;
    flex: 1; min-width: 160px; max-width: 340px;
  }
  .toolbar-label {
    font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--muted); white-space: nowrap; line-height: 1;
  }
  /* job-name-input is defined above; override sizing in toolbar context */
  .toolbar .job-name-input { font-size: 15px; }

  .view-toggle {
    display: flex;
    background: #f0edf8;
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
  }

  .view-btn {
    font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 600;
    padding: 5px 11px; border-radius: 8px; cursor: pointer;
    border: 1.5px solid var(--border); background: var(--surface); color: var(--muted);
    transition: all 0.15s; white-space: nowrap;
  }
  .view-btn:hover { background: var(--border); color: var(--ink); }
  .view-btn.active { background: var(--purple); color: white; border-color: var(--purple); }

  /* Mode toggle buttons inside .view-toggle use a pill style */
  .view-toggle .view-btn {
    border: none;
    background: transparent;
    color: var(--muted);
  }
  .view-toggle .view-btn:hover:not(.active) { background: rgba(255,255,255,0.6); color: var(--ink); }
  .view-toggle .view-btn.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(3,2,3,0.12); border: none; }

  .btn-add-card {
    font-family: 'DM Sans', sans-serif; font-size: 12.5px; font-weight: 600;
    padding: 6px 14px; border-radius: 8px; border: none; cursor: pointer;
    background: var(--purple); color: white;
    transition: opacity 0.15s; white-space: nowrap;
  }
  .btn-add-card:hover { opacity: 0.88; }

  .sync-indicator {
    font-size: 11px; color: var(--muted); white-space: nowrap; margin-left: auto;
  }

  /* ── COPY LINK BUTTON ─────────────────────────────────────────── */
  .btn-copy-link {
    background: var(--white); color: var(--purple); border-color: var(--purple);
    flex: 1;
  }
  .btn-copy-link:hover { background: var(--purple-light); }
  .btn-copy-link.copied { background: var(--green); border-color: var(--green); color: white; }

  /* ── BJB MODALS (History, Templates) ─────────────────────────── */
  .bjb-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(3,2,3,0.4);
    z-index: 200; align-items: center; justify-content: center;
    padding: 16px;
  }
  .bjb-backdrop.open { display: flex; }
  .bjb-modal {
    background: var(--surface); border-radius: 16px;
    padding: 28px; max-width: 520px; width: 100%;
    max-height: calc(100vh - 40px); overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.22);
    animation: modal-in 0.25s cubic-bezier(0.34,1.56,0.64,1);
    position: relative;
  }
  .bjb-modal-close {
    position: absolute; top: 14px; right: 16px;
    background: none; border: none; font-size: 20px;
    cursor: pointer; color: var(--muted); line-height: 1; padding: 4px;
  }
  .bjb-modal-close:hover { color: var(--ink); }
  .bjb-modal-title {
    font-family: 'Playfair Display', serif; font-size: 1.3rem; font-weight: 900;
    color: var(--purple); margin-bottom: 16px;
  }
  .bjb-modal-desc { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 14px; }
  .bjb-modal-save-row { display: flex; gap: 8px; margin-bottom: 16px; }
  .bjb-modal-input {
    flex: 1; font-family: 'DM Sans', sans-serif; font-size: 13px;
    border: 1.5px solid var(--border); border-radius: 8px;
    padding: 7px 12px; outline: none; color: var(--ink); background: var(--surface);
  }
  .bjb-modal-input:focus { border-color: var(--purple); }
  .bjb-modal-list { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
  .bjb-modal-empty {
    font-size: 13px; color: var(--muted); font-style: italic;
    text-align: center; padding: 24px 0; line-height: 1.6;
  }

  .bjb-eval-item {
    background: var(--surface); border: 1.5px solid var(--border);
    border-radius: 10px; padding: 12px 14px;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
  }
  .bjb-eval-info { flex: 1; min-width: 0; }
  .bjb-eval-name {
    font-weight: 600; font-size: 14px; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .bjb-eval-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
  .bjb-eval-actions { display: flex; gap: 6px; flex-shrink: 0; }
  .bjb-eval-load {
    font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 600;
    padding: 4px 12px; border-radius: 6px;
    border: 1.5px solid var(--purple); background: var(--surface); color: var(--purple);
    cursor: pointer; transition: background 0.15s;
  }
  .bjb-eval-load:hover { background: var(--purple-light); }
  .bjb-eval-delete {
    font-family: 'DM Sans', sans-serif; font-size: 12px;
    padding: 4px 8px; border-radius: 6px;
    border: 1.5px solid var(--border); background: var(--surface); color: var(--muted);
    cursor: pointer; transition: all 0.15s;
  }
  .bjb-eval-delete:hover { border-color: var(--red); color: var(--red); }
  .bjb-eval-delete:disabled { opacity: 0.4; cursor: not-allowed; }

  @media (max-width: 520px) {
    /* Toolbar */
    .toolbar { padding: 8px 12px; }
    .toolbar-sep { display: none; }
    .toolbar-job-wrap { max-width: 100%; flex: 1 0 100%; order: -1; }
    .toolbar .job-name-input { font-size: 13px; }
    .view-btn { padding: 5px 8px; font-size: 11px; }
    .btn-add-card { padding: 5px 10px; font-size: 12px; }

    /* More room for the grid */
    .container { padding: 8px 8px 40px; }
    .bingo-grid { gap: 3px; }
    .bingo-cell { padding: 4px; }

    /* Readable text: 2.5vw = ~9.4px on 375px — floor raised from 8 to 9px */
    .cell-text { font-size: clamp(9px, 2.5vw, 13px); }

    /* Info button: larger tap target */
    .info-btn { width: 16px; height: 16px; line-height: 16px; }

    /* Status bar */
    .status-bar { padding: 10px 12px; }
    .flag-count-item strong { font-size: 15px; }

    /* Legend */
    .legend { gap: 10px; margin-bottom: 12px; }
  }

  /* Remove hover lift on touch devices */
  @media (hover: none) {
    .bingo-cell:hover:not(.free-space) {
      transform: none;
      box-shadow: none;
      border-color: var(--border);
    }
  }

  /* ── GREEN FLAGS MODE ──────────────────────────────────────────────── */
  body.mode-green .bingo-cell.marked {
    background: var(--green-light);
    border-color: var(--green);
  }
  body.mode-green .bingo-cell.marked .cell-text {
    color: var(--green);
    font-weight: 600;
  }
  body.mode-green .bingo-cell.marked::after {
    content: '✓';
    color: var(--green);
  }
  body.mode-green .bingo-cell.marked .info-btn {
    background: rgba(26,102,69,0.15);
    color: var(--green);
  }
  body.mode-green .bingo-cell.marked .info-btn:hover {
    background: var(--green);
    color: white;
  }
  body.mode-green .bingo-cell.winner {
    background: var(--green-light);
    border-color: var(--green);
  }
  body.mode-green .bingo-cell.winner .cell-text { color: var(--green); }
  body.mode-green .bingo-banner {
    background: linear-gradient(135deg, var(--green), #0d4a30);
  }
  body.mode-green .bingo-banner::before {
    content: '✅';
  }
  body.mode-green .bingo-cell.free-space {
    background: #c8ead9;
    border-color: var(--green);
  }
  body.mode-green .bingo-cell.free-space .free-label {
    color: var(--green);
  }
  body.mode-green .legend { display: none; }
  body.mode-green .flag-counts { display: none; }
  body.mode-green .green-count-display { display: flex !important; }
  .green-count-display {
    display: none;
    font-size: 12px;
    color: var(--muted);
    align-items: center;
    gap: 5px;
  }
  .green-count-display strong {
    font-size: 18px;
    font-family: 'Playfair Display', serif;
    color: var(--green);
  }
  .verdict.green-mode {
    background: var(--green-light);
    color: var(--green);
  }

  /* ── MOBILE MODALS (bottom sheet) ──────────────────────────────── */
  @media (max-width: 500px) {
    .share-overlay {
      align-items: flex-end;
      padding: 0;
    }
    .share-modal {
      border-radius: 20px 20px 0 0;
      max-width: 100%;
      padding: 20px 16px 32px;
    }
    .bjb-backdrop {
      align-items: flex-end;
      padding: 0;
    }
    .bjb-modal {
      border-radius: 20px 20px 0 0;
      max-width: 100%;
      padding: 20px 16px 32px;
    }
  }
