:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --ink: #212121;
  --muted: #616161;
  --line: #e0e0e0;
  --brand: #2e7d32;
  --brand-dark: #1b5e20;
  --brand-soft: #e8f5e9;
  --accent: #854f0b;
  --accent-soft: #faeeda;
  --danger: #d32f2f;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; border: none; }
input, textarea { font: inherit; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 16px; flex: none;
}
.topbar .title { flex: 1; min-width: 0; }
.topbar .title h1 { margin: 0; font-size: 16px; font-weight: 600; }
.topbar .title p { margin: 0; font-size: 12px; color: var(--muted); }
.iconbtn {
  background: none; color: var(--muted); padding: 8px;
  border-radius: 10px; font-size: 14px;
}
.iconbtn:hover { background: var(--bg); }

.login-wrap {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 24px;
}
.login-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px; width: 100%; max-width: 360px;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p.sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); font-size: 16px;
}
.field input:focus { outline: 2px solid var(--brand); border-color: transparent; }
.btn-primary {
  width: 100%; padding: 12px; border-radius: 10px;
  background: var(--brand); color: #fff; font-weight: 600; font-size: 16px;
}
.btn-primary:active { transform: scale(0.99); }
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 10px; }

.chat-wrap { display: flex; flex-direction: column; height: 100dvh; }
#messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 760px; width: 100%; margin: 0 auto;
}
.msg { max-width: 86%; padding: 10px 14px; border-radius: var(--radius); line-height: 1.5; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.soledad { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.error { background: #fcebeb; border-color: #f0c0c0; color: var(--danger); }
.msg pre {
  overflow-x: auto; background: var(--bg); padding: 8px 10px;
  border-radius: 8px; font-size: 12.5px; line-height: 1.45;
}
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 6px; }
.msg.user .meta { color: rgba(255,255,255,0.75); }
.filechip {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); text-decoration: none; color: var(--ink); font-size: 14px;
}
.filechip:hover { border-color: var(--brand); }
.filechip .sz { color: var(--muted); font-size: 12px; margin-left: auto; }
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100% { opacity: 0.25; } 40% { opacity: 1; } }

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.composer-inner { max-width: 760px; width: 100%; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; }
.composer textarea {
  flex: 1; resize: none; max-height: 130px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
}
.composer textarea:focus { outline: 2px solid var(--brand); border-color: transparent; }
.send {
  background: var(--brand); color: #fff; width: 44px; height: 44px;
  border-radius: 12px; font-size: 18px; flex: none;
}
.send:disabled { opacity: 0.4; }
.attach { background: none; color: var(--muted); font-size: 20px; padding: 10px 6px; }
.pendingfiles { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px 6px; max-width: 760px; margin: 0 auto; width: 100%; }
.pendingfiles span {
  background: var(--accent-soft); color: var(--accent); font-size: 12px;
  padding: 4px 10px; border-radius: 8px;
}
.panel {
  position: absolute; right: 10px; top: 56px; width: min(340px, 92vw);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; z-index: 20;
  max-height: 60vh; overflow-y: auto;
}
.panel h2 { margin: 2px 4px 10px; font-size: 14px; color: var(--muted); font-weight: 600; }

.kiosk { max-width: 560px; margin: 0 auto; padding: 14px 14px 40px; }
.don-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
}
.don-card svg { flex: none; }
.don-card h1 { margin: 0; font-size: 18px; }
.don-card p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.don-badge {
  margin-left: auto; font-size: 12px; padding: 4px 10px;
  border-radius: 8px; background: var(--brand-soft); color: var(--brand);
  white-space: nowrap; font-weight: 600;
}
.searchbox {
  display: flex; align-items: center; gap: 8px; margin-top: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px 12px;
}
.searchbox input { flex: 1; border: none; background: none; padding: 12px 0; font-size: 17px; }
.searchbox input:focus { outline: none; }
.results { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.result {
  text-align: left; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 14px; font-size: 15px;
}
.result small { color: var(--muted); display: block; font-size: 12px; }
.result:active { background: var(--brand-soft); }
.selected {
  margin-top: 14px; background: var(--brand-soft); border-radius: 12px;
  padding: 12px 14px; font-size: 15px; font-weight: 600; color: var(--brand-dark);
  display: flex; align-items: center; gap: 8px;
}
.selected button { margin-left: auto; background: none; color: var(--brand); font-size: 16px; }
.toplogo { height: 30px; width: auto; }
.bigbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.bigbtn {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 20px 10px; text-align: center;
}
.bigbtn:disabled { opacity: 0.45; }
.bigbtn .ic { font-size: 26px; display: block; margin-bottom: 6px; }
.bigbtn span { font-size: 15px; font-weight: 600; }
.bigbtn:active { background: var(--brand-soft); }
.freetext {
  width: 100%; margin-top: 10px; background: var(--surface);
  border: 1px dashed var(--line); border-radius: 12px; padding: 14px;
  color: var(--muted); font-size: 14px;
}
.deps { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; justify-content: center; }
.deps span.lbl { font-size: 13px; color: var(--muted); }
.depchip {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 10px; padding: 7px 14px; font-size: 14px; font-weight: 600;
}
.depchip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; border-radius: 12px;
  padding: 12px 18px; display: flex; gap: 14px; align-items: center;
  font-size: 14px; z-index: 50; max-width: 92vw;
}
.toast button { background: none; color: #f5c573; font-weight: 700; }
.ranking { margin-top: 18px; font-size: 13px; color: var(--muted); text-align: center; }
.ranking b { color: var(--ink); }
.hidden { display: none !important; }
