/* Vaelico app — zine / brutalist theme, matching vaelico.ai design tokens. */
:root {
  --paper: #f3e8cf;
  --paper-2: #fbf5e6;
  --ink: #14171a;
  --ink-soft: #3b3f45;
  --pink: #ff3b6b;
  --yellow: #ffd23f;
  --blue: #0040a5;
  --cyan: #1abadb;
  --green: #9bb320;
  --orange: #df6303;
  --purple: #6b4eff;
  --line: rgba(20, 23, 26, 0.14);
  --font-display: 'Bowlby One', 'Anton', system-ui, sans-serif;
  --font-body: 'Space Grotesk', system-ui, sans-serif;
  --font-marker: 'Permanent Marker', cursive;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.55;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='400' height='400'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.08 0 0 0 0 0.07 0 0 0 0 0.05 0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 400px 400px;
}
#app { height: 100%; }
[hidden] { display: none !important; }
a { color: var(--blue); font-weight: 600; }

.mark {
  font-family: var(--font-display); font-size: 30px; color: var(--ink);
  letter-spacing: .005em; line-height: 1;
}
.mark::after { content: "."; color: var(--pink); }
.mark.sm { font-size: 20px; }

/* Buttons — hard border + brutalist offset shadow, press-in on hover. */
button { font-family: inherit; cursor: pointer; }
.btn {
  border: 2px solid var(--ink); background: var(--paper-2); color: var(--ink);
  padding: 9px 16px; border-radius: var(--radius); font-size: 14px; font-weight: 700;
  box-shadow: var(--shadow-sm); transition: transform .1s, box-shadow .1s;
}
.btn:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.btn-accent { background: var(--pink); color: #fff; }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn-ghost:hover { background: rgba(20,23,26,.06); transform: none; box-shadow: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); }
.link { background: none; border: 0; color: var(--ink-soft); font-size: 13px; padding: 4px; font-weight: 600; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; text-decoration-color: var(--yellow); }
.link:hover { color: var(--ink); text-decoration-color: var(--pink); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ── Auth ── */
.auth { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; gap: 20px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--paper-2);
  border: 2px solid var(--ink); border-radius: 14px; padding: 30px; box-shadow: var(--shadow);
}
.brand { text-align: center; }
.auth-lead { text-align: center; color: var(--ink-soft); margin: 6px 0 22px; font-weight: 500; }
.tabs { display: flex; gap: 0; border: 2px solid var(--ink); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.tab { flex: 1; border: 0; background: var(--paper); color: var(--ink-soft); padding: 9px; font-weight: 700; font-size: 14px; }
.tab + .tab { border-left: 2px solid var(--ink); }
.tab.is-active { background: var(--yellow); color: var(--ink); }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.form small { color: var(--ink-soft); font-weight: 500; text-transform: none; letter-spacing: 0; }
.form input {
  background: #fff; border: 2px solid var(--ink); color: var(--ink);
  border-radius: var(--radius); padding: 11px 12px; font-size: 15px; font-family: inherit; font-weight: 500;
}
.form input:focus { outline: none; border-color: var(--blue); box-shadow: var(--shadow-sm); }
.msg { min-height: 18px; font-size: 13.5px; font-weight: 600; text-align: center; margin: 12px 0 0; }
.msg.err { color: var(--pink); }
.msg.ok { color: var(--green); }
.auth-foot { font-size: 12px; color: var(--ink-soft); font-weight: 500; }

/* ── Shell ── */
.shell { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 22px; padding: 0 20px; height: 60px;
  border-bottom: 3px solid var(--ink); background: var(--paper-2);
}
.nav { display: flex; gap: 4px; }
.navlink { border: 0; background: none; color: var(--ink-soft); font-weight: 700; font-size: 14px; padding: 7px 10px; border-radius: 6px; }
.navlink:hover { color: var(--ink); }
.navlink.is-active { color: var(--ink); background: var(--cyan); box-shadow: var(--shadow-sm); border: 2px solid var(--ink); padding: 5px 10px; }
.account { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.email { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.badge {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 20px; background: var(--yellow); color: var(--ink); border: 2px solid var(--ink);
}
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ── Chat ── */
.chat-head { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-bottom: 2px solid var(--line); }
.select { background: #fff; color: var(--ink); border: 2px solid var(--ink); border-radius: var(--radius); padding: 7px 10px; font-family: inherit; font-size: 14px; font-weight: 700; box-shadow: var(--shadow-sm); }
.grow { flex: 1; }
.tune { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; }
.tune input[type=range] { accent-color: var(--pink); width: 90px; }
.thread { flex: 1; overflow-y: auto; padding: 26px 0; }
.thread .empty { max-width: 560px; margin: 60px auto; text-align: center; color: var(--ink-soft); }
.empty-title { font-family: var(--font-marker); font-size: 30px; color: var(--ink); margin: 0 0 8px; transform: rotate(-2deg); }
.empty-sub { font-weight: 500; }
.turn { max-width: 720px; margin: 0 auto; padding: 12px 24px; }
.turn .who { font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 6px; }
.turn.user .who { color: var(--pink); }
.turn.assistant .who { color: var(--blue); }
.turn .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.turn.assistant .body { font-size: 16px; line-height: 1.7; }
.turn .body .cursor { color: var(--pink); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.composer { display: flex; gap: 10px; padding: 14px 20px; border-top: 3px solid var(--ink); background: var(--paper-2); align-items: flex-end; }
.composer textarea {
  flex: 1; resize: none; max-height: 200px; background: #fff; color: var(--ink);
  border: 2px solid var(--ink); border-radius: 10px; padding: 11px 14px;
  font-family: inherit; font-size: 15px; line-height: 1.5; font-weight: 500; box-shadow: var(--shadow-sm);
}
.composer textarea:focus { outline: none; border-color: var(--blue); }
.send { align-self: stretch; }

/* ── Pages ── */
.page { max-width: 780px; margin: 0 auto; width: 100%; padding: 28px 24px 60px; overflow-y: auto; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.page-head h1 { font-family: var(--font-display); font-size: 26px; margin: 0; flex: 1; }
.hint { color: var(--ink-soft); font-size: 14px; font-weight: 500; margin: 4px 0 20px; }
.keys { display: flex; flex-direction: column; gap: 12px; margin-bottom: 34px; }
.keyrow { display: flex; align-items: center; gap: 14px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: var(--radius); padding: 13px 16px; box-shadow: var(--shadow-sm); }
.keyrow .kp { font-family: var(--font-mono); font-size: 13px; font-weight: 700; }
.keyrow .kn { color: var(--ink-soft); font-size: 13px; font-weight: 600; }
.keyrow .kd { margin-left: auto; color: var(--ink-soft); font-size: 12px; font-weight: 600; }
.reveal { font-family: var(--font-mono); font-size: 13px; background: var(--yellow); border: 2px dashed var(--ink); border-radius: var(--radius); padding: 12px 14px; word-break: break-all; margin-bottom: 10px; color: var(--ink); font-weight: 700; }
.connect { border-top: 2px solid var(--line); padding-top: 22px; }
.connect h2, .upsell h2 { font-family: var(--font-display); font-size: 18px; margin: 0 0 12px; }
.connect ol { margin: 0; padding-left: 20px; color: var(--ink-soft); line-height: 2; font-size: 14px; font-weight: 500; }
.connect code, .hint code { font-family: var(--font-mono); font-size: 12.5px; background: var(--cyan); padding: 2px 6px; border-radius: 5px; color: var(--ink); border: 1px solid var(--ink); font-weight: 700; }

.meter { margin: 8px 0 20px; }
.meter-bar { height: 16px; background: #fff; border-radius: 20px; overflow: hidden; border: 2px solid var(--ink); }
.meter-bar span { display: block; height: 100%; background: var(--pink); width: 0; transition: width .4s; }
.meter-label { color: var(--ink-soft); font-size: 13px; font-weight: 600; margin: 8px 0 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 30px; }
.stats div { background: var(--paper-2); border: 2px solid var(--ink); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.stats dt { color: var(--ink-soft); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.stats dd { margin: 3px 0 0; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; font-family: var(--font-display); }
.upsell { display: flex; align-items: center; gap: 16px; background: var(--purple); color: #fff; border: 2px solid var(--ink); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.upsell div { flex: 1; }
.upsell h2 { color: #fff; }
.upsell .hint { color: rgba(255,255,255,.85); }

.admin table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin th { text-align: left; color: var(--ink-soft); font-weight: 700; padding: 8px; border-bottom: 2px solid var(--ink); font-size: 12px; text-transform: uppercase; }
.admin td { padding: 8px; border-bottom: 1px solid var(--line); font-weight: 500; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); border: 2px solid var(--ink); color: var(--paper);
  padding: 11px 18px; border-radius: 10px; font-size: 14px; font-weight: 600; z-index: 50; box-shadow: var(--shadow);
}
.toast.err { background: var(--pink); color: #fff; }

@media (max-width: 560px) {
  .email { display: none; }
  .topbar { gap: 12px; padding: 0 12px; }
  .turn, .page { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Stop (durante streaming): mismo botón, intención opuesta. */
.send.stop { background: #2b2b2b; color: #ffb1c9; }

/* ── Multi-chat + system prompt ── */
.select.chats { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.sysrow { padding: 12px 20px 0; }
.sysrow textarea {
  width: 100%; resize: vertical; min-height: 64px; background: #fff; color: var(--ink);
  border: 2px solid var(--ink); border-radius: 10px; padding: 10px 14px;
  font-family: inherit; font-size: 14px; line-height: 1.5; box-shadow: var(--shadow-sm);
}
.sysrow textarea:focus { outline: none; border-color: var(--blue); }

/* Acciones por mensaje (edit / delete / regenerate) — visibles al pasar el ratón */
.turn .acts { display: flex; gap: 14px; margin-top: 5px; visibility: hidden; }
.turn:hover .acts, .turn:focus-within .acts { visibility: visible; }
.turn .acts .link { font-size: 11px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.editbox {
  display: block; width: 100%; min-height: 90px; resize: vertical; margin-bottom: 8px;
  background: #fff; color: var(--ink); border: 2px solid var(--blue); border-radius: 10px;
  padding: 10px 14px; font-family: inherit; font-size: 15px; line-height: 1.5;
}

/* ── Gráfica de uso (14 días) ── */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; margin-top: 8px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.chart .bar { width: 100%; background: var(--pink); border: 2px solid var(--ink); border-radius: 4px 4px 0 0; box-shadow: var(--shadow-sm); }
.chart .lbl { font-family: var(--font-mono); font-size: 9px; color: var(--ink-soft); }
