:root {
  --scale: 1;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5f6673;
  --border: #dfe2e8;
  --accent: #c62828;
  --accent-text: #ffffff;
  --next: #fff6d6;
  --next-border: #e0a800;
  --ok: #2e7d32;
  --info-bg: #e3f0ff;
  --error-bg: #fde7e7;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #111317;
  --surface: #1b1e24;
  --text: #eceef2;
  --muted: #9aa1ad;
  --border: #2c3038;
  --accent: #e53935;
  --next: #2d2714;
  --next-border: #d4a017;
  --ok: #66bb6a;
  --info-bg: #142338;
  --error-bg: #3a1717;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.muted { color: var(--muted); }

.btn {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.icon { display: inline-flex; align-items: center; justify-content: center; }

/* ---------- Barra superior ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.6rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand div { display: flex; flex-direction: column; line-height: 1.15; }
.brand span { font-size: 0.8rem; }

.tabs { display: flex; gap: 0.4rem; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  font: inherit;
  font-weight: 600;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.tab small { color: var(--muted); font-weight: 400; margin-left: 0.2rem; }
.tab.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.tab.active small { color: inherit; opacity: 0.75; }

.toolbar { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin-left: auto; }

.live { font-size: 0.85rem; color: var(--ok); margin-right: 0.6rem; white-space: nowrap; }
.live::before { content: "●"; margin-right: 0.3rem; }
.live.offline { color: var(--muted); }

.banner { padding: 0.75rem 1.25rem; font-weight: 600; }
.banner.info { background: var(--info-bg); }
.banner.error { background: var(--error-bg); }

/* ---------- Contenido ---------- */

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
  font-size: calc(1rem * var(--scale));
}

.summary-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem 1rem; margin-bottom: 1rem; }
.summary-head h1 { margin: 0; font-size: 1.6em; }

.warnings, .done {
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9em;
}
.warnings { background: var(--error-bg); }
.done { background: var(--surface); border: 1px solid var(--ok); color: var(--ok); font-weight: 600; }

.group h2 {
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 1.75rem 0 0.75rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 0.9rem;
  transition: opacity 0.2s;
}
.card.next { background: var(--next); border: 2px solid var(--next-border); }
.card.read { opacity: 0.55; }
.card.read h3 { text-decoration: line-through; text-decoration-thickness: 1px; }
.card.busy { opacity: 0.6; }

.card-head { display: flex; align-items: center; gap: 0.6rem; font-size: 0.85em; }
.num {
  display: inline-grid;
  place-items: center;
  width: 1.8em;
  height: 1.8em;
  border-radius: 50%;
  background: var(--text);
  color: var(--surface);
  font-weight: 700;
}
.source { color: var(--muted); font-weight: 600; }
.badge {
  margin-left: auto;
  background: var(--next-border);
  color: #000;
  font-weight: 700;
  font-size: 0.8em;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.card h3 { font-size: 1.35em; line-height: 1.25; margin: 0.6rem 0 0.4rem; }
.card p { font-size: 1.15em; line-height: 1.55; margin: 0; }

.read-info { margin-top: 0.6rem; color: var(--ok); font-weight: 600; font-size: 0.9em; }

.card-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }

.empty { text-align: center; padding: 4rem 1rem; }

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
}

dialog {
  border: none;
  border-radius: 12px;
  padding: 1.5rem;
  background: var(--surface);
  color: var(--text);
  width: min(360px, 90vw);
}
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
dialog h2 { margin-top: 0; }
dialog form { display: flex; flex-direction: column; gap: 0.75rem; }

input {
  font: inherit;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  width: 100%;
}

/* ---------- Login ---------- */

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  text-align: center;
}
.login-card h1 { margin: 0.25rem 0 0; }
.login-card p { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 0.35rem; text-align: left; font-weight: 600; }
.error { color: var(--accent); font-weight: 600; }

@media (max-width: 1200px) {
  .tabs { order: 3; width: 100%; flex: none; }
}

@media (max-width: 640px) {
  .topbar { gap: 0.5rem; padding: 0.5rem 0.75rem; }
  .brand { width: 100%; }
  .brand img { width: 30px; height: 30px; }
  .live { position: absolute; top: 1.1rem; right: 0.75rem; margin: 0; }

  .toolbar { width: 100%; gap: 0.35rem; }
  #who { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; }
  .toolbar .btn { flex: 1 1 auto; padding: 0.4rem 0.5rem; font-size: 0.85rem; text-align: center; }

  .tab { padding: 0.35rem 0.7rem; font-size: 0.9rem; }

  main { padding: 1rem 0.75rem 3rem; }
  .card-actions .btn { flex: 1; text-align: center; }
}

@media (max-width: 400px) {
  .wide-only { display: none; }
}
