/**
 * Task Grid Counter (Pro cloud) — a checklist arranged as a grid of boxes.
 *
 * Layout goals:
 *   - Desktop: the grid fills the screen (auto-fit columns) so a whole board is
 *     visible at once.
 *   - Mobile: fewer columns, the page scrolls vertically through the grid.
 * Colors derive from CSS vars set by layouts.app; --tg-accent is set inline.
 */

.tg-page {
    --tg-accent: #7c3aed;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1rem 4rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* ---- Top bar ---------------------------------------------------------- */
.tg-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.tg-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}
.tg-back:hover { color: var(--text-primary); }
.tg-sync-status {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.tg-sync-status.is-saving { color: var(--tg-accent); }
.tg-sync-status.is-error { color: #dc2626; }

/* ---- Header (title + progress + actions) ------------------------------ */
.tg-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    padding: 0.5rem 0;
    z-index: 5;
}
.tg-header-main { min-width: 0; flex: 1; }
.tg-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tg-progress {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    max-width: 420px;
}
.tg-progress-bar {
    flex: 1;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 999px;
    overflow: hidden;
}
.tg-progress-fill {
    display: block;
    height: 100%;
    background: var(--tg-accent);
    border-radius: 999px;
    transition: width 0.25s ease;
}
.tg-progress-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.tg-progress-label b { color: var(--text-primary); }

.tg-header-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tg-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.7rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.55rem;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}
.tg-btn:hover { background: var(--bg-tertiary); }
.tg-btn.is-active { background: var(--tg-accent); border-color: var(--tg-accent); color: #fff; }
.tg-btn span { display: inline; }
@media (max-width: 560px) {
    .tg-btn span { display: none; }
}

/* Fullscreen enter/exit visibility toggling */
.tg-exit-fs { display: none; }
.tg-page.is-fullscreen {
    background: var(--bg-primary);
    max-width: none;
    padding: 1rem 1.25rem 2rem;
    overflow-y: auto;
}
.tg-page.is-fullscreen .tg-enter-fs { display: none; }
.tg-page.is-fullscreen .tg-exit-fs { display: inline-flex; }

/* ---- Setup step ------------------------------------------------------- */
.tg-setup { display: flex; justify-content: center; padding: 1.5rem 0; }
.tg-setup-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    max-width: 520px;
    width: 100%;
}
.tg-setup-heading { font-size: 1.2rem; font-weight: 800; color: var(--text-primary); margin: 0 0 0.35rem; }
.tg-setup-sub { font-size: 0.85rem; color: var(--text-secondary); margin: 0 0 1.1rem; line-height: 1.5; }
.tg-field-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin: 1rem 0 0.4rem;
}
.tg-field-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.55rem;
    color: var(--text-primary);
    font-size: 0.95rem;
}
.tg-preset-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
@media (min-width: 460px) { .tg-preset-row { grid-template-columns: repeat(4, 1fr); } }
.tg-preset {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.7rem 0.4rem;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 0.65rem;
    cursor: pointer;
    color: var(--text-primary);
}
.tg-preset.is-active { border-color: var(--tg-accent); background: color-mix(in srgb, var(--tg-accent) 12%, transparent); }
.tg-preset-emoji { font-size: 1.35rem; }
.tg-preset-label { font-size: 0.75rem; font-weight: 600; }
.tg-count-row { display: flex; align-items: center; gap: 0.75rem; }
.tg-count-row input[type="range"] { flex: 1; accent-color: var(--tg-accent); }
.tg-count-num { width: 88px; flex: 0 0 auto; text-align: center; }
.tg-primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    margin-top: 1.25rem;
    padding: 0.75rem 1rem;
    background: var(--tg-accent);
    border: none;
    border-radius: 0.6rem;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
}
.tg-primary-btn:hover { filter: brightness(1.05); }

/* ---- Grid ------------------------------------------------------------- */
.tg-grid-wrap { display: flex; flex-direction: column; gap: 0.75rem; }
/* Column count is computed in JS (--tg-cols) so rows stay balanced/symmetric
   at every box count — never a 7+1 orphan row. 8 boxes → 4×2 on desktop,
   2×4 on mobile; bingo pins 5. */
.tg-grid {
    display: grid;
    grid-template-columns: repeat(var(--tg-cols, 4), minmax(0, 1fr));
    gap: clamp(6px, 1vw, 12px);
}

.tg-box {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    aspect-ratio: 1 / 1;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 0.7rem;
    cursor: pointer;
    text-align: center;
    color: var(--text-primary);
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
    overflow: hidden;
}
.tg-box:active { transform: scale(0.97); }
.tg-box.is-checked {
    background: color-mix(in srgb, var(--tg-accent) 16%, var(--bg-secondary));
    border-color: var(--tg-accent);
}
.tg-box-name {
    font-size: clamp(0.62rem, 1.6vmin, 0.9rem);
    font-weight: 600;
    line-height: 1.15;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    word-break: break-word;
}
.tg-box-name.is-placeholder { color: var(--text-tertiary); font-weight: 500; font-style: italic; }
.tg-box-index {
    position: absolute;
    top: 4px;
    left: 6px;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
}
.tg-box-check {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.4rem, 4vmin, 2.4rem);
    color: var(--tg-accent);
    pointer-events: none;
    opacity: 0.9;
}
.tg-box.is-checked .tg-box-check { display: flex; }
.tg-box.is-checked .tg-box-name { opacity: 0.55; }
.tg-box-tally {
    position: absolute;
    top: 4px;
    right: 5px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--tg-accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
}
.tg-box.has-tally .tg-box-tally { display: inline-flex; }
.tg-box.tg-longpress-armed { border-color: var(--tg-accent); }

/* Edit mode visuals */
.tg-grid.is-editing .tg-box { cursor: text; border-style: dashed; }
.tg-grid.is-editing .tg-box-check { display: none; }

.tg-edit-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.6rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.6rem;
}
.tg-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.7rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}
.tg-tool-done { margin-left: auto; background: var(--tg-accent); border-color: var(--tg-accent); color: #fff; }
.tg-edit-hint { font-size: 0.75rem; color: var(--text-secondary); }
.tg-play-hint { font-size: 0.75rem; color: var(--text-tertiary); text-align: center; margin: 0.25rem 0 0; }

/* ---- Run history ------------------------------------------------------ */
.tg-history {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 0 0.9rem;
}
.tg-history-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.8rem 0;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}
.tg-history-summary small { font-size: 0.65rem; font-weight: 500; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.08em; }
.tg-history-list { display: flex; flex-direction: column; gap: 0.5rem; padding-bottom: 0.9rem; max-height: 360px; overflow-y: auto; }
.tg-history-item {
    padding: 0.6rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 0.6rem;
}
.tg-history-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.2rem; }
.tg-history-done { font-size: 0.9rem; font-weight: 800; color: var(--tg-accent); font-variant-numeric: tabular-nums; }
.tg-history-status { font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; padding: 0.1rem 0.5rem; border-radius: 999px; }
.tg-history-status-active { background: color-mix(in srgb, var(--tg-accent) 18%, transparent); color: var(--tg-accent); }
.tg-history-status-closed { background: rgba(107,114,128,0.15); color: var(--text-tertiary); }
.tg-history-item-meta { display: flex; gap: 0.4rem; font-size: 0.7rem; color: var(--text-secondary); }
.tg-history-empty { font-size: 0.8rem; color: var(--text-tertiary); padding: 0.75rem 0.25rem; text-align: center; }
.tg-history-more {
    display: block; width: 100%; margin: 0 0 0.9rem;
    padding: 0.5rem; background: var(--bg-tertiary); border: 1px solid var(--border-color);
    border-radius: 0.5rem; color: var(--text-secondary); font-size: 0.75rem; font-weight: 600; cursor: pointer;
}

/* ---- Name-from-list modal --------------------------------------------- */
.tg-namelist-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.55);
    display: none; align-items: center; justify-content: center;
    z-index: 1000; padding: 1rem;
}
.tg-namelist-overlay.is-open { display: flex; }
.tg-namelist-modal {
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: 12px; max-width: 480px; width: 100%; padding: 1.25rem;
    box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.tg-namelist-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.tg-namelist-head h3 { margin: 0; font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }
.tg-namelist-close { background: transparent; border: none; color: var(--text-tertiary); font-size: 1.15rem; cursor: pointer; }
.tg-namelist-sub { font-size: 0.8rem; color: var(--text-secondary); margin: 0 0 0.75rem; line-height: 1.5; }
.tg-namelist-textarea {
    width: 100%; padding: 0.6rem 0.75rem;
    background: var(--bg-primary); border: 1px solid var(--border-color);
    border-radius: 0.55rem; color: var(--text-primary); font-size: 0.9rem;
    resize: vertical; font-family: inherit;
}
.tg-namelist-mode { display: flex; align-items: center; gap: 0.5rem; margin: 0.65rem 0; font-size: 0.8rem; color: var(--text-secondary); }
.tg-namelist-mode input { accent-color: var(--tg-accent); }

/* ============================================================
   v2 additions — per-box +/- counter, edit delete/drag, title
   rename, multi-list switcher, activity timeline, public pages
   ============================================================ */

/* Per-box count row (play + editor modes). Overrides the v1 top-right badge. */
.tg-box-count {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin-top: 0.15rem;
}
.tg-count-btn {
    width: clamp(20px, 3.4vmin, 26px);
    height: clamp(20px, 3.4vmin, 26px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}
.tg-count-btn:hover { background: var(--tg-accent); border-color: var(--tg-accent); color: #fff; }
.tg-box-tally {
    position: static;
    min-width: 1.2em;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-primary);
    font-size: clamp(0.7rem, 1.7vmin, 0.95rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.tg-box.has-tally .tg-box-tally { color: var(--tg-accent); }
/* Viewer read-only static tally badge (top-right). */
.tg-box-tally-static {
    position: absolute;
    top: 4px; right: 5px;
    min-width: 18px; height: 18px; padding: 0 4px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--tg-accent); color: #fff;
    font-size: 0.65rem; font-weight: 800; border-radius: 999px;
    font-variant-numeric: tabular-nums;
}

/* Edit-mode per-box controls */
.tg-box-del {
    position: absolute;
    top: 3px; right: 4px;
    width: 20px; height: 20px;
    display: none;
    align-items: center; justify-content: center;
    background: #fef2f2; color: #dc2626;
    border: 1px solid #fecaca; border-radius: 999px;
    font-size: 0.85rem; font-weight: 800; line-height: 1; cursor: pointer; padding: 0;
    z-index: 2;
}
.tg-box-drag {
    position: absolute;
    bottom: 4px; left: 50%; transform: translateX(-50%);
    display: none;
    color: var(--text-tertiary);
    font-size: 0.8rem;
    cursor: grab;
}
.tg-grid.is-editing .tg-box { cursor: grab; border-style: dashed; }
.tg-grid.is-editing .tg-box-del { display: inline-flex; }
.tg-grid.is-editing .tg-box-drag { display: inline-flex; }
.tg-grid.is-editing .tg-box-count,
.tg-grid.is-editing .tg-box-check { display: none; }
.tg-box.tg-dragging { opacity: 0.4; }
.tg-box.tg-drop-target { outline: 2px dashed var(--tg-accent); outline-offset: 2px; }

/* Inline title rename */
.tg-title-editable { cursor: text; border-radius: 0.35rem; padding: 0 0.15rem; margin-left: -0.15rem; }
.tg-title-editable:hover { background: var(--bg-tertiary); }
.tg-title[contenteditable="true"] { outline: 2px solid var(--tg-accent); background: var(--bg-primary); }

/* Multi-list switcher */
.tg-switcher { position: relative; margin-left: 0.5rem; }
.tg-switcher-summary {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: 0.5rem; font-size: 0.8rem; font-weight: 600;
    color: var(--text-primary); cursor: pointer; list-style: none;
}
.tg-switcher-summary::-webkit-details-marker { display: none; }
.tg-switcher-summary b { color: var(--tg-accent); }
.tg-switcher-caret { font-size: 0.65rem; color: var(--text-tertiary); }
.tg-switcher[open] .tg-switcher-caret { transform: rotate(180deg); }
.tg-switcher-menu {
    position: absolute; top: calc(100% + 0.35rem); left: 0; z-index: 30;
    min-width: 240px; max-width: 320px;
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: 0.6rem; box-shadow: 0 16px 40px rgba(0,0,0,.28);
    padding: 0.4rem;
}
.tg-switcher-list { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 0.2rem; }
.tg-switcher-item {
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
    padding: 0.5rem 0.6rem; border-radius: 0.45rem;
    text-decoration: none; color: var(--text-primary); font-size: 0.85rem;
}
.tg-switcher-item:hover { background: var(--bg-tertiary); }
.tg-switcher-item.is-current { background: color-mix(in srgb, var(--tg-accent) 14%, transparent); font-weight: 700; }
.tg-switcher-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-switcher-done { font-size: 0.7rem; color: var(--text-tertiary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tg-switcher-new { margin-top: 0.35rem; border-top: 1px solid var(--border-color); padding-top: 0.4rem; }
.tg-switcher-new button {
    width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.5rem; background: var(--tg-accent); color: #fff; border: none;
    border-radius: 0.45rem; font-size: 0.8rem; font-weight: 700; cursor: pointer;
}

/* Activity timeline */
.tg-activity-list { display: flex; flex-direction: column; gap: 0.4rem; padding-bottom: 0.9rem; max-height: 360px; overflow-y: auto; }
.tg-activity-item { padding: 0.5rem 0.65rem; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 0.55rem; }
.tg-activity-line { font-size: 0.82rem; color: var(--text-primary); }
.tg-activity-line b { font-weight: 700; }
.tg-activity-line i { color: var(--text-tertiary); margin-right: 0.15rem; }
.tg-activity-when { font-size: 0.68rem; color: var(--text-tertiary); margin-top: 0.15rem; }

/* Public view / edit chrome */
.tg-live-badge { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.06em; color: #dc2626; }
.tg-live-dot { width: 8px; height: 8px; border-radius: 999px; background: #dc2626; animation: tgPulse 1.6s ease-in-out infinite; }
@keyframes tgPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.tg-editor-banner {
    display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
    padding: 0.7rem 0.9rem; margin-bottom: 0.5rem;
    background: color-mix(in srgb, var(--tg-accent) 12%, var(--bg-secondary));
    border: 1px solid var(--tg-accent); border-radius: 0.6rem;
    font-size: 0.85rem; color: var(--text-primary);
}
.tg-actor-prompt {
    padding: 0.9rem; margin-bottom: 0.75rem;
    background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 0.6rem;
}
.tg-actor-prompt label { display: block; font-size: 0.8rem; font-weight: 700; margin-bottom: 0.4rem; }
.tg-actor-prompt label span { font-weight: 400; color: var(--text-tertiary); }
.tg-actor-row { display: flex; gap: 0.5rem; }
.tg-actor-row input {
    flex: 1; padding: 0.55rem 0.7rem; background: var(--bg-primary);
    border: 1px solid var(--border-color); border-radius: 0.5rem; color: var(--text-primary); font-size: 0.9rem;
}
.tg-actor-row button {
    padding: 0.55rem 1rem; background: var(--tg-accent); color: #fff; border: none;
    border-radius: 0.5rem; font-weight: 700; cursor: pointer;
}

.tg-grid.is-editing .tg-box { touch-action: none; }

/* ------------------------------------------------------------------
   Counter coupling: the −/+ counter (and viewer's static count) only
   appears once a box is CHECKED, pinned to the bottom-center with a
   little breathing room. The checkmark overlay stays centered.
   ------------------------------------------------------------------ */
.tg-box-count {
    position: absolute;
    left: 50%;
    bottom: 6px;
    transform: translateX(-50%);
    margin-top: 0;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 1px 4px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg-primary) 85%, transparent);
    z-index: 2;
}
.tg-box.is-checked .tg-box-count { display: flex; }

.tg-box-tally-static {
    position: absolute;
    left: 50%;
    right: auto;
    top: auto;
    bottom: 6px;
    transform: translateX(-50%);
    display: none;
    background: var(--tg-accent);
    color: #fff;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    z-index: 2;
}
.tg-box.is-checked .tg-box-tally-static { display: inline-flex; }

/* Never show the count controls while editing layout (even if checked). */
.tg-grid.is-editing .tg-box.is-checked .tg-box-count,
.tg-grid.is-editing .tg-box.is-checked .tg-box-tally-static { display: none; }

/* Give the checkmark room above the bottom counter (nudge it up slightly). */
.tg-box.is-checked .tg-box-check { align-items: flex-start; padding-top: 18%; }

/* ------------------------------------------------------------------
   Box-number hide toggle + name-from-list two-choice buffer
   ------------------------------------------------------------------ */
.tg-grid.tg-hide-numbers .tg-box-index { display: none; }

.tg-namelist-summary {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0.5rem 0 0.35rem;
    font-weight: 600;
}
.tg-namelist-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.4rem;
}
.tg-namelist-actions .tg-primary-btn { margin-top: 0; flex: 1 1 auto; }
.tg-secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    flex: 1 1 auto;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.6rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
}
.tg-secondary-btn:hover { background: var(--bg-tertiary); }
.tg-namelist-note {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    line-height: 1.5;
    margin: 0.65rem 0 0;
}

/* Count-driven fill: deeper accent background as a box's tally climbs.
   --tg-fill is set inline per box by the renderer (defaults to 16%). */
.tg-box.is-checked {
    background: color-mix(in srgb, var(--tg-accent) var(--tg-fill, 16%), var(--bg-secondary));
    border-color: var(--tg-accent);
}

/* ==================================================================
   v3: free-tier gating UI, activity-stream analytics, round drill-down,
   info modal
   ================================================================== */
.tg-setup-note { font-size: 0.75rem; color: var(--text-tertiary); margin: 0.5rem 0 0; line-height: 1.5; }
.tg-setup-note b { color: var(--tg-accent); }

/* Activity-stream analytics roll-up */
.tg-activity-stats { margin: 0 0 0.6rem; }
.tg-activity-stats:empty { display: none; }
.tg-stat-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.tg-stat-total { font-size: 0.85rem; font-weight: 800; color: var(--text-primary); }
.tg-stat-top { font-size: 0.78rem; color: var(--text-secondary); }
.tg-stat-top b { color: var(--tg-accent); }
.tg-stat-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tg-stat-chip {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.2rem 0.55rem; border-radius: 999px;
    background: var(--bg-tertiary); border: 1px solid var(--border-color);
    font-size: 0.72rem; color: var(--text-secondary);
}
.tg-stat-chip i { color: var(--text-tertiary); }
.tg-stat-chip b { color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* Round history items (clickable) */
.tg-history-item-clickable { cursor: pointer; transition: border-color 0.12s ease, background 0.12s ease; }
.tg-history-item-clickable:hover { border-color: var(--tg-accent); background: var(--bg-secondary); }
.tg-history-round { font-size: 0.82rem; font-weight: 800; color: var(--text-primary); }
.tg-history-chevron { color: var(--text-tertiary); font-size: 0.75rem; }

/* Round drill-down modal + info modal (shared overlay styling) */
.tg-round-overlay, .tg-info-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.55);
    display: none; align-items: center; justify-content: center; z-index: 1000; padding: 1rem;
}
.tg-round-overlay.is-open, .tg-info-overlay.is-open { display: flex; }
.tg-round-modal, .tg-info-modal {
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: 12px; max-width: 560px; width: 100%; padding: 1.25rem;
    max-height: calc(100vh - 2rem); overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.tg-round-head, .tg-info-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.tg-round-head h3, .tg-info-head h3 { margin: 0; font-size: 1.05rem; font-weight: 700; color: var(--text-primary); display: flex; align-items: center; gap: 0.5rem; }
.tg-round-close, .tg-info-close { background: transparent; border: none; color: var(--text-tertiary); font-size: 1.15rem; cursor: pointer; }
.tg-round-modal .tg-activity-list { max-height: 50vh; }

/* Info modal free/Pro columns */
.tg-info-lead { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.55; margin: 0 0 1rem; }
.tg-info-cols { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
@media (min-width: 480px) { .tg-info-cols { grid-template-columns: 1fr 1fr; } }
.tg-info-col { background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 0.7rem; padding: 0.85rem; }
.tg-info-col-pro { border-color: var(--tg-accent); background: color-mix(in srgb, var(--tg-accent) 8%, var(--bg-primary)); }
.tg-info-col h4 { margin: 0 0 0.5rem; font-size: 0.9rem; font-weight: 800; color: var(--text-primary); display: flex; align-items: center; gap: 0.4rem; }
.tg-info-col-pro h4 i { color: #f59e0b; }
.tg-info-col ul { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.35rem; }
.tg-info-col li { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.4; }
.tg-info-col li b { color: var(--text-primary); }
.tg-info-cta { margin-top: 1rem; text-decoration: none; }

/* Daily check-ins mini-bar chart (activity-stream roll-up + round drill-down) */
.tg-back-spacer { flex: 0 0 auto; }
.tg-daybars { margin: 0.5rem 0 0.25rem; }
.tg-daybars-title { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); margin-bottom: 0.3rem; }
.tg-daybars-row { display: flex; align-items: flex-end; gap: 0.5rem; height: 68px; }
.tg-day { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 0.15rem; flex: 1 1 0; min-width: 0; height: 100%; }
.tg-day-count { font-size: 0.65rem; font-weight: 800; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.tg-day-bar { width: 60%; max-width: 22px; min-height: 4px; background: var(--tg-accent); border-radius: 4px 4px 0 0; transition: height 0.25s ease; }
.tg-day-label { font-size: 0.6rem; color: var(--text-tertiary); }
.tg-stat-checkins { font-size: 0.78rem; color: var(--text-secondary); }
.tg-stat-checkins b { color: var(--tg-accent); font-variant-numeric: tabular-nums; }

/* Free-tier upsells: switcher "unlimited grids" + locked-rounds teaser */
.tg-switcher-upsell {
    display: flex; align-items: center; justify-content: center; gap: 0.4rem;
    margin-top: 0.35rem; border-top: 1px solid var(--border-color); padding: 0.55rem;
    text-decoration: none; border-radius: 0.45rem;
    background: color-mix(in srgb, var(--tg-accent) 12%, transparent);
    color: var(--tg-accent); font-size: 0.8rem; font-weight: 700;
}
.tg-switcher-upsell:hover { background: color-mix(in srgb, var(--tg-accent) 20%, transparent); }
.tg-round-lock {
    display: block; margin-top: 0.4rem; padding: 0.6rem 0.75rem;
    background: color-mix(in srgb, var(--tg-accent) 8%, var(--bg-tertiary));
    border: 1px dashed var(--tg-accent); border-radius: 0.55rem;
    font-size: 0.78rem; color: var(--text-secondary); text-decoration: none;
}
.tg-round-lock i { color: var(--tg-accent); margin-right: 0.3rem; }
.tg-round-lock b { color: var(--tg-accent); }
.tg-round-lock a { color: var(--tg-accent); text-decoration: none; }

/* Sample-template Pro badge in the setup step */
.tg-preset { position: relative; }
.tg-preset-badge {
    position: absolute; top: 3px; right: 4px;
    width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center;
    background: #f59e0b; color: #fff; border-radius: 999px; font-size: 0.55rem;
}
.tg-preset-pro { border-style: dashed; }

/* Pro upsell modal (opened on any free-tier cap) */
.tg-pro-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.55);
    display: none; align-items: center; justify-content: center; z-index: 1100; padding: 1rem;
}
.tg-pro-overlay.is-open { display: flex; }
.tg-pro-modal {
    position: relative;
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: 14px; max-width: 400px; width: 100%; padding: 1.5rem 1.35rem 1.35rem;
    text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.tg-pro-x { position: absolute; top: 0.6rem; right: 0.75rem; }
.tg-pro-crown {
    width: 52px; height: 52px; margin: 0 auto 0.6rem;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, #f59e0b 18%, transparent); color: #f59e0b;
    border-radius: 999px; font-size: 1.4rem;
}
.tg-pro-title { margin: 0 0 0.4rem; font-size: 1.15rem; font-weight: 800; color: var(--text-primary); }
.tg-pro-msg { margin: 0 0 0.9rem; font-size: 0.88rem; color: var(--text-secondary); line-height: 1.5; }
.tg-pro-points { list-style: none; margin: 0 0 1.1rem; padding: 0; text-align: left; display: flex; flex-direction: column; gap: 0.4rem; }
.tg-pro-points li { font-size: 0.82rem; color: var(--text-secondary); padding-left: 1.4rem; position: relative; }
.tg-pro-points li::before { content: "\f00c"; font-family: "Font Awesome 6 Free"; font-weight: 900; position: absolute; left: 0; color: var(--tg-accent); font-size: 0.72rem; }
.tg-pro-points li b { color: var(--text-primary); }
.tg-pro-points li span { color: var(--text-tertiary); }
.tg-pro-modal .tg-info-cta { margin-top: 0; }
.tg-pro-later { margin-top: 0.6rem; background: transparent; border: none; color: var(--text-tertiary); font-size: 0.8rem; cursor: pointer; }
.tg-pro-later:hover { color: var(--text-secondary); }
