/* ---------- theme ---------- */
:root[data-theme="dark"] {
  --app-bg: #0b141a;
  --panel: #111b21;
  --panel-2: #202c33;
  --header: #202c33;
  --text: #e9edef;
  --text-muted: #8696a0;
  --border: #222d34;
  --accent: #00a884;
  --accent-soft: rgba(0, 168, 132, .16);
  --bubble-out: #005c4b;
  --bubble-in: #202c33;
  --meta: rgba(233, 237, 239, .62);
  --tick-read: #53bdeb;
  --wallpaper: #0b141a;
  --hover: #202c33;
  --active: #2a3942;
  --input-bg: #2a3942;
  --search-bg: #202c33;
  --scroll: rgba(134, 150, 160, .35);
  --chip: rgba(32, 44, 51, .92);
  --shadow: 0 12px 36px rgba(0, 0, 0, .45);
  --wallpaper-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='0.035' stroke-width='1.2' stroke-linecap='round'%3E%3Ccircle cx='24' cy='28' r='9'/%3E%3Cpath d='M78 18l6 13-13-4z'/%3E%3Cpath d='M112 78c-7 0-7 11 0 11s7-11 0-11z'/%3E%3Cpath d='M30 100l5 5 11-13'/%3E%3Crect x='92' y='24' width='15' height='15' rx='3'/%3E%3Cpath d='M10 66h20M20 56v20'/%3E%3Cpath d='M60 96c0 8 12 8 12 0s-12-8-12 0z'/%3E%3Cpath d='M104 116l8-8M104 108l8 8'/%3E%3C/g%3E%3C/svg%3E");
}
:root[data-theme="light"] {
  --app-bg: #d1d7db;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --header: #f0f2f5;
  --text: #111b21;
  --text-muted: #667781;
  --border: #e9edef;
  --accent: #00a884;
  --accent-soft: rgba(0, 168, 132, .12);
  --bubble-out: #d9fdd3;
  --bubble-in: #ffffff;
  --meta: rgba(17, 27, 33, .55);
  --tick-read: #53bdeb;
  --wallpaper: #efeae2;
  --hover: #f5f6f6;
  --active: #f0f2f5;
  --input-bg: #ffffff;
  --search-bg: #f0f2f5;
  --scroll: rgba(102, 119, 129, .35);
  --chip: rgba(255, 255, 255, .9);
  --shadow: 0 12px 36px rgba(11, 20, 26, .18);
  --wallpaper-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cg fill='none' stroke='%23111b21' stroke-opacity='0.045' stroke-width='1.2' stroke-linecap='round'%3E%3Ccircle cx='24' cy='28' r='9'/%3E%3Cpath d='M78 18l6 13-13-4z'/%3E%3Cpath d='M112 78c-7 0-7 11 0 11s7-11 0-11z'/%3E%3Cpath d='M30 100l5 5 11-13'/%3E%3Crect x='92' y='24' width='15' height='15' rx='3'/%3E%3Cpath d='M10 66h20M20 56v20'/%3E%3Cpath d='M60 96c0 8 12 8 12 0s-12-8-12 0z'/%3E%3Cpath d='M104 116l8-8M104 108l8 8'/%3E%3C/g%3E%3C/svg%3E");
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--app-bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font-family: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
::selection { background: var(--accent-soft); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

.app {
  display: flex;
  height: 100dvh;
  width: 100vw;
  background: var(--panel);
  overflow: hidden;
}

/* ---------- sidebar ---------- */
.sidebar {
  width: clamp(290px, 25vw, 380px);
  min-width: 290px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  position: relative;
  z-index: 2;
}
.side-header {
  height: 60px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 16px;
  background: var(--header);
  position: relative;
}
.avatar {
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
  letter-spacing: .3px;
  flex: none;
  position: relative;
  user-select: none;
  overflow: visible;
}
.avatar.me {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #00a884, #008069);
}
.avatar.me svg { width: 22px; height: 22px; opacity: .95; }
.avatar .online-dot {
  position: absolute;
  right: 0;
  bottom: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #00d95f;
  border: 2px solid var(--panel);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .06);
}
.side-actions { display: flex; align-items: center; gap: 2px; }
.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.danger:hover { color: #f15c6d; }

.search-wrap { padding: 7px 12px 10px; background: var(--panel); }
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--search-bg);
  border-radius: 8px;
  padding: 0 12px;
  height: 38px;
}
.search-box svg { width: 18px; height: 18px; color: var(--text-muted); flex: none; }
.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-box input::-webkit-search-cancel-button { filter: invert(.6); }

.filters {
  display: flex;
  gap: 8px;
  padding: 0 12px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filter {
  border: 0;
  background: var(--panel-2);
  color: var(--text-muted);
  font-size: 13px;
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.filter:hover { background: var(--hover); color: var(--text); }
.filter.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.chat-list { flex: 1; overflow-y: auto; overflow-x: hidden; }
.chat-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 9px 12px 9px 13px;
  height: 72px;
  cursor: pointer;
  transition: background .12s ease;
  outline: none;
}
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); }
.chat-item .avatar { width: 49px; height: 49px; }
.chat-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.chat-row1 { display: flex; align-items: center; gap: 8px; }
.chat-name {
  flex: 1;
  min-width: 0;
  font-size: 16.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-time {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-time .pin svg { width: 14px; height: 14px; display: block; }
.chat-row2 { display: flex; align-items: center; gap: 8px; min-height: 20px; }
.chat-preview {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 20px;
}
.prev-tick { display: inline-flex; vertical-align: -2px; margin-right: 3px; color: var(--text-muted); }
.prev-tick svg { width: 16px; height: 11px; }
.prev-tick svg.read { color: var(--tick-read); }
.prev-author { color: var(--text); opacity: .85; }
.badge {
  flex: none;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
  line-height: 1;
}
.list-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}
.list-empty p { margin: 0 0 6px; color: var(--text); font-size: 15px; }
.list-empty span { font-size: 13px; }

.side-footer {
  flex: none;
  padding: 12px 16px 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.35;
  background: var(--panel);
}
.side-footer svg { width: 14px; height: 14px; flex: none; }

/* ---------- chat panel ---------- */
.chat-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--wallpaper);
  background-image: var(--wallpaper-pattern);
}
.chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.chat-header {
  height: 60px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--header);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 5;
}
.chat-header .back { display: none; }
.chat-avatar { width: 40px; height: 40px; font-size: 15px; }
.chat-title { flex: 1; min-width: 0; }
.chat-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-title p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-title p.online { color: var(--accent); }
.chat-actions { display: flex; align-items: center; gap: 2px; }

/* ---------- empty state ---------- */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  border-bottom: 6px solid var(--accent);
  background: var(--panel);
}
.empty-logo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--panel-2);
  display: grid;
  place-items: center;
  color: var(--accent);
  margin-bottom: 24px;
}
.empty-logo svg { width: 48px; height: 48px; }
.empty-state h1 { margin: 0 0 10px; font-size: 30px; font-weight: 300; letter-spacing: -.3px; }
.empty-state p { margin: 0; max-width: 440px; color: var(--text-muted); font-size: 14px; line-height: 1.55; }
.empty-note {
  margin-top: 34px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
}
.empty-note svg { width: 14px; height: 14px; }

/* ---------- messages ---------- */
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 6.5% 22px;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}
.day-chip {
  align-self: center;
  margin: 12px 0 10px;
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--chip);
  color: var(--text-muted);
  font-size: 12px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .08);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 1;
}
.messages-empty {
  margin: auto;
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--chip);
  color: var(--text-muted);
  font-size: 13px;
}
.bubble {
  position: relative;
  max-width: min(66%, 560px);
  width: fit-content;
  padding: 6px 9px 8px;
  border-radius: 8px;
  font-size: 14.5px;
  line-height: 20px;
  color: var(--text);
  box-shadow: 0 1px .6px rgba(0, 0, 0, .16);
  margin-top: 2px;
}
.bubble.first { margin-top: 9px; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); border-top-right-radius: 8px; }
.bubble.in { align-self: flex-start; background: var(--bubble-in); border-top-left-radius: 8px; }
.bubble.tail.out { border-bottom-right-radius: 0; }
.bubble.tail.in { border-bottom-left-radius: 0; }
.bubble.tail.out::after {
  content: "";
  position: absolute;
  right: -7px;
  bottom: 0;
  width: 8px;
  height: 14px;
  background: var(--bubble-out);
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}
.bubble.tail.in::after {
  content: "";
  position: absolute;
  left: -7px;
  bottom: 0;
  width: 8px;
  height: 14px;
  background: var(--bubble-in);
  clip-path: polygon(100% 0, 0 100%, 100% 100%);
}
.msg-text { white-space: pre-wrap; word-break: break-word; }
.author {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
  line-height: 17px;
}
.meta {
  float: right;
  margin: 6px 0 -3px 10px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  line-height: 15px;
  color: var(--meta);
  white-space: nowrap;
  position: relative;
  top: 2px;
}
.meta.inline { float: none; margin: 0 0 0 auto; top: 0; align-self: flex-end; }
.tick { color: var(--meta); flex: none; }
.tick.read { color: var(--tick-read); }

/* voice notes */
.bubble:has(.voice) { padding: 6px 10px 6px 8px; }
.voice { display: flex; align-items: center; gap: 9px; min-width: 270px; }
.play-btn {
  width: 32px;
  height: 32px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: rgba(134, 150, 160, .22);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.play-btn svg { width: 16px; height: 16px; }
.play-btn:hover { background: rgba(134, 150, 160, .35); }
.wave { display: flex; align-items: center; gap: 2px; height: 24px; flex: 1; }
.wave i {
  width: 2.5px;
  border-radius: 2px;
  background: currentColor;
  opacity: .45;
  transform-origin: center;
}
.bubble.playing .wave i { animation: wave 1s ease-in-out infinite; opacity: .8; }
.bubble.playing .wave i:nth-child(3n) { animation-delay: .12s; }
.bubble.playing .wave i:nth-child(3n + 1) { animation-delay: .24s; }
.bubble.playing .wave i:nth-child(4n) { animation-delay: .36s; }
@keyframes wave {
  0%, 100% { transform: scaleY(.55); }
  50% { transform: scaleY(1.25); }
}
.dur { font-size: 11.5px; color: var(--meta); flex: none; }

/* photo */
.bubble:has(.photo) { padding: 4px 4px 6px; max-width: min(74%, 330px); }
.photo {
  width: 268px;
  max-width: 100%;
  height: 168px;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 76% 26%, #ffe9a3 0 11%, transparent 12%),
    linear-gradient(170deg, #7fb9df 0%, #b9dced 46%, #6f9f5e 46.5%, #3f6b3a 100%);
}
.photo::before {
  content: "";
  position: absolute;
  left: -24%;
  bottom: -34%;
  width: 110%;
  height: 92%;
  background: #487a45;
  clip-path: polygon(52% 0, 100% 100%, 0 100%);
  transform: rotate(-7deg);
}
.photo::after {
  content: "";
  position: absolute;
  right: -18%;
  bottom: -40%;
  width: 95%;
  height: 88%;
  background: #33582f;
  clip-path: polygon(46% 0, 100% 100%, 0 100%);
  transform: rotate(5deg);
}
.caption {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 5px 6px 1px 7px;
  font-size: 14px;
  line-height: 19px;
  min-height: 24px;
}
.caption > span:first-child { flex: 1; word-break: break-word; }

/* documents */
.bubble:has(.doc) { padding: 6px 10px; }
.doc { display: flex; align-items: center; gap: 11px; min-width: 258px; }
.doc-icon {
  flex: none;
  width: 36px;
  height: 42px;
  border-radius: 5px;
  background: #f15c6d;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  letter-spacing: .5px;
}
.doc-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.doc-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-size { font-size: 11.5px; color: var(--meta); margin-top: 1px; }

/* typing indicator */
.bubble.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  margin-top: 9px;
}
.tdot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1.3s infinite ease-in-out;
}
.tdot:nth-child(2) { animation-delay: .18s; }
.tdot:nth-child(3) { animation-delay: .36s; }
@keyframes blink {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* ---------- composer ---------- */
.composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 16px;
  background: var(--header);
  position: relative;
  z-index: 6;
}
.composer > .icon-btn { flex: none; align-self: center; }
.input-wrap {
  flex: 1;
  min-width: 0;
  background: var(--input-bg);
  border-radius: 8px;
  padding: 9px 12px;
  min-height: 42px;
  display: flex;
  align-items: center;
}
.input-wrap textarea {
  width: 100%;
  max-height: 120px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 21px;
  padding: 0;
  margin: 0;
  overflow-y: auto;
}
.input-wrap textarea::placeholder { color: var(--text-muted); }
.send-btn {
  flex: none;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .1s ease;
}
.send-btn svg { width: 22px; height: 22px; }
.send-btn:hover { background: var(--hover); color: var(--text); }
.send-btn.active { background: var(--accent); color: #fff; }
.send-btn.active:hover { background: #06b78f; color: #fff; }
.send-btn:active { transform: scale(.94); }

/* recording */
.recording {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  height: 42px;
  padding: 0 8px 0 14px;
  background: var(--input-bg);
  border-radius: 8px;
}
.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f15c6d;
  flex: none;
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.8); }
}
.rec-time { font-size: 14px; font-variant-numeric: tabular-nums; flex: none; }
.rec-hint { flex: 1; min-width: 0; font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-send {
  flex: none;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.rec-send svg { width: 16px; height: 16px; }
.composer.recording .input-wrap,
.composer.recording #emojiBtn,
.composer.recording #attachBtn,
.composer.recording .send-btn { display: none; }

/* ---------- popovers ---------- */
.popover {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 80;
}
.menu-pop {
  position: absolute;
  top: 54px;
  right: 12px;
  width: 208px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  padding: 9px 11px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.3;
}
.menu-item:hover { background: var(--hover); }
.menu-item svg { width: 18px; height: 18px; color: var(--text-muted); flex: none; }
.menu-item.danger { color: #f15c6d; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }

.emoji-pop {
  position: absolute;
  left: 12px;
  bottom: 62px;
  width: 330px;
  max-height: 296px;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}
.emoji {
  border: 0;
  background: transparent;
  font-size: 21px;
  line-height: 1;
  padding: 5px 0;
  border-radius: 6px;
  cursor: pointer;
}
.emoji:hover { background: var(--hover); }

.attach-pop {
  position: absolute;
  left: 58px;
  bottom: 62px;
  width: 194px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.reaction-pop {
  position: fixed;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 4px;
  border-radius: 999px;
}
.reaction-pop .emoji {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 21px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: transform .12s ease, background .12s ease;
}
.reaction-pop .emoji:hover {
  background: var(--hover);
  transform: scale(1.2);
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 16px);
  background: #202c33;
  color: #e9edef;
  font-size: 13.5px;
  padding: 11px 20px;
  border-radius: 9px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 200;
  max-width: min(90vw, 420px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .messages { padding-left: 4%; padding-right: 4%; }
  .bubble { max-width: 72%; }
}
@media (max-width: 820px) {
  .sidebar { width: 100%; min-width: 0; border-right: 0; }
  .chat-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    z-index: 30;
    transform: translateX(100%);
    transition: transform .24s ease;
  }
  .app.chat-open .chat-panel { transform: translateX(0); }
  .chat-header .back { display: grid; }
  .chat-header { padding: 0 6px; gap: 8px; }
  .chat-header .chat-actions .icon-btn { width: 38px; height: 38px; }
  .messages { padding: 10px 10px 16px; }
  .bubble { max-width: 86%; }
  .bubble:has(.photo) { max-width: 92%; }
  .photo { width: 240px; height: 152px; }
  .composer { padding: 7px 8px; gap: 2px; }
  .composer > .icon-btn { width: 38px; height: 38px; }
  .emoji-pop { left: 8px; right: 8px; width: auto; }
  .attach-pop { left: 48px; }
  .side-footer { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
}
@media (max-width: 400px) {
  .chat-actions #chatSearchBtn { display: none; }
  .voice { min-width: 210px; }
  .doc { min-width: 210px; }
}
/* ============================================================
   Fieldline additions
   ============================================================ */

/* brand */
.brand-mark {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #00a884, #007a63);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  display: grid;
  place-items: center;
  letter-spacing: -.5px;
  box-shadow: 0 2px 10px rgba(0, 168, 132, .28);
}
.brand-copy { flex: 1; min-width: 0; margin-left: 10px; }
.brand-copy h1 { margin: 0; font-size: 16.5px; font-weight: 700; letter-spacing: -.2px; }
.brand-copy span {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* filter task count */
.filter .filter-count {
  display: inline-grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin-left: 3px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--text-muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  vertical-align: 1px;
}
.filter.active .filter-count { background: var(--accent); color: #fff; }

/* workspace switcher */
.workspace-switch {
  flex: none;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 12px 15px;
  border: 0;
  border-top: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.workspace-switch:hover { background: var(--hover); }
.ws-icon {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text-muted);
  display: grid;
  place-items: center;
}
.ws-icon svg { width: 17px; height: 17px; }
.ws-copy { flex: 1; min-width: 0; }
.ws-copy b { display: block; font-size: 13px; font-weight: 600; }
.ws-copy small { display: block; font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.ws-chev { color: var(--text-muted); font-size: 18px; line-height: 1; }

/* task button badge in chat header */
.tasks-toggle { position: relative; }
.task-count {
  position: absolute;
  top: 1px;
  right: 0;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid var(--header);
  line-height: 1;
}
.task-count:empty, .task-count[data-zero="true"] { display: none; }

/* message rows (wrapper for bubble + hover actions) */
.msg-row {
  display: flex;
  flex-direction: column;
  max-width: min(66%, 560px);
  position: relative;
}
.msg-row.out { align-self: flex-end; align-items: flex-end; }
.msg-row.in { align-self: flex-start; align-items: flex-start; }
.msg-row.first { margin-top: 9px; }
.msg-row .bubble { max-width: 100%; margin-top: 0; }
.msg-row.is-photo { max-width: min(76%, 340px); }
.msg-row.is-voice { max-width: min(82%, 390px); }
.msg-row.is-task { max-width: min(86%, 372px); }

.msg-actions {
  display: flex;
  gap: 5px;
  margin: 3px 3px 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}
.msg-row:hover .msg-actions,
.msg-row:focus-within .msg-actions { opacity: 1; pointer-events: auto; }
.msg-actions button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.msg-actions button:hover { color: var(--accent); border-color: var(--accent); }
.msg-actions svg { width: 12px; height: 12px; }

/* message reactions */
.reactions {
  clear: both;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 5px;
}
.reactions.out { justify-content: flex-end; }
.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 12px;
  line-height: 18px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .14);
  transition: transform .12s ease, border-color .12s ease;
}
.reaction-pill:hover { transform: translateY(-1px); border-color: var(--accent); }
.reaction-pill.mine { border-color: var(--accent); background: var(--accent-soft); }
.reaction-pill span { font-size: 10.5px; color: var(--text-muted); font-weight: 600; }

/* mentions + activity */
.mention {
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 0 2px;
  font-weight: 600;
}
.activity-chip {
  align-self: center;
  max-width: 82%;
  margin: 7px 0;
  padding: 5px 11px;
  border-radius: 7px;
  background: var(--chip);
  color: var(--text-muted);
  font-size: 11.5px;
  text-align: center;
  line-height: 1.4;
}

/* inline task cards */
.msg-row.is-task .bubble {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 3px 14px rgba(0, 0, 0, .14);
  width: 100%;
}
.msg-row.is-task .bubble::after { display: none; }
.task-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.task-card-head svg { width: 14px; height: 14px; flex: none; }
.task-card-head .task-card-time {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.task-card-body { padding: 10px 12px 12px; }
.task-card-title { font-size: 14.5px; font-weight: 600; line-height: 1.35; }
.task-card-sub { margin-top: 9px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-card-person { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-muted); }
.task-card-due { font-size: 11.5px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 4px; }
.task-card-due svg { width: 12px; height: 12px; }
.task-status-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.task-status-btn i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.task-status-btn.assigned { color: var(--text-muted); }
.task-status-btn.in_progress { color: #f0b232; border-color: rgba(240, 178, 50, .45); background: rgba(240, 178, 50, .1); }
.task-status-btn.review { color: #8f7cf6; border-color: rgba(143, 124, 246, .45); background: rgba(143, 124, 246, .12); }
.task-status-btn.closed { color: var(--accent); border-color: rgba(0, 168, 132, .45); background: var(--accent-soft); }
.task-status-btn:hover { filter: brightness(1.12); }
.task-card-desc {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.task-card-chips { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 5px; }
.task-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--chip);
  color: var(--text-muted);
  font-size: 10.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-card-foot-right { display: inline-flex; align-items: center; gap: 10px; }
.proof-flag { color: var(--accent) !important; font-weight: 600; }
.avatar-stack { display: inline-flex; align-items: center; }
.avatar-stack .stack-av {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: .2px;
  border: 1.5px solid var(--panel);
  margin-left: -5px;
}
.avatar-stack .stack-av:first-child { margin-left: 0; }
.avatar-stack .stack-av.more { background: var(--chip); color: var(--text-muted); }
.person-names { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.task-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  font-size: 10.5px;
  color: var(--text-muted);
}
.task-card-foot span { display: inline-flex; align-items: center; gap: 4px; }
.task-card-foot svg { width: 12px; height: 12px; }
.task-source-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: none;
  padding: 0;
  color: var(--text-muted);
  font: inherit;
  font-size: 10.5px;
  cursor: pointer;
}
.task-source-link:hover { color: var(--accent); }
.task-source-link svg { width: 12px; height: 12px; }
.msg-row.flash .bubble { animation: cardFlash 1.3s ease; }
@keyframes cardFlash {
  0%, 100% { box-shadow: 0 3px 14px rgba(0, 0, 0, .14); }
  25%, 65% { box-shadow: 0 0 0 3px var(--accent-soft), 0 3px 18px rgba(0, 168, 132, .35); }
}
.mini-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  flex: none;
  letter-spacing: .2px;
}

.task-list .list-subhead {
  padding: 14px 8px 4px;
}
.task-list .list-subhead b { font-size: 9.5px; }

/* composer task button */
.composer-task {
  flex: none;
  align-self: center;
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.composer-task svg { width: 15px; height: 15px; }
.composer-task:hover { color: var(--accent); border-color: var(--accent); }
.composer.recording .composer-task { display: none; }

/* ============================================================
   Task panel
   ============================================================ */
.tasks-panel {
  width: 288px;
  flex: none;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--border);
  position: relative;
  z-index: 2;
}
.app.tasks-hidden .tasks-panel { display: none; }
.tasks-header {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 17px 12px 12px 16px;
}
.tasks-heading-copy { min-width: 0; }
.tasks-heading-copy > span {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--text-muted);
}
.tasks-heading-copy h2 {
  margin: 4px 0 0;
  font-size: 15.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tasks-header .icon-btn { flex: none; margin-top: -4px; }
.tasks-header .icon-btn svg { width: 18px; height: 18px; }
.task-stats {
  flex: none;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 12px 16px;
  background: var(--panel-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.task-stats > div { display: flex; flex-direction: column; gap: 2px; }
.task-stats b { font-size: 20px; font-weight: 700; line-height: 1; }
.task-stats small {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  font-weight: 600;
}
.task-stats button {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.tasks-subhead {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 16px 7px;
}
.tasks-subhead b {
  font-size: 9.5px;
  letter-spacing: .09em;
  color: var(--text-muted);
  font-weight: 700;
}
.tasks-subhead button {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--accent);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.tasks-subhead button:hover { background: var(--hover); }
.task-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 8px; }
.side-task {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background .12s ease;
}
.side-task:hover { background: var(--hover); }
.side-task.selected { background: var(--accent-soft); }
.side-task .status-dot {
  width: 14px;
  height: 14px;
  flex: none;
  margin-top: 2px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  position: relative;
}
.side-task.assigned .status-dot { border-color: var(--text-muted); }
.side-task.in_progress .status-dot { border-color: #f0b232; }
.side-task.in_progress .status-dot::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: #f0b232;
}
.side-task.review .status-dot { border-color: #8f7cf6; }
.side-task.review .status-dot::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: #8f7cf6;
}
.side-task.closed .status-dot { background: var(--accent); border-color: var(--accent); }
.side-task.closed .status-dot::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 2.5px;
  width: 4px;
  height: 7px;
  border: solid #fff;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(42deg);
}
.side-task > div { min-width: 0; flex: 1; }
.side-task b {
  display: block;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-task.closed b { text-decoration: line-through; color: var(--text-muted); }
.side-task small {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-task .side-names { overflow: hidden; text-overflow: ellipsis; }
.task-list-empty {
  padding: 20px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}
.new-task {
  flex: none;
  margin: 8px 16px 16px;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.new-task:hover { background: #06b78f; }

/* ============================================================
   Task modal
   ============================================================ */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 65;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(2px);
}
.task-modal {
  width: min(480px, 100%);
  max-height: min(90dvh, 640px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: modalIn .18s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: none; }
}
.task-modal header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 18px 12px 20px;
}
.task-modal header span {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--accent);
}
.task-modal h2 { margin: 5px 0 0; font-size: 19px; font-weight: 600; letter-spacing: -.2px; }
.task-modal header .icon-btn { margin-top: -4px; }
.source-quote {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 20px 15px;
  padding: 10px 12px;
  background: var(--panel-2);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
}
.source-quote p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.source-quote .mini-avatar { margin-top: 1px; }
.task-modal .field {
  display: block;
  padding: 0 20px 14px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}
.task-modal .field input,
.task-modal .field select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}
.task-modal .field input:focus,
.task-modal .field select:focus { border-color: var(--accent); }
:root[data-theme="dark"] .task-modal input[type="date"] { color-scheme: dark; }
:root[data-theme="light"] .task-modal input[type="date"] { color-scheme: light; }
.task-modal .form-grid { display: grid; grid-template-columns: 1fr 1fr; }
.task-modal footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 15px 20px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
}
.task-modal footer button {
  border: 0;
  border-radius: 8px;
  padding: 9px 15px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.task-modal footer button:hover { background: var(--hover); color: var(--text); }
.task-modal footer .primary { background: var(--accent); color: #fff; }
.task-modal footer .primary:hover { background: #06b78f; color: #fff; }
.task-modal footer button:disabled { opacity: .45; cursor: not-allowed; }
.task-modal .field textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.45;
  outline: none;
  resize: vertical;
}
.task-modal .field textarea:focus { border-color: var(--accent); }
.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}
.field-label em { font-style: normal; font-weight: 500; opacity: .7; }
.people-field { padding-bottom: 12px !important; }
.chip-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.person-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}
.person-chip:hover { border-color: var(--accent); }
.person-chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.person-chip .mini-avatar { width: 20px; height: 20px; font-size: 8.5px; }
.task-readonly {
  margin: 0 20px 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
}
.task-readonly b { font-size: 13.5px; }
.task-readonly p { margin: 5px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--text-muted); }
.attach-field { padding-bottom: 14px !important; }
.attach-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 7px;
  background: var(--chip);
  color: var(--text-muted);
  font-size: 11px;
}
.attach-chip em { font-style: normal; opacity: .65; font-size: 10px; }
.attach-chip button {
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1;
  padding: 1px 2px;
  cursor: pointer;
}
.attach-chip button:hover { color: #e5484d; }
.attach-empty { font-size: 11px; color: var(--text-muted); opacity: .7; }
.attach-add { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.ghost-btn {
  border: 1px dashed var(--border);
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 10px;
  cursor: pointer;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }

/* task detail */
.task-modal.task-detail { width: min(540px, 100%); max-height: min(92dvh, 720px); }
.stage-track {
  display: flex;
  gap: 4px;
  margin: 0 20px 16px;
  padding: 5px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.stage-step {
  flex: 1;
  text-align: center;
  padding: 6px 4px;
  border-radius: 7px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  opacity: .6;
}
.stage-step.done { color: var(--accent); opacity: 1; }
.stage-step.current { background: var(--accent-soft); color: var(--accent); opacity: 1; }
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin: 0 20px 16px;
  font-size: 12px;
  color: var(--text);
}
.detail-meta > div { display: flex; flex-direction: column; gap: 2px; }
.detail-meta span {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.detail-section { padding: 0 20px 15px; }
.detail-section h3 {
  margin: 0 0 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.detail-desc { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text); }
.detail-people { display: flex; flex-direction: column; gap: 7px; }
.detail-person { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.detail-person .mini-avatar { width: 22px; height: 22px; font-size: 9px; }
.detail-note { font-style: normal; font-size: 10.5px; color: var(--text-muted); opacity: .8; }
.detail-section .attach-list { margin-top: 0; }
.proof-box {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-2);
}
.proof-box.empty { font-size: 12px; color: var(--text-muted); line-height: 1.45; }
.proof-box p { margin: 8px 0; font-size: 12.5px; line-height: 1.45; }
.proof-by { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-muted); }
.proof-form {
  margin: 0 20px 16px;
  padding: 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent-soft);
}
.proof-form .field-label { margin-bottom: 4px; }
.proof-form textarea {
  display: block;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  outline: none;
  resize: vertical;
}
.proof-form textarea:focus { border-color: var(--accent); }
.proof-attach-label { margin-top: 11px; }
.proof-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.proof-form-actions button {
  border: 0;
  border-radius: 8px;
  padding: 8px 13px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.proof-form-actions button:hover { background: var(--hover); color: var(--text); }
.proof-form-actions .primary { background: var(--accent); color: #fff; }
.proof-form-actions .primary:hover { background: #06b78f; color: #fff; }
.history { display: flex; flex-direction: column; gap: 2px; }
.history-item { display: flex; gap: 9px; padding: 4px 0; }
.history-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  opacity: .65;
}
.history-item b { font-size: 12px; font-weight: 600; }
.h-meta { font-size: 10.5px; color: var(--text-muted); margin-top: 1px; }
.task-detail footer { padding: 14px 20px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.detail-actions button { border-radius: 8px; padding: 9px 14px; }
.detail-actions .primary { background: var(--accent); color: #fff; }
.detail-actions .primary:hover { background: #06b78f; color: #fff; }

/* ============================================================
   Responsive additions
   ============================================================ */
@media (max-width: 1180px) {
  .app.tasks-hidden .tasks-panel { display: flex; }
  .tasks-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    max-width: 88vw;
    z-index: 70;
    transform: translateX(100%);
    transition: transform .24s ease;
    box-shadow: -14px 0 40px rgba(0, 0, 0, .35);
  }
  .app.tasks-open .tasks-panel { transform: none; }
  .composer-task span { display: none; }
  .composer-task { padding: 0 10px; }
}
@media (max-width: 1100px) {
  .chat-actions .hide-sm { display: none; }
}
@media (max-width: 820px) {
  .chat-panel { z-index: 30; }
  .tasks-panel { z-index: 80; width: 340px; }
  .messages { padding: 10px 10px 16px; }
  .msg-row { max-width: 86%; }
  .msg-row.is-photo { max-width: 92%; }
  .msg-row.is-voice { max-width: 94%; }
  .msg-row.is-task { max-width: 94%; }
  .msg-actions { opacity: 1; pointer-events: auto; }
  .side-header { padding-left: 14px; }
  .workspace-switch { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .composer { padding: 7px 8px; gap: 2px; }
  .composer > .icon-btn { width: 38px; height: 38px; }
  .composer-task { height: 38px; }
  .emoji-pop { left: 8px; right: 8px; width: auto; }
  .attach-pop { left: 48px; }
}
@media (max-width: 560px) {
  .task-modal .form-grid { grid-template-columns: 1fr; }
  .task-modal .form-grid .field:first-child { padding-bottom: 0; }
  .msg-row { max-width: 90%; }
  .voice { min-width: 0; }
  .doc { min-width: 0; }
  .chat-title h2 { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .app.tasks-open .tasks-panel {
    transform: translateX(0) !important;
    transition: none !important;
  }
}


