/* Team Chat — theme-aware (design-system tokens). Contrast guaranteed in BOTH themes:
   gold ACCENTS use --tc-ink (brand gold on dark, a dark bronze #7e6218 on light), so gold font is
   NEVER placed on a white/grey background; body text uses --ds-text*; surfaces use --ds-surface*.
   Light is the :root default; dark via prefers-color-scheme AND the explicit [data-theme] toggle. */
.tc-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; color: var(--ds-text); --tc-ink: #7e6218; }
@media (prefers-color-scheme: dark) { .tc-wrap { --tc-ink: var(--ds-accent, #D4AF37); } }
:root[data-theme="dark"] .tc-wrap { --tc-ink: var(--ds-accent, #D4AF37); }
:root[data-theme="light"] .tc-wrap { --tc-ink: #7e6218; }

.tc-head h2 { margin: 0 0 4px; font-size: 22px; color: var(--ds-text-hi); }
.tc-sub { margin: 0 0 12px; font-size: 13px; color: var(--ds-text-lo); }
.tc-tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--ds-hairline-strong); margin-bottom: 14px; }
.tc-tab { background: transparent; border: none; color: var(--ds-text-lo); padding: 8px 14px; cursor: pointer; font-size: 14px; border-bottom: 2px solid transparent; }
.tc-tab.on { color: var(--tc-ink); border-bottom-color: var(--tc-ink); font-weight: 600; }
.tc-body { flex: 1; min-height: 0; }
.tc-empty, .tc-emptyrow { color: var(--ds-text-lo); padding: 18px; font-size: 14px; }
.tc-err { color: var(--ds-danger, #c0392b); }

/* Chat layout */
.tc-chat, .tc-canvas { display: grid; grid-template-columns: 240px 1fr; gap: 14px; height: 100%; min-height: 420px; }
.tc-rail { border: 1px solid var(--ds-hairline-strong); border-radius: 12px; background: var(--ds-surface); padding: 10px; overflow: auto; }
.tc-railhead { display: flex; align-items: center; justify-content: space-between; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ds-text-lo); margin: 10px 4px 6px; }
.tc-chlist { list-style: none; margin: 0 0 6px; padding: 0; }
.tc-chrow { display: flex; align-items: center; justify-content: space-between; padding: 7px 9px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--ds-text); }
.tc-chrow:hover { background: var(--ds-surface-2); }
.tc-chrow.on { background: var(--ds-surface-2); color: var(--tc-ink); font-weight: 600; }
.tc-unread { background: var(--ds-accent, #D4AF37); color: #000; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.tc-mini { background: transparent; border: 1px solid var(--ds-hairline-strong); color: var(--tc-ink); border-radius: 6px; cursor: pointer; font-size: 12px; padding: 1px 7px; }
.tc-mini:hover { border-color: var(--ds-accent); }

.tc-thread { display: flex; flex-direction: column; border: 1px solid var(--ds-hairline-strong); border-radius: 12px; background: var(--ds-surface); min-height: 0; }
.tc-msghead { padding: 12px 16px; border-bottom: 1px solid var(--ds-hairline-strong); font-size: 15px; color: var(--ds-text-hi); font-weight: 600; }
.tc-msgs { flex: 1; overflow: auto; padding: 12px 16px; min-height: 0; }
.tc-msg { margin-bottom: 14px; }
.tc-bubble { background: var(--ds-surface-2); border: 1px solid var(--ds-hairline-strong); border-radius: 10px; padding: 8px 12px; }
.tc-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; margin-bottom: 6px; }
.tc-author { font-weight: 600; color: var(--tc-ink); font-size: 13px; }
.tc-time { font-size: 11px; color: var(--ds-text-lo); }
.tc-text { white-space: pre-wrap; word-break: break-word; color: var(--ds-text); font-size: 14px; }
.tc-replies { margin: 6px 0 0 18px; border-left: 2px solid var(--ds-hairline-strong); padding-left: 12px; }
.tc-replybtn { margin: 4px 0 0 2px; background: transparent; border: none; color: var(--tc-ink); cursor: pointer; font-size: 12px; }
.tc-compose { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--ds-hairline-strong); flex-wrap: wrap; }
.tc-replybar { width: 100%; font-size: 12px; color: var(--ds-text-lo); display: flex; gap: 8px; align-items: center; }
.tc-compose textarea { flex: 1; resize: vertical; background: var(--ds-surface-2); border: 1px solid var(--ds-hairline-strong); color: var(--ds-text-hi); border-radius: 8px; padding: 8px 10px; font: inherit; }
.tc-send, .tc-btn { background: var(--ds-surface-2); border: 1px solid var(--ds-hairline-strong); color: var(--tc-ink); border-radius: 8px; padding: 8px 16px; cursor: pointer; font: inherit; }
.tc-send:hover, .tc-btn:hover { border-color: var(--ds-accent); box-shadow: 0 0 10px rgba(212,175,55,.25); }

/* Lists */
.tc-lists { height: 100%; overflow: auto; }
.tc-listhead { margin-bottom: 12px; }
.tc-list { border: 1px solid var(--ds-hairline-strong); border-radius: 12px; background: var(--ds-surface); padding: 12px 14px; margin-bottom: 16px; }
.tc-listtitle { font-size: 16px; font-weight: 600; color: var(--ds-text-hi); margin-bottom: 8px; }
.tc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tc-table th { text-align: left; font-weight: 600; color: var(--ds-text-lo); padding: 6px 8px; border-bottom: 1px solid var(--ds-hairline-strong); font-size: 12px; }
.tc-table td { padding: 6px 8px; border-bottom: 1px solid var(--ds-hairline); color: var(--ds-text); vertical-align: middle; }
.tc-sel, .tc-date { background: var(--ds-surface-2); border: 1px solid var(--ds-hairline-strong); color: var(--ds-text-hi); border-radius: 6px; padding: 4px 6px; font: inherit; font-size: 13px; }
.tc-status-done { color: var(--ds-positive, #2e7d32); }
.tc-status-blocked { color: var(--ds-danger, #c0392b); }
.tc-additem { display: flex; gap: 8px; margin-top: 10px; }
.tc-newitem { flex: 1; background: var(--ds-surface-2); border: 1px solid var(--ds-hairline-strong); color: var(--ds-text-hi); border-radius: 8px; padding: 7px 10px; font: inherit; }

/* Canvas */
.tc-doc { display: flex; flex-direction: column; border: 1px solid var(--ds-hairline-strong); border-radius: 12px; background: var(--ds-surface); padding: 14px; min-height: 0; }
.tc-doctitle { background: transparent; border: none; border-bottom: 1px solid var(--ds-hairline-strong); color: var(--ds-text-hi); font-size: 18px; font-weight: 600; padding: 6px 2px; margin-bottom: 10px; font-family: inherit; }
.tc-docbody { flex: 1; min-height: 260px; resize: vertical; background: var(--ds-surface-2); border: 1px solid var(--ds-hairline-strong); color: var(--ds-text-hi); border-radius: 8px; padding: 12px; font: inherit; line-height: 1.5; }
.tc-docbar { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.tc-docmeta { font-size: 12px; color: var(--ds-text-lo); }

@media (max-width: 760px) {
  .tc-chat, .tc-canvas { grid-template-columns: 1fr; }
  .tc-rail { max-height: 160px; }
}

/* --- @mention autocomplete + highlight --- */
.tc-inputwrap { flex: 1; position: relative; display: flex; }
.tc-inputwrap textarea { width: 100%; box-sizing: border-box; }
.tc-mentions { position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; z-index: 30;
  background: var(--ds-surface); border: 1px solid var(--ds-hairline-strong); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.35); max-height: 220px; overflow: auto; }
.tc-mentrow { padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 14px; color: var(--ds-text); display: flex; gap: 8px; align-items: baseline; }
.tc-mentrow:hover, .tc-mentrow.on { background: var(--ds-surface-2); color: var(--tc-ink); }
.tc-mentrole { font-size: 11px; color: var(--ds-text-lo); }
.tc-mention { color: var(--tc-ink); background: var(--ds-accent-soft, rgba(212,175,55,.14)); border-radius: 4px; padding: 0 3px; font-weight: 600; }

/* --- teammate picker modal (DMs) --- */
.tc-modal-ov { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 60; }
.tc-modal { width: 360px; max-width: 92vw; max-height: 80vh; display: flex; flex-direction: column; background: var(--ds-surface); border: 1px solid var(--ds-hairline-strong); border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.4); overflow: hidden; }
.tc-modal-h { padding: 14px 16px; font-size: 15px; font-weight: 600; color: var(--ds-text-hi); border-bottom: 1px solid var(--ds-hairline-strong); }
.tc-pick { list-style: none; margin: 0; padding: 6px; overflow: auto; }
.tc-pickrow { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 9px 11px; border-radius: 8px; cursor: pointer; }
.tc-pickrow:hover { background: var(--ds-surface-2); }
.tc-pickname { color: var(--ds-text); font-size: 14px; }
.tc-pickrow:hover .tc-pickname { color: var(--tc-ink); }
.tc-pickrole { font-size: 11px; color: var(--ds-text-lo); }
.tc-modal-f { padding: 10px 14px; border-top: 1px solid var(--ds-hairline-strong); text-align: right; }

/* --- canvas save confirmation --- */
.tc-saved { color: var(--ds-positive, #2e7d32); font-weight: 600; }

/* ---- message controls: edit / delete / reactions / emoji / attachments ---- */
.tc-bubble { position: relative; }
.tc-acts { display: inline-flex; flex-wrap: wrap; margin-left: auto; gap: 6px; }
.tc-bubble:hover .tc-acts { display: inline-flex; }
.tc-act { background: var(--ds-surface-2,#1b1b1e); border: 1px solid var(--ds-hairline,rgba(212,175,55,.25)); color: var(--ds-text-mid,#c9c3b2); font-size: 12px; padding: 5px 10px; border-radius: 6px; cursor: pointer; }
.tc-act:hover { color: var(--ds-text-hi,#e9e3d2); border-color: var(--ds-accent-strong,#D4AF37); }
.tc-act--del:hover { color: #ff8a8a; border-color: #ff8a8a; }
.tc-edited { color: var(--ds-text-dim,#8a856f); font-size: 11px; }
.tc-deleted { color: var(--ds-text-dim,#8a856f); font-style: italic; }
.tc-bubble--del { opacity: .75; }
.tc-reactrow { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.tc-react { background: var(--ds-surface-2,#1b1b1e); border: 1px solid var(--ds-hairline,rgba(212,175,55,.25)); color: var(--ds-text-hi,#e9e3d2); font-size: 12px; padding: 1px 7px; border-radius: 10px; cursor: pointer; line-height: 1.5; }
.tc-react.mine { border-color: var(--ds-accent-strong,#D4AF37); background: rgba(212,175,55,.14); }
.tc-react:hover { border-color: var(--ds-accent-strong,#D4AF37); }
.tc-addreact { background: transparent; border: 1px dashed var(--ds-hairline,rgba(212,175,55,.3)); color: var(--ds-text-dim,#8a856f); font-size: 12px; padding: 1px 7px; border-radius: 10px; cursor: pointer; }
.tc-addreact:hover { color: var(--ds-text-hi,#e9e3d2); border-color: var(--ds-accent-strong,#D4AF37); }
.tc-atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tc-att { display: inline-flex; align-items: center; gap: 4px; background: var(--ds-surface-2,#1b1b1e); border: 1px solid var(--ds-hairline,rgba(212,175,55,.25)); color: var(--ds-accent-strong,#D4AF37); font-size: 12px; padding: 4px 9px; border-radius: 8px; cursor: pointer; text-decoration: none; }
.tc-att:hover { border-color: var(--ds-accent-strong,#D4AF37); text-decoration: underline; }
.tc-editbox { width: 100%; box-sizing: border-box; background: var(--ds-surface-2,#1b1b1e); border: 1px solid var(--ds-accent-strong,#D4AF37); border-radius: 8px; color: var(--ds-text-hi,#e9e3d2); font: 400 13.5px/1.5 var(--font-ui,system-ui); padding: 8px; min-height: 54px; outline: none; margin-top: 4px; }
.tc-editbar { display: flex; gap: 6px; margin-top: 6px; }
.tc-inputrow { display: flex; align-items: flex-end; gap: 8px; }
.tc-composeacts { display: flex; align-items: center; gap: 6px; }
.tc-iconbtn { background: var(--ds-surface-2,#1b1b1e); border: 1px solid var(--ds-hairline,rgba(212,175,55,.25)); border-radius: 8px; font-size: 16px; line-height: 1; padding: 8px 9px; cursor: pointer; }
.tc-iconbtn:hover { border-color: var(--ds-accent-strong,#D4AF37); }
.tc-iconbtn:disabled { opacity: .5; cursor: default; }
.tc-pending { display: none; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.tc-pendchip { display: inline-flex; align-items: center; gap: 4px; background: rgba(212,175,55,.12); border: 1px solid var(--ds-hairline,rgba(212,175,55,.3)); color: var(--ds-text-hi,#e9e3d2); font-size: 12px; padding: 3px 8px; border-radius: 8px; }
.tc-pendx { background: none; border: none; color: var(--ds-text-dim,#8a856f); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
.tc-pendx:hover { color: #ff8a8a; }
.tc-emojipop { position: fixed; z-index: 3000; width: 252px; max-height: 220px; overflow: auto; background: var(--ds-surface-1,#141416); border: 1px solid var(--ds-hairline,rgba(212,175,55,.35)); border-radius: 10px; padding: 8px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.tc-emoji { background: none; border: none; font-size: 18px; line-height: 1; padding: 5px; border-radius: 6px; cursor: pointer; }
.tc-emoji:hover { background: rgba(212,175,55,.18); }


/* Threads keep their own composer beneath the parent, never in the channel feed. */
.tc-replies { border-left-color: var(--tc-ink); margin-top: 10px; padding: 8px 0 0 14px; }
.tc-replies > .tc-bubble { margin: 8px 0; }
.tc-threadlabel { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--ds-text-hi); font-weight: 600; font-size: 13px; }
.tc-threadcomposer .tc-compose { margin-top: 10px; border: 1px solid var(--ds-hairline-strong); border-radius: 10px; background: var(--ds-surface); }
.tc-threadcomposer .tc-replybar { color: var(--tc-ink); font-weight: 600; }
.tc-inputrow { width: 100%; min-width: 0; }
.tc-inputwrap { min-width: 0; }
.tc-act { color: var(--ds-text-hi,var(--ds-text)); }
.tc-act--del { color: var(--ds-danger,#b42318); }
.tc-act:focus-visible,.tc-replybtn:focus-visible,.tc-mini:focus-visible { outline: 2px solid var(--tc-ink); outline-offset: 3px; }
@media (max-width: 600px) { .tc-inputrow { flex-wrap: wrap; } .tc-inputwrap { flex-basis: 100%; } .tc-replies { margin-left: 4px; padding-left: 8px; } }

/* ---- Canvas formatting toolbar + preview (bold / italic / emoji / @mention) ---- */
.tc-doctools { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tc-tool { background: var(--ds-surface-2,#1b1b1e); border: 1px solid var(--ds-hairline,rgba(212,175,55,.25)); color: var(--ds-text-hi,#e9e3d2); border-radius: 8px; font-size: 13px; line-height: 1; padding: 7px 10px; cursor: pointer; }
.tc-tool:hover { border-color: var(--ds-accent-strong,#D4AF37); box-shadow: 0 0 10px rgba(212,175,55,.2); }
.tc-tool--toggle { margin-left: auto; color: var(--tc-ink); }
/* Rendered canvas reads like the Slack source: plain text at the TOP, no input box/frame. */
.tc-docpreview { flex: 1; min-height: 120px; background: transparent; border: none; border-radius: 0; color: var(--ds-text-hi); padding: 4px 2px; line-height: 1.6; overflow-y: auto; white-space: normal; word-break: break-word; align-self: flex-start; width: 100%; box-sizing: border-box; }
/* Full content shows by default. Collapse is DISPLAY-ONLY: it caps the visible height (still scrollable) and never alters the stored body. */
.tc-docpreview.tc-docpreview--collapsed { flex: 0 0 auto; max-height: 340px; }
.tc-docpreview strong { color: var(--ds-text-hi,#e9e3d2); font-weight: 700; }
.tc-docpreview em { font-style: italic; }
.tc-docpreview a { color: var(--ds-accent,#D4AF37); text-decoration: underline; word-break: break-word; }
.tc-docpreview a:hover { color: var(--ds-accent-strong,#F7E7A1); }

/* ---- Lists: custom columns ---- */
.tc-tablewrap { width: 100%; overflow-x: auto; }
.tc-colh { white-space: nowrap; }
.tc-colx { background: none; border: none; color: var(--ds-text-lo,#9a927f); cursor: pointer; font-size: 13px; line-height: 1; padding: 0 2px; }
.tc-colx:hover { color: var(--ds-danger,#b42318); }
.tc-addcolh { text-align: right; }
.tc-addcol { background: none; border: 1px dashed var(--ds-hairline-strong,rgba(212,175,55,.35)); color: var(--tc-ink); border-radius: 8px; font-size: 12px; padding: 4px 9px; cursor: pointer; white-space: nowrap; }
.tc-addcol:hover { border-style: solid; border-color: var(--ds-accent-strong,#D4AF37); }
.tc-cell { width: 100%; min-width: 92px; box-sizing: border-box; background: var(--ds-surface-2,#1b1b1e); border: 1px solid var(--ds-hairline,rgba(212,175,55,.25)); color: var(--ds-text,#e9e3d2); border-radius: 6px; padding: 5px 7px; font: inherit; }
.tc-cell:focus { outline: none; border-color: var(--ds-accent-strong,#D4AF37); }
/* Long text cells wrap to the next line and show in full (never truncated to one line). */
.tc-cellarea { display: block; min-height: 2.2em; max-height: 220px; overflow-y: auto; resize: vertical; white-space: pre-wrap; word-break: break-word; line-height: 1.4; min-width: 180px; }
/* Table cells top-align and wrap; the Task column wraps instead of stretching the row off-screen. */
.tc-table td { vertical-align: top; white-space: normal; word-break: break-word; }
.tc-table td:first-child { max-width: 320px; white-space: pre-wrap; word-break: break-word; }

/* ---- scope labels (Team Lists / Team Canvases are internal-team-only) ---- */
.tc-scopehead { display: flex; flex-direction: column; gap: 1px; }
.tc-scopehead strong { color: var(--ds-text-hi,#e9e3d2); font-size: 14px; }
.tc-scope { color: var(--ds-text-lo,#9a927f); font-size: 11.5px; }
.tc-railscope { margin: 2px 0 8px; }
.tc-listhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---- Add-column dialog + typed cell editors ---- */
.tc-field { display: flex; flex-direction: column; gap: 5px; margin: 0 0 12px; }
.tc-field label { font-size: 12px; color: var(--ds-text-lo,#9a927f); }
.tc-modal-inp { background: var(--ds-surface-2,#1b1b1e); border: 1px solid var(--ds-hairline-strong,rgba(212,175,55,.35)); color: var(--ds-text-hi,#e9e3d2); border-radius: 8px; padding: 8px 10px; font: inherit; width: 100%; box-sizing: border-box; }
.tc-modal-inp:focus { outline: none; border-color: var(--ds-accent-strong,#D4AF37); }
.tc-btn--primary { background: var(--ds-accent,#D4AF37); color: #000; border-color: var(--ds-accent,#D4AF37); font-weight: 600; }
.tc-btn--primary:hover { box-shadow: 0 0 12px rgba(212,175,55,.4); }
.tc-cellsel { min-width: 110px; }
.tc-cellcheck { width: 18px; height: 18px; accent-color: var(--ds-accent,#D4AF37); cursor: pointer; }

/* ---- inline @mention autocomplete inside a Team Canvas ---- */
.tc-docbodywrap { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 260px; }
.tc-docmentions { bottom: auto; top: 8px; left: 8px; right: auto; min-width: 240px; max-width: 340px; max-height: 210px; overflow-y: auto; }
