/* ============ Mensagens ============ */
:root {
  --bubble-out: #0A84FF;
  --bubble-out-text: #FFFFFF;
  --bubble-in: #E9E9EB;
  --bubble-in-text: #1D1D1F;
  --live: #30A14E;
  --warn: #C25400;
  --warn-soft: rgba(194, 84, 0, .09);
  --list-active: #E8F0FB;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bubble-in: #262628;
    --bubble-in-text: #F5F5F7;
    --live: #30D158;
    --warn: #FF9F0A;
    --warn-soft: rgba(255, 159, 10, .12);
    --list-active: #1B2A3D;
  }
}

.nav-badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px;
  border-radius: 9px; background: var(--bubble-out); color: #fff; font-size: 11px; font-weight: 600; vertical-align: 1px;
}
.nav-badge.late { background: var(--red); }
.nav-badge[hidden] { display: none; }

body.inbox-mode main { max-width: none; padding: 0; }
body.inbox-mode { overflow: hidden; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn.on { color: var(--blue); background: var(--blue-soft); }
.icon-btn.tiny { width: 26px; height: 26px; }
.icon-btn.tiny svg { width: 14px; height: 14px; }
.only-mobile { display: none; }

.inbox {
  display: grid; grid-template-columns: 340px minmax(0, 1fr) 0;
  height: calc(100vh - 53px); height: calc(100dvh - 53px);
  transition: grid-template-columns .3s var(--ease);
}
.inbox.panel-open.has-thread { grid-template-columns: 340px minmax(0, 1fr) 340px; }
@media (min-width: 1069px) {
  .inbox.new-conv, .inbox.panel-open.has-thread.new-conv { grid-template-columns: 340px minmax(0, 1fr) 0; }
}
.inbox.new-conv .ib-panel { visibility: hidden; }

/* ---------- lista ---------- */
.ib-list { border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.ib-list-head { padding: 20px 16px 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; border-bottom: 1px solid var(--line-soft); }
.ib-list-title { display: flex; justify-content: space-between; align-items: center; }
.ib-list-title h1 { font-size: 28px; font-weight: 700; letter-spacing: -.025em; }
.ib-search { min-height: 36px; padding: 6px 12px; font-size: 15px; background: var(--bg-soft); border-color: transparent; }
select.input.ib-instance { min-height: 34px; padding-top: 4px; padding-bottom: 4px; padding-left: 12px; font-size: 13px; }
.ib-filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.ib-filters::-webkit-scrollbar { display: none; }
.ib-filters button {
  flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  border-radius: var(--r-pill); padding: 4px 11px; font-size: 13px; cursor: pointer;
}
.ib-filters button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.ib-convs { list-style: none; margin: 0; padding: 6px 8px; overflow-y: auto; overflow-x: hidden; flex: 1; }
.ib-empty { color: var(--text-2); font-size: 14px; padding: 32px 16px; text-align: center; }
.ib-conv {
  display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 12px; color: var(--text);
}
.ib-conv:hover { background: var(--bg-soft); text-decoration: none; }
.ib-conv.active { background: var(--list-active); }
.ib-conv-body { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.ib-conv-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ib-conv-top b { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-conv-top time { font-size: 12px; color: var(--text-3); flex: none; }
.ib-conv.unread .ib-conv-top time { color: var(--bubble-out); font-weight: 600; }
.ib-conv-bottom { display: flex; align-items: center; gap: 6px; }
.snippet { flex: 1; min-width: 0; font-size: 13.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -.01em; }
.ib-conv.unread .snippet { color: var(--text); font-weight: 500; }
.mark { color: var(--text-3); display: inline-grid; }
.mark svg { width: 14px; height: 14px; }
.mark.late { color: var(--red); }
.count { background: var(--bubble-out); color: #fff; font-size: 11px; font-weight: 600; min-width: 19px; height: 19px; border-radius: 10px; display: grid; place-items: center; padding: 0 5px; }

.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: linear-gradient(160deg, #A1A1A6, #6E6E73); color: #fff; font-size: 15px; font-weight: 600; letter-spacing: 0;
  position: relative;
}
.avatar.live::after {
  content: ""; position: absolute; right: 0; bottom: 1px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--live); box-shadow: 0 0 0 2px var(--bg);
}
.avatar.big { width: 72px; height: 72px; font-size: 24px; }

/* ---------- conversa ---------- */
.ib-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; background: var(--bg); }
.ib-thread.drop-over::after {
  content: "Solte para anexar"; position: absolute; inset: 12px; border: 2px dashed var(--blue); border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--bg) 80%, transparent); display: grid; place-items: center; font-weight: 600; color: var(--blue); z-index: 5;
}
.ib-placeholder { margin: auto; text-align: center; max-width: 380px; padding: 24px; }
.ib-placeholder h2 { font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.ib-placeholder p { color: var(--text-2); margin-top: 8px; }

.ib-head {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line-soft);
  background: var(--nav-bg); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.ib-head .avatar { width: 38px; height: 38px; font-size: 13px; }
.ib-head-id { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.ib-head-id b { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-head-id span { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* A janela de 24 h é a informação que mais decide o atendimento: fica em destaque. */
.wp-short, .cn-short { display: none; }
.window-pill { font-size: 12.5px; font-weight: 600; padding: 5px 11px; border-radius: var(--r-pill); white-space: nowrap; letter-spacing: -.005em; }
.window-pill.open { color: var(--live); background: color-mix(in srgb, var(--live) 12%, transparent); }
.window-pill.closed { color: var(--warn); background: var(--warn-soft); }

.ib-msgs { flex: 1; overflow-y: auto; padding: 18px 18px 8px; display: flex; flex-direction: column; gap: 3px; overscroll-behavior: contain; }
.ib-msgs:focus-visible { outline-offset: -3px; }
.ib-more { text-align: center; font-size: 12px; color: var(--text-3); margin: 4px 0 10px; }
.day-sep { text-align: center; margin: 16px 0 8px; }
.day-sep span { font-size: 12px; color: var(--text-2); font-weight: 500; }

.msg { display: flex; align-items: center; gap: 6px; max-width: 72%; }
.msg.out { align-self: flex-end; flex-direction: row-reverse; }
.msg.in { align-self: flex-start; }
.ib-bubble {
  padding: 7px 12px 5px; border-radius: 18px; font-size: 15px; line-height: 1.38; letter-spacing: -.01em;
  word-wrap: break-word; overflow-wrap: anywhere; min-width: 64px;
}
.msg.in .ib-bubble { background: var(--bubble-in); color: var(--bubble-in-text); border-bottom-left-radius: 6px; }
.msg.out .ib-bubble { background: var(--bubble-out); color: var(--bubble-out-text); border-bottom-right-radius: 6px; }
.msg.out.failed .ib-bubble { background: var(--red-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--red); }
.ib-bubble .txt { white-space: pre-wrap; }
.ib-bubble .txt.reaction { font-size: 26px; line-height: 1.1; }
.ib-bubble a { color: inherit; text-decoration: underline; }
.ib-bubble .cap { white-space: pre-wrap; margin-top: 6px; }
.ib-bubble .quote { font-size: 13px; opacity: .8; border-left: 3px solid currentColor; padding: 2px 8px; margin: 2px 0 6px; border-radius: 3px; }
.ib-bubble .meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 11px; opacity: .72; margin-top: 2px; }
.ib-bubble .from-phone { margin-right: 4px; font-style: italic; }
.ib-bubble .err { font-size: 12px; color: var(--red); margin-top: 4px; }
.tick { display: inline-flex; }
.tick svg { width: 13px; height: 13px; }
.tick.double svg + svg { margin-left: -8px; }
.tick.read { color: #BFE4FF; opacity: 1; }
.tick.failed { color: var(--red); font-weight: 600; }
.tick.sim { font-style: italic; }
.msg.out .ib-bubble:has(.tick.sim) { background: color-mix(in srgb, var(--bubble-out) 55%, var(--bg)); }
.msg.t-image .ib-bubble, .msg.t-video .ib-bubble, .msg.t-sticker .ib-bubble { padding: 4px 4px 5px; }
.msg.t-image .meta, .msg.t-video .meta { padding: 0 8px; }
.msg.t-image .cap, .msg.t-video .cap { padding: 0 8px; }
.media-img { display: block; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 14px; overflow: hidden; }
.media-img img { display: block; max-width: min(320px, 100%); max-height: 360px; object-fit: cover; }
.media-img.sticker img { max-width: 140px; }
.ib-bubble audio { width: 260px; max-width: 100%; height: 40px; display: block; }
.ib-bubble video { max-width: min(320px, 100%); border-radius: 14px; display: block; }
.media-doc { display: flex; gap: 10px; align-items: center; padding: 6px 2px; color: inherit; text-decoration: none; }
.media-doc:hover { text-decoration: none; opacity: .9; }
.media-doc svg { width: 34px; height: 34px; flex: none; }
.media-doc b { display: block; font-size: 14px; font-weight: 600; word-break: break-all; }
.media-doc small { font-size: 12px; opacity: .75; }
.msg-action {
  opacity: 0; border: 0; background: var(--bg-soft); color: var(--text-2); width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; transition: opacity .15s var(--ease);
}
.msg-action svg { width: 15px; height: 15px; }
.msg:hover .msg-action, .msg-action:focus-visible { opacity: 1; }

/* ---------- compositor ---------- */
.ib-composer { border-top: 1px solid var(--line-soft); padding: 10px 14px 14px; position: relative; background: var(--bg); }
.ib-compose-row { display: flex; align-items: flex-end; gap: 4px; }
.ib-text {
  flex: 1; min-height: 38px; max-height: 180px; resize: none; padding: 8px 14px; border-radius: 19px;
  border: 1px solid var(--line); background: var(--surface); font-size: 15px; line-height: 1.4; letter-spacing: -.01em; overflow-y: hidden;
}
.ib-text:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.send-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--bubble-out); color: #fff; cursor: pointer;
  display: grid; place-items: center; flex: none; transition: background-color .2s var(--ease), transform .1s var(--ease);
}
.send-btn:hover { background: var(--blue-hover); }
.send-btn:active { transform: scale(.94); }
.send-btn svg { width: 18px; height: 18px; }
.send-btn[disabled] { opacity: .5; }

.attach-wrap { position: relative; }
.attach-menu {
  position: absolute; bottom: 44px; left: 0; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow), 0 0 0 1px var(--line-soft);
  padding: 6px; display: grid; min-width: 190px; z-index: 10;
}
.attach-menu[hidden] { display: none; }
.attach-menu button { border: 0; background: none; text-align: left; padding: 9px 12px; border-radius: 9px; font-size: 14px; cursor: pointer; }
.attach-menu button:hover { background: var(--bg-soft); }

.compose-chip {
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 12px; margin-bottom: 8px;
  border-radius: 14px; background: var(--bg-soft); font-size: 13.5px;
}
.compose-chip.reply { border-left: 3px solid var(--blue); }
.compose-chip > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-preview { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; background: var(--surface); display: grid; place-items: center; flex: none; color: var(--text-2); }
.attach-preview img, .attach-preview video { width: 100%; height: 100%; object-fit: cover; }
.attach-preview audio { width: 56px; }
.attach-preview svg { width: 26px; height: 26px; }
.attach-info { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.attach-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-info small { color: var(--text-2); }
.attach-info .input { min-height: 32px; padding: 4px 10px; font-size: 14px; }
.attach-preview .spin { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--text-2); border-radius: 50%; animation: spin .8s linear infinite; }

.quick-pop {
  position: absolute; left: 14px; right: 14px; bottom: calc(100% - 4px); background: var(--surface); border-radius: 14px;
  box-shadow: var(--shadow), 0 0 0 1px var(--line-soft); padding: 6px; max-height: 320px; overflow-y: auto; z-index: 10;
}
.quick-pop[hidden] { display: none; }
.quick-pop button { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: baseline; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.quick-pop button[aria-selected="true"], .quick-pop button:hover { background: var(--blue-soft); }
.quick-pop button b { color: var(--blue); }
.quick-pop button span { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-pop small { color: var(--text-3); font-size: 11px; }
.quick-manage, .quick-none { display: block; font-size: 13px; padding: 8px 10px; }
.quick-none { color: var(--text-2); margin: 0; }

.recording { align-items: center; gap: 12px; padding: 2px 0; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: pulse 1.2s var(--ease) infinite; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 17px; }
.rec-label { flex: 1; color: var(--text-2); font-size: 14px; }

.closed-note { font-size: 13.5px; color: var(--text); background: var(--warn-soft); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; }
.closed-note b { color: var(--warn); }
.tpl-compose { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.tpl-vars { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0 10px; margin-top: 10px; }
.tpl-vars .field { margin-bottom: 8px; }
.tpl-vars .input { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.tpl-preview { font-size: 13.5px; background: var(--bg-soft); border-radius: 12px; padding: 10px 12px; white-space: pre-wrap; max-height: 140px; overflow-y: auto; color: var(--text-2); }

.ib-newconv { max-width: 560px; margin: 0 auto; padding: 40px 24px; overflow-y: auto; width: 100%; }
.ib-newconv h2 { font-size: 32px; font-weight: 700; letter-spacing: -.025em; }
.ib-newconv > p { margin: 6px 0 24px; }

/* ---------- painel ---------- */
.ib-panel { border-left: 1px solid var(--line-soft); overflow-y: auto; min-width: 0; background: var(--bg-elevated); }
.inbox:not(.panel-open) .ib-panel, .inbox:not(.has-thread) .ib-panel { visibility: hidden; }
.ib-panel { position: relative; }
.pn-close { position: absolute; top: 10px; right: 10px; display: none; }
.qr-attach .btn.secondary { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.pn-contact { text-align: center; padding: 28px 20px 20px; border-bottom: 1px solid var(--line-soft); }
.pn-contact .avatar { margin: 0 auto 12px; }
.pn-contact h2 { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.pn-contact p { color: var(--text-2); font-size: 14px; }
.pn-sec { padding: 18px 20px; border-bottom: 1px solid var(--line-soft); }
.ib-panel section + section { margin-top: 0; }
.pn-sec h3 { font-size: 15px; font-weight: 600; margin-bottom: 10px; display: flex; gap: 6px; }
.pn-sec > .small { margin: -4px 0 10px; }
.pn-note { min-height: 80px; font-size: 14px; }
.pn-add { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.pn-add .input { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.pn-add textarea.input { min-height: 72px; }
.pn-add .btn { min-height: 34px; font-size: 14px; }
.presets { display: flex; flex-wrap: wrap; gap: 5px; }
.presets button { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-pill); padding: 3px 10px; font-size: 12.5px; cursor: pointer; color: var(--text-2); }
.presets button[aria-pressed="true"] { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.small-seg { margin: 0; }
.small-seg button { font-size: 13px; padding: 4px 14px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--text-2); }
.check input { accent-color: var(--blue); }

.pn-tasks, .pn-fups { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.task { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 6px; padding: 7px 0; border-top: 1px solid var(--line-soft); font-size: 14px; }
.task label { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; }
.task input { margin-top: 3px; accent-color: var(--blue); }
.task small { grid-column: 1; padding-left: 24px; font-size: 12px; color: var(--text-2); }
.task.late small { color: var(--red); font-weight: 500; }
.task.done span { text-decoration: line-through; color: var(--text-3); }
.task .icon-btn { grid-row: 1; grid-column: 2; opacity: .5; }
.task .icon-btn:hover { opacity: 1; }
.pn-done-label { font-size: 12px; color: var(--text-3); padding: 10px 0 2px; }
.fup { border-top: 1px solid var(--line-soft); padding: 9px 0; font-size: 13.5px; }
.fup > div:first-child { display: flex; justify-content: space-between; gap: 8px; }
.fup p { color: var(--text-2); margin: 2px 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.fup small { font-size: 12px; color: var(--text-3); }
.fup-status { font-size: 12px; font-weight: 600; color: var(--text-3); }
.fup.scheduled .fup-status { color: var(--blue); }
.fup.sent .fup-status { color: var(--live); }
.fup.failed .fup-status { color: var(--red); }
.fup .actions { gap: 14px; margin-top: 4px; }
.fup .link-btn { font-size: 13px; }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .86); z-index: 60; display: grid; place-items: center; padding: 24px;
  animation: fade .2s var(--ease);
}
@keyframes fade { from { opacity: 0; } }
.lightbox img { max-width: 100%; max-height: calc(100vh - 120px); border-radius: 12px; }
.lb-actions { display: flex; gap: 10px; position: absolute; bottom: 24px; }

/* ---------- página de tarefas ---------- */
.task-board { list-style: none; padding: 0; margin: 0 0 40px; border-top: 1px solid var(--line-soft); }
.task-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 16px; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--line-soft); }
.task-row input { width: 18px; height: 18px; accent-color: var(--blue); }
.task-main { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.task-main b { font-weight: 500; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-main a { font-size: 13px; }
.task-due { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.task-row.late .task-due, .section-title.late { color: var(--red); }
.task-row.done b { text-decoration: line-through; color: var(--text-3); }
.fup-ico { color: var(--blue); display: grid; }
.fup-ico svg { width: 18px; height: 18px; }

/* ---------- mensagens rápidas ---------- */
.qr-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line-soft); }
.qr-list li { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.qr-list b { color: var(--blue); }
.qr-list p { color: var(--text-2); font-size: 14px; margin-top: 2px; white-space: pre-wrap; }
.qr-list small { color: var(--text-3); font-size: 12px; }
.qr-list .actions { flex: none; gap: 14px; align-items: flex-start; }
.qr-attach { display: flex; gap: 10px; align-items: center; min-height: 40px; }

/* ---------- responsivo ---------- */
@media (max-width: 1068px) {
  .inbox, .inbox.panel-open.has-thread { grid-template-columns: 300px minmax(0, 1fr); }
  .ib-list, .ib-thread { min-width: 0; }
  .ib-panel {
    position: fixed; top: 53px; right: 0; bottom: 0; width: min(360px, 100vw); z-index: 30;
    box-shadow: -12px 0 32px rgba(0, 0, 0, .12); transform: translateX(100%); transition: transform .3s var(--ease);
  }
  .inbox.panel-open.has-thread .ib-panel { transform: none; visibility: visible; }
  .pn-close { display: inline-grid; }
}
@media (max-width: 734px) {
  .inbox, .inbox.panel-open.has-thread { grid-template-columns: minmax(0, 1fr); }
  .inbox { height: calc(100vh - 49px - var(--tabbar-h)); height: calc(100dvh - 49px - var(--tabbar-h)); }
  body.inbox-mode { padding-bottom: var(--tabbar-h); }
  .inbox.has-thread .ib-list { display: none; }
  .inbox:not(.has-thread) .ib-thread { display: none; }
  .only-mobile { display: inline-grid; }
  .ib-head { padding: 8px 10px; gap: 8px; }
  .ib-head .avatar { display: none; }
  .window-pill { font-size: 11px; padding: 4px 8px; }
  .msg { max-width: 88%; }
  .msg-action { opacity: 1; }
  .task-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "chk main del" "chk due del";
    column-gap: 14px; row-gap: 3px; padding: 12px 2px;
  }
  .task-row > input, .task-row > .fup-ico { grid-area: chk; align-self: start; margin-top: 3px; }
  .task-row .task-main { grid-area: main; }
  .task-row .task-due { grid-area: due; font-size: 12.5px; }
  .task-row > button { grid-area: del; }
  .task-row > span:empty { display: none; }
}

/* ============ Nota de voz ============ */
.vn {
  --vn-accent: var(--bubble-out);
  --vn-on-accent: #fff;
  --vn-bar: color-mix(in srgb, var(--bubble-in-text) 28%, transparent);
  --vn-bar-on: var(--bubble-out);
  display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 10px; align-items: center;
  width: 250px; max-width: 100%; padding: 4px 2px 0;
}
.msg.out .vn {
  --vn-accent: #fff;
  --vn-on-accent: var(--bubble-out);
  --vn-bar: rgba(255, 255, 255, .42);
  --vn-bar-on: #fff;
}
.vn-play {
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer; padding: 0;
  display: grid; place-items: center; background: var(--vn-accent); color: var(--vn-on-accent);
  transition: transform .12s var(--ease), opacity .2s var(--ease);
}
.vn-play:active { transform: scale(.92); }
.vn-play svg { width: 18px; height: 18px; grid-area: 1 / 1; transition: opacity .15s var(--ease), transform .15s var(--ease); }
.vn-play svg:first-child { margin-left: 2px; }
.vn-play svg:last-child { opacity: 0; transform: scale(.6); }
.vn.playing .vn-play svg:first-child { opacity: 0; transform: scale(.6); }
.vn.playing .vn-play svg:last-child { opacity: 1; transform: none; }
.vn.loading .vn-play { opacity: .7; }

.vn-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; min-width: 0; }
.vn-wave {
  display: flex; align-items: center; gap: 2px; height: 30px; cursor: pointer; touch-action: none;
  border-radius: 6px; outline-offset: 3px;
}
.vn-wave i {
  flex: 1; min-width: 2px; max-width: 4px; height: 30%; border-radius: 2px;
  background: var(--vn-bar); transition: background-color .12s linear, height .35s var(--ease);
}
.vn-wave i.on { background: var(--vn-bar-on); }
.vn.pending .vn-wave i { opacity: .55; }
.vn.loading .vn-wave { animation: vn-breathe 1.2s var(--ease) infinite; }
@keyframes vn-breathe { 50% { opacity: .45; } }
.vn.failed .vn-wave { opacity: .35; cursor: default; }

.vn-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; line-height: 1; }
.vn-time { font-variant-numeric: tabular-nums; opacity: .75; letter-spacing: 0; }
.vn-rate {
  border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: 11px; letter-spacing: 0;
  padding: 3px 7px; border-radius: 999px; color: inherit;
  background: color-mix(in srgb, currentColor 14%, transparent);
}
.vn-rate:hover { background: color-mix(in srgb, currentColor 22%, transparent); }

/* versão compacta, na prévia do anexo */
.vn.compact { width: 100%; grid-template-columns: 30px minmax(0, 1fr); gap: 8px; padding: 0; }
.vn.compact .vn-play { width: 30px; height: 30px; }
.vn.compact .vn-play svg { width: 14px; height: 14px; }
.vn.compact .vn-wave { height: 22px; }
.attach-preview svg { color: var(--bubble-out); }

/* onda ao vivo do microfone */
.rec-wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 30px; min-width: 0; overflow: hidden; }
.rec-wave i { flex: 1; min-width: 2px; max-width: 4px; height: 8%; border-radius: 2px; background: var(--red); opacity: .85; transition: height .07s linear; }


/* ============ ajustes de celular ============ */
@media (max-width: 734px) {
  /* Conversa aberta ocupa a tela inteira; o "voltar" do cabeçalho leva à lista. */
  body.thread-open .nav, body.thread-open .nav-links { display: none; }
  body.thread-open { padding-bottom: 0; }
  body.thread-open .inbox { height: 100vh; height: 100dvh; }
  body.thread-open #toast { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }

  .ib-head { padding: 8px 8px 8px 4px; gap: 6px; padding-top: max(8px, env(safe-area-inset-top, 0px)); }
  .ib-head-id b { font-size: 16px; }
  .wp-long { display: none; }
  .wp-short { display: inline; }
  .window-pill { font-size: 11.5px; padding: 4px 9px; }

  .ib-msgs { padding: 12px 10px 6px; }
  .msg { max-width: 86%; }
  .msg-action { opacity: 0; pointer-events: none; transition: opacity .15s var(--ease); }
  .msg.selected .msg-action { opacity: 1; pointer-events: auto; }
  .msg.selected .ib-bubble { filter: brightness(.96); }

  .ib-composer { padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .ib-compose-row { gap: 2px; }
  .ib-composer .icon-btn { width: 40px; height: 40px; }

  /* iOS dá zoom ao focar campo com fonte < 16px. */
  .ib-text, .ib-search, .input, select.input, textarea.input, .pn-add .input, .tpl-vars .input, .attach-info .input { font-size: 16px; }

  .ib-panel { top: 0; width: 100vw; box-shadow: none; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .pn-close { top: max(10px, env(safe-area-inset-top, 0px)); width: 40px; height: 40px; background: var(--bg-soft); }
  .ib-list-head { padding: 14px 14px 10px; }
  .ib-newconv { padding: 20px 16px calc(24px + env(safe-area-inset-bottom, 0px)); }
  .ib-newconv .btn.large { width: 100%; }
  .cn-long { display: none; }
  .cn-short { display: inline; }
  .closed-note { font-size: 13px; padding: 8px 12px; margin-bottom: 8px; }
  .tpl-compose { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .tpl-compose .btn { min-height: 44px; padding: 0 16px; }
  .ib-composer[data-mode="template"] { max-height: 55vh; overflow-y: auto; }
  .tpl-vars { grid-template-columns: minmax(0, 1fr); }
  .ib-list-title h1 { font-size: 26px; }
}
