/* Aplicación Raven AI */
body { overflow: hidden; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(800px 500px at 50% 0%, rgba(25,227,227,.12), transparent); overflow: auto; height: 100vh; }
.auth .card { width: min(400px, 100%); padding: 32px; }
.auth .logo { width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 14px; background: url(/assets/raven-mark.png) center/cover; box-shadow: var(--glow); }
.auth h1 { font-family: var(--display); font-weight: 400; font-size: 20px; text-align: center; margin: 0 0 6px; }
.auth p.lead { text-align: center; color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.auth .err { color: var(--danger); font-size: 14px; min-height: 20px; margin-bottom: 8px; }

.shell { display: grid; grid-template-columns: 272px 1fr; height: 100vh; }
.side { display: flex; flex-direction: column; background: var(--bg-2); border-right: 1px solid var(--line); min-height: 0; }
.side .top { padding: 14px 14px 8px; }
.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 6px 12px 10px; }
.modes a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px; border-radius: var(--radius-sm); color: var(--muted); font-size: 11.5px; border: 1px solid transparent; }
.modes a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.modes a.on { background: var(--cyan-soft); color: var(--cyan); border-color: rgba(25,227,227,.25); }
.side .new { margin: 0 12px 10px; }
.side .list { flex: 1; overflow-y: auto; padding: 0 8px; min-height: 0; }
.side .list .h { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); padding: 10px 8px 6px; }
.side .item { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text); font-size: 14px; cursor: pointer; }
.side .item:hover { background: var(--panel); text-decoration: none; }
.side .item.on { background: var(--panel-2); }
.side .item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .item .x { opacity: 0; color: var(--dim); border: 0; background: none; cursor: pointer; padding: 0 4px; }
.side .item:hover .x { opacity: 1; }
.side .foot { border-top: 1px solid var(--line); padding: 12px; }
.meter { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 6px 0 4px; }
.meter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--cyan)); border-radius: 6px; }
.meter.hot > i { background: linear-gradient(90deg, var(--warn), var(--danger)); }
.userbtn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px; border-radius: var(--radius-sm); background: none; border: 0; cursor: pointer; text-align: left; }
.userbtn:hover { background: var(--panel); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--cyan), var(--teal)); color: #021214; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100vh; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line); min-height: 56px; }
.topbar .title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar select { width: auto; padding: 6px 10px; }
.menu-btn { display: none; }

/* Chat */
.chat { flex: 1; overflow-y: auto; min-height: 0; }
.chat .inner { max-width: 820px; margin: 0 auto; padding: 24px 20px 40px; }
.msg { display: flex; gap: 14px; margin: 0 0 26px; }
.msg .who { width: 30px; height: 30px; border-radius: 50%; flex: none; }
.msg.assistant .who { background: url(/assets/raven-mark.png) center/cover; box-shadow: 0 0 12px rgba(25,227,227,.3); }
.msg.user { justify-content: flex-end; }
.msg.user .body { background: var(--panel-2); border: 1px solid var(--line); padding: 10px 14px; border-radius: 14px 14px 4px 14px; max-width: 85%; white-space: pre-wrap; }
.msg.assistant .body { flex: 1; min-width: 0; padding-top: 3px; }
.msg .skills { margin-bottom: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.msg .meta { font-size: 12px; color: var(--dim); margin-top: 8px; }
.cursor::after { content: '▍'; color: var(--cyan); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.empty { text-align: center; padding: 12vh 20px 20px; }
.empty .logo { width: 110px; height: 110px; margin: 0 auto 18px; border-radius: 50%; background: url(/assets/raven-mark.png) center/cover; box-shadow: var(--glow); }
.empty h2 { font-family: var(--display); font-weight: 400; font-size: 22px; margin: 0 0 8px; }
.suggest { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; max-width: 700px; margin: 26px auto 0; }
.suggest button { text-align: left; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; font-size: 14px; color: var(--muted); }
.suggest button:hover { border-color: var(--teal); color: var(--text); }

.composer { padding: 0 20px 18px; }
.composer .box { max-width: 820px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; padding: 10px 12px 8px; transition: border-color .15s, box-shadow .15s; }
.composer .box:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px var(--cyan-soft); }
.composer textarea { width: 100%; background: none; border: 0; outline: none; resize: none; max-height: 240px; min-height: 26px; line-height: 1.5; padding: 4px 4px; }
.composer .bar { display: flex; align-items: center; gap: 8px; }
.composer .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 4px 2px 10px; }
.chip button { background: none; border: 0; color: var(--dim); cursor: pointer; }
.composer .hint { max-width: 820px; margin: 6px auto 0; font-size: 12px; color: var(--dim); text-align: center; }
.send { width: 34px; height: 34px; border-radius: 10px; border: 0; background: linear-gradient(135deg, var(--cyan), var(--teal)); color: #021214; cursor: pointer; display: grid; place-items: center; }
.send:disabled { opacity: .35; cursor: not-allowed; }

/* Agente (Cowork / Code) */
.feed { font-size: 14px; }
.step { display: flex; gap: 10px; align-items: flex-start; padding: 6px 10px; margin: 4px 0; border-radius: var(--radius-sm); background: var(--bg-2); border: 1px solid var(--line); font-family: var(--mono); font-size: 12.5px; }
.step .k { color: var(--cyan); flex: none; }
.step .v { min-width: 0; overflow-wrap: anywhere; }
.step details { width: 100%; }
.step summary { cursor: pointer; }
.step pre { margin: 6px 0 0; white-space: pre-wrap; color: var(--muted); max-height: 220px; overflow: auto; }
.cowork { display: grid; grid-template-columns: 1fr 300px; flex: 1; min-height: 0; }
.cowork .files { border-left: 1px solid var(--line); overflow-y: auto; padding: 14px; }
.files .f { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: 13px; }
.files .f:hover { background: var(--panel); }
.files .f .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.drop { border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 14px; text-align: center; color: var(--dim); font-size: 13px; cursor: pointer; margin-bottom: 12px; }
.drop:hover, .drop.over { border-color: var(--cyan); color: var(--cyan); }

.ide { display: grid; grid-template-columns: 220px 1fr 380px; flex: 1; min-height: 0; }
.ide .tree { border-right: 1px solid var(--line); overflow-y: auto; padding: 10px 6px; background: var(--bg-2); }
.ide .tree .f { cursor: pointer; }
.ide .tree .f.on { background: var(--panel-2); color: var(--cyan); }
.ide .center { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ide .tabs { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.editor { flex: 1; width: 100%; resize: none; border: 0; outline: none; background: #03080a; color: var(--text); font: 13px/1.6 var(--mono); padding: 14px 16px; tab-size: 2; white-space: pre; overflow: auto; }
.preview { flex: 1; border: 0; background: #fff; width: 100%; }
.ide .agent { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.ide .agent .feed { flex: 1; overflow-y: auto; padding: 14px; }
.ide .agent .composer { padding: 0 10px 10px; }

/* Terminal */
.term-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 16px; gap: 12px; }
.term { flex: 1; background: #020607; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; font: 13px/1.6 var(--mono); overflow-y: auto; cursor: text; min-height: 0; }
.term .ln { white-space: pre-wrap; overflow-wrap: anywhere; }
.term .p { color: var(--cyan); }
.term .e { color: var(--danger); }
.term .d { color: var(--dim); }
.term .ok { color: var(--ok); }
.term .in { display: flex; gap: 8px; }
.term .in input { flex: 1; background: none; border: 0; outline: none; font: inherit; color: var(--text); padding: 0; }

/* Ajustes */
.settings { flex: 1; overflow-y: auto; }
.settings .inner { max-width: 960px; margin: 0 auto; padding: 24px 20px 60px; }
.stabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; overflow-x: auto; }
.stabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.stabs a.on { color: var(--cyan); border-color: var(--cyan); text-decoration: none; }
.stabs a:hover { text-decoration: none; color: var(--text); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi .n { font-size: 26px; font-weight: 700; margin-top: 4px; }
.kpi .l { font-size: 13px; color: var(--muted); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.t th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 10px; }
.bars i { flex: 1; background: linear-gradient(180deg, var(--cyan), var(--teal)); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.plans-grid .card.cur { border-color: var(--cyan); box-shadow: var(--glow); }
.keybox { font-family: var(--mono); background: #03080a; border: 1px solid var(--teal); padding: 12px; border-radius: var(--radius-sm); overflow-wrap: anywhere; margin: 10px 0; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: min(620px, 100%); max-height: 90vh; overflow-y: auto; }
.section-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }
.section-h h3 { margin: 0; }

@media (max-width: 1100px) { .ide { grid-template-columns: 180px 1fr; } .ide .agent { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); max-height: 45vh; } .ide { grid-template-rows: 1fr auto; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .shell.open .side { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.6); }
  .menu-btn { display: inline-flex; }
  .cowork { grid-template-columns: 1fr; } .cowork .files { border-left: 0; border-top: 1px solid var(--line); max-height: 35vh; }
  /* En móvil: archivos arriba (corto), editor con alto propio y el agente debajo */
  .ide { grid-template-columns: 1fr; grid-template-rows: auto minmax(260px, 1fr) auto; } .ide .tree { max-height: 110px; border-right: 0; border-bottom: 1px solid var(--line); }
}

.thinking { margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.thinking summary { cursor: pointer; color: var(--teal); }
.thinking pre { white-space: pre-wrap; font: 12.5px/1.55 var(--mono); color: var(--dim); max-height: 260px; overflow: auto; border-left: 2px solid var(--line-2); padding-left: 10px; margin: 6px 0 0; }

/* Capturas del navegador del agente */
.browser { margin: 6px 0 10px; }
.browser .shot { display: block; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; max-width: 520px; }
.browser .shot img { display: block; width: 100%; height: auto; }
.browser .shot-url { font-size: 12px; margin-top: 4px; overflow-wrap: anywhere; }

/* Búsqueda web en el Chat */
.web-toggle { gap: 6px; color: var(--muted); border-radius: 99px; }
.web-toggle.on { color: var(--cyan); background: var(--cyan-soft); border-color: rgba(25,227,227,.3); }
.search-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--teal); margin-bottom: 8px; }
.search-status .dim { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }
.md a.cite { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; margin: 0 1px; border-radius: 9px;
  font-size: 11px; font-weight: 600; text-decoration: none; vertical-align: 2px; background: var(--cyan-soft); color: var(--cyan); }
.md a.cite:hover { background: var(--cyan); color: #021214; }
.sources { display: grid; gap: 6px; margin-top: 12px; font-size: 13px; }
.sources > .dim { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.sources a { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; padding: 7px 10px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text); text-decoration: none; min-width: 0; }
.sources a:hover { border-color: var(--teal); }
.sources .n { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--cyan-soft); color: var(--cyan); font-size: 11px; font-weight: 600; }
.sources .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sources .h { color: var(--dim); font-size: 12px; }
.auth .consent { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); margin: 4px 0 14px; line-height: 1.45; }
.auth .consent input { margin-top: 3px; accent-color: var(--cyan); flex: none; }
.composer .hint a { color: var(--dim); text-decoration: underline; }
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; }
.modal { width: min(420px, 100%); padding: 22px; }
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal p { margin: 0 0 6px; font-size: 14px; }
.modal .input { width: 100%; margin-top: 8px; }
.step.live { color: var(--cyan); border-color: rgba(25,227,227,.25); }
.step.live .v { font-family: var(--font); }
.step .spin { width: 12px; height: 12px; margin-top: 2px; flex: none; border-radius: 50%; border: 2px solid rgba(25,227,227,.25); border-top-color: var(--cyan); animation: rvspin .8s linear infinite; }
@keyframes rvspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .step .spin { animation: none; } }

/* Alto real de la pantalla en móvil (la barra del navegador no tapa el compositor) */
@supports (height: 100dvh) { .shell, .main { height: 100dvh; } .auth { min-height: 100dvh; height: 100dvh; } }
/* El ✕ de la lista se ve con teclado y en pantallas táctiles (sin hover no se veía pero se podía pulsar) */
.side .item:focus-within .x, .side .item .x:focus-visible { opacity: 1; }
@media (hover: none) { .side .item .x { opacity: .7; } }
/* Editor de skills: diálogo ancho propio (.modal es el de las confirmaciones) */
.modal-wide { width: min(620px, 100%); max-height: 90vh; overflow-y: auto; padding: 22px; }
@media (max-width: 860px) {
  /* Cowork: la conversación se desplaza y el compositor y los archivos siempre quedan a la vista */
  .cowork { grid-template-rows: minmax(0, 1fr) auto; }
  .cowork .files { max-height: 28vh; }
  /* Code: el editor cede sitio para que el compositor del agente quepa en el teléfono */
  .ide { grid-template-rows: auto minmax(0, 1fr) auto; }
  .ide .agent { max-height: 40dvh; }
}
