/* =====================================================================
   Analyze Together
   Uses the tokens from app.css, plus one color per seat.
   ===================================================================== */
:root { --seat-a: #17807a; --seat-a-soft: #dff1ef; --seat-b: #6a4dc4; --seat-b-soft: #ece7fa; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --seat-a: #4fc6bd; --seat-a-soft: #12302e; --seat-b: #a995f0; --seat-b-soft: #251f3d; } }
:root[data-theme="dark"] { --seat-a: #4fc6bd; --seat-a-soft: #12302e; --seat-b: #a995f0; --seat-b-soft: #251f3d; }

.tg-backend { font-size: var(--fs-sm); color: var(--text-2); margin: -8px 0 14px; display: flex; align-items: center; gap: 8px; }
.tg-backend .dot, .tg-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; }
.tg-backend .dot.ok { background: var(--good); }
.tg-backend .dot.warn { background: var(--accent-bright); }
.tg-backend .dot.off { background: var(--attn); }
.tg-you { padding: 14px 18px; }

.tg-promo { display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 22px; border-radius: var(--r-md); background: var(--ink); color: var(--ink-text); text-decoration: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.07); }
.tg-promo:hover { text-decoration: none; background: var(--ink-2); }
.tg-promo .grow { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.tg-promo .grow strong { font-family: var(--font-display); font-size: var(--fs-lg); }
.tg-promo .grow span { color: var(--ink-muted); font-size: var(--fs-sm); }
.tg-promo-ic { width: 38px; height: 38px; border-radius: var(--r-md); background: var(--accent-bright); color: #1b1408; display: grid; place-items: center; flex: none; }
.tg-promo-ic svg { width: 20px; height: 20px; }
.tg-promo .btn.primary { background: var(--accent-bright); color: #1b1408; border-color: transparent; }

.tg-status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); padding: 5px 10px; border-radius: var(--r-pill); background: var(--surface-3); white-space: nowrap; }
.tg-status.ok .dot { background: var(--good); }
.tg-status.busy .dot { background: var(--accent-bright); animation: tg-pulse 1s ease infinite; }
.tg-status.off { background: var(--attn-soft); color: var(--attn); }
.tg-status.off .dot { background: var(--attn); }
@keyframes tg-pulse { 50% { opacity: 0.35; } }

.tg-meta { display: grid; grid-template-columns: 180px 150px 220px minmax(200px, 1fr); gap: 12px 16px; align-items: end; margin-bottom: 14px; }
.tg-progress-line { font-size: var(--fs-sm); color: var(--text-2); margin: 2px 0 6px; }
.tg-news { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; background: var(--info-soft); color: var(--text); border-radius: var(--r-md); margin-bottom: 12px; font-size: var(--fs-sm); }
.tg-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.tg-toolbar .grow { flex: 1; }
.tg-toolbar .seg .count { font-size: 10px; background: var(--surface-3); border-radius: var(--r-pill); padding: 0 6px; margin-left: 2px; color: var(--text-2); }
.tg-colswitch { display: none; }

/* The comparison grid: a label column and three sheets, row-aligned. */
.tg-grid { --tg-label: 190px; display: flex; flex-direction: column; }
.tg-head, .tg-row { display: grid; grid-template-columns: var(--tg-label) repeat(3, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.tg-head { position: sticky; top: 0; z-index: 8; background: var(--bg); padding: 10px 0; border-bottom: 1px solid var(--line); }
.tg-col-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.tg-col-head.shared { background: var(--accent-soft); border-color: transparent; }
.tg-col-meta { min-width: 0; }
.tg-col-name { font-weight: 600; font-size: var(--fs-sm); display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-col-sub { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: var(--text-3); flex: none; }
.tg-avatar.seat-a { background: var(--seat-a); color: var(--text-inverse); }
.tg-avatar.seat-b { background: var(--seat-b); color: var(--text-inverse); }
.tg-avatar.shared { background: var(--accent-bright); color: #1b1408; }
.tg-avatar.shared svg { width: 16px; height: 16px; }
.tg-avatar.empty { background: var(--surface-3); color: var(--text-3); }
.tg-avatar.sm { width: 22px; height: 22px; font-size: 11px; }
.tg-presence { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; }
.tg-presence.on { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.tg-presence.away { background: var(--accent-bright); }

.tg-section { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg); margin-top: 18px; padding-bottom: 6px; }
.tg-row { padding: 10px 0; border-top: 1px solid var(--line); }
.tg-row .tg-thread { grid-column: 2 / -1; }
.tg-label { min-width: 0; padding-top: 4px; }
.tg-label-name { font-weight: 600; font-size: var(--fs-md); }
.tg-label-name a { color: inherit; }
.tg-target, .tg-hint { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }
.tg-target { font-variant-numeric: tabular-nums; }
.tg-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tg-talk { margin-top: 6px; display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); color: var(--text-3); background: none; border: 0; padding: 2px 0; }
.tg-talk svg { width: 13px; height: 13px; }
.tg-talk:hover, .tg-talk.has { color: var(--text-2); }
.tg-talk.has { font-weight: 600; }
.tg-talk.unread { color: var(--attn); }

.tg-cell { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px; display: flex; flex-direction: column; gap: 4px; min-height: 68px; min-width: 0; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.tg-cell.shared { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); border-color: color-mix(in srgb, var(--accent-bright) 40%, var(--line)); }
.tg-cell.ro { background: var(--surface-2); }
.tg-cell.mine.seat-a, .tg-cell.theirs.seat-a { border-left: 3px solid var(--seat-a); }
.tg-cell.mine.seat-b, .tg-cell.theirs.seat-b { border-left: 3px solid var(--seat-b); }
.tg-fields { display: flex; flex-direction: column; gap: 2px; }
.tg-where { border: 0; background: transparent; font-size: var(--fs-xs); font-weight: 600; color: var(--accent); padding: 3px 5px; border-radius: 4px; width: 100%; font-variant-numeric: tabular-nums; }
.tg-where::placeholder { color: var(--text-3); font-weight: 400; }
.tg-where:focus { outline: none; background: var(--surface-2); }
.tg-cell .textarea { border-color: transparent; background: transparent; padding: 4px 5px; font-size: var(--fs-sm); line-height: 1.5; }
.tg-cell .textarea:hover { border-color: var(--line); }
.tg-cell .textarea:focus { background: var(--surface); border-color: var(--accent-bright); }
.tg-cell .textarea[readonly] { cursor: not-allowed; opacity: 0.75; }
.tg-cell .tg-note { font-size: var(--fs-xs); color: var(--text-2); }
.tg-cell .tg-note:placeholder-shown { display: none; }
.tg-cell:focus-within .tg-note { display: block; }
.tg-ro-where { display: inline-block; font-size: var(--fs-xs); font-weight: 600; color: var(--accent); padding: 3px 5px; font-variant-numeric: tabular-nums; }
.tg-ro-what { font-size: var(--fs-sm); line-height: 1.5; padding: 4px 5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tg-ro-note { font-size: var(--fs-xs); color: var(--text-2); padding: 0 5px 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tg-empty { font-size: var(--fs-xs); color: var(--text-3); padding: 6px 5px; font-style: italic; }

.tg-actions { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 4px; flex-wrap: wrap; }
.tg-actions .grow { flex: 1; }
.tg-act { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-pill); padding: 3px 9px; font-size: var(--fs-xs); font-weight: 500; color: var(--text-2); white-space: nowrap; }
.tg-act svg { width: 12px; height: 12px; }
.tg-act:hover { color: var(--text); background: var(--surface-2); }
.tg-act[disabled] { opacity: 0.35; pointer-events: none; }
.tg-act.subtle { border-color: transparent; background: transparent; color: var(--text-3); padding: 3px 5px; }
.tg-act.subtle:hover { color: var(--text); background: var(--surface-3); }
.tg-agree[aria-pressed="true"] { background: var(--good-soft); border-color: var(--good); color: var(--good); font-weight: 600; }
.tg-agree-dots { display: inline-flex; gap: 3px; }
.tg-agree-dots i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--line-strong); }
.tg-agree-dots i.seat-a.on { background: var(--seat-a); border-color: var(--seat-a); }
.tg-agree-dots i.seat-b.on { background: var(--seat-b); border-color: var(--seat-b); }
.tg-row[data-state="agreed"] .tg-cell.shared { border-color: var(--good); }

/* Where your friend is right now */
.tg-grid[data-peer="a"] .tg-cell.tg-peer { box-shadow: 0 0 0 2px var(--seat-a); }
.tg-grid[data-peer="b"] .tg-cell.tg-peer { box-shadow: 0 0 0 2px var(--seat-b); }
.tg-lock { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); padding: 0 5px; }
.tg-conflict-item { background: var(--attn-soft); border-radius: var(--r-sm); padding: 8px 10px; font-size: var(--fs-xs); display: flex; flex-direction: column; gap: 6px; }
.tg-conflict-item blockquote { margin: 0; padding-left: 8px; border-left: 2px solid var(--attn); white-space: pre-wrap; color: var(--text-2); }
.tg-flash { animation: tg-flash 1.4s ease; }
@keyframes tg-flash { 0% { box-shadow: 0 0 0 3px var(--accent-ring); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* Row filters */
.tg-grid[data-filter="discuss"] .tg-row:not([data-state="discuss"]),
.tg-grid[data-filter="agreed"] .tg-row:not([data-state="agreed"]),
.tg-grid[data-filter="open"] .tg-row[data-state="agreed"],
.tg-grid[data-filter="open"] .tg-row[data-state="empty"],
.tg-grid[data-filter="new"] .tg-row:not([data-new="1"]) { display: none; }

/* Threads */
.tg-thread-inner { background: var(--surface-2); border-radius: var(--r-md); padding: 10px 12px; }
.tg-general .tg-thread-inner { background: transparent; padding: 0; }
.tg-msgs { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.tg-msg { display: flex; gap: 8px; align-items: flex-start; }
.tg-msg.pending { opacity: 0.6; }
.tg-msg-body { min-width: 0; flex: 1; }
.tg-msg-head { display: flex; gap: 8px; align-items: baseline; font-size: var(--fs-xs); }
.tg-msg-text { font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.tg-msg-del { border: 0; background: none; color: var(--text-3); padding: 0; opacity: 0; margin-left: auto; }
.tg-msg-del svg { width: 12px; height: 12px; }
.tg-msg:hover .tg-msg-del, .tg-msg-del:focus-visible { opacity: 1; }
.tg-msg-form { display: flex; gap: 8px; align-items: flex-end; }
.tg-msg-form .textarea { flex: 1; background: var(--surface); font-size: var(--fs-sm); padding: 6px 9px; }
.tg-general { margin-top: 22px; }

/* Popover menu */
.tg-menu { position: absolute; z-index: 80; min-width: 270px; max-width: 340px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-2); padding: 6px; display: flex; flex-direction: column; }
.tg-menu button { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: var(--r-sm); font-size: var(--fs-sm); display: flex; flex-direction: column; gap: 1px; color: var(--text); }
.tg-menu button span { font-size: var(--fs-xs); color: var(--text-3); }
.tg-menu button:hover { background: var(--surface-2); }
.tg-menu button.danger { color: var(--attn); }
.tg-menu-sep { height: 1px; background: var(--line); margin: 4px 0; }

/* History dialog */
.tg-hist-sec + .tg-hist-sec { margin-top: 16px; }
.tg-hist-item { padding: 10px 0; border-top: 1px solid var(--line); }
.tg-hist-item.current { border-top: 0; }
.tg-hist-meta { display: flex; align-items: center; gap: 8px; font-size: var(--fs-xs); flex-wrap: wrap; }
.tg-hist-meta .btn { margin-left: auto; }
.tg-hist-text { font-size: var(--fs-sm); color: var(--text); white-space: pre-wrap; margin-top: 4px; overflow-wrap: anywhere; }

@media (max-width: 1150px) {
  .tg-grid { --tg-label: 150px; }
  .tg-meta { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tg-progress { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .tg-colswitch { display: inline-flex; }
  .tg-head, .tg-row { grid-template-columns: 1fr; gap: 8px; }
  .tg-corner { display: none; }
  .tg-row .tg-thread { grid-column: 1; }
  .tg-meta { grid-template-columns: 1fr 1fr; }
  .tg-grid[data-col="mine"] .tg-cell:not(.mine), .tg-grid[data-col="mine"] .tg-col-head:not(.mine),
  .tg-grid[data-col="shared"] .tg-cell:not(.shared), .tg-grid[data-col="shared"] .tg-col-head:not(.shared),
  .tg-grid[data-col="theirs"] .tg-cell:not(.theirs), .tg-grid[data-col="theirs"] .tg-col-head:not(.theirs) { display: none; }
  .tg-promo { flex-wrap: wrap; }
}
