:root {
  --bg: #050d18;
  --bg-soft: #081424;
  --panel: rgba(8, 19, 34, .82);
  --panel-solid: #0a1728;
  --panel-2: #0d1d31;
  --panel-3: #10243d;
  --line: rgba(153, 184, 226, .12);
  --line-strong: rgba(153, 184, 226, .22);
  --text: #edf4ff;
  --text-soft: #c7d5e8;
  --muted: #7e91aa;
  --accent: #7da9ff;
  --accent-soft: #abc7ff;
  --success: #6ed3aa;
  --warning: #d8b66d;
  --danger: #ec8592;
  --shadow: 0 28px 70px rgba(0,0,0,.34);
  --sidebar: 248px;
  --inspector: 286px;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; }
html { background: var(--bg); }
body {
  color: var(--text);
  font-family: "Segoe UI Variable Text", "Aptos", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  background:
    radial-gradient(900px 600px at 23% -10%, rgba(76, 126, 219, .18), transparent 66%),
    radial-gradient(760px 520px at 83% 9%, rgba(68, 113, 210, .11), transparent 70%),
    linear-gradient(145deg, #06101d 0%, #07111e 52%, #050b14 100%);
  overflow: hidden;
}

.ambient { position: fixed; pointer-events: none; filter: blur(90px); border-radius: 50%; opacity: .42; z-index: 0; }
.ambient-one { width: 420px; height: 420px; left: 23%; top: 18%; background: rgba(56, 105, 194, .12); }
.ambient-two { width: 360px; height: 360px; right: 5%; bottom: 4%; background: rgba(55, 98, 175, .09); }

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  height: 100dvh;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: rgba(5, 14, 25, .76);
  backdrop-filter: blur(28px) saturate(1.18);
  padding: 24px 18px 18px;
  display: flex;
  flex-direction: column;
}
.brand { padding: 4px 2px 24px; border-bottom: 1px solid var(--line); }
.brand-mark {
  font-family: "Segoe UI Variable Display", "Aptos Display", "Segoe UI", sans-serif;
  font-size: 25px;
  line-height: 1;
  font-weight: 760;
  letter-spacing: .17em;
  color: #f5f8ff;
}
.brand-sub { margin-top: 9px; font-size: 9px; color: var(--accent); letter-spacing: .19em; font-weight: 750; }

.section-label, .panel-title { font-size: 9px; letter-spacing: .17em; color: #7086a4; font-weight: 800; margin: 21px 2px 10px; }
.no-margin { margin: 0; }
.section-row { display: flex; justify-content: space-between; align-items: center; margin: 22px 2px 10px; }
.tiny-badge { border: 1px solid var(--line); border-radius: 99px; padding: 2px 7px; color: #8095b0; font-size: 9px; }
.status-card { border: 1px solid var(--line); background: rgba(255,255,255,.018); border-radius: 13px; padding: 5px 11px; }
.status-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; font-size: 11px; color: #a9b8cb; }
.status-row + .status-row { border-top: 1px solid rgba(255,255,255,.04); }
.state { font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.state.ok { color: var(--success); }
.state.bad { color: var(--danger); }
.state.pending { color: var(--warning); }
.muted { color: var(--muted); }
.mono { font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; }

.module-list { display: grid; gap: 7px; overflow-y: auto; overflow-x: hidden; margin-bottom: 12px; min-height: 0; max-height: 27vh; padding-right: 3px; }
.module-item { border: 1px solid var(--line); background: rgba(255,255,255,.018); border-radius: 11px; padding: 10px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.module-item strong { font-size: 11px; font-weight: 650; color: #dfe9f8; }
.module-item span { font-size: 9px; color: var(--muted); }

.primary-button, .secondary-button, .ghost-button { border-radius: 10px; padding: 10px 14px; font-weight: 650; transition: .18s ease; }
.primary-button { border: 0; color: #061226; background: linear-gradient(135deg, #a4c4ff, #76a4fa); box-shadow: 0 10px 28px rgba(87,135,225,.16); }
.secondary-button { color: #d9e6fb; background: rgba(38, 69, 116, .46); border: 1px solid rgba(118,157,224,.22); }
.ghost-button { color: #aabbd1; background: transparent; border: 1px solid var(--line); margin-top: 7px; }
.primary-button:hover, .secondary-button:hover, .ghost-button:hover { filter: brightness(1.06); }
.full { width: 100%; }
.sidebar-foot { margin-top: auto; padding-top: 15px; border-top: 1px solid var(--line); color: #60748e; font-size: 9px; line-height: 1.7; }

.main { min-width: 0; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.topbar {
  flex: 0 0 108px;
  min-height: 108px;
  padding: 22px 30px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 26px;
  background: rgba(6, 15, 27, .36);
  backdrop-filter: blur(18px);
}
.header-copy { min-width: 0; }
.eyebrow { color: var(--accent); font-size: 9px; letter-spacing: .18em; font-weight: 800; }
h1, h2, h3, .answer-content h2, .answer-content h3 {
  font-family: "Segoe UI Variable Display", "Aptos Display", "Segoe UI", sans-serif;
}
h1 { margin: 6px 0 4px; font-size: clamp(22px, 2vw, 27px); letter-spacing: -.035em; font-weight: 660; }
.topbar p { margin: 0; color: #7c8fa8; font-size: 11px; }
.top-stats { display: flex; gap: 7px; flex-shrink: 0; }
.stat { min-width: 84px; border: 1px solid var(--line); background: rgba(255,255,255,.016); border-radius: 11px; padding: 9px 11px; }
.stat span { display: block; font-size: 15px; font-weight: 690; }
.stat small { display: block; margin-top: 2px; color: #6c809b; font-size: 8px; text-transform: uppercase; letter-spacing: .09em; }

.workspace {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--inspector);
}
.chat-panel { position: relative; min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.conversation {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 28px clamp(24px, 5vw, 78px) 26px;
  scroll-behavior: smooth;
}
.conversation::-webkit-scrollbar, .inspector-panel::-webkit-scrollbar, .module-list::-webkit-scrollbar { width: 8px; }
.conversation::-webkit-scrollbar-track, .inspector-panel::-webkit-scrollbar-track, .module-list::-webkit-scrollbar-track { background: transparent; }
.conversation::-webkit-scrollbar-thumb, .inspector-panel::-webkit-scrollbar-thumb, .module-list::-webkit-scrollbar-thumb { background: rgba(132,160,199,.22); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
.conversation::-webkit-scrollbar-thumb:hover, .inspector-panel::-webkit-scrollbar-thumb:hover { background: rgba(132,160,199,.38); border: 2px solid transparent; background-clip: padding-box; }

.welcome { max-width: 720px; margin: min(10vh, 72px) auto 0; }
.welcome-kicker { font-size: 10px; font-weight: 800; letter-spacing: .23em; color: #739fef; }
.welcome h2 { font-size: clamp(30px, 3.3vw, 44px); margin: 10px 0 11px; font-weight: 580; letter-spacing: -.045em; }
.welcome p { max-width: 650px; color: #8b9bb0; line-height: 1.68; font-size: 13px; }
.suggestions { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; margin-top: 24px; }
.suggestions button { text-align: left; border: 1px solid var(--line); color: #aebed4; background: rgba(255,255,255,.018); border-radius: 12px; padding: 11px 12px; font-size: 10px; transition: .16s ease; }
.suggestions button:hover { border-color: rgba(121,167,255,.32); background: rgba(121,167,255,.045); color: #dce9ff; }

.message { width: min(920px, 100%); margin: 0 auto 24px; }
.message-label { font-size: 8px; letter-spacing: .13em; color: #60748f; font-weight: 800; margin: 0 0 7px 3px; }
.message.user { display: flex; flex-direction: column; align-items: flex-end; }
.message.user .message-label { align-self: flex-end; margin-right: 3px; }
.message.user .bubble { max-width: min(720px, 82%); background: linear-gradient(145deg, rgba(25,53,89,.88), rgba(18,39,68,.9)); border: 1px solid rgba(121,167,255,.17); }
.message.assistant .bubble { width: 100%; background: rgba(10, 23, 40, .48); border: 1px solid rgba(153,184,226,.10); box-shadow: 0 16px 50px rgba(0,0,0,.08); }
.bubble { border-radius: 16px; padding: 17px 19px; font-size: 13px; line-height: 1.68; color: #dce7f6; word-break: break-word; overflow-wrap: anywhere; }
.message.user .bubble { white-space: pre-wrap; }
.message.assistant .bubble { white-space: normal; }

.answer-content { max-width: 100%; color: #dce7f6; }
.answer-content > *:first-child { margin-top: 0 !important; }
.answer-content > *:last-child { margin-bottom: 0 !important; }
.answer-content h2 { font-size: 18px; margin: 22px 0 8px; color: #f0f5ff; font-weight: 620; letter-spacing: -.018em; }
.answer-content h3 { font-size: 14px; margin: 18px 0 7px; color: #dfe9f8; font-weight: 650; }
.answer-content p { margin: 0 0 12px; color: #cbd8e9; }
.answer-content strong { color: #f1f6ff; font-weight: 690; }
.answer-content em { color: #afc0d6; }
.answer-content ul, .answer-content ol { margin: 7px 0 14px; padding-left: 22px; }
.answer-content li { margin: 5px 0; color: #c5d3e5; }
.answer-content code { font-family: "Cascadia Code", Consolas, monospace; font-size: .9em; color: #b9d2ff; background: rgba(108,151,224,.09); border: 1px solid rgba(108,151,224,.09); border-radius: 5px; padding: 1px 5px; }
.answer-content pre { overflow-x: auto; margin: 12px 0 15px; padding: 13px 14px; background: #07111e; border: 1px solid var(--line); border-radius: 11px; color: #bad0ec; }
.answer-content pre code { background: transparent; border: 0; padding: 0; color: inherit; }
.answer-content blockquote { margin: 12px 0; padding: 4px 0 4px 13px; border-left: 2px solid rgba(121,167,255,.55); color: #a9bad0; }
.answer-table-wrap { width: 100%; overflow-x: auto; margin: 12px 0 16px; border: 1px solid var(--line); border-radius: 11px; background: rgba(6,15,27,.44); }
.answer-content table { width: 100%; border-collapse: collapse; min-width: 620px; font-size: 11px; }
.answer-content th, .answer-content td { padding: 9px 11px; text-align: left; vertical-align: top; border-bottom: 1px solid rgba(153,184,226,.08); }
.answer-content th { color: #a9c5ef; background: rgba(80,124,194,.06); font-weight: 680; }
.answer-content td { color: #bac9dc; }
.answer-content tr:last-child td { border-bottom: 0; }

.scroll-bottom { position: absolute; z-index: 5; right: 26px; bottom: 112px; border: 1px solid var(--line-strong); background: rgba(10,24,42,.9); color: #acc0db; border-radius: 99px; padding: 7px 11px; font-size: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.22); }
.hidden { display: none !important; }

.composer-wrap {
  flex: 0 0 auto;
  position: relative;
  z-index: 4;
  padding: 10px clamp(20px, 5vw, 74px) 15px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(5,13,24,.75), rgba(5,13,24,.96) 28%);
  backdrop-filter: blur(22px);
}
.composer-shell { width: min(920px, 100%); margin: 0 auto; border: 1px solid rgba(153,184,226,.15); background: rgba(10,24,42,.78); border-radius: 17px; box-shadow: 0 17px 45px rgba(0,0,0,.18); }
.composer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 11px 0; }
.scope-control { display: flex; gap: 7px; align-items: center; color: #667d9a; font-size: 9px; }
.composer-hint { color: #536a86; font-size: 8px; }
select, input, textarea { color: var(--text); background: #0a1829; border: 1px solid var(--line); outline: none; }
select { border-radius: 7px; padding: 4px 7px; font-size: 9px; color: #aebed2; }
.composer { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; padding: 4px 7px 7px 11px; }
textarea { width: 100%; min-height: 48px; max-height: 128px; resize: none; overflow-y: auto; border: 0; background: transparent; border-radius: 0; padding: 12px 4px 7px; line-height: 1.45; color: #e8f0fc; }
textarea::placeholder { color: #657a95; }
textarea:focus { box-shadow: none; }
.send-button { min-width: 76px; height: 38px; margin-bottom: 1px; border: 1px solid rgba(145,183,250,.22); border-radius: 11px; background: linear-gradient(145deg, #8cb3f9, #6696eb); color: #071326; font-weight: 700; font-size: 11px; transition: .16s ease; }
.send-button:hover { filter: brightness(1.06); transform: translateY(-1px); }

.inspector-panel { min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 22px 16px; background: rgba(6,15,27,.42); }
.inspector-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.panel-title { margin: 0; }
.panel-title.small { margin-top: 19px; }
.panel-subtitle { color: #5f748f; font-size: 9px; margin-top: 5px; }
.trace-empty { color: #667c97; font-size: 10px; line-height: 1.58; border: 1px dashed var(--line); border-radius: 11px; padding: 12px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.metric { min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; background: rgba(255,255,255,.014); }
.metric small { display: block; color: #677d99; font-size: 8px; text-transform: uppercase; letter-spacing: .09em; }
.metric strong { display: block; font-size: 14px; margin: 3px 0 1px; overflow: hidden; text-overflow: ellipsis; }
.metric span { color: #5b708b; font-size: 8px; }
.metric.mini strong { font-size: 12px; }
.trace-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; padding: 7px 1px; border-bottom: 1px solid rgba(255,255,255,.04); font-size: 9px; color: #607691; }
.trace-meta b { color: #9eb2ca; font-weight: 620; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-trace { display: grid; gap: 6px; }
.tool-item { border: 1px solid var(--line); border-radius: 9px; padding: 8px 9px; background: rgba(255,255,255,.012); }
.tool-item strong { font-size: 9px; color: #bfd0e7; }
.tool-item pre { margin: 5px 0 0; white-space: pre-wrap; word-break: break-word; color: #7086a3; font-size: 8px; font-family: "Cascadia Code", Consolas, monospace; }
.tool-item .tool-time { color: #576d88; font-size: 8px; margin-top: 5px; }

.modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 50; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(1,7,14,.72); backdrop-filter: blur(8px); }
.modal-card { position: relative; width: min(520px, calc(100vw - 34px)); background: #0b1728; border: 1px solid var(--line-strong); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.modal-head h3 { margin: 6px 0 0; font-size: 21px; }
.close-button { background: transparent; color: #768aa5; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 10px; }
.modal-copy { color: #8293aa; line-height: 1.6; font-size: 12px; }
#uploadForm { display: grid; gap: 8px; margin-top: 18px; }
#uploadForm label { color: #6f839f; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; margin-top: 6px; }
#uploadForm input { border-radius: 9px; padding: 10px 11px; }
#uploadForm .primary-button { margin-top: 10px; }
.form-message { min-height: 20px; margin-top: 10px; font-size: 11px; color: #8ba0ba; }

@media (max-width: 1180px) {
  :root { --sidebar: 220px; --inspector: 250px; }
  .top-stats .stat { min-width: 72px; }
  .suggestions { grid-template-columns: 1fr; max-width: 440px; }
}
@media (max-width: 960px) {
  :root { --sidebar: 205px; }
  .workspace { grid-template-columns: minmax(0,1fr); }
  .inspector-panel { display: none; }
  .top-stats { display: none; }
}
@media (max-width: 720px) {
  body { overflow: hidden; }
  .shell { display: block; }
  .sidebar { display: none; }
  .main { width: 100%; }
  .topbar { flex-basis: 92px; min-height: 92px; padding: 17px 18px; }
  .topbar p { display: none; }
  .conversation { padding: 22px 15px 20px; }
  .message.user .bubble { max-width: 92%; }
  .composer-wrap { padding: 9px 12px 11px; }
  .composer-toolbar { padding: 6px 8px 0; }
  .composer-hint { display: none; }
  .send-button { min-width: 68px; }
  .welcome { margin-top: 8vh; }
}

/* v0.3.3 - selector de modo Código / Asistente */
.mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid rgba(153,184,226,.14);
  background: rgba(4,13,24,.62);
  border-radius: 10px;
}
.mode-button {
  border: 0;
  background: transparent;
  color: #6f829b;
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 8px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: .08em;
  transition: .16s ease;
}
.mode-button:hover { color: #b5c6dc; }
.mode-button.active {
  color: #eaf2ff;
  background: linear-gradient(145deg, rgba(65,104,166,.62), rgba(37,71,122,.58));
  box-shadow: inset 0 0 0 1px rgba(143,180,243,.15);
}
.composer-toolbar { flex-wrap: wrap; }
.scope-control { margin-left: auto; }
@media (max-width: 720px) {
  .mode-switch { order: 1; }
  .scope-control { order: 2; margin-left: 0; }
  .composer-toolbar { justify-content: space-between; }
}

/* v0.3.4 debug */
.diagnostic-mini { margin-top: 8px; padding: 8px 4px; }
.diagnostics-card { width: min(820px, calc(100vw - 34px)); max-height: 82vh; display: flex; flex-direction: column; }
.diagnostic-actions { display: flex; justify-content: flex-end; margin: 4px 0 10px; }
.diagnostics-output {
  flex: 1 1 auto;
  min-height: 320px;
  max-height: 58vh;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #050d18;
  color: #aebed2;
  white-space: pre-wrap;
  word-break: break-word;
  font: 10px/1.55 "Cascadia Code", Consolas, monospace;
}

.check-row { display:flex; align-items:center; gap:8px; margin:10px 0 14px; font-size:13px; color:var(--muted, #9fb0c3); }
.check-row input { width:auto; margin:0; }
