/* secre — estilos mobile-first (oscuro, limpio, solo chat) */
:root {
  --bg: #0d1117; --bg2: #161b22; --bg3: #1f2630;
  --txt: #e6edf3; --muted: #8b949e; --line: #2d333b;
  --accent: #2ea88a; --accent2: #237a63; --danger: #f85149; --warn: #e3b341;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--txt); font-size: 16px; line-height: 1.5;
  overscroll-behavior: none;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font: inherit; color: var(--txt); background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }

/* ---- login ---- */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at top, #14212b, var(--bg)); z-index: 50; }
.login-card { width: min(340px, 100%); background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px 24px; text-align: center; display: grid; gap: 12px; }
.logo { font-size: 42px; }
.login h1 { font-size: 26px; letter-spacing: 1px; }
.sub, .muted { color: var(--muted); font-size: 13.5px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---- estructura app ---- */
.app { height: 100dvh; display: flex; flex-direction: column; }
.view { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.bar {
  display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: var(--bg2); border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.bar-title { flex: 1; display: flex; align-items: center; gap: 10px; }
.bar h2 { font-size: 18px; }
.icon-btn { font-size: 20px; padding: 6px 8px; border-radius: 10px; }
.icon-btn:active { background: var(--bg3); }
.icon-btn.small { font-size: 14px; padding: 2px 4px; color: var(--muted); }

.badge-cost { background: rgba(46,168,138,.14); color: var(--accent); border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.badge-cost.hot { background: rgba(248,81,73,.16); color: var(--danger); }

/* ---- presupuesto ---- */
.budget { position: relative; height: 22px; background: var(--bg2); border-bottom: 1px solid var(--line); flex-shrink: 0; }
.budget-fill { height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); width: 0; transition: width .4s; }
.budget-fill.hot { background: linear-gradient(90deg, #a82c2c, var(--danger)); }
.budget-txt { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11.5px; color: var(--txt); text-shadow: 0 1px 2px rgba(0,0,0,.6); }

/* ---- lista de tareas ---- */
.search-wrap { padding: 10px 14px; flex-shrink: 0; }
.search-wrap input { width: 100%; }
.task-list { flex: 1; overflow-y: auto; padding: 0 14px calc(90px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.task-card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.task-card:active { background: var(--bg3); }
.task-top { display: flex; align-items: center; gap: 8px; }
.task-name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-id { font-family: ui-monospace, monospace; font-size: 11.5px; color: var(--muted); background: var(--bg3); padding: 2px 7px; border-radius: 6px; }
.task-desc { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-bottom { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot.pendiente { background: var(--warn); } .dot.curso { background: #58a6ff; } .dot.cerrada { background: var(--accent); }
.task-msgs { margin-left: auto; }
.fab {
  position: fixed; right: 18px; bottom: calc(22px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%; font-size: 28px; line-height: 1;
  background: var(--accent); color: #06251d; font-weight: 700;
  box-shadow: 0 6px 18px rgba(0,0,0,.45); z-index: 10;
}
.empty { color: var(--muted); text-align: center; margin-top: 40px; font-size: 14px; }


/* ---- chat ---- */
.chat-bar { align-items: flex-start; }
.chat-title { flex: 1; min-width: 0; }
.chat-name-row { display: flex; align-items: center; gap: 6px; }
#chat-name { font-weight: 600; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; font-size: 11.5px; color: var(--muted); }
.chip-select { font-size: 11.5px; padding: 2px 6px; border-radius: 999px; background: var(--bg3); border-color: var(--line); color: var(--txt); }

.messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; border-radius: var(--radius); padding: 10px 14px; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, var(--accent2), var(--accent)); color: #052b22; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--bg2); border: 1px solid var(--line); border-bottom-left-radius: 4px; max-width: 95%; }
.msg.assistant.error { border-color: var(--danger); color: #ffb4ae; }
.msg .meta { font-size: 10.5px; color: var(--muted); margin-top: 6px; text-align: right; }
.msg.user .meta { color: rgba(5,43,34,.65); }

.msg h1, .msg h2, .msg h3 { font-size: 1.05em; margin: 10px 0 4px; }
.msg p { margin: 4px 0; }
.msg ul, .msg ol { margin: 4px 0 4px 20px; }
.msg code { font-family: ui-monospace, monospace; font-size: .9em; background: rgba(110,118,129,.25); padding: 1px 5px; border-radius: 5px; }
.msg pre { background: #0a0e14; border: 1px solid var(--line); border-radius: 10px; padding: 10px; overflow-x: auto; margin: 8px 0; }
.msg pre code { background: none; padding: 0; }
.msg a { color: var(--accent); }
.msg.user a { color: #052b22; text-decoration: underline; }
.msg table { border-collapse: collapse; font-size: .9em; margin: 8px 0; }
.msg th, .msg td { border: 1px solid var(--line); padding: 4px 8px; }
.cursor { display: inline-block; width: 8px; height: 15px; background: var(--accent); vertical-align: text-bottom; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }

.composer {
  display: flex; gap: 10px; align-items: flex-end; padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg2); border-top: 1px solid var(--line); flex-shrink: 0;
}
.composer textarea { flex: 1; resize: none; max-height: 40dvh; min-height: 44px; border-radius: 22px; padding: 11px 16px; }
.round { width: 44px; height: 44px; border-radius: 50%; font-size: 17px; flex-shrink: 0; display: grid; place-items: center; }
.btn-primary { background: var(--accent); color: #06251d; font-weight: 700; border-radius: 10px; padding: 10px 16px; }
.btn-primary:disabled { opacity: .5; }
.btn-stop { background: var(--danger); color: #fff; }
.btn-ghost { color: var(--muted); padding: 10px 16px; border-radius: 10px; }
.btn-danger { background: rgba(248,81,73,.14); color: var(--danger); border-radius: 10px; padding: 10px 16px; width: 100%; }

/* ---- menú contextual ---- */
.menu { position: fixed; top: calc(64px + env(safe-area-inset-top)); right: 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 40; min-width: 230px; }
.menu button { display: block; width: 100%; text-align: left; padding: 12px 16px; font-size: 14.5px; border-bottom: 1px solid var(--line); }
.menu button:last-child { border-bottom: none; }
.menu button:active { background: var(--bg3); }
.menu .danger { color: var(--danger); }

/* ---- ajustes ---- */
.settings { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 10px; }
.card h3 { font-size: 15px; }
.card label { display: grid; gap: 4px; font-size: 13.5px; color: var(--muted); }
.stats-box { font-size: 14px; display: grid; gap: 6px; }
.stats-box .row { display: flex; justify-content: space-between; }
.stats-box .row b { color: var(--accent); }

/* ---- modal y toast ---- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 20px; z-index: 60; }
.modal-box { width: min(420px, 100%); background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; gap: 12px; }
.modal-box h3 { font-size: 16px; }
.modal-box input, .modal-box textarea { width: 100%; }
.modal-box textarea { min-height: 140px; resize: vertical; font-family: ui-monospace, monospace; font-size: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: calc(80px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--bg3); border: 1px solid var(--line); border-radius: 999px; padding: 8px 18px; font-size: 13.5px; z-index: 70; box-shadow: 0 6px 20px rgba(0,0,0,.5); }

/* ---- desktop: columna central tipo chat ---- */
@media (min-width: 760px) {
  .view { max-width: 860px; margin: 0 auto; width: 100%; }
  .app { background: linear-gradient(180deg, #10151c, var(--bg)); }
  .fab { right: calc(50% - 380px); }
}
