:root {
  --bg: #f6f3ee;
  --side: #ffffff;
  --line: #e7e1d8;
  --text: #1f2a2e;
  --muted: #6b7478;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #e3f2ef;
  --chat-bg: #efe9df;
  --bubble: #d9f2ec;
  --bubble-ink: #15312d;
  --mark: #ffd970;
  --mark-ink: #1f2a2e;
  --hover: #f3efe9;
  --danger: #b4372b;
  --shadow-line: rgba(31, 42, 46, 0.08);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1416;
    --side: #151b1e;
    --line: #263036;
    --text: #e6ecee;
    --muted: #93a0a6;
    --brand: #2bb3a3;
    --brand-ink: #062421;
    --brand-soft: #17322f;
    --chat-bg: #0c1113;
    --bubble: #134640;
    --bubble-ink: #e3f4f1;
    --mark: #c9a227;
    --mark-ink: #111;
    --hover: #1b2327;
    --danger: #e0685c;
    --shadow-line: rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button { font: inherit; color: inherit; }
input, textarea { font: inherit; color: inherit; }
/* No iPhone, campo com letra menor que 16px faz a tela dar zoom ao tocar. */
@media (pointer: coarse), (max-width: 820px) {
  input, textarea, select { font-size: 16px; }
}
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

[hidden] { display: none !important; }

.screen { display: none; height: var(--app-h, 100dvh); }
.screen.active { display: flex; }

/* ---------- Splash e login ---------- */

.splash, .auth {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 24px;
}
.splash-name { font-weight: 700; font-size: 20px; color: var(--brand); }
.auth h1 { margin: 6px 0 0; font-size: 28px; }
.tagline { margin: 0 0 18px; color: var(--muted); font-size: 16px; }
.auth-err { color: var(--danger); min-height: 1.2em; max-width: 320px; margin: 4px 0 0; }

.btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 22px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; color: var(--brand); padding: 6px 12px; }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-danger { background: var(--danger); color: #fff; }

.icon-btn {
  border: 0;
  background: transparent;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:disabled { opacity: 0.35; cursor: default; background: transparent; }

/* ---------- App ---------- */

#screen-app.active { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; }

.sidebar {
  background: var(--side);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.side-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(12px + env(safe-area-inset-top)) 12px 8px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand strong { font-size: 18px; color: var(--brand); }

.avatar-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  font-size: 13px;
  flex: none;
}
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }

.search-box {
  margin: 4px 12px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--hover);
  color: var(--muted);
}
.search-box svg { width: 18px; height: 18px; flex: none; }
.search-box input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 10px 0;
  min-width: 0;
}
.mini-btn {
  width: 30px;
  height: 30px;
  margin-right: -6px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}
.mini-btn:hover { background: var(--line); color: var(--text); }
.mini-btn svg { width: 18px; height: 18px; }
.clear-btn { display: none; }
.search-box.has-q .clear-btn { display: flex; }
.date-pick {
  position: fixed;
  top: 60px;
  left: 12px;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  padding: 0;
  pointer-events: none;
}
.prev .kind { font-weight: 600; }

.tabs { display: flex; gap: 6px; padding: 2px 12px 8px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0;
  border-radius: 999px;
  padding: 5px 12px;
  background: var(--hover);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
}
.tabs button.active { background: var(--brand-soft); color: var(--brand); }

.chat-list { flex: 1; overflow-y: auto; min-height: 0; }

.chat-item {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 10px 16px;
  cursor: pointer;
}
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--brand-soft); }
.chat-item .body { flex: 1; min-width: 0; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: -10px; }
.chat-item .row1, .chat-item .row2 { display: flex; gap: 8px; align-items: baseline; }
.chat-item .name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .time { font-size: 12px; color: var(--muted); flex: none; }
.chat-item .prev {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item mark { background: var(--mark); color: var(--mark-ink); border-radius: 3px; }
.chat-item .snippet { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 7px;
  flex: none;
}

.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
}
.av-0 { background: #0f766e; }
.av-1 { background: #3b6fb6; }
.av-2 { background: #a2582d; }
.av-3 { background: #7a4fa3; }
.av-4 { background: #4d7c2a; }
.av-5 { background: #b0466e; }

.list-info { padding: 28px 24px; text-align: center; color: var(--muted); font-size: 14px; }
.list-head { padding: 8px 16px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.local-note {
  margin: 0;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Painel do chat ---------- */

.panel { min-width: 0; min-height: 0; display: flex; background: var(--chat-bg); }

.panel-empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  padding: 24px;
}
.panel-empty h2 { color: var(--text); margin: 12px 0 4px; }
.panel-empty p { margin: 0; }

.chat-view { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px 14px;
  background: var(--side);
  border-bottom: 1px solid var(--line);
}
.chat-head .chat-avatar .avatar { width: 38px; height: 38px; font-size: 14px; }
.chat-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back-btn { display: none; }

.find-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px 6px 14px;
  background: var(--side);
  border-bottom: 1px solid var(--line);
}
.find-bar input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 7px 10px;
  outline: 0;
}
.find-bar input:focus { border-color: var(--brand); }
.find-count { font-size: 12px; color: var(--muted); min-width: 64px; max-width: 46%; text-align: center; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 6% 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 0;
}

.day {
  align-self: center;
  margin: 12px 0 8px;
  padding: 4px 12px;
  border-radius: 8px;
  background: var(--side);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 1px 0 var(--shadow-line);
}

.msg {
  align-self: flex-end;
  max-width: min(78%, 620px);
  background: var(--bubble);
  color: var(--bubble-ink);
  border-radius: 10px 10px 2px 10px;
  padding: 6px 10px 5px;
  box-shadow: 0 1px 0 var(--shadow-line);
  cursor: pointer;
  border: 0;
  text-align: left;
  font: inherit;
  transition: outline-color 0.3s;
  outline: 2px solid transparent;
  outline-offset: 1px;
}
.msg .author { display: block; font-size: 12px; font-weight: 700; color: var(--brand); margin-bottom: 2px; }
.msg .text { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; line-height: 1.4; }
.msg .meta {
  float: right;
  margin: 6px 0 -2px 10px;
  font-size: 11px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.msg .meta svg { width: 12px; height: 12px; }
.msg mark { background: var(--mark); color: var(--mark-ink); border-radius: 3px; }
.msg.current { outline-color: var(--brand); }
.msg.flash { outline-color: var(--brand); }

.messages-empty { margin: auto; text-align: center; color: var(--muted); max-width: 320px; font-size: 14px; }

.trash-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  background: var(--side);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--side);
  border-top: 1px solid var(--line);
}
body.kb-open .composer { padding-bottom: 8px; }
.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 10px 14px;
  background: var(--bg);
  outline: 0;
  max-height: 160px;
  line-height: 1.35;
  overflow-y: hidden;
}
.composer textarea:focus { border-color: var(--brand); }
.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--brand);
  color: var(--brand-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}
.send-btn:disabled { opacity: 0.45; cursor: default; }

.mic-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}
.mic-btn:hover { background: var(--hover); color: var(--text); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- Áudio ---------- */

.composer.recording textarea, .composer.recording #btn-mic, .composer.recording #btn-photo { display: none; }
.rec-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  min-width: 0;
}
.rec-bar[hidden] { display: none; }
.rec-bar #rec-cancel { color: var(--danger); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); flex: none; animation: pulse 1.2s ease-in-out infinite; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 42px; }
.rec-hint { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.msg.audio { min-width: min(260px, 78vw); }
.audio-row { display: flex; align-items: center; gap: 10px; padding: 2px 0 4px; }
.play-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  background: var(--brand);
  color: var(--brand-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}
.play-btn svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.play-btn.loading { opacity: 0.6; animation: pulse 1s ease-in-out infinite; }
.audio-track { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.audio-bar { height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--muted) 30%, transparent); overflow: hidden; }
.audio-bar span { display: block; height: 100%; width: 0; background: var(--brand); }
.audio-time { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.msg.audio .text { display: block; margin-top: 2px; }
.audio-note { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); font-style: italic; }
.audio-note.err { color: var(--danger); font-style: normal; }

/* ---------- Fotos ---------- */

.msg.photo { width: min(320px, 78vw); padding: 4px 4px 5px; }
.msg.photo > .text, .msg.photo > .audio-note, .msg.photo > .author, .msg.photo .photo-ocr { margin-left: 6px; margin-right: 6px; }
.msg.photo > .text { display: block; margin-top: 5px; }
.msg.photo .meta { margin-right: 6px; }
.photo-box {
  display: block;
  width: 100%;
  max-height: 420px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  cursor: zoom-in;
}
.photo-box img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-box img:not([src]) { visibility: hidden; }
.photo-box.broken { cursor: default; }
.msg.queued .photo-box { cursor: pointer; opacity: 0.75; }
.photo-ocr {
  display: block;
  margin-top: 6px;
  padding: 6px 8px;
  border-left: 3px solid var(--brand);
  border-radius: 4px;
  background: color-mix(in srgb, var(--side) 55%, transparent);
  font-size: 13px;
  line-height: 1.35;
}
.photo-ocr-label { display: block; font-size: 11px; font-weight: 700; color: var(--brand); margin-bottom: 2px; }
.photo-ocr-text {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.current .photo-ocr-text, .msg .photo-ocr-text:has(mark) { -webkit-line-clamp: 30; }
.photo-preview { display: flex; justify-content: center; margin-bottom: 12px; }
.photo-preview img { max-width: 100%; max-height: 46vh; border-radius: 8px; object-fit: contain; }
.photo-preview.many { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; max-height: 46vh; overflow-y: auto; }
.photo-preview.many img { width: 100%; aspect-ratio: 1; object-fit: cover; max-height: none; }
.modal .photo-preview + form textarea { min-height: 60px; }
.photo-hint { font-size: 12px; margin: -4px 0 12px !important; }
.ocr-full {
  max-height: 55vh;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  margin-bottom: 10px;
  line-height: 1.4;
}
.ocr-desc { font-size: 13px; }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.92);
  color: #fff;
}
.viewer[hidden] { display: none; }
.viewer-bar { display: flex; justify-content: flex-end; gap: 4px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px; }
.viewer-bar .icon-btn { color: #fff; }
.viewer-bar .icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.viewer-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 8px; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-cap { margin: 0; padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); text-align: center; white-space: pre-wrap; }
.viewer-cap:empty { display: none; }

/* ---------- Arquivo apagado (texto mantido) ---------- */

.media-gone {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--muted) 12%, transparent);
  color: var(--muted);
  font-size: 12.5px;
}
.media-gone svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.msg.photo .media-gone { margin: 2px 2px 4px; }
.msg.audio .media-gone + .text { display: block; }

/* ---------- Lista de tarefas ---------- */

.task-bar {
  display: flex;
  gap: 6px;
  padding: 6px 14px;
  background: var(--side);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.task-bar[hidden] { display: none; }
.task-bar button {
  border: 0;
  border-radius: 999px;
  padding: 5px 12px;
  background: var(--hover);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
}
.task-bar button b { font-weight: 700; margin-left: 2px; }
.task-bar button.active { background: var(--brand-soft); color: var(--brand); }

.msg.task { position: relative; padding-left: 38px; }
.msg.task.photo { padding-left: 4px; }
.task-check {
  position: absolute;
  left: 8px;
  top: 6px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--muted);
  background: var(--side);
  color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1;
}
.msg.task.photo .task-check { left: 10px; top: 10px; }
.msg.task.photo.gone { padding-left: 38px; }
.msg.task.photo.gone .task-check { left: 8px; top: 6px; }
.task-check svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.task-check:hover:not(:disabled) { border-color: var(--brand); }
.task-check.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.task-check:disabled { cursor: default; opacity: 0.7; }
.msg.done .text, .msg.done .photo-ocr-text { text-decoration: line-through; color: var(--muted); }
.msg.done .photo-box img { opacity: 0.6; }

/* ---------- Diálogos de arquivos e conta ---------- */

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.check-row:last-of-type { margin-bottom: 14px; }
.modal .check-row input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--danger); }
.check-row span { flex: 1; font-weight: 600; }
.check-row small { color: var(--muted); font-size: 13px; }
.del-list { margin: -6px 0 14px; padding-left: 20px; color: var(--muted); font-size: 14px; }
.del-list li { margin-bottom: 4px; }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; }

/* ---------- Mensagens de outras pessoas ---------- */

.msg.in {
  align-self: flex-start;
  background: var(--side);
  color: var(--text);
  border-radius: 10px 10px 10px 2px;
}

/* ---------- Senha, compartilhamento e convites ---------- */

.name-row { display: flex; align-items: center; gap: 5px; flex: 1; min-width: 0; }
.name-row .name { flex: 0 1 auto; }
.ico { width: 14px; height: 14px; flex: none; color: var(--muted); }
.prev .ico { vertical-align: -2px; margin-right: 3px; }

.invite {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  background: var(--brand-soft);
  border-bottom: 1px solid var(--line);
}
.invite .body { flex: 1; min-width: 0; }
.invite .body strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.invite .body span { font-size: 12.5px; color: var(--muted); }
.invite .inv-actions { display: flex; gap: 6px; margin-top: 8px; }
.invite .btn { padding: 6px 14px; font-size: 13px; }

.list-note { padding: 10px 16px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); }

.share-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.share-form input { flex: 1 1 200px; margin: 0 !important; }
.share-form select, .person select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.person select { padding: 5px 8px; font-size: 13px; }

.people { display: flex; flex-direction: column; max-height: 46vh; overflow-y: auto; margin-bottom: 14px; border-top: 1px solid var(--line); }
.person { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.person .avatar { width: 36px; height: 36px; font-size: 13px; }
.person .p-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person .p-body strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.person .p-body span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .btn-ghost { color: var(--danger); font-size: 13px; padding: 5px 10px; }
.modal .form-err { color: var(--danger); font-size: 13px; margin: -8px 0 12px; }
.modal .form-err:empty { display: none; }
.modal .link-btn { border: 0; background: none; color: var(--brand); cursor: pointer; padding: 0; font-size: 13px; margin-right: auto; }
.modal .actions { align-items: center; }

/* ---------- Menus, modais, avisos ---------- */

.menu-layer { position: fixed; inset: 0; z-index: 40; }
.menu {
  position: fixed;
  min-width: 200px;
  max-width: 280px;
  background: var(--side);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.menu .menu-info { padding: 8px 16px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu .menu-info strong { display: block; }
.menu .menu-info span { display: block; font-size: 12px; color: var(--muted); word-break: break-word; }
.menu button {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 10px 16px;
  cursor: pointer;
}
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }

.modal-bg {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  width: min(440px, 100%);
  background: var(--side);
  border-radius: 14px;
  padding: 20px;
}
.modal h3 { margin: 0 0 6px; font-size: 18px; }
.modal p { margin: 0 0 14px; color: var(--muted); }
.modal input, .modal textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--bg);
  outline: 0;
  margin-bottom: 16px;
}
.modal textarea { min-height: 140px; resize: vertical; line-height: 1.4; }
.modal input:focus, .modal textarea:focus { border-color: var(--brand); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  z-index: 60;
  background: #1f2a2e;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  max-width: calc(100% - 32px);
}

/* ---------- Celular ---------- */

@media (max-width: 820px) {
  #screen-app.active { grid-template-columns: 1fr; }
  .panel { display: none; }
  body.has-chat .sidebar { display: none; }
  body.has-chat .panel { display: flex; }
  .back-btn { display: inline-flex; }
  .chat-head { padding-left: 4px; }
  .messages { padding: 10px 10px 14px; }
  .msg { max-width: 86%; }
}
