/* Winning Ranch app: same structure as the Winning App (top bar, Home with feature
   cards and tiles, Messages, bottom bar), in the ranch brand. */
@font-face { font-family: "Cinzel"; src: url("../fonts/cinzel-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../fonts/barlow-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../fonts/barlow-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../fonts/barlow-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --red: #CC232A; --red-deep: #A71B21; --ink: #0E0E0E; --ink-soft: #625B52;
  --paper: #F6F0E5; --card: #FFFFFF; --sand: #E7D7BA; --line: rgba(14,14,14,.12);
  --tile: #1c1a18; --bubble-theirs: #ECE4D6;
  --display: "Cinzel", "Trajan Pro", Georgia, serif; --body: "Barlow", system-ui, sans-serif;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --radius: 18px; --shadow: 0 18px 40px -22px rgba(14,14,14,.45);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #EDE6DA; --ink-soft: #B0A799; --paper: #0E0E0E; --card: #1A1918; --sand: #3a342b;
  --line: rgba(255,255,255,.12); --tile: #26231f; --bubble-theirs: #2a2724; --shadow: 0 18px 40px -22px rgba(0,0,0,.9);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { min-height: 100%; }
body { font-family: var(--body); color: var(--ink); background: var(--paper); line-height: 1.5; -webkit-font-smoothing: antialiased; padding-bottom: calc(84px + var(--sab)); }
img, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.1; letter-spacing: .01em; }
.wrap { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--ink-soft); }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 40; background: #0E0E0E; color: #F6F0E5; padding-top: var(--sat); }
.topbar__inner { max-width: 640px; margin: 0 auto; padding: 0 12px 0 16px; height: 60px; display: flex; align-items: center; justify-content: space-between; }
.topbar__logo img { height: 38px; width: auto; }
.topbar__right { display: flex; align-items: center; gap: 8px; }
.icon-btn { position: relative; width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(246,240,229,.2); background: none; color: #F6F0E5; display: grid; place-items: center; }
.icon-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.badge { position: absolute; top: -3px; right: -3px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--red); color: #fff; font: 600 .72rem/19px var(--body); }
.role-chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid rgba(246,240,229,.25); background: rgba(246,240,229,.08); color: #F6F0E5; border-radius: 999px; padding: 7px 12px; font-weight: 600; font-size: .88rem; }
.role-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.menu, .notif { position: absolute; right: 12px; top: calc(60px + var(--sat)); background: var(--card); color: var(--ink); border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.35); padding: 8px; min-width: 230px; z-index: 50; }
.menu__who { padding: 8px 10px; font-size: .9rem; color: var(--ink-soft); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu button, .menu a { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 11px 10px; border-radius: 10px; font-weight: 500; }
.menu button:hover, .menu a:hover { background: var(--paper); }
.notif { width: min(340px, calc(100vw - 24px)); max-height: 60vh; overflow: auto; }
.notif h3 { font-size: 1rem; padding: 8px 10px; }
.notif a { display: block; padding: 10px; border-radius: 10px; }
.notif a:hover { background: var(--paper); }
.notif small { color: var(--ink-soft); display: block; }

/* Home */
.view { padding-top: 18px; }
.greeting { margin: 4px 0 18px; }
.greeting .eyebrow { font-style: italic; color: var(--red); font-weight: 500; }
.greeting h1 { font-size: clamp(1.8rem, 7vw, 2.3rem); margin-top: 2px; }
.section-label { font: 600 .82rem var(--body); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin: 22px 0 10px; }
.feature { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border: 1px solid var(--line); width: 100%; text-align: left; }
.feature + .feature { margin-top: 10px; }
.feature__ic { width: 50px; height: 50px; border-radius: 14px; background: linear-gradient(150deg, var(--red), var(--red-deep)); color: #fff; display: grid; place-items: center; flex: none; position: relative; }
.feature__ic svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.feature__ic .badge { top: -5px; right: -5px; box-shadow: 0 0 0 2px var(--card); }
.feature__txt h3 { font-family: var(--body); font-weight: 600; font-size: 1.08rem; margin-bottom: 1px; letter-spacing: 0; }
.feature__txt p { color: var(--ink-soft); font-size: .92rem; }
.feature__arrow { margin-left: auto; color: var(--ink-soft); flex: none; font-size: 1.3rem; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { aspect-ratio: 1; border-radius: 16px; background: var(--tile); color: #F6F0E5; display: flex; flex-direction: column; justify-content: space-between; padding: 12px; border: 0; text-align: left; position: relative; overflow: hidden; }
.tile::after { content: ""; position: absolute; right: -18px; bottom: -18px; width: 60px; height: 60px; border-radius: 50%; background: rgba(204,35,42,.35); }
.tile svg { width: 26px; height: 26px; fill: none; stroke: #F6F0E5; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tile span { font-weight: 600; font-size: .86rem; line-height: 1.2; position: relative; z-index: 1; }

/* Horse cards */
.horse { display: grid; grid-template-columns: 92px 1fr; gap: 14px; align-items: center; background: var(--card); border-radius: var(--radius); padding: 10px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.horse + .horse { margin-top: 10px; }
.horse__img { width: 92px; height: 92px; border-radius: 14px; overflow: hidden; background: #0E0E0E; position: relative; }
.horse__img img { width: 100%; height: 100%; object-fit: cover; }
.horse__img .sil { position: absolute; inset: 18%; background: var(--sand); -webkit-mask: url("../img/horse.svg") center / contain no-repeat; mask: url("../img/horse.svg") center / contain no-repeat; }
.horse h3 { font-size: 1.3rem; }
.horse p { color: var(--ink-soft); font-size: .92rem; }
.horse .new { display: inline-block; background: var(--red); color: #fff; border-radius: 999px; font-size: .75rem; font-weight: 600; padding: 1px 8px; margin-left: 6px; vertical-align: middle; }

/* Shift card */
.shift-card { background: var(--card); border-radius: var(--radius); padding: 18px; border: 1px solid var(--line); box-shadow: var(--shadow); border-top: 6px solid var(--line); text-align: center; }
.shift-card.on { border-top-color: #1f8a4c; }
.shift-card.brk { border-top-color: #c98a00; }
.shift-card .state { font-weight: 600; }
.shift-card .worked { font: 600 2.6rem/1.1 var(--body); font-variant-numeric: tabular-nums; margin: 4px 0 12px; }
.shift-card .worked small { font-size: 1rem; color: var(--ink-soft); font-weight: 500; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 18px; border-radius: 14px; border: 2px solid var(--ink); background: transparent; color: var(--ink); font-weight: 600; font-size: 1.02rem; width: 100%; }
.btn--red { background: var(--red); border-color: var(--red); color: #fff; }
.btn--big { min-height: 64px; font-size: 1.2rem; }
.btn:disabled { opacity: .55; }
.err { color: var(--red); font-weight: 600; margin-top: 8px; min-height: 1em; }

/* Feed */
.back { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; margin-bottom: 12px; color: var(--ink-soft); }
.post { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.post + .post { margin-top: 12px; }
.post__head { display: flex; justify-content: space-between; padding: 12px 14px 0; font-size: .92rem; color: var(--ink-soft); }
.post__head b { color: var(--ink); }
.post__text { padding: 6px 14px 12px; white-space: pre-wrap; }
.post__media { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.post__media.one { grid-template-columns: 1fr; }
.post__media button { border: 0; padding: 0; aspect-ratio: 1; overflow: hidden; background: #000; }
.post__media.one button { aspect-ratio: 4 / 3; }
.post__media img { width: 100%; height: 100%; object-fit: cover; }
.post__media video { width: 100%; grid-column: 1 / -1; background: #000; max-height: 520px; }
.day { font: 600 .95rem var(--display); color: var(--ink-soft); margin: 18px 0 8px; }

/* Messages */
.chat-row { display: flex; gap: 12px; align-items: center; padding: 12px 6px; border-bottom: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: linear-gradient(150deg, var(--red), var(--red-deep)); color: #fff; display: grid; place-items: center; font: 600 1.05rem var(--display); flex: none; }
.avatar.team { background: #0E0E0E; border: 2px solid var(--red); }
.chat-row .meta { flex: 1; min-width: 0; }
.chat-row .meta b { display: block; }
.chat-row .meta span { display: block; color: var(--ink-soft); font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row .side { text-align: right; font-size: .8rem; color: var(--ink-soft); }
.chat-row .unread { display: inline-block; margin-top: 4px; background: var(--red); color: #fff; border-radius: 999px; min-width: 22px; padding: 1px 7px; font-weight: 600; font-size: .78rem; text-align: center; }
.thread { display: flex; flex-direction: column; min-height: calc(100vh - 60px - 84px - var(--sat) - var(--sab)); }
.thread__head { display: flex; align-items: center; gap: 10px; padding: 4px 0 10px; border-bottom: 1px solid var(--line); }
.thread__msgs { flex: 1; padding: 12px 0 90px; display: flex; flex-direction: column; gap: 6px; }
.msg { display: flex; flex-direction: column; align-items: flex-start; }
.msg.mine { align-items: flex-end; }
.msg .who { font-size: .76rem; color: var(--ink-soft); margin: 6px 6px 2px; }
.msg-bubble { max-width: 80%; padding: 9px 13px; border-radius: 18px; background: var(--bubble-theirs); white-space: pre-wrap; word-wrap: break-word; border-bottom-left-radius: 5px; }
.msg.mine .msg-bubble { background: var(--red); color: #fff; border-bottom-left-radius: 18px; border-bottom-right-radius: 5px; }
.msg-bubble img { max-width: 220px; max-height: 280px; border-radius: 12px; margin: 3px 0; cursor: zoom-in; }
.msg-bubble video { max-width: 240px; border-radius: 12px; }
.msg time { font-size: .72rem; color: var(--ink-soft); margin: 2px 8px 0; }
.composer { position: fixed; left: 0; right: 0; bottom: calc(68px + var(--sab)); z-index: 30; background: var(--paper); border-top: 1px solid var(--line); padding: 8px 12px; }
.composer form { max-width: 640px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); background: var(--card); border-radius: 20px; padding: 10px 14px; max-height: 120px; min-height: 44px; }
.composer .attach, .composer .send { width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; flex: none; }
.composer .attach { background: var(--card); border: 1px solid var(--line); }
.composer .send { background: var(--red); color: #fff; }
.composer svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.composer .pending { font-size: .82rem; color: var(--ink-soft); max-width: 640px; margin: 0 auto 6px; }

/* Checklist */
.check-sec { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); padding: 6px 14px; margin-bottom: 12px; }
.check-sec h3 { font-size: 1.05rem; padding: 10px 0 4px; }
.check-item { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.check-item:first-of-type { border-top: 0; }
.check-item input { width: 24px; height: 24px; accent-color: #1f8a4c; flex: none; }
.check-item input:checked + span { color: var(--ink-soft); text-decoration: line-through; }
.progress { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 6px 0 16px; }
.progress i { display: block; height: 100%; background: #1f8a4c; transition: width .3s ease; }

/* Bottom bar */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--sab); display: flex; justify-content: space-around; align-items: center; height: calc(68px + var(--sab)); }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .78rem; font-weight: 600; color: var(--ink-soft); position: relative; padding-top: 6px; }
.bottom-nav a svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav a.on { color: var(--red); }
.nav-dot { position: absolute; top: 4px; left: calc(50% + 8px); width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--card); }
.fab { width: 62px; height: 62px; border-radius: 50%; background: var(--red); color: #fff; border: 4px solid var(--paper); margin-top: -30px; display: grid; place-items: center; box-shadow: 0 10px 24px rgba(204,35,42,.45); flex: none; }
.fab svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 18px calc(24px + var(--sab)); background: radial-gradient(900px 500px at 80% -10%, rgba(204,35,42,.55), transparent 60%), #0E0E0E; color: #F6F0E5; margin-bottom: -84px; }
.login__card { width: min(400px, 100%); }
.login__card img { width: 120px; margin: 0 auto 18px; }
.login h1 { text-align: center; font-size: 2rem; margin-bottom: 6px; }
.login p { text-align: center; color: #c9c1b4; margin-bottom: 22px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; text-align: left; }
.field label { font-weight: 600; font-size: .95rem; }
.field input, .field textarea, .field select { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 14px; font-size: 1.02rem; min-height: 50px; }
.login .field input { background: #1c1a18; border-color: #3a362f; color: #F6F0E5; }

/* Sheet + lightbox + toast */
.sheet { border: 0; padding: 0; width: 100%; max-width: 640px; margin: auto auto 0; border-radius: 20px 20px 0 0; background: var(--card); color: var(--ink); overflow-y: auto; overscroll-behavior: contain;
  max-height: 92vh; max-height: calc(100dvh - 12px - env(safe-area-inset-top, 0px)); }
.sheet__bar { position: sticky; top: 0; z-index: 3; display: flex; justify-content: flex-end; padding: 8px 8px 0; height: 0; overflow: visible; pointer-events: none; }
.sheet__x { pointer-events: auto; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--card); color: var(--ink); font-size: 1.8rem; line-height: 1; cursor: pointer; }
.sheet h2 { padding-right: 44px; }
.sheet::backdrop { background: rgba(0,0,0,.55); }
.sheet__body { padding: 20px 18px calc(20px + var(--sab)); }
.sheet h2 { font-size: 1.4rem; margin-bottom: 12px; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.thumbs img { width: 74px; height: 74px; object-fit: cover; border-radius: 10px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 8px 0; }
.bar i { display: block; height: 100%; width: 0; background: var(--red); }
.lightbox { border: 0; background: transparent; width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh; padding: 0; }
.lightbox::backdrop { background: rgba(0,0,0,.94); }
.lightbox img { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox button { position: absolute; top: calc(14px + var(--sat)); right: 14px; z-index: 2; width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 1.8rem; }
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--sab)); transform: translate(-50%, 16px); opacity: 0; pointer-events: none; background: #0E0E0E; color: #F6F0E5; padding: 11px 16px; border-radius: 12px; font-weight: 600; z-index: 80; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--ink-soft); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.visit { margin-top: 18px; padding-top: 16px; border-top: 1px solid #3a362f; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.visit span { width: 100%; text-align: center; color: #c9c1b4; font-size: .92rem; }
.visit a { border: 1px solid #4a453d; border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: .92rem; color: #F6F0E5; }
.visit a:hover { border-color: #F6F0E5; }
.login .btn--big + .err:empty { display: none; }
.login a.btn { color: #fff; }
img { height: auto; }
.login { margin-top: -18px; }

/* Documents */
.doc-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.doc-card + .doc-card { margin-top: 10px; }
.doc-card.requested { border-left: 5px solid var(--red); }
.doc-card.signed { border-left: 5px solid #1f8a4c; }
.doc-card__top { display: flex; gap: 12px; align-items: flex-start; }
.doc-card__top h3 { font-family: var(--body); font-weight: 600; font-size: 1.08rem; letter-spacing: 0; }
.doc-card__top p { color: var(--ink-soft); font-size: .92rem; }
.doc-card__actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.doc-card__actions .btn { min-height: 46px; width: auto; flex: 1 1 140px; }
.doc-card__more { margin-top: 8px; font-size: .88rem; }
.textlink { text-decoration: underline; text-decoration-color: var(--red); }
/* Signature request card in chats */
.sign-card { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--red); border-radius: 14px; padding: 10px 12px; max-width: 85%; min-width: 240px; }
.sign-card b { display: block; margin-bottom: 6px; }
.sign-card__row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.sign-card__row em { font-style: normal; font-weight: 600; color: var(--ink-soft); font-size: .9rem; }
.sign-card__row em.ok { color: #1f8a4c; }
.sign-go { background: var(--red); color: #fff; border-radius: 999px; padding: 6px 16px; font-weight: 600; }
.sign-card .muted { margin-top: 6px; font-size: .9rem; }
.req-btn { margin-left: auto; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 12px; font-weight: 600; font-size: .88rem; }
.pick { display: flex; gap: 10px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--line); font-weight: 500; }
.pick input { width: 22px; height: 22px; accent-color: var(--red); }

.msgs-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.sys { text-align: center; color: var(--ink-soft); font-size: .8rem; margin: 8px 0; }
.title-btn { background: none; border: 0; text-align: left; display: flex; flex-direction: column; padding: 0; }
.title-btn small { color: var(--ink-soft); font-size: .78rem; }
.seg2 { display: grid; grid-template-columns: 1fr 1fr; background: var(--paper); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg2 button { border: 0; background: none; padding: 10px; border-radius: 9px; font-weight: 600; color: var(--ink-soft); }
.seg2 button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.member { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.member .linkish { margin-left: auto; background: none; border: 0; color: var(--red); font-weight: 600; }
.row-form { display: flex; gap: 8px; margin-bottom: 8px; }
.row-form input { flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--card); }
.row-form .btn { width: auto; min-height: 46px; }
.ok-line { font-weight: 600; margin: 4px 0 12px; }
b.ok, .ok { color: #1f8a4c; }
.sheet .chat-row { width: 100%; }
/* Report or block, next to the time of someone else's message */
.msg-more { border: 1px solid var(--line); background: var(--card, transparent); color: var(--ink); font-family: inherit; font-weight: 700; font-size: 1rem; line-height: 1; letter-spacing: .08em; padding: 3px 9px 6px; margin-left: 6px; border-radius: 999px; cursor: pointer; }
.menu .menu__danger { color: var(--red); }

/* Chats, like the Winning App: cards in the list; bubbles grouped by day, reactions, replies, files, "Seen by",
   a menu when you hold a message, and a people sheet */
.chat-search { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 11px 14px; margin: 4px 0 12px; }
.chat-card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; margin-bottom: 10px; }
.chat-card.has-new { border-left: 4px solid var(--red); } /* red only when something is unread */
.chat-card.has-new { box-shadow: 0 10px 24px -18px rgba(204,35,42,.8); }
.chat-card__top { display: flex; align-items: center; gap: 8px; }
.chat-card__top b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-card__ago { color: var(--ink-soft); font-size: .8rem; flex: none; }
.chat-card__last { display: block; color: var(--ink-soft); font-size: .92rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-card.has-new .chat-card__last { color: var(--ink); font-weight: 500; }
.new-pill { flex: none; background: var(--red); color: #fff; border-radius: 999px; padding: 1px 9px; font-size: .76rem; font-weight: 600; }

.thread__head .title-btn { flex: 1; min-width: 0; }
.thread__head .title-btn b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 11px; font-weight: 600; font-size: .86rem; flex: none; }
.head-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.thread__head .req-btn { margin-left: 0; }
.thread__note { text-align: center; font-size: .82rem; color: var(--ink-soft); padding: 6px 0 0; }
.thread__empty { text-align: center; margin-top: 30px; }
.thread .thread__msgs { padding-bottom: 6px; gap: 4px; }
#pend { padding-bottom: 130px; display: flex; flex-direction: column; gap: 6px; }

.msg-dayblock { display: flex; flex-direction: column; gap: 4px; }
.msg-day { position: sticky; top: calc(64px + var(--sat)); z-index: 2; text-align: center; margin: 10px 0 6px; pointer-events: none; }
.msg-day span { display: inline-block; background: var(--card); border: 1px solid var(--line); color: var(--ink-soft); border-radius: 999px; padding: 2px 12px; font-size: .76rem; font-weight: 600; }
.msg-row { display: flex; justify-content: flex-start; }
.msg-row.mine { justify-content: flex-end; }
.msg-wrap { max-width: 82%; display: flex; flex-direction: column; align-items: flex-start; }
.msg-row.mine .msg-wrap { align-items: flex-end; }
.msg-row .msg-bubble { max-width: 100%; padding: 8px 12px 6px; border-radius: 18px; border-bottom-left-radius: 5px; background: var(--bubble-theirs); white-space: normal; word-wrap: break-word; overflow-wrap: anywhere;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: pan-y; transition: transform .12s ease, filter .12s ease; text-align: left; border: 0; font: inherit; color: inherit; }
.msg-row.mine .msg-bubble { background: var(--red); color: #fff; border-bottom-left-radius: 18px; border-bottom-right-radius: 5px; }
.msg-row .msg-bubble.pressing { transform: scale(.97); filter: brightness(.95); }
.msg-row .msg-bubble.msg-selected { outline: 2px solid var(--red); outline-offset: 2px; }
.msg-row.mine .msg-bubble.msg-selected { outline-color: var(--ink); }
.msg-row .msg-bubble.swipe-ready { filter: brightness(.92); }
.msg-text { white-space: pre-wrap; }
.msg-from { font-size: .76rem; font-weight: 600; color: var(--red); margin-bottom: 2px; }
.msg-time { font-size: .7rem; opacity: .7; text-align: right; margin-top: 3px; }
.msg-link { text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.msg-row.mine .msg-link { color: #fff; }
.msg-deleted i { opacity: .75; }
.msg-row.mine .msg-bubble.msg-deleted { background: transparent; color: var(--ink-soft); border: 1px dashed var(--line); }
.msg-row .msg-bubble.msg-deleted { background: transparent; border: 1px dashed var(--line); }
.msg-quote { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; width: 100%; text-align: left; background: rgba(0,0,0,.07); border: 0; border-left: 3px solid var(--red); border-radius: 10px; padding: 5px 9px; margin: 2px 0 6px; font-size: .84rem; color: inherit; }
.msg-row.mine .msg-quote { background: rgba(255,255,255,.18); border-left-color: #fff; }
.msg-quote b { grid-column: 2; font-size: .78rem; }
.msg-quote span { grid-column: 2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.msg-quote .mq-img { grid-row: 1 / span 2; width: 36px; height: 36px; object-fit: cover; border-radius: 6px; margin: 0; }
.msg-gallery { display: grid; gap: 3px; margin: 3px 0; border-radius: 12px; overflow: hidden; }
.msg-gallery.g2 { grid-template-columns: 1fr 1fr; }
.msg-gallery.g3 { grid-template-columns: 1fr 1fr 1fr; }
.msg-gallery .msg-img { width: 100%; max-width: 260px; max-height: 300px; object-fit: cover; cursor: zoom-in; margin: 0; border-radius: 0; }
.msg-gallery.g2 .msg-img, .msg-gallery.g3 .msg-img { aspect-ratio: 1; height: 100%; }
.msg-row .msg-bubble video { max-width: 260px; border-radius: 12px; margin: 3px 0; }
.msg-file { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.06); border-radius: 12px; padding: 8px 10px; margin: 3px 0; min-width: 200px; }
.msg-row.mine .msg-file { background: rgba(255,255,255,.18); }
.msg-file .fi { font-size: 1.5rem; flex: none; }
.msg-file .fn { min-width: 0; display: flex; flex-direction: column; }
.msg-file b { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-file small { font-size: .74rem; opacity: .75; }
.msg-reacts { display: inline-flex; gap: 4px; margin: -6px 8px 0; position: relative; z-index: 1; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; font-size: .84rem; }
.msg-seen { display: flex; align-items: center; justify-content: flex-end; gap: 3px; font-size: .7rem; color: var(--ink-soft); margin: 2px 4px 4px; cursor: pointer; }
.msg-seen .ms-av { width: 16px; height: 16px; border-radius: 50%; background: var(--sand); color: var(--ink); display: grid; place-items: center; font-size: .6rem; font-weight: 600; }
.msg-seen .ms-t { margin-left: 3px; }
.msg-pending { opacity: .75; cursor: default; }
.msg-pending.failed { opacity: 1; cursor: pointer; outline: 2px solid #f0b400; }
.msg-pend-files { font-size: .86rem; }
.msg-flash .msg-bubble { animation: msgflash 1.4s ease; }
@keyframes msgflash { 0%, 60% { box-shadow: 0 0 0 4px rgba(204,35,42,.45); } 100% { box-shadow: none; } }
.sign-bubble { background: transparent !important; padding: 0 !important; color: var(--ink) !important; }
.sign-bubble .sign-card { max-width: 100%; }
.sign-bubble .msg-time { color: var(--ink-soft); }

.mode-bar { max-width: 640px; margin: 0 auto 6px; display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--red); border-radius: 12px; padding: 6px 6px 6px 10px; }
.mode-bar .mb-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: .84rem; }
.mode-bar .mb-txt span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-soft); }
.mode-bar button { width: 34px; height: 34px; border-radius: 50%; border: 0; background: none; font-size: 1.4rem; line-height: 1; }

#msgMenu { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; animation: mmfade .15s ease; }
@keyframes mmfade { from { opacity: 0; } }
.mm-sheet { width: 100%; max-width: 520px; background: var(--card); border-radius: 22px 22px 0 0; padding: 12px 12px calc(14px + var(--sab)); box-shadow: var(--shadow); }
.mm-reacts { display: flex; justify-content: space-between; gap: 4px; background: var(--paper); border-radius: 999px; padding: 6px 8px; margin-bottom: 8px; }
.mm-reacts button { border: 0; background: none; font-size: 1.6rem; width: 44px; height: 44px; border-radius: 50%; line-height: 1; }
.mm-reacts button.on { background: var(--sand); }
.mm-preview { font-size: .86rem; color: var(--ink-soft); padding: 4px 8px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.mm-act { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; text-align: left; padding: 12px 10px; border-radius: 12px; font-weight: 500; font-size: 1rem; }
.mm-act span { width: 24px; text-align: center; }
.mm-act:hover { background: var(--paper); }
.mm-act.danger { color: var(--red); }
.mm-cancel { justify-content: center; font-weight: 600; margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0; }

.cp-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.cp-av { width: 36px; height: 36px; font-size: .9rem; }
.cp-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cp-name small { color: var(--ink-soft); font-size: .78rem; }
.cp-btn { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--red); border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: .86rem; }
.cp-btn.cp-add { background: var(--red); border-color: var(--red); color: #fff; }
.cp-btn:disabled { opacity: .5; }
@media (prefers-reduced-motion: reduce) { .msg-row .msg-bubble, #msgMenu, .msg-flash .msg-bubble { transition: none; animation: none; } }
.composer textarea { scrollbar-width: none; }
.composer textarea::-webkit-scrollbar { display: none; }

/* @mentions */
.msg-mention { font-weight: 700; background: rgba(204,35,42,.12); border-radius: 5px; padding: 0 3px; }
.msg-row.mine .msg-mention { background: rgba(255,255,255,.22); color: #fff; }
.msg-row .msg-bubble.mentions-me { box-shadow: 0 0 0 2px var(--red); }
.at-pill { background: var(--ink); }
.mention-box { max-width: 640px; margin: 0 auto 6px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.mention-box button { display: flex; align-items: baseline; gap: 8px; width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; padding: 10px 14px; }
.mention-box button:last-child { border-bottom: 0; }
.mention-box button span { color: var(--ink-soft); font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mention-box button:hover { background: var(--paper); }

/* Post an update: quick notes (fed, watered…) */
.quick-tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.quick-tags .qt { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 12px; font-weight: 600; font-size: .9rem; }
.quick-tags .qt[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.care-box { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--red); border-radius: 12px; padding: 10px 14px; margin: 10px 0 6px; }
.care-box p { white-space: pre-wrap; margin-top: 4px; }

/* "See the app as…": a bar on top while the office previews someone's app */
.preview-bar { position: sticky; top: 0; z-index: 60; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #F0B400; color: #0E0E0E; padding: calc(6px + var(--sat)) 14px 6px; font-size: .9rem; }
.preview-bar button { border: 0; background: #0E0E0E; color: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 600; flex: none; }
.preview-bar { min-height: calc(34px + var(--sat)); }
body.previewing .topbar { top: calc(34px + var(--sat)); padding-top: 0; }

/* Jenna: the chat's name and People stay on top while scrolling through the messages */
.thread__head { position: sticky; top: calc(60px + var(--sat)); z-index: 20; background: var(--paper); padding-top: 8px; margin-top: -4px; }
.msg-day { top: calc(128px + var(--sat)); }
body.previewing .thread__head { top: calc(94px + var(--sat)); }
body.previewing .msg-day { top: calc(162px + var(--sat)); }
.preview-bar { height: calc(34px + var(--sat)); min-height: 0; padding: var(--sat) 12px 0; font-size: .82rem; white-space: nowrap; }
.preview-bar span { overflow: hidden; text-overflow: ellipsis; }
.preview-bar button { padding: 4px 12px; }

/* Shared from another app: the picker */
.share-preview { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--red); border-radius: 12px; padding: 10px 12px; margin: 10px 0 12px; white-space: pre-wrap; word-break: break-word; max-height: 140px; overflow: auto; font-size: .92rem; }
