:root {
  --bg: #262624;
  --sidebar: #1f1e1d;
  --surface: #30302e;
  --surface-2: #3a3936;
  --hover: rgba(255, 255, 255, 0.06);
  --active: rgba(255, 255, 255, 0.1);
  --border: rgba(222, 220, 209, 0.15);
  --border-strong: rgba(222, 220, 209, 0.28);
  --text: #faf9f5;
  --text-2: #c2c0b6;
  --muted: #9c9a92;
  --accent: #d97757;
  --accent-hover: #c6613f;
  --user-bubble: #141413;
  --code-bg: #1a1918;
  --danger: #e5746a;
  --ok: #7bbf7b;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --serif: "Source Serif 4", "Tiempos Text", Georgia, "Times New Roman", serif;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #faf9f5;
    --sidebar: #f5f4ed;
    --surface: #ffffff;
    --surface-2: #f0eee6;
    --hover: rgba(0, 0, 0, 0.045);
    --active: rgba(0, 0, 0, 0.08);
    --border: rgba(31, 30, 29, 0.15);
    --border-strong: rgba(31, 30, 29, 0.3);
    --text: #141413;
    --text-2: #3d3d3a;
    --muted: #73726c;
    --user-bubble: #f0eee6;
    --code-bg: #f5f4ed;
    --danger: #b53333;
    --ok: #2f7d32;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.spark {
  display: inline-block;
  width: 26px; height: 26px;
  background: url(/icon.svg) center / contain no-repeat;
}
.spark.big { width: 36px; height: 36px; }
.brand-name { font-family: var(--serif); font-size: 22px; letter-spacing: -0.01em; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: transparent;
  font-weight: 500;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-primary:hover { background: var(--text-2); border-color: var(--text-2); }
.btn-block { width: 100%; padding: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: 0; border-radius: 8px;
  background: transparent;
  color: var(--text-2);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.outline { border: 1px solid var(--border); }

/* ---------- Campos ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--text-2); font-weight: 500; }
.field small { font-size: 12px; color: var(--muted); }
.field code { font-family: var(--mono); font-size: 11.5px; background: var(--hover); padding: 1px 4px; border-radius: 4px; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 80px; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.form-error { color: var(--danger); font-size: 13px; min-height: 0; }
.form-error:empty { display: none; }

/* ---------- Login ---------- */
.auth-view {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 16px;
  background:
    radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 420px; text-align: center; }
.auth-brand { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 40px; }
.auth-title {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(36px, 7vw, 52px); line-height: 1.08; letter-spacing: -0.02em;
  margin: 0 0 14px;
}
.auth-subtitle { color: var(--text-2); margin: 0 0 32px; font-size: 16px; }
.auth-form {
  display: flex; flex-direction: column; gap: 16px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.auth-foot { color: var(--muted); font-size: 12.5px; margin-top: 20px; }

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

.sidebar {
  width: 288px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  transition: margin-left .2s ease, transform .2s ease;
  z-index: 30;
}
.app-view.collapsed .sidebar { margin-left: -288px; }
.sidebar-top { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; }
.sidebar-brand { font-size: 20px; }

.search {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 10px 8px; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg);
  color: var(--muted);
}
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; color: var(--text); }
.search:focus-within { border-color: var(--border-strong); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 8px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; text-align: left; color: var(--text-2);
}
.nav-item:hover { background: var(--hover); color: var(--text); }
#btn-new { color: var(--text); }
#btn-new svg { background: var(--accent); color: #fff; border-radius: 50%; padding: 2px; width: 20px; height: 20px; stroke-width: 2; }

.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.conv-group-title { font-size: 12px; color: var(--muted); padding: 14px 10px 6px; }
.conv-item {
  position: relative;
  display: flex; align-items: center;
  border-radius: 8px;
}
.conv-item a {
  flex: 1; min-width: 0;
  padding: 7px 10px;
  color: var(--text-2); text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 14px;
}
.conv-item:hover { background: var(--hover); }
.conv-item:hover a, .conv-item.active a { color: var(--text); }
.conv-item.active { background: var(--active); }
.conv-item .more {
  opacity: 0; width: 28px; height: 28px; margin-right: 2px;
}
.conv-item:hover .more, .conv-item.active .more, .conv-item .more[aria-expanded="true"] { opacity: 1; }
.conv-empty { color: var(--muted); font-size: 13px; padding: 12px 10px; }

.sidebar-footer { position: relative; padding: 8px; border-top: 1px solid var(--border); }
.user-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px; border: 0; border-radius: 10px; background: transparent; text-align: left;
}
.user-btn:hover { background: var(--hover); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--text-2); color: var(--bg);
  font-weight: 600; font-size: 13px; flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 12px; color: var(--muted); }
.chev { width: 16px; height: 16px; color: var(--muted); }

.menu {
  position: absolute;
  min-width: 180px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 100;
  display: flex; flex-direction: column;
}
.menu button {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; text-align: left; font-size: 14px;
}
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }
.menu button.selected { background: var(--active); }
#user-menu { bottom: calc(100% + 4px); left: 8px; right: 8px; }

.sidebar-backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; min-height: 52px;
}
.topbar-title {
  flex: 1; min-width: 0; text-align: center;
  font-size: 14px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#btn-open-sidebar { visibility: hidden; }
.app-view.collapsed #btn-open-sidebar { visibility: visible; }

.scroller { flex: 1; overflow-y: auto; scroll-behavior: auto; }

/* ---------- Tela inicial ---------- */
.welcome { display: none; }
.main.empty .welcome { display: flex; }
.main.empty .scroller { flex: 0 0 auto; margin-top: auto; overflow: visible; }
.main.empty .composer-wrap { margin-bottom: auto; }
.main.empty .disclaimer { display: none; }
.main.empty .topbar-title { visibility: hidden; }
.welcome { justify-content: center; padding: 0 16px 28px; }
.greeting {
  display: flex; align-items: center; gap: 14px;
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(30px, 5vw, 42px); letter-spacing: -0.015em;
  margin: 0; text-align: center;
}

/* ---------- Mensagens ---------- */
.messages { max-width: 768px; margin: 0 auto; padding: 8px 24px 24px; }
.msg { margin: 20px 0; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble {
  max-width: 85%;
  background: var(--user-bubble);
  border-radius: 16px;
  padding: 10px 16px;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg-images { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-bottom: 8px; }
.msg-images img {
  max-width: 220px; max-height: 220px; border-radius: 12px;
  border: 1px solid var(--border); cursor: zoom-in; object-fit: cover;
}

.msg.assistant .content {
  font-family: var(--serif);
  font-size: 16.5px; line-height: 1.65;
  word-wrap: break-word;
}
.content > :first-child { margin-top: 0; }
.content > :last-child { margin-bottom: 0; }
.content p { margin: 0 0 14px; }
.content h1, .content h2, .content h3, .content h4 { font-family: var(--serif); font-weight: 600; line-height: 1.3; margin: 22px 0 10px; }
.content h1 { font-size: 1.5em; } .content h2 { font-size: 1.3em; } .content h3 { font-size: 1.12em; }
.content ul, .content ol { padding-left: 24px; margin: 0 0 14px; }
.content li { margin: 4px 0; }
.content a { color: var(--accent); }
.content blockquote { margin: 0 0 14px; padding-left: 14px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.content hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.content table { border-collapse: collapse; margin: 0 0 14px; font-family: var(--sans); font-size: 14px; display: block; overflow-x: auto; }
.content th, .content td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.content th { background: var(--hover); }
.content :not(pre) > code {
  font-family: var(--mono); font-size: .85em;
  background: var(--hover); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 5px;
}
.code-block { margin: 0 0 14px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px 6px 14px; font-family: var(--sans); font-size: 12px; color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.code-head button { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 4px 8px; border-radius: 6px; }
.code-head button:hover { background: var(--hover); color: var(--text); }
.code-block pre { margin: 0; padding: 14px; overflow-x: auto; }
.code-block code { font-family: var(--mono); font-size: 13px; line-height: 1.55; }

.thinking { margin: 0 0 12px; border: 1px solid var(--border); border-radius: 12px; font-family: var(--sans); }
.thinking summary { cursor: pointer; padding: 8px 12px; font-size: 13px; color: var(--muted); user-select: none; }
.thinking .thinking-body { padding: 0 14px 12px; font-size: 13.5px; color: var(--text-2); white-space: pre-wrap; max-height: 360px; overflow: auto; }

.msg-actions { display: flex; align-items: center; gap: 2px; margin-top: 8px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg.last .msg-actions { opacity: 1; }
.msg.user .msg-actions { justify-content: flex-end; }
.msg-actions .icon-btn { width: 28px; height: 28px; }
.msg-actions svg { width: 16px; height: 16px; }
.msg-meta { font-size: 12px; color: var(--muted); margin-left: 8px; font-family: var(--sans); }

.msg-error {
  border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
  border-radius: 12px; padding: 10px 14px; font-size: 14px;
}

.cursor::after {
  content: ""; display: inline-block;
  width: 10px; height: 10px; margin-left: 4px;
  background: var(--accent); border-radius: 50%;
  vertical-align: middle;
  animation: pulse 1s ease-in-out infinite;
}
.typing { display: inline-flex; padding: 6px 0; }
.typing .spark { width: 28px; height: 28px; animation: spin 2.4s linear infinite; }
@keyframes pulse { 50% { opacity: .3; transform: scale(.8); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Composer ---------- */
.composer-wrap { padding: 0 16px 12px; }
.composer {
  max-width: 720px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 12px 12px 10px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .12);
  transition: border-color .15s;
}
.composer:focus-within { border-color: var(--border-strong); }
.composer textarea {
  display: block; width: 100%;
  min-height: 28px; max-height: 280px;
  padding: 4px 6px 8px;
  border: 0; background: transparent; outline: none; resize: none;
  font-size: 16px; line-height: 1.5;
}
.composer textarea::placeholder { color: var(--muted); }
.composer-bar { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }

.attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 4px 10px; }
.attachments:empty { display: none; }
.thumb { position: relative; width: 72px; height: 72px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.thumb button {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.thumb button svg { width: 12px; height: 12px; stroke-width: 2; }

.model-picker { position: relative; }
.model-btn {
  display: inline-flex; align-items: center; gap: 4px;
  border: 0; background: transparent; border-radius: 8px;
  padding: 6px 8px; font-size: 14px; color: var(--text-2);
  max-width: 240px;
}
.model-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-btn:hover { background: var(--hover); color: var(--text); }
.model-menu { bottom: calc(100% + 6px); right: 0; max-height: 320px; overflow-y: auto; min-width: 240px; }
.model-menu button { flex-direction: column; align-items: flex-start; gap: 0; }
.model-menu small { color: var(--muted); font-size: 12px; }
.model-menu .menu-note { padding: 8px 10px; font-size: 13px; color: var(--muted); }

.send-btn {
  width: 34px; height: 34px; border: 0; border-radius: 10px;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, opacity .15s;
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:disabled { opacity: .4; cursor: default; }
.send-btn svg { stroke-width: 2; }
.send-btn .ic-stop { display: none; fill: currentColor; stroke: none; }
.send-btn.streaming .ic-send { display: none; }
.send-btn.streaming .ic-stop { display: block; }

.disclaimer { text-align: center; font-size: 12px; color: var(--muted); margin: 8px 0 0; }

.drop-overlay {
  position: absolute; inset: 0; z-index: 50;
  display: none; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(2px);
}
.drop-overlay div {
  padding: 36px 48px; border: 2px dashed var(--accent); border-radius: 20px;
  font-family: var(--serif); font-size: 22px;
}
.main.dragging .drop-overlay { display: flex; }

/* ---------- Modal ---------- */
.modal {
  width: min(600px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal[open] { display: flex; flex-direction: column; }
.modal::backdrop { background: rgba(0, 0, 0, .55); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 8px; }
.modal-head h2 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 22px; }
.tabs { display: flex; gap: 4px; padding: 0 20px; border-bottom: 1px solid var(--border); }
.tab {
  border: 0; background: transparent; padding: 10px 12px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 14px;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel { padding: 20px; overflow-y: auto; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack h3 { margin: 8px 0 0; font-size: 15px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.test-result { font-size: 13px; }
.test-result.ok { color: var(--ok); }
.test-result.err { color: var(--danger); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.user-form-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list-title { margin: 24px 0 10px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 15px; }
.user-list { display: flex; flex-direction: column; gap: 4px; }
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px;
}
.user-row .info { flex: 1; min-width: 0; }
.user-row small { color: var(--muted); }

/* ---------- Diversos ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, .85);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out; padding: 24px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: var(--shadow); z-index: 300;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); margin-left: 0 !important; box-shadow: var(--shadow); }
  .app-view.mobile-open .sidebar { transform: none; }
  .app-view.mobile-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; }
  #btn-open-sidebar { visibility: visible; }
  .messages { padding: 8px 16px 16px; }
  .msg.user .bubble { max-width: 92%; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .model-btn { max-width: 150px; }
}

/* ---------- Raciocínio / preferências ---------- */
.hide-thinking .thinking { display: none !important; }
.typing { align-items: center; gap: 10px; }
.typing-label { font-family: var(--sans); font-size: 14px; color: var(--muted); }
.model-effort { color: var(--muted); }
.model-menu { min-width: 280px; max-height: 70vh; }
.menu-section { font-size: 12px; color: var(--muted); padding: 8px 10px 4px; }
.menu-prefs { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 2px; }
.pref-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 10px; font-size: 14px; border-radius: 8px;
}
.pref-row > span { display: flex; flex-direction: column; }
.pref-row small { font-size: 12px; color: var(--muted); margin-top: 2px; }
.switch {
  appearance: none; -webkit-appearance: none; flex-shrink: 0;
  width: 36px; height: 20px; border-radius: 999px; margin: 0;
  background: var(--border-strong); position: relative; cursor: pointer;
  transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform .15s;
}
.switch:checked { background: #3a8bb7; }
.switch:checked::after { transform: translateX(16px); }
.switch:disabled { opacity: .4; cursor: default; }
.segmented { display: inline-flex; background: var(--hover); border-radius: 8px; padding: 2px; }
.segmented button {
  border: 0; background: transparent; padding: 3px 10px; border-radius: 6px;
  font-size: 13px; color: var(--text-2);
}
.menu .segmented button:hover { background: transparent; color: var(--text); }
.segmented button[aria-checked="true"] { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.segmented button:disabled { opacity: .4; cursor: default; }
.group { border: 1px solid var(--border); border-radius: 12px; padding: 6px 4px; margin: 0; }
.group legend { font-size: 13px; color: var(--text-2); font-weight: 500; padding: 0 6px; }
.select-sm { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--bg); }

/* ---------- Mostrar senha ---------- */
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 32px; height: 32px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.pw-toggle:hover { background: var(--hover); color: var(--text); }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input::-ms-reveal { display: none; }

/* ---------- Pesquisa na web ---------- */
.tool-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: transparent; color: var(--text-2); font-size: 13.5px;
  transition: background .15s, color .15s, border-color .15s;
}
.tool-toggle svg { width: 16px; height: 16px; }
.tool-toggle:hover { background: var(--hover); color: var(--text); }
.tool-toggle.active {
  color: #6cb4e0; border-color: color-mix(in srgb, #3a8bb7 55%, transparent);
  background: color-mix(in srgb, #3a8bb7 16%, transparent);
}
.tool-toggle.active.warn { color: var(--muted); border-style: dashed; background: transparent; }
@media (max-width: 520px) { .tool-toggle span { display: none; } .tool-toggle { width: 32px; padding: 0; justify-content: center; } }

.tool-steps { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-family: var(--sans); }
.tool-steps:empty { display: none; }
.tool-step { border: 1px solid var(--border); border-radius: 10px; font-size: 13.5px; }
.tool-step summary {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; color: var(--text-2); cursor: pointer; user-select: none; list-style: none;
}
.tool-step summary::-webkit-details-marker { display: none; }
.tool-step summary.empty { cursor: default; }
.tool-step summary svg { width: 15px; height: 15px; color: var(--muted); }
.tool-step summary span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-step.running summary svg { color: var(--accent); animation: pulse 1s ease-in-out infinite; }
.tool-step.failed summary, .tool-step.failed summary svg { color: var(--danger); }
.tool-step-body { display: flex; flex-direction: column; padding: 0 8px 8px; }
.tool-step.failed .tool-step-body { padding: 0 12px 10px; color: var(--muted); font-size: 12.5px; }
.tool-step-body a {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 5px 6px; border-radius: 6px; color: var(--text-2); text-decoration: none;
}
.tool-step-body a:hover { background: var(--hover); color: var(--text); }
.tool-step-body .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-step-body .h { color: var(--muted); flex-shrink: 0; font-size: 12px; }
.group-body { display: flex; flex-direction: column; gap: 14px; padding: 6px 10px 8px; }
.field small a { color: var(--accent); }

/* ---------- Duplicar usuário ---------- */
.user-form-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.user-form-head h3 { margin: 0; }
.link-btn { border: 0; background: transparent; color: var(--accent); font-size: 13px; padding: 0; }
.link-btn:hover { text-decoration: underline; }
