* { box-sizing: border-box; }
html, body {
  min-height: 100%;
  scrollbar-gutter: stable;
}
body {
  --shell-sidebar-width: 0px;
  margin: 0;
  font-family: var(--font-family-base, Inter, system-ui, -apple-system, "Segoe UI", sans-serif);
  color: var(--text, #eff6ff);
  background:
    radial-gradient(circle at 12% 14%, rgba(138, 43, 226, 0.18), transparent 30%),
    radial-gradient(circle at 86% 16%, rgba(0, 240, 255, 0.16), transparent 30%),
    radial-gradient(circle at 50% 100%, rgba(255, 47, 214, 0.08), transparent 26%),
    linear-gradient(180deg, #08070b 0%, #090b12 100%);
  scrollbar-gutter: stable both-edges;
}
body.sidebar-docked {
  --shell-sidebar-width: min(320px, calc(100vw - 48px));
}

/* ==========================================================================
   SISTEMA DE ROLAGEM E SCROLLBARS CANÔNICAS (DESPOLUÍDO)
   ========================================================================== */
:where(
  body,
  .sidebar,
  .nav-wrap,
  .workspace,
  .table-wrap,
  .chat-pane,
  .chat-editor-body,
  .chat-stream,
  .chat-terminal-body,
  .chat-file-preview,
  .chat-preview-empty
) {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 240, 255, 0.2) transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 240, 255, 0.18);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(41, 243, 156, 0.5), rgba(0, 240, 255, 0.6));
}
::-webkit-scrollbar-corner {
  background: transparent;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }
.app {
  min-height: 100vh;
  display: block;
}

.mobile-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-card, 14px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(7, 8, 12, 0.72);
  color: var(--text, #eff6ff);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.mobile-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 240, 255, 0.28);
  background: rgba(10, 14, 22, 0.9);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  width: min(320px, calc(100vw - 24px));
  height: 100vh;
  padding: 18px 16px 20px;
  background: linear-gradient(180deg, rgba(7, 8, 12, 0.82), rgba(7, 8, 12, 0.58));
  backdrop-filter: blur(12px);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.03), 0 28px 80px rgba(0, 0, 0, 0.42);
  overflow-y: auto;
  overflow-x: hidden;
  transform: translateX(calc(-100% - 20px));
  transition: transform 0.28s ease;
  scrollbar-gutter: stable;
}
.sidebar.is-open { transform: translateX(0); }
.sidebar-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.sidebar-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-top: 6px;
  border-radius: var(--radius-card, 14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text, #eff6ff);
  cursor: pointer;
}
.sidebar-close:hover {
  border-color: rgba(0, 240, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: var(--space-compact-gap, 8px);
  margin-bottom: 18px;
  padding: 12px 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-control, 12px);
  background: linear-gradient(180deg, rgba(13, 17, 27, 0.78), rgba(8, 10, 16, 0.64));
  box-shadow: var(--shadow-panel, 0 28px 70px rgba(0, 0, 0, 0.52));
  flex: 1 1 auto;
}
.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-control, 12px);
  object-fit: contain;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px;
}
.brand strong {
  font-size: var(--brand-size, 29px);
  line-height: 1;
  letter-spacing: 0;
  color: #d9eeff;
  text-shadow: 0 0 14px rgba(0, 240, 255, 0.72), 0 0 30px rgba(138, 43, 226, 0.36);
  animation: pulseGlow 2.9s ease-in-out infinite;
}
.brand span {
  color: var(--muted, #9cb0d1);
  font-size: 12px;
  line-height: 1.4;
}

.sidebar-session {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 2px 14px;
  padding: 10px 12px;
  border-radius: var(--radius-control, 12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted, #9cb0d1);
  font-size: 12px;
  line-height: 1.2;
  flex: 0 0 auto;
}
.sidebar-session strong {
  color: #eaf6ff;
  font-size: 12px;
  font-weight: 700;
}
.sidebar-session a {
  color: var(--cyan, #00f0ff);
  white-space: nowrap;
}

.nav-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  margin-right: -6px;
}
.nav-group + .nav-group { margin-top: 18px; }
.nav-group h3 {
  margin: 0 0 10px;
  color: var(--muted, #9cb0d1);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.nav-list { display: grid; gap: var(--space-control-gap, 10px); padding-bottom: 8px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 11px 14px;
  border-radius: var(--radius-control, 12px);
  border: 1px solid transparent;
  color: #d9e6ff;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.3s ease;
}
.nav-item span {
  font-size: var(--nav-size, 14px);
  line-height: 1.2;
}
.nav-item .nav-icon {
  width: 24px;
  flex: 0 0 24px;
  color: var(--cyan, #00f0ff);
  text-align: center;
  font-size: 14px;
}
.nav-item i {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-pill, 999px);
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 0 0 rgba(138, 43, 226, 0.0);
}
.nav-item:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(0, 240, 255, 0.22);
}
.nav-item.is-active {
  border-color: rgba(138, 43, 226, 0.9);
  box-shadow: 0 0 0 1px rgba(138, 43, 226, 0.3), 0 0 22px rgba(138, 43, 226, 0.16);
  background: linear-gradient(135deg, rgba(138, 43, 226, 0.18), rgba(0, 240, 255, 0.08));
}
.nav-item.is-active i {
  background: var(--cyan, #00f0ff);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.85);
}

.sidebar-footer {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  padding: 14px;
  border-radius: var(--radius-control, 12px);
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(6, 8, 13, 0.7);
  color: var(--muted, #9cb0d1);
  font-size: 12px;
  line-height: 1.5;
  overflow: hidden;
}
.sidebar-shortcut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-panel, 16px);
  border: 1px solid rgba(0, 240, 255, 0.35);
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.14), rgba(138, 43, 226, 0.18));
  color: #eff6ff;
  text-decoration: none;
  font-weight: 700;
  box-shadow: 0 0 0 1px rgba(0, 240, 255, 0.08) inset;
}
.sidebar-shortcut-meta {
  font-size: 12px;
  opacity: 0.8;
}

.workspace {
  padding: 26px 26px 34px;
  min-width: 0;
  width: 100%;
  overflow-x: clip;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 4px 0 8px;
  background: linear-gradient(180deg, rgba(8, 7, 11, 0.96), rgba(8, 7, 11, 0.72) 72%, rgba(8, 7, 11, 0));
  backdrop-filter: blur(10px);
}
.title-block {
  flex: 1;
  text-align: center;
}
.title-block h1 {
  margin: 0;
  font-size: var(--title-size, 36px);
  line-height: 1.05;
  letter-spacing: 0;
}
.title-block p {
  margin: 8px 0 0;
  color: var(--muted, #9cb0d1);
  max-width: var(--measure-reading-width, 760px);
  line-height: 1.5;
}

.pill-row {
  min-width: 260px;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-control-gap, 10px);
  align-items: center;
  justify-content: flex-end;
}
.pill,
.endpoint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-pill, 999px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #dce7ff;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
  white-space: nowrap;
}
.endpoint {
  border-color: rgba(0, 240, 255, 0.24);
  color: #e8feff;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.08), rgba(138, 43, 226, 0.08));
}

.flash {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: var(--radius-control, 12px);
  border: 1px solid rgba(0, 240, 255, 0.2);
  background: rgba(0, 240, 255, 0.08);
  color: #d7fdff;
}

.sidebar-backdrop {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.sidebar-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}
body.sidebar-open {
  overflow: hidden;
}

.grid-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
  gap: var(--space-section-gap, 18px);
  align-items: start;
}

.panel {
  border-radius: var(--radius-panel, 16px);
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: linear-gradient(180deg, rgba(14, 18, 28, 0.88), rgba(10, 12, 19, 0.8));
  box-shadow: var(--shadow-panel, 0 28px 70px rgba(0, 0, 0, 0.52));
  backdrop-filter: blur(12px);
}
.panel.is-interactive {
  min-height: 280px;
  cursor: pointer;
}
.panel.is-selected {
  border-color: rgba(0, 240, 255, 0.35);
  box-shadow:
    var(--shadow-panel, 0 28px 70px rgba(0, 0, 0, 0.52)),
    0 0 0 1px rgba(0, 240, 255, 0.16);
  background: linear-gradient(180deg, rgba(10, 20, 30, 0.92), rgba(10, 16, 26, 0.86));
}
.panel.pad { padding: 18px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-panel-gap, 16px);
  margin-top: 16px;
}

.stat-card {
  padding: 16px;
  min-height: 132px;
  text-align: center;
  border-radius: var(--radius-card, 14px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02)),
    radial-gradient(circle at 20% 10%, rgba(0, 240, 255, 0.08), transparent 42%);
  box-shadow: var(--shadow-elevated, 0 18px 36px rgba(0, 0, 0, 0.28));
  transition: all 0.3s ease;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
  line-height: 1.25;
}
.stat-card p { margin: 0; color: var(--muted, #9cb0d1); line-height: 1.45; }
.stat-card .meta {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-compact-gap, 8px);
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-pill, 999px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
}
.badge.on { color: var(--green, #29f39c); border-color: rgba(41, 243, 156, 0.3); }
.badge.off { color: var(--red, #ff0055); border-color: rgba(255, 0, 85, 0.3); }
.badge.neon { color: var(--cyan, #00f0ff); border-color: rgba(0, 240, 255, 0.3); }

.section-title {
  margin: 0 0 14px;
  font-size: 17px;
  line-height: 1.25;
  text-align: center;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  scrollbar-gutter: stable both-edges;
  border-radius: var(--radius-card, 14px);
  overscroll-behavior: contain;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}
th, td {
  text-align: left;
  padding: 13px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  vertical-align: middle;
}
th {
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted, #9cb0d1);
}
td { color: #eaf3ff; }

.history-item.is-stretch {
  align-items: stretch;
}
.history-item.is-selected {
  border-color: rgba(0, 240, 255, 0.35);
  background: rgba(0, 240, 255, 0.08);
  box-shadow: 0 0 0 1px rgba(0, 240, 255, 0.12);
}

.surface-note,
.surface-note-warning,
.surface-note-success,
.surface-note-danger {
  text-align: left;
}
.surface-note-warning {
  border-color: rgba(255, 184, 77, 0.35);
  background: rgba(255, 184, 77, 0.08);
  color: #fff2d6;
}
.surface-note-success {
  border-color: rgba(41, 243, 156, 0.35);
  background: rgba(41, 243, 156, 0.08);
  color: #dcfff0;
}
.surface-note-danger {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
  color: #ffe4e6;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 80;
  padding: 24px;
  overflow: auto;
  backdrop-filter: blur(10px);
  background: rgba(2, 6, 23, 0.78);
}
.modal-shell.modal-shell-strong {
  z-index: 120;
  backdrop-filter: blur(12px);
  background: rgba(2, 6, 23, 0.82);
}
.modal-card {
  width: min(100%, 1180px);
  margin: 5vh auto;
}
.modal-card.modal-card-sm {
  width: min(100%, 560px);
  margin: 6vh auto;
}
.modal-header,
.modal-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.modal-toolbar {
  margin-bottom: 14px;
}
.modal-toolbar .pill-row,
.modal-header .pill-row {
  margin: 0;
}
.modal-body-stack {
  display: grid;
  gap: 16px;
}

.toolbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.toolbar-row.is-top {
  margin-bottom: 16px;
}
.toolbar-row.is-start {
  align-items: flex-start;
}
.toolbar-grow {
  flex: 1 1 320px;
}
.toolbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search-control {
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border-radius: 18px;
}

.code-compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.code-scroll {
  margin: 0;
  padding: 14px;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  border-radius: var(--radius-card, 14px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #0b1220;
}
.code-scroll.is-proposed {
  border-color: rgba(41, 243, 156, 0.2);
  background: #08111c;
}
.code-scroll.is-tall {
  max-height: 480px;
}
.code-scroll.is-compact {
  max-height: 260px;
  margin-top: 10px;
  padding: 12px;
  border-radius: var(--radius-control, 12px);
}
.code-scroll.is-snippet {
  max-height: 220px;
  margin-top: 10px;
  padding: 12px;
  border-radius: var(--radius-control, 12px);
}
.code-scroll code {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.form-stack {
  display: grid;
  gap: var(--space-control-gap, 10px);
}
.flow-top-sm { margin-top: 10px; }
.flow-top-md { margin-top: 14px; }
.flow-top-lg { margin-top: 16px; }
.flow-top-xl { margin-top: 18px; }

.muted-copy {
  margin: 6px 0 0;
  color: var(--muted, #9cb0d1);
}
.history-item-main {
  flex: 1 1 auto;
  min-width: 0;
}
.history-item-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-panel-gap, 16px);
}
.field { display: grid; gap: var(--space-compact-gap, 8px); }
.field.full { grid-column: 1 / -1; }
.field label {
  font-size: var(--label-size, 13px);
  color: #d6e3ff;
}
.field input,
.field textarea {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  border-radius: var(--radius-control, 12px);
  color: var(--text, #eff6ff);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(7, 11, 18, 0.8);
  outline: none;
  transition: all 0.3s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus,
.field textarea:focus {
  transform: translateY(-2px);
  border-color: rgba(0, 240, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.12);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-control-gap, 10px);
  margin-top: 16px;
}
.btn,
button {
  appearance: none;
  border: 0;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-control, 12px);
  color: white;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0;
  transition: all 0.3s ease;
  background: linear-gradient(135deg, var(--violet, #8a2be2), var(--cyan, #00f0ff));
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.28);
}
.btn:hover,
button:hover { transform: translateY(-2px); }
.btn.secondary,
button.secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn.danger,
button.danger {
  background: linear-gradient(135deg, var(--red, #ff0055), #b7003b);
}

.grid-cols-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-panel-gap, 16px);
}
.mini-card {
  padding: 14px;
  min-height: 110px;
  text-align: center;
  border-radius: var(--radius-card, 14px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  transition: all 0.3s ease;
}
.mini-card:hover { transform: translateY(-2px); }
.mini-card strong { display: block; font-size: 15px; margin-bottom: 8px; }
.mini-card p { margin: 0; color: var(--muted, #9cb0d1); line-height: 1.45; }

.metric-chart {
  display: grid;
  gap: var(--space-control-gap, 10px);
  margin-top: 16px;
}
.metric-row {
  padding: 12px 14px;
  border-radius: var(--radius-control, 12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}
.metric-row-head,
.metric-row-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.metric-row-head strong {
  font-size: 14px;
  line-height: 1.3;
}
.metric-row-head span,
.metric-row-foot small {
  color: var(--muted, #9cb0d1);
  font-size: 12px;
  line-height: 1.3;
}
.meter {
  height: 10px;
  margin: 10px 0 8px;
  border-radius: var(--radius-pill, 999px);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.07);
}
.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green, #29f39c), var(--cyan, #00f0ff), var(--violet, #8a2be2));
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.3);
  transition: width 0.4s ease;
}

.history-grid {
  display: grid;
  gap: var(--space-control-gap, 10px);
}
.history-item {
  padding: 12px 14px;
  border-radius: var(--radius-control, 12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-width: 0;
}
.history-item small { color: var(--muted, #9cb0d1); display: block; margin-top: 3px; }

.ghost-note {
  padding: 14px;
  text-align: center;
  border-radius: var(--radius-control, 12px);
  border: 1px dashed rgba(0, 240, 255, 0.22);
  background: rgba(0, 240, 255, 0.04);
  color: #d9fcff;
  line-height: 1.45;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 18% 22%, rgba(0, 240, 255, 0.18), transparent 28%),
    radial-gradient(circle at 82% 22%, rgba(138, 43, 226, 0.2), transparent 30%),
    linear-gradient(180deg, #08070b 0%, #090b12 100%);
}
.login-shell {
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: var(--space-section-gap, 18px);
  align-items: center;
}
.hero-copy {
  padding: 24px 8px;
}
.login-brand-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: var(--radius-panel, 16px);
  padding: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 18px;
}
.hero-copy h1 {
  margin: 0;
  font-size: var(--login-hero-size, clamp(42px, 6vw, 72px));
  line-height: 0.95;
  letter-spacing: 0;
  text-shadow: 0 0 22px rgba(0, 240, 255, 0.28);
}
.hero-copy p {
  max-width: 650px;
  margin: 16px 0 0;
  color: var(--muted, #9cb0d1);
  line-height: 1.6;
  font-size: 16px;
}
.login-card {
  padding: 24px;
  border-radius: var(--radius-panel, 16px);
  background: rgba(9, 12, 18, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-panel, 0 28px 70px rgba(0, 0, 0, 0.52));
  backdrop-filter: blur(14px);
}
.login-card h2 { margin: 0 0 8px; font-size: 26px; }
.login-card p { margin: 0 0 18px; color: var(--muted, #9cb0d1); line-height: 1.5; }
.login-card .field { margin-bottom: 14px; }

/* ==========================================================================
   MÓDULO CANÔNICO DE LAYOUT DO CHAT - ESTILO IDE (VS CODE / CURSOR CHAT)
   ========================================================================== */
.chat-ide-shell {
  display: grid !important;
  /* Proporção Canônica Assimétrica Premium para 100% de Zoom */
  grid-template-columns: 260px minmax(0, 1fr) 340px !important;
  grid-template-rows: minmax(0, 1fr) 160px !important;
  gap: 10px !important;
  width: 100% !important;
  max-width: 100% !important;
  height: calc(100dvh - var(--topbar-height, 74px) - 24px) !important;
  margin: 0 auto !important;
  overflow: hidden !important;
}

/* Mecânica de Colapso das Laterais via Eventos do Painel */
.chat-ide-shell.is-left-collapsed {
  grid-template-columns: 0px minmax(0, 1fr) 340px !important;
}
.chat-ide-shell.is-right-collapsed {
  grid-template-columns: 260px minmax(0, 1fr) 0px !important;
}
.chat-ide-shell.is-left-collapsed.is-right-collapsed {
  grid-template-columns: minmax(0, 1fr) !important;
}

.chat-pane {
  min-height: 0 !important;
  height: 100% !important;
  padding: 0 !important; /* Despolui as margens externas */
  overflow: hidden !important; /* Trava o container pai; o scroll se move para as subzonas */
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.chat-pane-left,
.chat-pane-center,
.chat-pane-right {
  display: grid;
  gap: 10px;
  min-width: 0;
  height: 100%;
}

/* Zonas de Scroll Isoladas (Fim do Scroll Duplo Coexistente) */
.chat-stream,
.chat-context-preview,
.chat-editor-body {
  flex: 1 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  scrollbar-gutter: stable !important;
  overscroll-behavior: contain !important;
  padding: 12px !important;
}

.chat-pane-right {
  grid-template-rows: auto 1fr auto !important; /* Fixa o Topo, expande o Meio e fixa a Base */
  overflow: hidden !important;
}
.chat-pane-center {
  grid-template-rows: minmax(0, 1fr) !important;
  overflow: hidden !important;
}

.chat-rail,
.chat-context-matrix,
.chat-editor-shell,
.chat-explorer-shell,
.chat-tree,
.chat-file-audit,
.chat-file-audit-list,
.chat-rail-stack,
.chat-rail-summary,
.chat-rail-governance,
.chat-rail-meta-grid,
.chat-shell-hero,
.chat-context-drawer-body {
  display: grid;
}

.chat-rail,
.chat-context-matrix,
.chat-editor-shell,
.chat-explorer-shell,
.chat-file-audit,
.chat-rail-stack,
.chat-rail-summary,
.chat-rail-governance,
.chat-context-drawer-body {
  gap: var(--space-control-gap, 10px);
}

.chat-rail,
.chat-editor-shell,
.chat-context-card,
.chat-runtime-card,
.chat-editor-summary-card,
.chat-explorer-item,
.chat-command-card {
  min-width: 0;
}

.chat-context-matrix,
.chat-file-audit-list {
  gap: var(--space-compact-gap, 8px);
}

.chat-rail-head,
.chat-terminal-head,
.chat-breadcrumb,
.chat-context-card,
.chat-explorer-title,
.chat-file-audit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-rail-title,
.chat-terminal-title,
.chat-editor-title,
.chat-runtime-card {
  display: grid;
  gap: 4px;
}
.chat-rail-title strong { font-size: 15px; }

.chat-runtime-grid.chat-runtime-grid-compact,
.chat-rail-meta-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-compact-gap, 8px);
}

.chat-runtime-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--chat-context-min, 220px)), 1fr));
  gap: var(--space-control-gap, 10px);
}

.chat-runtime-card,
.chat-context-card,
.chat-editor-summary,
.chat-file-meta,
.chat-file-audit,
.chat-diff-stat {
  border-radius: var(--radius-card, 14px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.025);
}
.chat-runtime-card {
  gap: 6px;
  padding: 8px 9px;
}

.chat-runtime-grid.chat-runtime-grid-compact .chat-runtime-card,
.chat-rail-meta-item,
.chat-rail-governance-item {
  padding: 7px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}
.chat-rail-meta-item,
.chat-rail-governance-item {
  min-width: 0;
}
.chat-rail-meta-item strong,
.chat-rail-governance-item strong {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #9cb0d1);
}
.chat-rail-meta-item small,
.chat-rail-governance-item small {
  display: block;
  margin-top: 2px;
  color: #eff6ff;
  line-height: 1.25;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.chat-runtime-card strong,
.chat-editor-summary-card strong,
.chat-diff-stat strong {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #9cb0d1);
}
.chat-runtime-card small {
  color: #eff6ff;
  line-height: 1.3;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.chat-context-card {
  align-items: center;
  padding: 12px 14px;
}
.chat-context-matrix {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--chat-context-min, 220px)), 1fr));
}
.chat-context-card strong,
.chat-explorer-title strong {
  display: block;
  font-size: 15px;
}
.chat-context-card small,
.chat-explorer-title small,
.chat-file-audit-item small {
  color: var(--muted, #9cb0d1);
  line-height: 1.35;
}

.chat-composer {
  display: grid;
  gap: 8px;
  align-content: end;
}
.chat-composer .field,
.chat-composer .actions,
.chat-composer .ghost-note,
.chat-composer .chat-stream-wrap {
  margin-top: 0 !important;
}
.chat-composer .actions { justify-content: flex-start; }

.chat-stream-wrap {
  margin-top: 0 !important;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-panel, 16px);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.015));
  padding: 8px 9px 9px;
  display: grid;
  min-height: 0;
  overflow: hidden;
}
.chat-stream-wrap .history-item,
.chat-context-preview .history-item,
.chat-context-preview .ghost-note {
  padding: 8px 9px;
}
.chat-stream-wrap .history-item strong,
.chat-context-preview .history-item strong {
  font-size: 12px;
}
.chat-stream-wrap .history-item small,
.chat-context-preview .history-item small,
.chat-pane .ghost-note {
  font-size: 11px;
  line-height: 1.3;
}

.chat-pane-left .section-title,
.chat-pane-right .section-title {
  margin-top: 0;
  text-align: left;
}
.chat-pane-center .chat-editor-shell {
  height: 100%;
  min-height: 0;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
}
.chat-rail {
  height: 100%;
  min-height: 0;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.chat-shell-hero,
.chat-context-drawer,
.chat-rail-summary,
.chat-rail-governance {
  border-radius: var(--radius-panel, 16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(10, 14, 22, 0.96), rgba(8, 10, 16, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}
.chat-shell-hero {
  padding: 10px 11px;
}
.chat-shell-hero-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.chat-shell-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.chat-pane .pill,
.chat-pane .badge {
  min-height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 9px;
  line-height: 1;
}
.chat-pane .field label,
.chat-pane .toggle-row strong,
.chat-pane .toggle-row div,
.chat-pane textarea,
.chat-pane input,
.chat-pane select {
  font-size: 11px;
}
.chat-pane textarea,
.chat-pane input,
.chat-pane select {
  padding-top: 8px;
  padding-bottom: 8px;
}

.chat-shell-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 9px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #eff6ff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}
.chat-shell-toggle:hover {
  border-color: rgba(0, 240, 255, 0.22);
  background: rgba(0, 240, 255, 0.08);
  transform: translateY(-1px);
}
.chat-shell-toggle.is-collapsed {
  border-color: rgba(0, 240, 255, 0.2);
  background: rgba(0, 240, 255, 0.1);
}
.chat-shell-toggle-label-short {
  display: none;
}
.chat-shell-hero-breadcrumb {
  margin-top: 8px;
}

.chat-ide-terminal {
  grid-column: 1 / -1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-panel, 16px);
  background: linear-gradient(180deg, rgba(8, 10, 16, 0.94), rgba(8, 10, 16, 0.88));
  padding: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02), 0 12px 24px rgba(0, 0, 0, 0.18);
}
.chat-terminal-head { margin-bottom: 12px; }
.chat-terminal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}
.chat-terminal-body {
  min-height: clamp(140px, 18vh, 220px);
  max-height: min(42vh, 340px);
  border-radius: var(--radius-card, 14px);
  border: 1px dashed rgba(0, 240, 255, 0.22);
  background: rgba(0, 240, 255, 0.04);
  padding: 12px;
  color: #d9fcff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  overflow: auto;
  overscroll-behavior: contain;
}

.chat-editor-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-compact-gap, 8px);
}
.chat-editor-tab,
.chat-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-control, 12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
}
.chat-editor-tab {
  padding: 6px 9px;
  font-size: 11px;
}
.chat-editor-tab.is-active {
  border-color: rgba(0, 240, 255, 0.28);
  background: rgba(0, 240, 255, 0.12);
}

.chat-editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.chat-editor-summary {
  display: grid;
  gap: 8px;
  margin-top: 4px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.018);
}
.chat-editor-summary-grid,
.chat-diff-summary {
  display: grid;
  gap: var(--space-control-gap, 10px);
}
.chat-editor-summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
}
.chat-editor-summary-card {
  padding: 7px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.14);
}
.chat-editor-summary-card span {
  display: block;
  font-size: 11px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.chat-editor-title strong { font-size: 14px; }
.chat-editor-subtitle,
.chat-rail-subtitle {
  font-size: 11px;
  line-height: 1.25;
}

.chat-editor-body {
  min-height: 0;
  height: 100%;
  border-radius: var(--radius-panel, 16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(13, 16, 24, 0.98), rgba(8, 10, 16, 0.96));
  padding: 10px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: var(--space-control-gap, 10px);
}
.chat-editor-empty {
  display: grid;
  place-items: center;
  min-height: min(240px, 100%);
  color: var(--muted, #9cb0d1);
  text-align: center;
  border-radius: var(--radius-card, 14px);
  border: 1px dashed rgba(0, 240, 255, 0.18);
  background: rgba(255, 255, 255, 0.02);
  padding: 14px;
}

.chat-sticky-context {
  position: sticky;
  top: 0;
  z-index: 20;
}
.chat-context-drawer {
  overflow: hidden;
}
.chat-context-drawer[open] {
  border-color: rgba(0, 240, 255, 0.16);
}
.chat-context-drawer-summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 10px;
  cursor: pointer;
}
.chat-context-drawer-summary::-webkit-details-marker {
  display: none;
}
.chat-context-drawer-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.chat-context-drawer-title strong {
  font-size: 14px;
}
.chat-context-drawer-title small {
  color: var(--muted, #9cb0d1);
  line-height: 1.2;
  font-size: 11px;
  overflow-wrap: anywhere;
}
.chat-context-drawer-summary .pill-row {
  min-width: 0;
  margin: 0;
}
.chat-context-drawer-body {
  padding: 0 10px 10px;
}
.chat-context-drawer-body .chat-workspace-banner,
.chat-context-drawer-body .chat-context-form,
.chat-context-drawer-body .ghost-note {
  margin-top: 0;
}

.chat-side-drawer {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}
.chat-side-drawer-summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 9px;
  cursor: pointer;
}
.chat-side-drawer-summary::-webkit-details-marker {
  display: none;
}
.chat-side-drawer-summary strong {
  display: block;
  font-size: 12px;
}
.chat-side-drawer-summary small {
  display: block;
  margin-top: 2px;
  color: var(--muted, #9cb0d1);
  line-height: 1.2;
  font-size: 10px;
}
.chat-side-drawer-body {
  padding: 0 9px 9px;
}

.chat-active-file-shell {
  align-items: flex-start;
}

.chat-breadcrumb {
  flex-wrap: wrap;
  align-items: flex-start;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  letter-spacing: 0.01em;
}
.chat-breadcrumb code,
.chat-command-card code {
  display: block;
  border-radius: var(--radius-control, 12px);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat-breadcrumb code {
  flex: 1 1 320px;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid rgba(0, 240, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: #e9feff;
  font-size: 11px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.chat-breadcrumb .pill-row,
.chat-editor-header .pill-row,
.chat-rail-head .pill-row,
.chat-terminal-head .pill-row {
  min-width: 0;
  flex: 0 1 auto;
}

.chat-command-card {
  display: grid;
  gap: var(--space-control-gap, 10px);
  padding: 12px 12px 10px;
  border-radius: var(--radius-panel, 16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(13, 16, 24, 0.98), rgba(8, 10, 16, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02), 0 12px 24px rgba(0, 0, 0, 0.16);
  margin-top: 10px;
}
.chat-command-card code {
  padding: 12px 14px;
  border: 1px solid rgba(0, 240, 255, 0.16);
  background: rgba(0, 0, 0, 0.28);
  color: #eff6ff;
}

.chat-explorer-list { display: grid; gap: 8px; }
.chat-explorer-list { gap: var(--space-compact-gap, 8px); }
.chat-tree-branch {
  margin-left: 14px;
  padding-left: 12px;
  border-left: 1px solid rgba(0, 240, 255, 0.14);
  display: grid;
  gap: var(--space-compact-gap, 8px);
}

.chat-explorer-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 6px 7px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  text-align: left;
  flex-wrap: wrap;
}
.chat-explorer-item > div {
  flex: 1 1 160px;
  min-width: 0;
}
.chat-explorer-item strong {
  font-size: 12px;
  line-height: 1.2;
}
.chat-explorer-item:hover,
.chat-action-btn:hover {
  border-color: rgba(0, 240, 255, 0.25);
  background: rgba(0, 240, 255, 0.08);
}
.chat-explorer-item.is-active {
  border-color: rgba(0, 240, 255, 0.42);
  background: rgba(0, 240, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(0, 240, 255, 0.08);
}
.chat-explorer-item.is-expanded {
  border-color: rgba(41, 243, 156, 0.28);
  background: rgba(41, 243, 156, 0.06);
}
.chat-explorer-item .path {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color: var(--muted, #9cb0d1);
  font-size: 10px;
  margin-top: 2px;
  overflow-wrap: anywhere;
}
.chat-explorer-item .badge {
  min-height: 18px;
  padding: 0 6px;
  font-size: 9px;
}

.chat-explorer-title { flex-wrap: wrap; align-items: flex-start; }
.chat-explorer-title small { display: block; margin-top: 4px; overflow-wrap: anywhere; }
.chat-explorer-item .path.is-active-path { color: #dffcff; }

.chat-action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.chat-action-btn {
  min-height: 30px;
  padding: 0 9px;
  font-size: 11px;
}

.chat-file-preview {
  margin-top: 8px;
  padding: 10px;
  border-radius: var(--radius-card, 14px);
  border: 1px solid rgba(0, 240, 255, 0.14);
  background: rgba(0, 0, 0, 0.24);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: none;
  overflow: visible;
}

.chat-file-meta {
  gap: 6px;
  margin-top: 8px;
  padding: 8px 9px;
  color: var(--muted, #9cb0d1);
  font-size: 11px;
}
.chat-file-meta code {
  color: #dffcff;
  word-break: break-all;
}

.chat-diff-summary {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--chat-diff-min, 160px)), 1fr));
  gap: var(--space-compact-gap, 8px);
  margin-top: 10px;
}
.chat-diff-stat {
  padding: 8px 9px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}
.chat-diff-stat strong { margin-bottom: 4px; }
.chat-diff-stat span {
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: #eff6ff;
}

.chat-diff-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}
.chat-diff-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-control, 12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.18);
  font-size: 12px;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  overflow-wrap: anywhere;
}
.chat-diff-row ins,
.chat-diff-row del { text-decoration: none; }
.chat-diff-row.is-add {
  border-color: rgba(41, 243, 156, 0.24);
  background: rgba(41, 243, 156, 0.08);
}
.chat-diff-row.is-del {
  border-color: rgba(255, 84, 112, 0.26);
  background: rgba(255, 84, 112, 0.08);
}
.chat-diff-row.is-same { opacity: 0.88; }
.chat-diff-sign {
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted, #9cb0d1);
}

.chat-file-audit {
  margin-top: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
}
.chat-file-audit-item {
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius-control, 12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.18);
}
.chat-file-audit-item small {
  display: block;
  margin-top: 4px;
  white-space: pre-wrap;
}

.chat-workspace-banner {
  margin-top: 2px;
  border-color: rgba(0, 240, 255, 0.16);
  background: rgba(0, 240, 255, 0.04);
}
.chat-rail-summary { padding: 8px; }
.chat-rail-governance { padding: 8px; gap: 8px; }
.chat-rail-governance-item + .chat-rail-governance-item { margin-top: 0; }
.chat-context-form { gap: 8px; margin-top: 8px; }
.chat-context-preview { margin-top: 4px; }

.chat-editor-subtitle,
.chat-rail-subtitle,
.chat-terminal-routing-note,
.chat-preview-truncated {
  color: var(--muted, #9cb0d1);
}
.chat-terminal-routing-note,
.chat-preview-truncated {
  font-size: 12px;
}

.chat-explorer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 6px 0 8px;
}
.chat-suggestions-shell {
  grid-column: 1 / -1;
  margin-top: 10px;
}
.chat-note-danger {
  border-color: rgba(255, 84, 112, 0.28);
  background: rgba(255, 84, 112, 0.08);
  color: #ffd9e3;
}

.chat-preview-empty {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: none;
  overflow: visible;
  padding: 12px 14px;
  border-radius: var(--radius-control, 12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.22);
  color: #dffcff;
  font-size: 12px;
  line-height: 1.55;
}
.chat-preview-diff-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.chat-exec-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  min-height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-control, 12px);
  border: 1px solid rgba(0, 240, 255, 0.22);
  background: linear-gradient(135deg, rgba(138, 43, 226, 0.82), rgba(0, 240, 255, 0.72));
  color: #fff;
  font-weight: 800;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.24);
}
.chat-exec-btn:hover { transform: translateY(-1px); }
.chat-exec-btn.is-loading { opacity: 0.9; cursor: wait; }
.chat-exec-btn.is-success {
  background: linear-gradient(135deg, rgba(41, 243, 156, 0.92), rgba(0, 240, 255, 0.68));
}
.chat-exec-btn.is-error {
  background: linear-gradient(135deg, rgba(255, 0, 85, 0.92), rgba(255, 120, 0, 0.72));
}
.chat-clear-btn { margin-left: auto; }

@keyframes pulseGlow {
  0%, 100% { opacity: 1; filter: drop-shadow(0 0 0 rgba(0, 240, 255, 0.12)); }
  50% { opacity: 0.92; filter: drop-shadow(0 0 14px rgba(138, 43, 226, 0.18)); }
}

/* ==========================================================================
   MÁQUINA DE RESPONSIVIDADE GOVERNADA (PROTEÇÃO CONTRA DRIFT)
   ========================================================================== */
@media (max-width: 1200px) {
  .chat-ide-shell,
  .chat-ide-shell.is-left-collapsed,
  .chat-ide-shell.is-right-collapsed,
  .chat-ide-shell.is-left-collapsed.is-right-collapsed {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto !important;
    height: auto !important;
    overflow-y: auto !important;
  }
  .chat-ide-terminal {
    grid-column: auto !important;
  }
  .chat-pane {
    height: auto !important;
    overflow: visible !important;
  }
  .chat-pane-center,
  .chat-pane-right {
    overflow: visible !important;
  }
  .chat-rail,
  .chat-pane-center .chat-editor-shell {
    height: auto !important;
  }
}

@media (max-width: 1120px) {
  .sidebar {
    width: min(92vw, 320px);
  }
  .workspace { padding: 20px 18px 28px; }
  .topbar { align-items: flex-start; flex-wrap: wrap; }
  .title-block { order: 3; width: 100%; text-align: left; }
  .grid-hero,
  .login-shell { grid-template-columns: 1fr; }
  .grid-cols-3,
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1121px) {
  .app {
    display: grid;
    grid-template-columns: var(--shell-sidebar-width) minmax(0, 1fr);
    transition: grid-template-columns 0.28s ease;
  }
  .sidebar {
    position: sticky;
    inset: auto;
    top: 0;
    width: var(--shell-sidebar-width);
    min-width: 0;
    transform: none;
    transition:
      width 0.28s ease,
      padding 0.28s ease,
      opacity 0.2s ease,
      border-right-color 0.2s ease,
      box-shadow 0.2s ease;
  }
  body:not(.sidebar-docked) .sidebar {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    border-right-color: transparent;
    box-shadow: none;
    opacity: 0;
    pointer-events: none;
  }
  body:not(.sidebar-docked) .sidebar > * {
    opacity: 0;
  }
  body.sidebar-docked .sidebar {
    opacity: 1;
    pointer-events: auto;
  }
  body.sidebar-docked .sidebar > * {
    opacity: 1;
  }
  .sidebar-backdrop {
    display: none !important;
  }
  body.sidebar-open {
    overflow: auto;
  }
}

@media (max-width: 980px) {
  .login-shell { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .workspace { padding: 18px 14px 24px; }
  .grid-cols-3,
  .stats-grid,
  .form-grid { grid-template-columns: 1fr; }
  .code-compare-grid { grid-template-columns: 1fr; }
  .pill-row { min-width: 0; justify-content: flex-start; }
  .title-block h1 { font-size: clamp(30px, 8vw, var(--title-size, 36px)); }
  
  .chat-editor-header,
  .chat-terminal-head,
  .chat-shell-hero-head,
  .chat-context-drawer-summary {
    flex-direction: column;
    align-items: flex-start;
  }
  .chat-shell-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .chat-shell-toggle-label-full {
    display: none;
  }
  .chat-shell-toggle-label-short {
    display: inline;
  }
  .chat-runtime-grid.chat-runtime-grid-compact,
  .chat-rail-meta-grid {
    grid-template-columns: 1fr;
  }
  .chat-breadcrumb code {
    white-space: normal;
  }
  .chat-explorer-toolbar {
    align-items: flex-start;
  }
}