:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f2530;
  --text: #e8eaed;
  --muted: #9aa3af;
  --accent: #ff5a36;
  --accent-2: #1f6feb;
  --user: #243042;
  --bot: #1c2128;
  --border: #2a2f3a;
}

* { box-sizing: border-box; }
/* El atributo hidden debe ganar a los display:flex de .screen/.modal */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.screen { height: 100dvh; display: flex; flex-direction: column; }

/* LOGIN */
#login { align-items: center; justify-content: center; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: min(92vw, 380px);
  text-align: center;
}
.card h1 { margin: 0 0 4px; font-size: 22px; }
.sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
#login-form { display: flex; flex-direction: column; gap: 12px; }
input, textarea {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
}
input:focus, textarea:focus { outline: 2px solid var(--accent-2); outline-offset: -1px; }
button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: default; }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); font-weight: 500; padding: 8px 12px; }
.error { color: #ff6b6b; font-size: 13px; margin-top: 12px; }

/* CHAT */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.brand { font-weight: 700; }
.actions { display: flex; gap: 8px; }
.messages { flex: 1; overflow-y: auto; padding: 20px 16px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 760px; width: fit-content; padding: 12px 16px; border-radius: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--bot); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.bot.thinking::after { content: "▍"; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.composer { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--panel); }
.composer textarea { flex: 1; max-height: 160px; }
.composer button { align-self: flex-end; }

.empty { color: var(--muted); text-align: center; margin: auto; font-size: 14px; max-width: 420px; }

/* MODAL */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 24px; width: min(92vw, 440px); }
.modal-card h2 { margin: 0 0 4px; font-size: 18px; }
.modal-card textarea { width: 100%; margin-top: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.status { font-size: 13px; color: var(--muted); margin-top: 10px; }
