/* ==========================================================================
   Chat Z — Interface
   premium-dark-saas + minimalism · elevação por luz · 1 acento cirúrgico
   ========================================================================== */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    var(--gradient-ambient),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  letter-spacing: var(--tracking-tight);
  font-feature-settings: "cv01" 1, "cv11" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* textura atmosférica, sem competir com o conteúdo */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2000;
  pointer-events: none;
  opacity: 0.34;
  background: radial-gradient(circle at 1px 1px, oklch(1 0 0 / 0.035) 0.6px, transparent 0.8px) 0 0 / 5px 5px;
  -webkit-mask-image: linear-gradient(to bottom, black, transparent 72%);
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}
:root[data-theme="light"] body::after { opacity: 0.14; }

::selection { background: var(--accent-subtle); color: var(--text); }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
button:disabled { cursor: not-allowed; }

input, textarea, select {
  font: inherit;
  color: var(--text);
  letter-spacing: inherit;
}

svg { flex-shrink: 0; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
  border-radius: var(--r-4);
}

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- Shell ---------- */
.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100%;
  background: color-mix(in oklab, var(--bg-subtle) 94%, transparent);
  border-right: 1px solid var(--border-subtle);
  box-shadow: inset -1px 0 0 oklch(1 0 0 / 0.018);
  transition: margin-left var(--t-slow) var(--ease-out);
  z-index: 40;
}
.app.collapsed .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: var(--sp-3) var(--sp-3) var(--sp-2) var(--sp-4);
}

.brand {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-align: left;
  letter-spacing: var(--tracking-tighter);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  color: var(--accent);
  background: var(--gradient-obsidian);
  border: 1px solid oklch(1 0 0 / 0.08);
  box-shadow: 0 0 26px -8px var(--accent-glow), var(--sheen);
}
:root[data-theme="light"] .brand-mark { color: oklch(0.82 0.16 298); }
.brand-copy { display: grid; line-height: 1.15; }
.brand-copy strong { font-size: 14px; font-weight: 620; letter-spacing: -0.02em; }
.brand-copy small {
  margin-top: 3px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.brand-z { transition: transform var(--t-med) var(--ease-out); }
.brand:hover .brand-z { transform: rotate(-6deg) scale(1.05); }

.new-chat {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px var(--sp-3) var(--sp-3);
  padding: 11px 12px;
  border-radius: var(--r-12);
  border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--border));
  background: linear-gradient(135deg, var(--accent-subtle), var(--surface));
  box-shadow: var(--sheen), 0 12px 30px -24px var(--accent-glow);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.new-chat:hover { background: linear-gradient(135deg, color-mix(in oklab, var(--accent-subtle) 72%, var(--surface-hover)), var(--surface-hover)); border-color: color-mix(in oklab, var(--accent) 50%, var(--border)); }
.new-chat:active { transform: scale(0.985); }
.new-chat svg { color: var(--accent); }
.new-chat kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 1px 5px;
}

.conv-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 var(--sp-3) var(--sp-2);
  padding: 0 10px;
  border-radius: var(--r-8);
  border: 1px solid var(--border-subtle);
  background: color-mix(in oklab, var(--surface) 52%, transparent);
  color: var(--text-subtle);
  transition: border-color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.conv-search:focus-within {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
}
.conv-search input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  padding: 7px 0;
  font-size: var(--text-sm);
}
.conv-search input::placeholder { color: var(--text-subtle); }
.conv-search input::-webkit-search-cancel-button { display: none; }

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-1) var(--sp-3) var(--sp-4);
  overscroll-behavior: contain;
}

.conv-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-subtle);
  padding: var(--sp-5) 10px 6px;
  user-select: none;
}

.conv-item {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  gap: 8px;
  padding: 9px 10px;
  margin: 2px 0;
  border-radius: var(--r-12);
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: left;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.conv-copy {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 1px;
}
.conv-item:hover { background: var(--surface-hover); color: var(--text); }
.conv-item[aria-current="page"] {
  background: linear-gradient(90deg, var(--accent-subtle), transparent 92%);
  color: var(--text);
  font-weight: 500;
  box-shadow: inset 2px 0 0 var(--accent);
}
.conv-item .conv-name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-preview {
  overflow: hidden;
  color: var(--text-subtle);
  font-size: 10.5px;
  font-weight: 400;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-time {
  align-self: flex-start;
  padding-top: 1px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 8.5px;
  white-space: nowrap;
}
.conv-item:hover .conv-time { display: none; }
.conv-item .conv-del {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: var(--text-subtle);
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.conv-item:hover .conv-del,
.conv-item:focus-within .conv-del { opacity: 1; }
.conv-item .conv-del:hover { color: var(--danger); background: oklch(0.71 0.17 22 / 0.12); }

.conv-empty {
  padding: var(--sp-6) 10px;
  font-size: var(--text-sm);
  color: var(--text-subtle);
}

.sidebar-foot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-top: 1px solid var(--border-subtle);
  background: linear-gradient(to top, var(--bg-subtle), transparent);
}
.foot-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 7px 8px;
  border-radius: var(--r-8);
  font-size: var(--text-sm);
  color: var(--text-muted);
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.foot-btn:hover { background: var(--surface-hover); color: var(--text); }
.foot-count {
  margin-left: auto;
  min-width: 19px;
  padding: 0 5px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 17px;
  text-align: center;
}
.foot-count:empty { display: none; }

/* tema: mostra o ícone do modo oposto */
.theme-ico-light { display: none; }
:root[data-theme="light"] .theme-ico-light { display: block; }
:root[data-theme="light"] .theme-ico-dark { display: none; }

.scrim {
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease-out);
  z-index: 35;
}

/* ==========================================================================
   MAIN / TOPBAR
   ========================================================================== */
.main {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 60px;
  padding: 0 var(--sp-5);
  background: var(--glass);
  border-bottom: 1px solid color-mix(in oklab, var(--border-subtle) 64%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  backdrop-filter: blur(18px) saturate(130%);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.main .topbar-menu { display: none; }
.app.collapsed .main .topbar-menu { display: grid; }

.topbar-context {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.topbar-brand {
  display: none;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 9px;
  color: var(--accent);
  background: var(--accent-faint);
  border: 1px solid color-mix(in oklab, var(--accent) 26%, transparent);
}
.app.collapsed .topbar-brand { display: grid; }

.topbar-title {
  min-width: 0;
  display: flex;
  align-items: center;
  min-height: 30px;
}
.topbar-title-text {
  font-size: 13px;
  font-weight: 520;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40ch;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: text;
  transition: color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.topbar-title-empty {
  display: none;
  padding: 4px 8px;
  color: var(--text-subtle);
  font-size: 12px;
}
.topbar-title-text:empty + .topbar-title-empty { display: inline; }
.topbar-title-text:hover {
  color: var(--text-muted);
  background: var(--surface-hover);
}
.topbar-title-text:empty { display: none; }
.topbar-title input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 13px;
  width: 30ch;
}

.topbar-stats {
  margin-left: var(--sp-2);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-subtle);
  opacity: 0.8;
  white-space: nowrap;
}

.topbar-presence {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 4px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.presence-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--success) 15%, transparent);
}
.topbar-presence.offline .presence-dot { background: var(--warning); box-shadow: none; }

/* ==========================================================================
   THREAD
   ========================================================================== */
.thread-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}
.thread {
  height: 100%;
  overflow-y: auto;
  padding: 88px var(--sp-6) var(--sp-8);
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.thread-inner {
  max-width: var(--thread-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.jump-down {
  position: absolute;
  right: var(--sp-5);
  bottom: var(--sp-4);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-full);
  background: var(--surface-over);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-menu);
  color: var(--text-muted);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out);
  z-index: 15;
}
.jump-down.show { opacity: 1; transform: none; pointer-events: auto; }
.jump-down:hover { color: var(--text); border-color: var(--border-strong); }

/* ---------- Zero state ---------- */
.zero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: calc(100dvh - 76px - 184px);
  padding: var(--sp-10) var(--sp-4) var(--sp-8);
  animation: rise 400ms var(--ease-out);
}
.zero-z {
  width: 62px;
  height: 62px;
  margin-bottom: var(--sp-6);
  padding: 15px;
  border: 1px solid oklch(1 0 0 / 0.08);
  border-radius: 20px;
  color: var(--accent);
  background: var(--gradient-obsidian);
  box-shadow: 0 30px 80px -30px var(--accent-glow), 0 0 44px -14px var(--accent-glow), var(--sheen);
}
:root[data-theme="light"] .zero-z { color: oklch(0.8 0.16 298); border-color: oklch(1 0 0 / 0.14); }
.zero-z path.draw {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: zdraw 900ms var(--ease-out) 150ms forwards;
}
.zero-hi {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  max-width: 680px;
  font-size: clamp(2.55rem, 1.7rem + 3.1vw, 4.5rem);
  line-height: var(--leading-tight);
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.zero-sub {
  margin: var(--sp-4) 0 0;
  max-width: 42ch;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-muted);
}
.zero-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
  width: 100%;
  max-width: 690px;
  margin-top: var(--sp-12);
}
.zero-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  min-height: 118px;
  padding: 18px;
  border-radius: var(--r-16);
  border: 1px solid var(--border-subtle);
  background: linear-gradient(145deg, color-mix(in oklab, var(--surface) 58%, transparent), transparent);
  text-align: left;
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out);
  opacity: 0;
  animation: rise 420ms var(--ease-out) forwards;
}
.zero-card:nth-child(1) { animation-delay: 120ms; }
.zero-card:nth-child(2) { animation-delay: 170ms; }
.zero-card:nth-child(3) { animation-delay: 220ms; }
.zero-card:nth-child(4) { animation-delay: 270ms; }
.zero-card:hover {
  background: linear-gradient(145deg, var(--accent-faint), var(--surface));
  border-color: color-mix(in oklab, var(--accent) 42%, var(--border));
  transform: translateY(-3px);
  box-shadow: 0 20px 45px -34px var(--accent-glow), var(--sheen);
}
:root[data-theme="light"] .zero-card:hover { background: var(--accent-faint); }
.zero-card-kind {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--accent);
}
.zero-card-text {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-muted);
}
.zero-card:hover .zero-card-text { color: var(--text); }

/* ---------- Mensagens ---------- */
.msg { margin-bottom: clamp(1.8rem, 3.8vw, 3.25rem); }
.msg.entering { animation: rise 280ms var(--ease-out); }

/* usuário: superfície tonal à direita */
.msg.user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--sp-2);
}
.user-turn {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 7px;
  max-width: 100%;
}
.msg.user .bubble {
  max-width: min(85%, 36rem);
  padding: 11px 16px;
  color: var(--accent-fg);
  background: var(--gradient-ember);
  border: 1px solid transparent;
  border-radius: 18px 18px 6px 18px;
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.28), 0 14px 34px -22px var(--accent-glow);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-size: 15px;
  font-weight: 480;
  line-height: 1.55;
}
.msg.user .bubble a { color: var(--accent-fg); text-decoration-color: oklch(0 0 0 / 0.4); }
.user-actions {
  display: flex;
  gap: 2px;
  padding-bottom: 3px;
  opacity: 0;
  transform: translateX(4px);
  transition: opacity var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.msg.user:hover .user-actions,
.msg.user:focus-within .user-actions { opacity: 1; transform: none; }
.user-actions .icon-btn { width: 26px; height: 26px; }
.user-meta {
  padding-right: 4px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 9px;
  opacity: 0.72;
}
.msg.user .bubble-imgs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: flex-end;
}
.msg.user .bubble-imgs img {
  max-width: 160px;
  max-height: 160px;
  border-radius: var(--r-8);
  box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.1);
  display: block;
  cursor: zoom-in;
}

/* modelo: document-style no canvas */
.msg.model {
  position: relative;
  max-width: var(--measure);
  padding-left: 34px;
}
.msg-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: var(--sp-3);
  user-select: none;
}
.msg-head .msg-z {
  display: grid;
  place-items: center;
  position: absolute;
  left: 0;
  top: -2px;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  color: var(--accent);
  background: var(--accent-subtle);
}
.msg-author {
  font-size: 13px;
  font-weight: 550;
  color: var(--text);
}
.msg-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-subtle);
}
.msg-status.working {
  background: linear-gradient(90deg, var(--text-subtle) 0%, var(--accent) 45%, var(--accent-soft) 55%, var(--text-subtle) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer-text 2.4s linear infinite;
}
@keyframes shimmer-text { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.msg-body { min-width: 0; }

/* ações do turno */
.msg-actions {
  display: flex;
  gap: 4px;
  margin-top: var(--sp-3);
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease-out);
}
.msg.model:hover .msg-actions,
.msg.model:focus-within .msg-actions { opacity: 1; }
.msg-actions .icon-btn { width: 26px; height: 26px; }

/* caret de streaming + assinatura de conclusão */
.z-caret {
  display: inline-block;
  width: 2px;
  height: 1.02em;
  margin-left: 2px;
  vertical-align: -0.12em;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
  animation: blink 1.05s steps(2, start) infinite;
}
.z-enddot {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 5px;
  vertical-align: 0.06em;
  border-radius: var(--r-full);
  background: var(--accent);
  animation: cool 900ms var(--ease-out) forwards;
}

/* erro inline calmo */
.msg-error {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding: 10px 14px;
  border: 1px solid oklch(0.72 0.18 295 / 0.3);
  border-radius: var(--r-12);
  background: var(--accent-faint);
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.msg-error .btn { margin-left: auto; }

/* ==========================================================================
   MARKDOWN
   ========================================================================== */
.md { font-size: var(--text-base); line-height: var(--leading-body); overflow-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 0.9em; text-wrap: pretty; }
.md h1, .md h2, .md h3, .md h4 {
  font-weight: 600;
  letter-spacing: var(--tracking-tighter);
  line-height: var(--leading-snug);
  margin: 1.4em 0 0.5em;
  text-wrap: balance;
}
.md h1 { font-size: var(--text-xl); }
.md h2 { font-size: 1.19rem; }
.md h3 { font-size: 1.06rem; }
.md h4 { font-size: 1rem; }
.md ul, .md ol { margin: 0 0 0.9em; padding-left: 1.3em; }
.md li { margin: 0.3em 0; }
.md li::marker { color: var(--text-subtle); }
.md blockquote {
  margin: 0 0 0.9em;
  padding: 0.1em 0 0.1em 1em;
  border-left: 2px solid var(--border-strong);
  color: var(--text-muted);
}
.md a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.md a:hover { color: var(--accent-hover); }
.md hr { border: none; border-top: 1px solid var(--border-subtle); margin: 1.4em 0; }
.md strong { font-weight: 600; }
.md code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-hover);
  border-radius: 5px;
  padding: 0.12em 0.38em;
}
.md .codeblock {
  margin: 0 0 1em;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-12);
  background: var(--bg-subtle);
  overflow: hidden;
}
:root[data-theme="light"] .md .codeblock { background: oklch(0.965 0.004 265); }
.md .codeblock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.md .codeblock-lang {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-subtle);
}
.md .codeblock pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
}
.md .codeblock code {
  background: none;
  padding: 0;
  font-size: 0.84rem;
  line-height: 1.55;
  font-feature-settings: "calt" 1;
}
.md table {
  border-collapse: collapse;
  margin: 0 0 1em;
  font-size: var(--text-sm);
  display: block;
  max-width: 100%;
  overflow-x: auto;
}
.md th, .md td {
  border: 1px solid var(--border-subtle);
  padding: 7px 12px;
  text-align: left;
}
.md th {
  font-size: 12px;
  font-weight: 550;
  color: var(--text-muted);
  background: var(--bg-subtle);
}
.md .think {
  color: var(--text-subtle);
  font-size: var(--text-sm);
  border-left: 2px solid var(--border-subtle);
  padding-left: 1em;
  margin-bottom: 0.9em;
}

/* o que o modo Auto decidiu */
.route-chip {
  font-size: 11px;
  letter-spacing: 0.01em;
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--accent);
  border: 1px solid oklch(0.72 0.18 295 / 0.28);
  background: oklch(0.72 0.18 295 / 0.08);
  cursor: help;
  white-space: nowrap;
}

/* fontes de busca (grounding) */
.md-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--sp-3);
}
.md-sources a {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-subtle);
  text-decoration: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  padding: 3px 10px;
  transition: color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.md-sources a:hover { color: var(--accent); border-color: oklch(0.72 0.18 295 / 0.4); }

/* ==========================================================================
   MÍDIA GERADA
   ========================================================================== */
.media-card {
  position: relative;
  margin-top: var(--sp-2);
  max-width: 480px;
  border-radius: var(--r-4);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.1);
  background: var(--bg-subtle);
}
.media-card img, .media-card video {
  display: block;
  width: 100%;
  height: auto;
}
.media-card img { cursor: zoom-in; }
.media-card .media-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease-out);
}
.media-card:hover .media-actions,
.media-card:focus-within .media-actions { opacity: 1; }
.media-actions .icon-btn {
  background: oklch(0.145 0.004 265 / 0.72);
  backdrop-filter: blur(8px);
  color: oklch(0.945 0.002 265);
  border: 1px solid oklch(1 0 0 / 0.14);
}
.media-actions .icon-btn:hover { background: oklch(0.145 0.004 265 / 0.9); color: #fff; }

/* skeleton / render em progresso */
.media-pending {
  margin-top: var(--sp-2);
  max-width: 480px;
  border-radius: var(--r-4);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}
.media-pending .sk-canvas {
  position: relative;
  background: var(--bg-subtle);
  overflow: hidden;
}
.media-pending .sk-canvas::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, oklch(1 0 0 / 0.04) 50%, transparent 70%);
  animation: shimmer 1.5s var(--ease-in-out) infinite;
}
.media-pending .sk-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 9px 12px;
  border-top: 1px solid var(--border-subtle);
}
.media-pending .sk-label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.media-pending .sk-bar {
  position: relative;
  flex: 1;
  max-width: 120px;
  height: 2px;
  border-radius: 2px;
  background: var(--border-subtle);
  overflow: hidden;
}
.media-pending .sk-bar::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 40%;
  border-radius: 2px;
  background: var(--accent);
  animation: slide 1.3s var(--ease-in-out) infinite;
}

/* áudio TTS */
.audio-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
  max-width: 480px;
  padding: 10px 14px;
  border-radius: var(--r-12);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--sheen);
}
.audio-play {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  background: var(--accent-subtle);
  color: var(--accent);
  transition: background var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.audio-play:hover { background: oklch(0.72 0.18 295 / 0.2); }
.audio-play:active { transform: scale(0.94); }
.audio-play .i-pause { display: none; }
.audio-card.playing .i-pause { display: block; }
.audio-card.playing .i-play { display: none; }
.audio-wave {
  display: flex;
  align-items: center;
  gap: 2.5px;
  flex: 1;
  height: 30px;
}
.audio-wave i {
  flex: 1;
  min-width: 2px;
  border-radius: 2px;
  background: var(--border-strong);
  transform-origin: center;
  transition: background var(--t-med) var(--ease-out);
}
.audio-card.playing .audio-wave i {
  background: var(--accent);
  animation: wave 900ms var(--ease-in-out) calc(var(--i) * 60ms) infinite alternate;
}
.audio-time {
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-subtle);
}

/* visualizador de mídia em tela cheia */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: minmax(48px, 7vw) minmax(0, 1fr) minmax(48px, 7vw);
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: oklch(0.04 0.004 70 / 0.96);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  animation: fade var(--t-med) var(--ease-out);
  color: #fff;
  overscroll-behavior: contain;
}
.lightbox-topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  z-index: 3;
  background: linear-gradient(oklch(0 0 0 / 0.52), transparent);
}
.lightbox-count {
  font: 500 11px/1 var(--font-mono);
  letter-spacing: .04em;
  color: oklch(0.86 0 0);
  min-width: 5rem;
}
.lightbox-tools { display: flex; align-items: center; gap: 6px; }
.lightbox-tool,
.lightbox-nav {
  border: 1px solid oklch(1 0 0 / 0.14);
  background: oklch(0.16 0.004 70 / 0.78);
  color: #fff;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out), opacity var(--t-fast) var(--ease-out);
}
.lightbox-tool {
  min-width: 38px;
  height: 38px;
  padding: 0 11px;
  border-radius: var(--r-full);
  display: inline-grid;
  place-items: center;
  font: 500 13px/1 var(--font-mono);
}
.lightbox-tool:hover,
.lightbox-nav:hover { background: oklch(0.26 0.008 70 / 0.9); border-color: oklch(1 0 0 / 0.26); }
.lightbox-tool:active,
.lightbox-nav:active { transform: scale(.96); }
.lightbox-tool:focus-visible,
.lightbox-nav:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lightbox-tool:disabled { opacity: .35; cursor: default; }
.lightbox-viewport {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  touch-action: none;
  cursor: zoom-in;
  border-radius: var(--r-12);
}
.lightbox-viewport.zoomed { cursor: grab; }
.lightbox-viewport.zoomed:active { cursor: grabbing; }
.lightbox-stage {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.lightbox-media {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--r-8);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.1), 0 28px 90px -28px oklch(0 0 0 / 0.95);
  transform-origin: center;
  transition: transform 90ms linear;
  user-select: none;
  -webkit-user-drag: none;
}
video.lightbox-media {
  width: min(100%, 1200px);
  max-height: 100%;
  touch-action: manipulation;
}
.lightbox-nav {
  align-self: center;
  justify-self: center;
  width: 44px;
  height: 56px;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  font: 300 34px/1 system-ui, sans-serif;
  z-index: 2;
}
.lightbox-nav.prev { grid-column: 1; grid-row: 2; }
.lightbox-nav.next { grid-column: 3; grid-row: 2; }
.lightbox-hint {
  grid-column: 1 / -1;
  grid-row: 3;
  margin: 0;
  min-height: 42px;
  padding: 8px 16px max(10px, env(safe-area-inset-bottom));
  text-align: center;
  color: oklch(0.72 0 0);
  font: 500 10px/1.3 var(--font-mono);
  letter-spacing: .015em;
}
.lightbox-error {
  padding: 18px 22px;
  border: 1px solid oklch(1 0 0 / .12);
  border-radius: var(--r-12);
  color: oklch(.82 0 0);
  background: oklch(.14 0 0 / .72);
}
body.lightbox-open { overflow: hidden; touch-action: none; }

@media (max-width: 640px) {
  .lightbox { grid-template-columns: 44px minmax(0, 1fr) 44px; }
  .lightbox-topbar { min-height: 54px; }
  .lightbox-tool { min-width: 36px; height: 36px; padding-inline: 9px; }
  .lightbox-nav { width: 38px; height: 48px; font-size: 29px; }
  .lightbox-hint { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox, .lightbox-media { animation: none; transition: none; }
}

/* ==========================================================================
   COMPOSER
   ========================================================================== */
.composer-zone {
  position: relative;
  z-index: 10;
  padding: 0 var(--sp-6) calc(var(--sp-4) + env(safe-area-inset-bottom));
}
.composer-zone::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: -52px;
  height: 52px;
  background: linear-gradient(var(--bg-0), var(--bg));
  pointer-events: none;
}

.attach-strip {
  display: flex;
  gap: var(--sp-2);
  max-width: var(--composer-max);
  margin: 0 auto;
}
.attach-strip:not(:empty) { padding-bottom: var(--sp-2); }
.attach-chip {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: var(--r-8);
  overflow: hidden;
  border: 1px solid var(--border);
  animation: rise 200ms var(--ease-out);
}
.attach-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-chip button {
  position: absolute;
  top: 2px; right: 2px;
  display: grid;
  place-items: center;
  width: 16px; height: 16px;
  border-radius: var(--r-full);
  background: oklch(0.145 0.004 265 / 0.8);
  color: #fff;
}

.composer {
  position: relative;
  max-width: var(--composer-max);
  margin: 0 auto;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid color-mix(in oklab, var(--accent) 12%, var(--border));
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(16px) saturate(125%);
  backdrop-filter: blur(16px) saturate(125%);
  box-shadow: var(--shadow-composer);
  transition: border-color var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out);
}
.composer:focus-within {
  border-color: color-mix(in oklab, var(--accent) 48%, var(--border-strong));
  box-shadow: var(--shadow-composer), 0 0 0 3px var(--accent-faint), 0 0 40px -18px var(--accent-glow);
}
.composer.thinking {
  animation: breathe 2.2s var(--ease-in-out) infinite alternate;
}

.composer textarea {
  display: block;
  width: 100%;
  max-height: 40dvh;
  resize: none;
  background: none;
  border: none;
  outline: none;
  min-height: 58px;
  padding: 17px 18px 8px;
  font-size: 16px;
  line-height: 1.5;
  overflow-y: auto;
}
.composer textarea::placeholder { color: var(--text-subtle); }

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 7px 10px 10px;
}
.composer-left, .composer-right {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.model-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: var(--r-12);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.model-badge:hover, .model-badge[aria-expanded="true"] { background: var(--surface-hover); border-color: var(--border-subtle); color: var(--text); }
.model-badge svg:first-child { color: var(--accent); }
.model-badge .chev { color: var(--text-subtle); transition: transform var(--t-med) var(--ease-out); }
.model-badge[aria-expanded="true"] .chev { transform: rotate(180deg); }

.tool-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--r-full);
  border: 1px solid transparent;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-subtle);
  transition: color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.tool-toggle:hover { color: var(--text-muted); background: var(--surface-hover); }
.tool-toggle[aria-pressed="true"] {
  color: var(--accent);
  border-color: oklch(0.72 0.18 295 / 0.35);
  background: var(--accent-faint);
}
.tool-toggle.hidden, .live-btn.hidden { display: none; }

.media-opts { display: flex; align-items: center; gap: 4px; min-width: 0; overflow-x: auto; }
.chip-group {
  display: flex;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  padding: 2px;
}
.chip {
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-subtle);
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.chip:hover { color: var(--text-muted); }
.chip[aria-pressed="true"] { background: var(--accent-subtle); color: var(--accent); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-8);
  color: var(--text-subtle);
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn:active { transform: scale(0.93); }
.icon-btn.hidden { display: none; }
.icon-btn.ok { color: var(--success); }
.icon-btn.loading { opacity: 0.45; animation: pulse-soft 1.2s var(--ease-in-out) infinite; }
.icon-btn.playing { color: var(--accent); background: var(--accent-faint); }

.send {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: var(--send-glow);
  transition: background var(--t-fast) var(--ease-out), opacity var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.send:hover:not(:disabled) { background: var(--accent-hover); }
.send:active:not(:disabled) { transform: scale(0.93); }
.send:disabled { opacity: 0.35; box-shadow: none; }
.send .ico-stop { display: none; }
.send.generating .ico-stop { display: block; }
.send.generating .ico-send { display: none; }
.send.generating { background: var(--surface-over); color: var(--text); box-shadow: none; border: 1px solid var(--border-strong); opacity: 1; }

.composer-note {
  margin: var(--sp-2) auto 0;
  max-width: var(--composer-max);
  text-align: center;
  font-size: 11px;
  color: var(--text-subtle);
  opacity: 0.72;
  user-select: none;
}
.note-key {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0;
}

.edit-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  max-width: var(--composer-max);
  margin: 0 auto var(--sp-2);
  padding: 9px 10px 9px 13px;
  border: 1px solid color-mix(in oklab, var(--accent) 32%, var(--border));
  border-radius: var(--r-12);
  background: color-mix(in oklab, var(--accent-faint) 65%, var(--surface));
  box-shadow: var(--sheen);
}
.edit-notice[hidden] { display: none; }
.edit-notice > span { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.edit-notice strong { color: var(--accent); font-size: 12px; font-weight: 600; }
.edit-notice small { overflow: hidden; color: var(--text-subtle); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.drop-hint {
  position: absolute;
  z-index: 3;
  inset: 5px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1px dashed var(--accent);
  border-radius: 15px;
  color: var(--accent);
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease-out);
}
.drop-hint span { font-size: 13px; font-weight: 550; }
.composer.dragging .drop-hint { opacity: 1; }
.composer.dragging > :not(.drop-hint) { opacity: 0.14; }

/* ==========================================================================
   MODEL MENU
   ========================================================================== */
.model-menu {
  position: fixed;
  z-index: 60;
  min-width: 290px;
  padding: 6px;
  border-radius: var(--r-12);
  background: var(--surface-over);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-menu);
  transform-origin: bottom left;
  animation: pop 180ms var(--ease-out);
}
.model-menu hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 6px 8px;
}
.model-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-8);
  text-align: left;
  transition: background var(--t-fast) var(--ease-out);
}
.model-item:hover, .model-item:focus-visible { background: var(--surface-hover); outline: none; }
.model-item .mi-glyph {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-8);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  transition: color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.model-item:hover .mi-glyph { color: var(--accent); border-color: oklch(0.72 0.18 295 / 0.3); }
.model-item .mi-name { font-size: var(--text-sm); font-weight: 500; }
.model-item .mi-tag { font-size: 12px; color: var(--text-subtle); }
.model-item .mi-check { margin-left: auto; color: var(--accent); visibility: hidden; }
.model-item[aria-checked="true"] .mi-check { visibility: visible; }
.model-item[aria-checked="true"] .mi-glyph { color: var(--accent); border-color: oklch(0.72 0.18 295 / 0.35); background: var(--accent-faint); }

/* ==========================================================================
   DIALOGS
   ========================================================================== */
.dlg {
  width: min(30rem, calc(100vw - 2rem));
  max-height: min(85vh, 640px);
  padding: 0;
  border: none;
  border-radius: var(--r-16);
  background: var(--surface-over);
  color: var(--text);
  box-shadow: var(--shadow-overlay);
}
.dlg::backdrop {
  background: oklch(0 0 0 / 0.6);
  backdrop-filter: blur(2px);
}
.dlg[open] { animation: pop 200ms var(--ease-out); }

.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5) var(--sp-2);
}
.dlg-head h2 { margin: 0; font-size: var(--text-lg); font-weight: 600; letter-spacing: var(--tracking-tighter); }
.dlg-body { padding: var(--sp-2) var(--sp-5); overflow-y: auto; max-height: 60vh; }
.dlg-body h2 { margin: var(--sp-2) 0 0; font-size: var(--text-lg); font-weight: 600; letter-spacing: var(--tracking-tighter); }
.dlg-sub { color: var(--text-muted); font-size: var(--text-sm); margin: var(--sp-2) 0 0; }
.dlg-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
}

.set-group { margin-bottom: var(--sp-5); }
.set-group h3 {
  margin: 0 0 var(--sp-3);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-subtle);
}
.field { display: block; margin-bottom: var(--sp-3); }
.field-label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.field-row { display: flex; gap: var(--sp-2); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--r-8);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--text-sm);
  transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(0.72 0.18 295 / 0.15);
}
.field textarea { resize: vertical; min-height: 60px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--r-8);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.btn:active { transform: scale(0.97); }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn.primary { background: var(--accent); color: var(--accent-fg); box-shadow: var(--send-glow); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { color: var(--text-muted); border: 1px solid var(--border); background: transparent; }
.btn.ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn.danger { background: oklch(0.71 0.17 22 / 0.12); color: var(--danger); border: 1px solid oklch(0.71 0.17 22 / 0.3); }
.btn.danger:hover { background: oklch(0.71 0.17 22 / 0.2); }

/* ---------- galeria ---------- */
.gallery-dlg {
  width: min(68rem, calc(100vw - 2rem));
  height: min(48rem, calc(100dvh - 2rem));
  max-height: none;
  overflow: hidden;
}
.gallery-dlg .dlg-head {
  padding: var(--sp-5) var(--sp-6) var(--sp-3);
  border-bottom: 0;
}
.gallery-dlg .dlg-head > div { display: grid; gap: 2px; }
.dlg-kicker {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 550;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.gallery-tools {
  display: flex;
  gap: 5px;
  padding: var(--sp-2) var(--sp-6) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
}
.gallery-filter {
  padding: 6px 11px;
  border: 1px solid transparent;
  border-radius: var(--r-full);
  color: var(--text-subtle);
  font-size: 12px;
}
.gallery-filter:hover { color: var(--text); background: var(--surface-hover); }
.gallery-filter[aria-pressed="true"] {
  color: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 32%, var(--border));
  background: var(--accent-faint);
}
.gallery-filter span { margin-left: 4px; color: var(--text-subtle); font-family: var(--font-mono); font-size: 9px; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  align-content: start;
  gap: var(--sp-3);
  height: calc(100% - 133px);
  padding: var(--sp-5) var(--sp-6) var(--sp-6);
  overflow-y: auto;
}
.gallery-item {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-16);
  background: var(--bg-subtle);
  box-shadow: var(--sheen);
  transition: transform var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out);
}
.gallery-item:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.gallery-preview {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 0.78;
  overflow: hidden;
  background: var(--surface);
}
.gallery-preview img, .gallery-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-preview.audio { color: var(--accent); background: radial-gradient(circle at center, var(--accent-subtle), var(--surface)); }
.gallery-preview.audio svg { width: 28px; height: 28px; }
.gallery-kind {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 7px;
  border-radius: var(--r-full);
  color: #fff;
  background: oklch(0.12 0 0 / 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.gallery-info { display: grid; gap: 2px; padding: 10px 11px 11px; }
.gallery-title { overflow: hidden; color: var(--text-muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.gallery-date { color: var(--text-subtle); font-family: var(--font-mono); font-size: 9px; }
.gallery-open,
.gallery-delete {
  position: absolute;
  bottom: 7px;
  opacity: 0;
  background: var(--surface-over);
  box-shadow: var(--shadow-menu);
}
.gallery-open { right: 7px; }
.gallery-delete { right: 7px; color: var(--danger); }
.gallery-open ~ .gallery-delete { right: 39px; }
.gallery-open svg { transform: rotate(-90deg); }
.gallery-item:hover .gallery-open,
.gallery-item:focus-within .gallery-open,
.gallery-item:hover .gallery-delete,
.gallery-item:focus-within .gallery-delete { opacity: 1; }
.gallery-empty {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 18rem;
  color: var(--text-subtle);
  font-size: 13px;
  text-align: center;
}

/* ==========================================================================
   Z LIVE
   ========================================================================== */
.live-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: oklch(0.13 0.004 265 / 0.92);
  backdrop-filter: blur(20px);
  animation: fade var(--t-slow) var(--ease-out);
}
:root[data-theme="light"] .live-overlay { background: oklch(0.97 0.003 265 / 0.94); }
.live-overlay[hidden] { display: none; }

.live-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-6);
  padding: var(--sp-6);
  text-align: center;
}

.live-orb {
  position: relative;
  width: 216px;
  height: 216px;
  display: grid;
  place-items: center;
}
/* halo atmosférico — reage ao nível de voz */
.live-orb::before {
  content: "";
  position: absolute;
  inset: -32%;
  border-radius: var(--r-full);
  background: radial-gradient(circle, var(--accent-glow) 0%, oklch(0.5 0.25 282 / 0.16) 46%, transparent 70%);
  filter: blur(28px);
  opacity: 0.5;
  transform: scale(calc(1 + var(--lvl, 0) * 0.2));
  transition: opacity var(--t-slow) var(--ease-out-quart), transform 110ms linear;
}
.live-orb.listening::before,
.live-orb.speaking::before { opacity: 0.95; }

.live-orb-core {
  position: relative;
  width: 150px;
  height: 150px;
  border-radius: var(--r-full);
  overflow: hidden;
  background: radial-gradient(circle at 30% 25%,
    oklch(0.95 0.09 300),
    oklch(0.72 0.2 297) 38%,
    oklch(0.36 0.19 285) 72%,
    oklch(0.1 0.03 288) 100%);
  box-shadow:
    inset 0 0 70px oklch(0 0 0 / 0.5),
    0 0 130px -12px oklch(0.72 0.18 295 / 0.7),
    0 0 0 1px oklch(0.72 0.18 295 / 0.32);
  animation: orb-breathe 6s var(--ease-in-out) infinite;
}
/* brilho especular */
.live-orb-core::before {
  content: "";
  position: absolute;
  left: 10%;
  top: 8%;
  width: 40%;
  height: 40%;
  border-radius: var(--r-full);
  background: radial-gradient(circle, oklch(1 0 0 / 0.9), transparent 70%);
  filter: blur(5px);
  opacity: 0.85;
}
/* veio de magma + sheen cônico girando */
.live-orb-core::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(70% 40% at 70% 92%, oklch(0.16 0.07 285 / 0.7), transparent 60%),
    conic-gradient(from 220deg, transparent 0deg, oklch(1 0 0 / 0.1) 40deg, transparent 90deg, oklch(1 0 0 / 0.06) 200deg, transparent 260deg);
  mix-blend-mode: screen;
  animation: orb-spin 16s linear infinite;
}

.live-ring {
  position: absolute;
  width: 150px;
  height: 150px;
  border-radius: var(--r-full);
  border: 1px solid var(--accent);
  opacity: 0;
  pointer-events: none;
}
.live-orb.listening .live-ring,
.live-orb.speaking .live-ring { animation: ring-expand 2.4s var(--ease-out-quart) infinite; }
.live-orb.listening .r2,
.live-orb.speaking .r2 { animation-delay: 1.2s; }

.live-orb.listening .live-orb-core { animation: orb-listen 3.4s var(--ease-in-out) infinite; }
.live-orb.speaking .live-orb-core { animation: orb-breathe 1.1s var(--ease-in-out) infinite; }
.live-orb.connecting .live-orb-core { animation: pulse-soft 1.6s var(--ease-in-out) infinite; }

.live-state {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-subtle);
}
.live-caption {
  margin: 0;
  min-height: 3em;
  max-width: 44ch;
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-lg);
  line-height: 1.45;
  color: var(--text-muted);
  text-wrap: balance;
}
.live-controls { display: flex; gap: var(--sp-3); }
.live-controls .btn.muted { color: var(--danger); border-color: oklch(0.71 0.17 22 / 0.4); }

/* ==========================================================================
   LOGIN (modo hospedado)
   ========================================================================== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  background: var(--bg);
  overflow-y: auto;
}
.login-screen[hidden] { display: none; }

/* ---- painel de marca (esquerda) ---- */
.login-brand {
  position: relative;
  display: none;
  width: 45%;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg-subtle);
  border-right: 1px solid var(--border-subtle);
}
@media (min-width: 940px) { .login-brand { display: flex; } }
.login-aurora {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 60% at 12% 8%, oklch(0.6 0.22 300 / 0.34), transparent 70%),
    radial-gradient(50% 50% at 92% 96%, oklch(0.5 0.25 283 / 0.24), transparent 70%);
  filter: blur(24px);
}
.login-brand-copy { position: relative; z-index: 1; max-width: 32rem; padding: var(--sp-16); }
.login-brand-copy h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 1rem + 2.6vw, 3.1rem);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: var(--tracking-tighter);
}
.login-brand-copy h1 span { color: var(--accent); }
.login-rule { width: 48px; height: 4px; margin-top: var(--sp-6); background: var(--accent); }
.login-wordmark {
  position: absolute;
  left: var(--sp-16);
  bottom: var(--sp-16);
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

/* ---- painel do formulário (direita) ---- */
.login-panel {
  flex: 1;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
}
.login-box { width: min(26rem, 100%); animation: rise 420ms var(--ease-out); }
.login-head { margin-bottom: var(--sp-8); }
.login-head h2 {
  margin: 0 0 var(--sp-3);
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: var(--tracking-tighter);
}
.login-head p { margin: 0; color: var(--text-muted); font-size: 15px; }

.login-field { margin-bottom: var(--sp-4); }
.login-field label,
.login-field-head label {
  display: block;
  margin: 0 0 7px 4px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.login-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.login-field-head label { margin-bottom: 0; }
.login-field input {
  width: 100%;
  height: 54px;
  padding: 0 16px;
  border-radius: var(--r-12);
  border: 1px solid var(--border);
  background: oklch(1 0 0 / 0.03);
  font-size: 15px;
  transition: border-color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
:root[data-theme="light"] .login-field input { background: var(--surface); }
.login-field input::placeholder { color: var(--text-disabled); }
.login-field input:focus {
  outline: none;
  border-color: var(--accent-ring);
  background: oklch(1 0 0 / 0.05);
}
:root[data-theme="light"] .login-field input:focus { background: var(--surface); }

.login-link {
  color: var(--accent);
  font-size: 12px;
  opacity: 0.8;
  transition: opacity var(--t-fast) var(--ease-out);
}
.login-link:hover { opacity: 1; }
.login-link.strong {
  color: var(--text);
  font-size: inherit;
  border-bottom: 1px solid var(--border-strong);
  opacity: 1;
}
.login-link.strong:hover { color: var(--accent); border-bottom-color: var(--accent); }

.login-err {
  min-height: 1.2em;
  margin: 0 0 var(--sp-3);
  font-size: 13px;
  color: var(--danger);
}

.login-submit {
  width: 100%;
  height: 54px;
  border-radius: var(--r-12);
  background: var(--accent);
  color: var(--accent-fg);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  box-shadow: 0 0 26px -8px var(--accent-glow);
  transition: background var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.login-submit:hover:not(:disabled) { background: var(--accent-hover); }
.login-submit:active:not(:disabled) { transform: scale(0.99); }
.login-submit:disabled { opacity: 0.55; cursor: not-allowed; }

.login-foot {
  margin-top: var(--sp-10);
  text-align: center;
  color: var(--text-subtle);
  font-size: 14px;
}
.login-foot[hidden] { display: none; }

/* ==========================================================================
   HUB — vitrine da plataforma
   ========================================================================== */
.hub-screen {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg);
  background-image: var(--gradient-ambient);
}
.hub-screen[hidden] { display: none; }
.hub-screen::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image:
    linear-gradient(oklch(1 0 0 / 0.5) 1px, transparent 1px),
    linear-gradient(90deg, oklch(1 0 0 / 0.5) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse at center, black 35%, transparent 78%);
  mask-image: radial-gradient(ellipse at center, black 35%, transparent 78%);
}
:root[data-theme="light"] .hub-screen::before { opacity: 0.04; background-image: linear-gradient(oklch(0 0 0 / 0.5) 1px, transparent 1px), linear-gradient(90deg, oklch(0 0 0 / 0.5) 1px, transparent 1px); }

.hub-top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 clamp(var(--sp-4), 4vw, var(--sp-10));
}
.hub-brand { display: flex; align-items: center; gap: 10px; }
.hub-brand strong { font-size: var(--text-sm); font-weight: 600; letter-spacing: var(--tracking-tighter); }
.hub-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  color: oklch(0.78 0.16 297);
  background: var(--gradient-obsidian);
  border: 1px solid oklch(1 0 0 / 0.08);
  box-shadow: 0 0 22px -8px var(--accent-glow), var(--sheen);
}
.hub-top-right { display: flex; align-items: center; gap: var(--sp-2); }
.hub-user,
.hub-exit {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  color: var(--text-subtle);
  font-size: 12px;
}
.hub-user[hidden], .hub-exit[hidden] { display: none; }
.hub-user::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
  background: var(--success);
}
.hub-exit { transition: color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out); }
.hub-exit:hover { color: var(--text); border-color: var(--border-strong); }

.hub-main {
  position: relative;
  z-index: 1;
  flex: 1;
  display: grid;
  place-items: center;
  padding: var(--sp-6) var(--sp-4) var(--sp-10);
}
.hub-list {
  display: grid;
  gap: var(--sp-4);
  width: 100%;
  max-width: 44rem;
}

.hub-tile {
  /* o tile é sempre um card escuro: fixa o acento claro para legibilidade
     também no tema claro, onde --accent é violeta profundo */
  --accent: oklch(0.75 0.17 297);
  --accent-fg: oklch(0.14 0.02 290);
  --accent-ring: oklch(0.75 0.17 297 / 0.5);
  --accent-glow: oklch(0.75 0.17 297 / 0.42);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  min-height: 168px;
  padding: var(--sp-6) clamp(var(--sp-5), 3vw, var(--sp-8));
  border-radius: 26px;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  text-align: left;
  isolation: isolate;
  opacity: 0;
  animation: rise 550ms var(--ease-out-quart) forwards;
  transition: transform var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out);
}
.hub-tile:nth-child(1) { animation-delay: 40ms; }
.hub-tile:nth-child(2) { animation-delay: 130ms; }
.hub-tile:nth-child(3) { animation-delay: 220ms; }
.hub-tile:nth-child(4) { animation-delay: 310ms; }

/* arte de fundo por tile (sem imagens externas: CSP-safe) */
.hub-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  transition: transform var(--t-slow) var(--ease-out);
}
.hub-tile[data-art="criativo"]::before {
  background:
    radial-gradient(70% 120% at 88% 18%, oklch(0.68 0.22 300 / 0.85), transparent 62%),
    radial-gradient(60% 100% at 68% 92%, oklch(0.5 0.24 283 / 0.7), transparent 60%),
    var(--gradient-obsidian);
}
.hub-tile[data-art="especialista"]::before {
  background:
    radial-gradient(70% 120% at 88% 22%, oklch(0.6 0.2 262 / 0.7), transparent 62%),
    radial-gradient(60% 100% at 72% 90%, oklch(0.46 0.2 292 / 0.6), transparent 60%),
    var(--gradient-obsidian);
}
.hub-tile[data-art="hub"]::before {
  background:
    radial-gradient(70% 120% at 88% 20%, oklch(0.62 0.2 318 / 0.7), transparent 62%),
    radial-gradient(60% 100% at 70% 92%, oklch(0.45 0.22 288 / 0.6), transparent 60%),
    var(--gradient-obsidian);
}
.hub-tile[data-art="influencer"]::before {
  background:
    radial-gradient(70% 120% at 88% 22%, oklch(0.66 0.21 288 / 0.75), transparent 62%),
    radial-gradient(60% 100% at 70% 90%, oklch(0.48 0.24 272 / 0.6), transparent 60%),
    var(--gradient-obsidian);
}
/* véu escuro da esquerda para o texto respirar */
.hub-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg,
    oklch(0.11 0.014 288 / 0.96) 0%,
    oklch(0.11 0.014 288 / 0.8) 44%,
    oklch(0.11 0.014 288 / 0.3) 70%,
    transparent 100%);
}
.hub-tile-copy { display: grid; gap: 5px; max-width: 68%; position: relative; }
.hub-kicker {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.hub-title {
  color: oklch(0.97 0.005 290);
  font-size: clamp(1.2rem, 0.7rem + 1.7vw, 1.9rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: var(--tracking-tighter);
  text-transform: uppercase;
}
.hub-title em { font-style: normal; color: var(--accent); }
.hub-desc {
  margin-top: 3px;
  color: oklch(0.78 0.012 290);
  font-size: 13.5px;
  line-height: 1.45;
}
.hub-go {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: var(--r-full);
  border: 1px solid oklch(1 0 0 / 0.12);
  background: oklch(1 0 0 / 0.06);
  color: oklch(0.97 0 0);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: background var(--t-med) var(--ease-out), color var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out);
}

/* tile ativo */
.hub-tile:not(.locked) { cursor: pointer; }
.hub-tile:not(.locked):hover {
  transform: translateY(-2px);
  border-color: var(--accent-ring);
  box-shadow: 0 26px 70px -34px var(--accent-glow);
}
.hub-tile:not(.locked):hover::before { transform: scale(1.05); }
.hub-tile:not(.locked):hover .hub-go {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
  transform: translateX(2px);
}
.hub-tile:not(.locked):active { transform: translateY(0) scale(0.995); }

/* tiles bloqueados */
.hub-tile.locked { cursor: not-allowed; }
.hub-tile.locked .hub-tile-copy { opacity: 0.5; }
.hub-tile.locked::before { filter: saturate(0.25); }
.hub-soon {
  flex-shrink: 0;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

@media (max-width: 620px) {
  .hub-tile { min-height: 150px; border-radius: 20px; }
  .hub-tile-copy { max-width: 74%; }
  .hub-go { width: 40px; height: 40px; }
  .hub-desc { font-size: 12.5px; }
}

/* conta / cota (modo hospedado) */
.set-group.account { display: none; }
body.hosted .set-group.account { display: block; }
body.hosted .set-group.access { display: none; }
.account-row {
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-8);
  background: var(--surface);
}
.account-name { font-size: var(--text-sm); font-weight: 500; }
.account-name::before { content: "●"; color: var(--success); font-size: 9px; margin-right: 8px; vertical-align: 1px; }

.quota-note {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-subtle);
  white-space: nowrap;
  padding: 3px 9px;
  border: 1px dashed var(--border);
  border-radius: var(--r-full);
}
.quota-note.full { color: var(--warning); border-color: oklch(0.83 0.16 84 / 0.4); }

.media-deleted {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-subtle);
  padding: 6px 0;
}

/* ==========================================================================
   TOASTS
   ========================================================================== */
.toasts {
  position: fixed;
  left: var(--sp-5);
  bottom: var(--sp-5);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  min-width: 200px;
  max-width: 340px;
  border-radius: var(--r-12);
  background: var(--surface-over);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  box-shadow: var(--shadow-menu);
  font-size: var(--text-sm);
  animation: rise 240ms var(--ease-out);
}
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--success); }
.toast.leaving { animation: sink 200ms var(--ease-in) forwards; }

/* ==========================================================================
   KEYFRAMES
   ========================================================================== */
@keyframes rise { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
@keyframes sink { to { opacity: 0; transform: translateY(6px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop  { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes zdraw { to { stroke-dashoffset: 0; } }
@keyframes cool {
  0%   { box-shadow: 0 0 12px var(--accent-glow); background: var(--accent); }
  100% { box-shadow: none; background: var(--text-subtle); }
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes slide { from { left: -40%; } to { left: 100%; } }
@keyframes pulse-soft { 50% { opacity: 0.45; } }
@keyframes breathe {
  from { box-shadow: var(--sheen); }
  to   { box-shadow: inset 0 1px 0 oklch(0.72 0.18 295 / 0.25), inset 0 22px 26px -18px oklch(0.72 0.18 295 / 0.12); }
}
@keyframes wave { from { transform: scaleY(0.35); } to { transform: scaleY(1); } }
@keyframes ripple {
  0%   { opacity: 0.5; transform: scale(0.62); }
  100% { opacity: 0; transform: scale(1.18); }
}
@keyframes orb-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}
@keyframes orb-listen {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25%      { transform: scale(1.08) rotate(2deg); }
  50%      { transform: scale(1.02) rotate(-2deg); }
  75%      { transform: scale(1.1) rotate(1deg); }
}
@keyframes orb-spin { to { transform: rotate(360deg); } }
@keyframes ring-expand {
  0%   { transform: scale(0.62); opacity: 0.85; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* ==========================================================================
   RESPONSIVO
   ========================================================================== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-104%);
    transition: transform 280ms cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: none;
    margin-left: 0 !important;
  }
  .app.nav-open .sidebar {
    transform: none;
    box-shadow: 0 0 60px oklch(0 0 0 / 0.5);
  }
  .app.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .sidebar-collapse { display: none; }
  .topbar-menu { display: grid !important; }
  .thread { padding: 76px var(--sp-4) var(--sp-6); }
  .composer-zone { padding: 0 var(--sp-3) calc(var(--sp-3) + env(safe-area-inset-bottom)); }
  .topbar-stats { display: none; }
  .topbar { height: 56px; padding-inline: var(--sp-3); }
  .topbar-brand { display: grid; }
  .topbar-presence { padding-inline: 7px; }
  .presence-label { display: none; }
  .zero-grid { grid-template-columns: 1fr; max-width: 420px; margin-top: var(--sp-8); }
  .zero { min-height: calc(100dvh - 220px); }
  .msg.user .bubble { max-width: 92%; }
  .msg.model { padding-left: 31px; }
  .composer-note { overflow: hidden; height: 16px; white-space: nowrap; }
  .tool-toggle span { display: none; }
  .tool-toggle { padding: 6px 8px; }
  .toasts { left: var(--sp-3); right: var(--sp-3); bottom: auto; top: var(--sp-3); }
  .toast { max-width: none; width: 100%; }
  .model-menu { min-width: 260px; }
  .composer textarea { padding: 12px 14px 4px; }
  .gallery-dlg { width: calc(100vw - 1rem); height: calc(100dvh - 1rem); }
  .gallery-dlg .dlg-head { padding: var(--sp-4); }
  .gallery-tools { padding: var(--sp-2) var(--sp-4) var(--sp-3); overflow-x: auto; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); height: calc(100% - 121px); padding: var(--sp-3); }
}

@media (max-width: 520px) {
  .zero-hi { font-size: clamp(2.35rem, 12vw, 3.25rem); }
  .zero-sub { font-size: 14px; }
  .zero-grid { gap: var(--sp-2); }
  .zero-card { min-height: 104px; padding: 15px; }
  .model-badge { padding-inline: 8px; }
  .model-badge .chev { display: none; }
  .media-opts { max-width: 44vw; }
  .edit-notice small { display: none; }
  .gallery-grid { grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
}

@media (hover: none) {
  .msg-actions { opacity: 1; }
  .user-actions { opacity: 1; transform: none; }
  .media-card .media-actions { opacity: 1; }
  .conv-item .conv-del { opacity: 1; }
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  .z-caret { animation: none; opacity: 1; }
  .thread { scroll-behavior: auto; }
}
