:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --panel-2: #efece5;
  --text: #1d211f;
  --muted: #6b716d;
  --line: #e2ded5;
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --claude: #c2643a;
  --codex: #3b5bab;
  --warn: #b5432f;
  --mine: #e7f0ea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161917; --panel: #1e2220; --panel-2: #262b28; --text: #e7e9e6; --muted: #9aa19c;
    --line: #2f3531; --accent: #5fae86; --accent-ink: #0f1411; --claude: #e08a5f; --codex: #7f9be6;
    --warn: #e2735f; --mine: #23302a; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--warn); min-height: 1.2em; margin: 0; }
.spacer { flex: 1; }

button, .btn-like { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; }
button:hover, .btn-like:hover { border-color: var(--muted); }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.ghost { background: transparent; }
.small { padding: 3px 9px; font-size: 13px; }
.icon-btn { border: 0; background: transparent; font-size: 20px; padding: 2px 8px; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .2px; }
.brand img { width: 24px; height: 24px; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.login-card .brand { font-size: 22px; }
.login-card .brand img { width: 30px; height: 30px; }
.login-card p { margin: 0; }
.login-card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card input { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }

/* layout */
.app { height: 100%; display: grid; grid-template-columns: 300px 1fr; grid-template-rows: auto 1fr; }
.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.me { color: var(--muted); font-size: 14px; }
.presence { display: flex; gap: 6px; flex-wrap: wrap; }
.presence span { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); }
.presence span::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 5px; vertical-align: 1px; }
.mobile-only { display: none; }

/* arquivos */
.files { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; position: relative; }
.files.dragging { outline: 2px dashed var(--accent); outline-offset: -6px; }
.files-head { padding: 12px 12px 8px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.files-actions { display: flex; gap: 6px; }
.crumbs { font-size: 13px; display: flex; flex-wrap: wrap; gap: 2px; }
.crumbs a { color: var(--accent); cursor: pointer; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { color: var(--muted); }
.file-list { list-style: none; margin: 0; padding: 6px; overflow: auto; flex: 1; }
.file-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; font-size: 14px; }
.file-list li:hover { background: var(--panel-2); }
.file-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.file-list .meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.file-list .row-actions { display: none; gap: 2px; }
.file-list li:hover .row-actions { display: flex; }
.file-list .row-actions button { border: 0; background: transparent; padding: 0 4px; color: var(--muted); }
.file-list .row-actions button:hover { color: var(--text); }
.file-list li.fresh .name::after { content: " • alterado"; color: var(--claude); font-size: 12px; }
.file-list .empty { color: var(--muted); justify-content: center; }
.drop-hint { font-size: 12px; color: var(--muted); text-align: center; padding: 6px; }
.history { border-top: 1px solid var(--line); padding: 8px 12px; font-size: 13px; max-height: 40%; overflow: auto; }
.history summary { cursor: pointer; color: var(--muted); }
.history ul { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.history li b { font-weight: 600; }
.history li small { color: var(--muted); display: block; }

/* chat */
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.messages { flex: 1; overflow: auto; padding: 20px 16px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 820px; width: 100%; margin: 0 auto; }
.msg .head { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.msg .head b { color: var(--text); }
.tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; color: #fff; }
.tag.claude { background: var(--claude); }
.tag.codex { background: var(--codex); }
.msg .bubble { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--panel-2); white-space: pre-wrap; }
.msg.user.mine .bubble { background: var(--mine); }
.msg.system { text-align: center; color: var(--muted); font-size: 13px; }
.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble pre { background: var(--panel-2); padding: 10px; border-radius: 8px; overflow: auto; font-size: 13px; }
.bubble code { font-family: ui-monospace, "Cascadia Code", Menlo, monospace; font-size: .92em; }
.bubble table { border-collapse: collapse; display: block; overflow: auto; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 4px 8px; }
.tools { margin: 0 0 8px; font-size: 12.5px; color: var(--muted); }
.tools summary { cursor: pointer; }
.tools ol { margin: 6px 0 0; padding-left: 20px; font-family: ui-monospace, Menlo, monospace; }
.tools li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.working { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-top: 6px; }
.dots::after { content: "…"; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* abas IA / Conversa */
.tabs { display: flex; gap: 4px; padding: 8px 16px 0; border-bottom: 1px solid var(--line); background: var(--panel); }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; padding: 6px 14px 8px; color: var(--muted); font-weight: 600; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 99px; background: var(--warn); color: #fff; font-size: 11px; line-height: 18px; text-align: center; margin-left: 4px; }
.pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.small-text { font-size: 12px; }
.dm .msg { display: flex; flex-direction: column; align-items: flex-start; }
.dm .msg.mine { align-items: flex-end; }
.dm .msg .line { display: flex; align-items: center; gap: 6px; width: 100%; }
.dm .msg.mine .line { justify-content: flex-end; }
.dm-del { border: 0; background: transparent; padding: 2px 4px; opacity: 0; color: var(--muted); font-size: 14px; }
.dm .msg:hover .dm-del, .dm-del:focus { opacity: .7; }
.dm-del:hover { opacity: 1 !important; }
@media (hover: none) { .dm-del { opacity: .5; } }
.dm .msg .bubble { max-width: min(560px, 85%); white-space: pre-wrap; background: var(--panel); }
.dm .msg.mine .bubble { background: var(--mine); }
.dm .msg + .msg.same .head { display: none; }
.dm .msg.same { margin-top: -10px; }
.dm-empty { margin: auto; color: var(--muted); text-align: center; }

/* fila + composer */
.composer-wrap { border-top: 1px solid var(--line); background: var(--panel); padding: 10px 16px 14px; }
.queue { max-width: 820px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 6px; }
.queue:not(:empty) { margin-bottom: 8px; }
.queue .chip { font-size: 12.5px; background: var(--panel-2); border-radius: 99px; padding: 3px 6px 3px 10px; display: flex; gap: 6px; align-items: center; max-width: 100%; }
.queue .chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 380px; }
.queue .chip button { border: 0; background: transparent; padding: 0 4px; color: var(--muted); }
.composer { max-width: 820px; margin: 0 auto; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding: 8px; }
.composer textarea { width: 100%; border: 0; outline: 0; resize: none; background: transparent; max-height: 220px; padding: 4px 6px; }
.composer-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.engine { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.engine input { display: none; }
.engine span { display: block; padding: 4px 12px; cursor: pointer; font-size: 13px; }
.engine input:checked + span { color: #fff; font-weight: 600; }
.engine label:first-child input:checked + span { background: var(--claude); }
.engine label:last-child input:checked + span { background: var(--codex); }

.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 10; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow); animation: in .2s ease-out; }
@keyframes in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .mobile-only { display: inline-block; }
  .presence, .me { display: none; }
  .files { position: fixed; inset: 53px 0 0 0; z-index: 5; transform: translateX(-100%); transition: transform .2s; }
  .files.open { transform: none; }
  .file-list .row-actions { display: flex; }
}
