/* Team chat (Gabe ↔ Zai) — ported from the chat in Dalia's app (dalias-zizi/backend/public/index.html,
   "Chat" + "GIF picker" + "Full-screen media viewer" blocks), 2026-10-06. Same sizes, radii, spacing and
   behaviour; Dalia's mint accent (#cbe0b6 on #22331a) is swapped for Mizufox's rose gold (#e3a797 on
   #292823), the same swap app.css made for AZNA's teal. Class names carry a tc- prefix so nothing here
   can collide with the Support inbox's website chat. */
:root { --tc-accent: #e3a797; --tc-on-accent: #292823; --tc-accent-tx: #e3a797; --tc-accent-soft: rgba(227,167,151,.18); --tc-accent-glow: rgba(227,167,151,.6); --tc-red: #e5484d; }
html[data-theme="light"] { --tc-accent-tx: #b06a55; }   /* readable rose on light paper (Dalia used a darker mint here) */
#chatSection, .tc-menu-ov, .gif-ov, .tc-viewer { font-feature-settings: "lnum" 1; font-variant-numeric: lining-nums; }

/* flex:none + min-height:0 are critical: .sec-view's flex:1 (and the desktop min-height) would beat the
   JS-set height, so long threads stretched the section and the composer slid off-screen. The section is
   sized by tcSize() instead. */
#chatSection { padding: 0; flex: none; min-height: 0; overflow: hidden; justify-content: flex-start; }
@media (min-width: 1000px) { #chatSection { min-height: 0; justify-content: flex-start; } }
#chatSection.hidden { display: none !important; }
.tc-contacts { display: flex; flex-direction: column; gap: 0; padding: 12px; overflow-y: auto; }
.tc-contacts.hidden { display: none; }
/* Inbox rows: name + last message + when (flat rows, iMessage-style) */
.tc-contact { display: flex; align-items: center; gap: 11px; background: none; border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: 12px 4px; cursor: pointer; text-align: left; width: 100%; font-family: inherit; }
.tc-contact:last-child { border-bottom: none; }
.tc-contact:hover { background: var(--paper-warm); }
.tc-c-av { width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: var(--tc-on-accent); background: var(--tc-accent); }
.tc-c-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tc-c-name { font-size: 14px; font-weight: 700; color: var(--ink); }
.tc-c-prev { font-size: 12.5px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-contact.unread .tc-c-prev { color: var(--ink); }
.tc-c-when { font-size: 11px; color: var(--ink-soft); }
.tc-c-right { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.tc-c-badge { background: var(--tc-red); color: #fff; font-size: 11px; font-weight: 800; min-width: 20px; height: 20px; border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 6px; }
.tc-empty { text-align: center; color: var(--ink-soft); padding: 40px 20px; font-size: 14px; }

.tc-thread { display: flex; flex-direction: column; flex: 1; min-height: 0; background: var(--paper); }
.tc-thread.hidden { display: none; }
.tc-thead { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex: 0 0 auto; position: relative; }
.tc-back { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--ink); font-size: 22px; cursor: pointer; padding: 4px 6px; display: flex; }
.tc-back.hidden { display: none; }
.tc-with-wrap { text-align: center; }
.tc-with { font-size: 15px; font-weight: 800; color: var(--ink); text-transform: uppercase; letter-spacing: .06em; }
.tc-with-sub { font-size: 10.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }
.tc-with-sub:empty { display: none; }
.tc-msgs { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; overscroll-behavior: contain; }
.tc-bub { max-width: 78%; padding: 9px 13px; border-radius: 16px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; position: relative; -webkit-touch-callout: none; }
.tc-bub.me { align-self: flex-end; background: var(--tc-accent); color: var(--tc-on-accent); border-bottom-right-radius: 5px; }
.tc-bub.them { align-self: flex-start; background: var(--paper-warm); color: var(--ink); border-bottom-left-radius: 5px; }
/* Tapbacks — the badge tucks onto the bubble's top corner, like iOS */
.tc-bub.has-reacts { margin-top: 13px; }
.tc-reacts { position: absolute; top: -14px; display: flex; align-items: center; gap: 1px; padding: 2px 6px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(0,0,0,.35); font-size: 12px; line-height: 1.5; white-space: nowrap; cursor: pointer; color: var(--ink); }
.tc-bub.them .tc-reacts { right: -8px; }
.tc-bub.me .tc-reacts { left: -8px; }
.tc-reacts.mine { border-color: var(--tc-accent); }
.tc-reacts .n { font-size: 10px; font-weight: 800; color: var(--ink-soft); margin: 0 2px 0 1px; }
/* Quoted message inside a bubble */
.tc-quote { display: block; border-left: 2.5px solid currentColor; padding: 2px 0 2px 8px; margin-bottom: 6px; opacity: .72; font-size: 12.5px; line-height: 1.35; cursor: pointer; max-height: 3.1em; overflow: hidden; }
.tc-quote .qn { display: block; font-size: 10.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.tc-bub.flash { animation: tcFlash 1.2s ease; }
@keyframes tcFlash { 25%, 60% { box-shadow: 0 0 0 3px var(--tc-accent-glow); } }
/* Reply / edit strip above the composer */
.tc-replybar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--paper); flex: 0 0 auto; }
.tc-replybar.hidden { display: none; }
.tc-replybar .rb-bar { width: 3px; align-self: stretch; border-radius: 2px; background: var(--tc-accent); flex: 0 0 auto; }
.tc-replybar .rb-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tc-replybar .rb-who { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--tc-accent-tx); }
.tc-replybar .rb-txt { font-size: 12.5px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-replybar button { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); cursor: pointer; display: flex; align-items: center; justify-content: center; }
/* Long-press menu: tapbacks on top, then Reply / Edit / Copy / Delete */
.tc-menu-ov { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 1150; display: flex; align-items: flex-end; justify-content: center; }
.tc-menu { width: min(430px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 20px 20px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); box-sizing: border-box; }
.tc-tapbacks { display: flex; gap: 6px; margin-bottom: 12px; }
.tc-tapbacks button { flex: 1; height: 48px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); font-size: 21px; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.tc-tapbacks button.on { background: var(--tc-accent-soft); border-color: var(--tc-accent); }
.tc-acts { display: flex; flex-direction: column; gap: 8px; }
.tc-acts button { width: 100%; padding: 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }
.tc-acts button.danger { color: var(--tc-red); border-color: rgba(229,72,77,.5); }
@media (min-width: 1000px) { .tc-menu-ov { align-items: center; } .tc-menu { border-radius: 20px; padding-bottom: 14px; } }
.tc-time { font-size: 10px; color: var(--ink-soft); margin: 1px 5px 8px; }
.tc-time.me { align-self: flex-end; }
.tc-time .tc-receipt { color: var(--tc-accent-tx); font-weight: 700; }
/* align-items:flex-end so the +, GIF and send buttons stay on the bottom line while the box grows upward */
.tc-compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px max(10px, calc(env(safe-area-inset-bottom) - 14px)); border-top: 1px solid var(--line); flex: 0 0 auto; background: var(--paper); }
.tc-inputwrap { flex: 1; position: relative; display: flex; min-width: 0; }
/* A textarea, not an input: long messages wrap and the box grows (Dalia, Zai 2026-08-03) */
.tc-compose textarea {
  width: 100%; background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
  padding: 12px 42px 12px 16px; color: var(--ink); font-size: 14px; font-family: inherit;
  line-height: 1.35; resize: none; overflow-y: auto; box-sizing: border-box;
  height: 44px; min-height: 44px; max-height: 132px;  /* ~6 lines, then it scrolls */
  display: block; transition: border-radius .12s;
}
.tc-compose textarea:focus { border-color: var(--tc-accent); outline: none; }
.tc-compose textarea.multiline { border-radius: 18px; }   /* a stadium shape reads wrong once it's several lines tall */
/* Waveform mic lives INSIDE the message bar, right end, pinned to the bottom of the box */
.tc-compose .tc-mic { position: absolute; right: 5px; bottom: 5px; width: 34px; height: 34px; border: none; background: transparent; color: #888888; border-radius: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; font-size: inherit; }
.tc-compose .tc-mic:active { color: var(--ink); }
.tc-compose > button { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--tc-accent); color: var(--tc-on-accent); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.tc-compose .tc-attach { background: transparent; border: 1px solid var(--line); color: var(--ink-soft); }
.tc-compose .tc-attach:disabled { opacity: .5; cursor: default; }
.tc-compose .gif-lbl { font-size: 11px; font-weight: 800; letter-spacing: .02em; font-family: inherit; }
.tc-spin { animation: tcSpin 1s linear infinite; display: inline-block; }
@keyframes tcSpin { to { transform: rotate(360deg); } }
/* Photo / video bubbles */
.tc-bub.media { padding: 4px; background: var(--card); color: var(--ink); }
.tc-bub.media.me { background: var(--card); color: var(--ink); }
.tc-bub img, .tc-bub video { display: block; max-width: min(240px, 62vw); max-height: 320px; border-radius: 14px; cursor: pointer; }
.tc-bub .tc-cap { padding: 6px 8px 4px; font-size: 14px; }
/* Voice messages */
.tc-bub audio { display: block; width: min(240px, 62vw); height: 40px; }
.tc-voice { display: flex; align-items: center; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--paper); flex: 0 0 auto; }
.tc-voice.hidden { display: none; }
.tc-vs-rec, .tc-vs-preview { display: flex; align-items: center; gap: 10px; width: 100%; }
.tc-vs-rec.hidden, .tc-vs-preview.hidden { display: none; }
.tc-vs-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tc-red); animation: tcPulse 1s infinite; flex: 0 0 auto; }
@keyframes tcPulse { 50% { opacity: .3; } }
.tc-vs-time { font-weight: 700; font-variant-numeric: tabular-nums lining-nums; color: var(--ink); }
.tc-vs-hint { color: var(--ink-soft); font-size: 13px; flex: 1; }
.tc-vs-audio { flex: 1; min-width: 0; height: 40px; }
.tc-voice button { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.tc-voice .tc-vs-stop { background: var(--tc-red); border: none; color: #fff; }
.tc-voice .tc-vs-send { background: var(--tc-accent); border: none; color: var(--tc-on-accent); }
/* PDF file card */
.tc-pdf { display: flex; align-items: center; gap: 10px; width: min(240px, 62vw); padding: 10px 12px; border-radius: 14px; background: var(--paper-warm); border: 1px solid var(--line); text-decoration: none; color: var(--ink); box-sizing: border-box; }
.tc-pdf-ic { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 10px; background: var(--tc-accent-soft); color: var(--tc-accent-tx); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.tc-pdf-info { min-width: 0; display: flex; flex-direction: column; }
.tc-pdf-name { font-size: 13px; font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-pdf-sub { font-size: 10.5px; color: var(--ink-soft); margin-top: 1px; }
/* Phone: an open thread takes the whole screen (native-messenger style) — its own header up top, messages
   scrolling in the middle, composer pinned to the bottom. It's moved under <body> while open (tcOpenThread)
   so no transformed ancestor can re-anchor it. The page behind is scroll-locked. */
@media (max-width: 999px) {
  .tc-thread:not(.hidden) { position: fixed; inset: 0; z-index: 90; background: var(--paper); }
  .tc-thread:not(.hidden) .tc-thead { padding-top: calc(10px + env(safe-area-inset-top)); }
  .tc-thread:not(.hidden) .tc-back { top: calc(50% + env(safe-area-inset-top) / 2); }
  .tc-contacts { padding-bottom: 84px; }
}
body.tc-thread-open { overflow: hidden; }
/* GIF picker — bottom sheet with search + grid */
.gif-ov { position: fixed; inset: 0; z-index: 1100; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; }
.gif-ov.hidden { display: none; }
.gif-sheet { width: 100%; max-width: 560px; max-height: 72vh; background: var(--paper); border-radius: 18px 18px 0 0; display: flex; flex-direction: column; overflow: hidden; }
.gif-head { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.gif-head input { flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px; color: var(--ink); font-size: 14px; font-family: inherit; }
.gif-head input:focus { border-color: var(--tc-accent); outline: none; }
.gif-head button { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.gif-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 10px; min-height: 200px; align-content: start; }
.gif-grid .tc-empty { grid-column: 1 / -1; }
.gif-grid img { width: 100%; height: 110px; object-fit: cover; border-radius: 10px; cursor: pointer; background: var(--card); }
.gif-credit { text-align: center; font-size: 10px; color: var(--ink-soft); padding: 6px 0 calc(8px + env(safe-area-inset-bottom)); flex: 0 0 auto; }
/* Full-screen media viewer */
.tc-viewer { position: fixed; inset: 0; z-index: 1200; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; }
.tc-viewer.hidden { display: none; }
.tc-viewer .cv-frame { position: relative; display: inline-flex; max-width: 96vw; max-height: 88vh; }   /* hugs the image so the ✕ sits on its corner */
.tc-viewer img, .tc-viewer video { max-width: 96vw; max-height: 88vh; border-radius: 8px; display: block; }
.tc-viewer .cv-close { position: absolute; top: -14px; right: -14px; width: 36px; height: 36px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.18); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); color: #fff; font-size: 17px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 2; }
/* Unread badge on the phone bottom bar's chat button (the rail one uses the shared .rail-badge rules) */
.pill-nav [data-pill="chat"] .rail-badge { top: 1px; right: 1px; }
