.portal-chat { --chat-ink: #123448; --chat-muted: #536d7b; --chat-line: #dce8ed; --chat-bg: #fff; --chat-soft: #f1f7fa; position: fixed; bottom: 20px; right: 20px; z-index: 1050; font-size: 14px; color: var(--chat-ink); }
.portal-chat, .portal-chat * { box-sizing: border-box; }
.portal-chat button { cursor: pointer; }
.portal-chat-toggle, .portal-chat form button { background: #08768e; color: #fff; border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 600; }
.portal-chat-toggle { box-shadow: 0 6px 24px #08334825; }
.portal-chat-panel { position: absolute; bottom: 60px; right: 0; width: min(420px, calc(100vw - 32px)); height: min(660px, calc(100dvh - 110px)); display: flex; flex-direction: column; overflow: hidden; background: var(--chat-bg); border: 1px solid var(--chat-line); border-radius: 20px; box-shadow: 0 16px 56px #08334830; }
.portal-chat-panel[hidden] { display: none; }
.portal-chat-panel header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; background: #083348; color: #fff; flex-shrink: 0; }
.portal-chat-panel header strong { font-size: 15px; }
.portal-chat-panel header small { display: block; font-size: 12px; color: #b8dce6; margin-top: 4px; }
.portal-chat-badge { display: inline-block; font-size: 10px; padding: 3px 6px; margin-left: 4px; border: 1px solid #79cbd4; border-radius: 5px; color: #b4f1f5; vertical-align: middle; }
.portal-chat-panel header button { border: 0; background: transparent; font-size: 26px; color: #fff; width: 40px; height: 40px; }
.portal-chat-notice { flex-shrink: 0; font-size: 12px; padding: 10px 18px; margin: 0; color: var(--chat-muted); border-bottom: 1px solid var(--chat-line); max-height: 25%; overflow-y: auto; }
.portal-chat-notice summary { cursor: pointer; }
.portal-chat-notice p { margin: 8px 0 0; line-height: 1.5; }
.portal-chat-messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px; }
.portal-chat-message { white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 4px 14px 14px; padding: 12px 14px; background: var(--chat-soft); line-height: 1.65; margin: 0 18px 14px 0; }
.portal-chat-message a { color: #08768e; text-decoration: underline; text-underline-offset: 3px; }
.portal-chat-user { background: #08768e; color: #fff; margin: 0 0 14px 32px; border-radius: 14px 4px 14px 14px; }
.portal-chat-links { flex-shrink: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; gap: 8px; padding: 10px 18px; border-top: 1px solid var(--chat-line); }
.portal-chat-links a { color: var(--chat-ink); font-size: 12px; border: 1px solid var(--chat-line); border-radius: 8px; padding: 7px 10px; text-decoration: none; }
.portal-chat-links button { margin-left: auto; border: 0; padding: 8px; background: transparent; color: var(--chat-muted); }
.portal-chat form { flex-shrink: 0; display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 0 18px 14px; }
.portal-chat form label { grid-column: 1 / -1; font-size: 12px; color: var(--chat-muted); }
.portal-chat textarea { width: 100%; min-width: 0; resize: none; border: 1px solid var(--chat-line); border-radius: 10px; padding: 10px; background: var(--chat-bg); color: var(--chat-ink); font-size: 14px; }
.portal-chat form button { padding: 10px 12px; font-size: 12px; max-width: 100px; }
.portal-chat [data-status] { grid-column: 1 / -1; font-size: 12px; color: var(--chat-muted); }
.portal-chat [data-status]:empty { display: none; }
.portal-chat button:disabled { opacity: .6; cursor: wait; }
.portal-chat :focus-visible { outline: 3px solid #e4ac34; outline-offset: 2px; }
body.dark-mode .portal-chat { --chat-ink: #e0edf5; --chat-muted: #aac3d1; --chat-line: #345367; --chat-bg: #102b3c; --chat-soft: #19394c; }
body.dark-mode .portal-chat-message a { color: #7adce9; }
@media (max-width: 600px) {
  .portal-chat { bottom: max(12px, env(safe-area-inset-bottom)); right: 12px; }
  .portal-chat-panel { position: fixed; inset: 12px 12px auto; width: auto; height: calc(100dvh - 84px - env(safe-area-inset-bottom)); border-radius: 16px; }
  .portal-chat textarea { font-size: 16px; }
}
/* Guided report uses the original portal form, moved here without cloning data. */
.portal-chat [hidden] { display: none !important; }
.portal-chat-report { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 18px; }
.portal-chat-report-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 11px; color: var(--chat-muted); }
.portal-chat-report-heading button { background: transparent; border: 0; padding: 6px 0; color: var(--chat-ink); }
.portal-chat-report h3 { font-size: 20px; color: var(--chat-ink); margin-bottom: 8px; }
.portal-chat-report [data-report-help] { font-size: 13px; line-height: 1.6; color: var(--chat-muted); }
.portal-chat-report form { display: block; padding: 0; }
.portal-chat-report fieldset { border: 0; padding: 0; margin: 0 0 16px; }
.portal-chat-report legend { font-size: 14px; font-weight: 600; color: var(--chat-ink); }
.portal-chat-report .portal-cidadao-type-grid, .portal-chat-report .portal-cidadao-form-grid, .portal-chat-report .portal-cidadao-dependent-fields { display: grid; grid-template-columns: 1fr; gap: 12px; }
.portal-chat-report .portal-cidadao-type-option { max-width: none; width: 100%; background: var(--chat-soft); color: var(--chat-ink); border: 1px solid var(--chat-line); text-align: left; }
.portal-chat-report .portal-cidadao-type-option.is-selected { border-color: #08768e; box-shadow: 0 0 0 2px #08768e; }
.portal-chat-report .portal-cidadao-field { display: grid; gap: 5px; }
.portal-chat-report .portal-cidadao-field-wide { grid-column: auto; }
.portal-chat-report input:not([type=checkbox]):not([type=file]), .portal-chat-report select, .portal-chat-report textarea { width: 100%; background: var(--chat-bg); color: var(--chat-ink); border: 1px solid var(--chat-line); border-radius: 8px; padding: 10px; font-size: 16px; }
.portal-chat-report small, .portal-chat-report .portal-cidadao-identity-note { font-size: 12px; color: var(--chat-muted); }
.portal-chat-report form button { max-width: none; }
.portal-chat-report .portal-cidadao-consent { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; margin-top: 18px; }
.portal-chat-report .portal-cidadao-upload-box { flex-wrap: wrap; padding: 12px; }
.portal-chat-report .portal-cidadao-upload-label { margin: 8px 0 0; }
.portal-chat-report-actions { display: flex; gap: 10px; margin-top: 16px; }
.portal-chat-report-actions button { flex: 1; border: 1px solid var(--chat-line); border-radius: 10px; background: var(--chat-soft); color: var(--chat-ink); padding: 12px; }
.portal-chat-report-actions [data-report-next] { background: #08768e; color: #fff; }
.portal-chat-report [data-report-feedback]:not(:empty) { background: var(--chat-soft); padding: 12px; border-radius: 8px; font-size: 13px; }
.portal-chat-report dl { font-size: 13px; background: var(--chat-soft); padding: 12px; border-radius: 10px; }
.portal-chat-report dd { overflow-wrap: anywhere; white-space: pre-wrap; margin-bottom: 10px; }
.portal-chat-links :is([data-start-report], [data-about-oceano]) { margin-left: 0; border: 1px solid var(--chat-line); border-radius: 8px; padding: 7px 10px; font-size: 12px; }

@media (max-width: 600px) {
  html:has(.portal-chat-panel:not([hidden])), body:has(.portal-chat-panel:not([hidden])) { overflow: hidden !important; }
  .portal-chat-panel { inset: var(--chat-viewport-top, 0px) 0 auto; width: 100%; height: var(--chat-viewport-height, 100dvh); max-height: none; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .portal-chat:has(.portal-chat-panel:not([hidden])) .portal-chat-toggle { visibility: hidden; }
  .portal-chat-panel header { padding: 10px 14px; }
  .portal-chat-panel header button { width: 44px; height: 44px; }
  .portal-chat-notice { padding: 8px 14px; }
  .portal-chat-notice summary { min-height: 28px; display: list-item; }
  .portal-chat-messages { padding: 14px; }
  .portal-chat-message { margin-right: 8px; }
  .portal-chat-user { margin-left: 24px; margin-right: 0; }
  .portal-chat-links { padding: 8px 12px; gap: 6px; flex-wrap: wrap; }
  .portal-chat-links :is(a, button) { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .portal-chat > .portal-chat-panel > form { padding: 0 12px 10px; }
  .portal-chat-report { padding: 12px 14px; scroll-padding-bottom: 76px; }
  .portal-chat-report-heading button { min-height: 44px; }
  .portal-chat-report-actions { position: sticky; bottom: -12px; background: var(--chat-bg); padding: 12px 0; border-top: 1px solid var(--chat-line); }
  .portal-chat-report .portal-cidadao-form-grid,
  .portal-chat-report .portal-cidadao-identity-fieldset .portal-cidadao-form-grid { grid-template-columns: minmax(0, 1fr); }
  .portal-chat-report :is(input:not([type=hidden]):not([type=checkbox]), select) { min-height: 46px; }
  .portal-chat-report .portal-cidadao-consent input { flex-shrink: 0; width: 22px; height: 22px; }
}


/* Suggestions live inside the scrolling conversation, leaving the composer available. */
.portal-chat-suggestions { display: block; margin: 18px 0 8px; }
.portal-chat-suggestions summary { color: var(--chat-ink); font-size: 14px; }
.portal-chat-suggestions > span { color: var(--chat-muted); font-size: 12px; margin-bottom: 4px; }
.portal-chat-suggestions button { min-height: 44px; width: 100%; padding: 11px 14px; border: 1px solid var(--chat-line); border-radius: 12px; text-align: left; background: var(--chat-bg); color: var(--chat-ink); font: inherit; font-size: 13px; line-height: 1.4; cursor: pointer; }
.portal-chat-suggestions button:hover { background: var(--chat-soft); border-color: #08768e; }
.portal-chat-suggestions button:focus-visible { outline: 3px solid #e7ae35; outline-offset: 2px; }

/* Keep utility controls out of the quick actions and preserve conversation space. */
.portal-chat-header-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.portal-chat-panel header .portal-chat-header-actions button { display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; }
.portal-chat-header-actions button:hover { background: #ffffff18; }
.portal-chat-panel:has([data-report]:not([hidden])) [data-clear] { display: none; }
.portal-chat-links > :is(a, button) { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 44px; margin: 0; padding: 7px 6px; text-align: center; line-height: 1.35; font-family: inherit; }
.portal-chat-panel > form { grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; }
.portal-chat-panel > form textarea { min-height: 58px; }
.portal-chat-panel > form button { white-space: nowrap; }
.portal-chat-messages { scrollbar-width: thin; scrollbar-color: var(--chat-line) transparent; }

/* Color distinguishes the persistent shortcuts from conversation suggestions. */
.portal-chat-links > :is(a, button) {
  border-radius: 12px;
  font-weight: 600;
  border-color: var(--shortcut-border);
  background: linear-gradient(135deg, var(--shortcut-start), var(--shortcut-end));
  color: var(--shortcut-text);
  box-shadow: 0 2px 5px var(--shortcut-shadow);
  transition: box-shadow .18s ease, border-color .18s ease;
}
.portal-chat-links > [data-start-report] {
  --shortcut-start: #083348; --shortcut-end: #083348;
  --shortcut-text: #fff; --shortcut-border: #083348;
  --shortcut-shadow: #08768e26;
}
.portal-chat-links > a {
  --shortcut-start: #083348; --shortcut-end: #083348;
  --shortcut-text: #fff; --shortcut-border: #083348;
  --shortcut-shadow: #065f4612;
}
.portal-chat-links > [data-about-oceano] {
  --shortcut-start: #2563eb; --shortcut-end: #1e40af;
  --shortcut-text: #fff; --shortcut-border: #2563eb;
  --shortcut-shadow: #2563eb26;
}
.portal-chat-links > :is(a, button):not(:disabled):hover {
  border-color: var(--shortcut-text);
  box-shadow: 0 4px 10px var(--shortcut-shadow);
}
body.dark-mode .portal-chat-links > [data-start-report] {
  --shortcut-start: #083348; --shortcut-end: #083348;
  --shortcut-border: #38b7c9; --shortcut-shadow: #0003;
}
body.dark-mode .portal-chat-links > a {
  --shortcut-start: #083348; --shortcut-end: #083348;
  --shortcut-text: #fff; --shortcut-border: #345367;
  --shortcut-shadow: #0003;
}
body.dark-mode .portal-chat-links > [data-about-oceano] {
  --shortcut-start: #1d4ed8; --shortcut-end: #1e40af;
  --shortcut-border: #6398ff; --shortcut-shadow: #0003;
}
@media (prefers-reduced-motion: reduce) {
  .portal-chat-links > :is(a, button) { transition: none; }
}

.portal-chat-suggestions summary { cursor: pointer; min-height: 44px; align-content: center; font-weight: 600; }
.portal-chat-suggestions summary::after { content: "Expandir"; float: right; font-size: 11px; font-weight: 400; color: var(--chat-muted); }
.portal-chat-suggestions[open] summary::after { content: "Recolher"; }
.portal-chat-suggestions > span { display: block; margin: 4px 0 12px; }
.portal-chat-suggestions > button { margin-bottom: 8px; }

.portal-chat-telegram { margin-left: 8px; background: #229ED9; text-decoration: none; }
.portal-chat-telegram:hover { background: #1b86b9; color: #fff; }
