:root {
  --ink: #0b1220;
  --paper: #eef6ff;
  --card: #ffffff;
  --muted: #4b5d78;
  --accent: #12b5a0;
  --accent-deep: #0d8f7e;
  --sun: #f5ff7a;
  --mint: #b8f5d4;
  --sky: #cfe3ff;
  --pink: #ffd0e8;
  --line: 2px solid var(--ink);
  --shadow: 5px 5px 0 var(--ink);
  --radius: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% -10%, rgba(18, 181, 160, 0.28), transparent 34%),
    radial-gradient(circle at 92% 0%, rgba(245, 255, 122, 0.55), transparent 28%),
    radial-gradient(circle at 50% 100%, rgba(207, 227, 255, 0.7), transparent 40%),
    linear-gradient(180deg, #f7fbff 0%, var(--paper) 48%, #e8f3ff 100%);
  font-family: "Outfit", "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

body, h1, h2, h3, p { overflow-wrap: anywhere; }

h1, h2, h3 {
  font-family: "Syne", "Outfit", sans-serif;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0 0 0.4em;
}

h1 { font-size: clamp(2.1rem, 5vw, 3.6rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }

a { color: inherit; }

img { max-width: 100%; height: auto; display: block; }

button, input, textarea, select { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 3px solid #2f6fed;
  outline-offset: 2px;
}

::selection { background: #b8f5d4; }

@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pop {
  from { transform: scale(0.96); }
  to { transform: scale(1); }
}

@keyframes brand-spin {
  from { transform: rotate(-8deg); }
  to { transform: rotate(8deg); }
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--sun);
  color: var(--ink);
  padding: 8px 12px;
  z-index: 40;
}

.skip:focus { top: 12px; }

.wrap {
  width: min(980px, calc(100% - 28px));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(238, 246, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: var(--line);
}

.header-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 74px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: 1.4rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: var(--line);
  border-radius: 12px;
  background: var(--accent);
  box-shadow: 3px 3px 0 var(--ink);
  animation: brand-spin 2.8s ease-in-out infinite alternate;
}

.nav-toggle { display: none; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px 14px;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-links a {
  text-decoration: none;
  font-weight: 650;
  padding: 6px 2px;
}

.nav-links a.is-active { text-decoration: underline; text-underline-offset: 5px; }

.me-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: var(--line);
  border-radius: 999px;
  background: white;
}

.me-chip strong, .me-chip small { display: block; }
.me-chip small { color: var(--muted); font-size: 0.78rem; }

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--sun);
  border: var(--line);
  font-weight: 700;
}

.btn, .adder button, .nav-toggle {
  border: var(--line);
  border-radius: 999px;
  background: white;
  padding: 10px 16px;
  box-shadow: 3px 3px 0 var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s ease, background 0.15s ease;
}

.btn:hover, .adder button:hover, .nav-toggle:hover { transform: translate(-1px, -1px); }

.btn-primary { background: var(--accent); font-weight: 700; color: #04241f; }

.btn-ghost { background: transparent; box-shadow: none; }

.btn-danger { background: var(--ink); color: #f5fbff; }

.btn-tiny { padding: 4px 10px; box-shadow: none; background: transparent; color: #f5fbff; }

.site-footer {
  margin-top: 48px;
  padding: 28px 0 40px;
  color: var(--muted);
}

.hero {
  padding: 28px 0 10px;
  animation: rise-in 0.55s ease both;
}

.hero p:last-child { max-width: 62ch; }

.kicker {
  display: inline-block;
  margin: 0 0 8px;
  padding: 3px 8px;
  border: var(--line);
  border-radius: 999px;
  background: var(--sun);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.card {
  background: var(--card);
  border: var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  animation: rise-in 0.5s ease both;
}

.stack { display: grid; gap: 16px; }
.stack > *:nth-child(1) { animation-delay: 0.02s; }
.stack > *:nth-child(2) { animation-delay: 0.06s; }
.stack > *:nth-child(3) { animation-delay: 0.1s; }
.stack > *:nth-child(4) { animation-delay: 0.14s; }
.stack > *:nth-child(5) { animation-delay: 0.18s; }

.post-card h2 a, .result h2 a { text-decoration: none; }
.post-card h2 a:hover, .result h2 a:hover { text-decoration: underline; text-underline-offset: 4px; }

.card-top, .section-head, .spark-row, .pager, .search-mini, .password-row, .code-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.meta, .fine, .char-count { color: var(--muted); }
.fine, .char-count { font-size: 0.92rem; }
.excerpt { margin: 0.3em 0 0.6em; }

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 18px;
}

.pill {
  flex: 0 0 auto;
  text-decoration: none;
  border: var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: white;
  font-weight: 650;
  transition: transform 0.15s ease;
}

.pill:hover { transform: translateY(-1px); }

.pill.is-on { background: var(--ink); color: #f5fbff; }
.pill-tecnologia { background: var(--mint); }
.pill-arte { background: var(--pink); }
.pill-musica { background: var(--sky); }
.pill-deportes { background: #ffd8b8; }
.pill-ciencia { background: #c9fff1; }
.pill-vida { background: #ffe0f0; }
.pill-juegos { background: var(--sun); }
.pill-opinion { background: #d9e7ff; }
.pill-humor { background: #d7ff8a; }
.pill-aprendizaje { background: #cde4ff; }
.pill.is-on.pill-tecnologia,
.pill.is-on.pill-arte,
.pill.is-on.pill-musica,
.pill.is-on.pill-deportes,
.pill.is-on.pill-ciencia,
.pill.is-on.pill-vida,
.pill.is-on.pill-juegos,
.pill.is-on.pill-opinion,
.pill.is-on.pill-humor,
.pill.is-on.pill-aprendizaje { background: var(--ink); color: #f5fbff; }

.search-mini { margin: 16px 0 8px; align-items: stretch; }
.search-mini input { flex: 1; }

.flashes { display: grid; gap: 8px; padding-top: 16px; }

.flash, .form-error, .empty {
  border: var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}

.flash-ok { background: var(--mint); }
.flash-info { background: var(--sky); }
.flash-error, .form-error { background: #ffd6df; }
.form-error[hidden] { display: none !important; }
.empty { background: white; }

.auth-shell {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 22px;
  align-items: center;
  padding: 34px 0;
}

.auth-story { animation: rise-in 0.55s ease both; }
.auth-card { animation: pop 0.45s ease both; }

.auth-card, .narrow { display: grid; gap: 12px; }
.narrow { max-width: 640px; margin: 28px auto; }

.field { display: grid; gap: 6px; font-weight: 650; }
.field span { font-size: 0.92rem; }

input, textarea, select {
  width: 100%;
  border: var(--line);
  border-radius: 12px;
  padding: 12px 12px;
  background: white;
  font-size: 16px;
}

textarea { min-height: 130px; resize: vertical; }

.password-row input { flex: 1; }
.password-row .btn { white-space: nowrap; }

.pager { margin: 18px 0 8px; }

.post-read { padding-top: 26px; animation: rise-in 0.5s ease both; }
.post-body, .comment { display: grid; gap: 14px; }
.reputation-line { margin-top: 0; }

.rich-text { white-space: pre-wrap; font-size: 1.06rem; }

.block-image img, .block-video, .code-wrap {
  border: var(--line);
  border-radius: 16px;
}

.block-video {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--ink);
}

.block-video iframe { width: 100%; height: 100%; border: 0; }

.code-wrap { overflow: hidden; background: #0b1220; color: #f5fbff; }
.code-top { padding: 8px 12px; color: #b8f5d4; font-size: 0.85rem; }
.code-wrap pre { margin: 0; padding: 14px; overflow: auto; }
.code-wrap code { font-family: "Cascadia Code", Consolas, monospace; font-size: 0.92rem; }

.spark-row { align-items: flex-start; flex-direction: column; margin: 18px 0; }
.spark-btn {
  border: var(--line);
  background: white;
  border-radius: 999px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease;
}
.spark-btn:hover { transform: translateY(-1px); }
.spark-btn.is-on { background: var(--sun); }
.spark-btn.is-own { background: var(--paper); }

.comments { padding-bottom: 20px; }
.section-head { margin: 10px 0; }
.section-head a { font-weight: 700; }
.comment { scroll-margin-top: 92px; }

.composer { margin: 12px 0 28px; }
.composer form, .search-form { display: grid; gap: 12px; }
.search-form { margin-bottom: 18px; }

.blocks:empty::before {
  content: "Todavía no hay bloques. Suma texto, una imagen, YouTube o código.";
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.piece {
  border: var(--line);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 10px;
  background: #f4faff;
  animation: rise-in 0.35s ease both;
}

.piece header, .adder { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.piece header { margin-bottom: 8px; font-weight: 700; }
.piece-actions, .adder { flex-wrap: wrap; }
.icon-btn {
  border: var(--line);
  background: white;
  border-radius: 10px;
  min-width: 36px;
  height: 36px;
}
.adder { margin: 4px 0 8px; }
.adder button { background: var(--sun); }

.preview {
  margin-top: 8px;
  width: min(100%, 280px);
  border: var(--line);
  border-radius: 12px;
}

.drop { outline: 3px dashed var(--accent); }

.code-input {
  font-family: "Cascadia Code", Consolas, monospace;
  background: #0b1220;
  color: #f5fbff;
  min-height: 160px;
}

.emoji-pop {
  position: fixed;
  z-index: 50;
  width: min(320px, calc(100vw - 20px));
  max-height: min(360px, 70vh);
  overflow: auto;
  background: white;
  border: var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 10px;
  animation: pop 0.2s ease both;
}

.emoji-pop[hidden] { display: none !important; }
.emoji-pop input { margin-bottom: 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.emoji-grid button {
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  border-radius: 8px;
  padding: 4px;
}
.emoji-grid button:hover { background: var(--sun); }

.score {
  height: 8px;
  border: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}
.score span { display: block; height: 100%; background: var(--accent); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

p code, .fine code {
  font-family: Consolas, monospace;
  background: white;
  border: 1px solid var(--ink);
  border-radius: 6px;
  padding: 0 0.35em;
}

@media (max-width: 800px) {
  .nav-toggle { display: inline-flex; margin-left: auto; }
  .nav-links {
    display: none;
    position: absolute;
    top: 74px;
    left: 0;
    right: 0;
    margin: 0;
    padding: 12px 14px 16px;
    background: var(--paper);
    border-bottom: var(--line);
    flex-direction: column;
    align-items: stretch;
  }
  .nav-links.is-open { display: flex; }
  .header-bar { position: relative; }
  .auth-shell { grid-template-columns: 1fr; padding-top: 20px; }
  .card { box-shadow: 3px 3px 0 var(--ink); }
  .spark-btn, .btn-primary { width: 100%; }
  .nav-links .btn-primary { width: auto; }
  .password-row, .search-mini, .card-top { align-items: stretch; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn:hover, .adder button:hover, .pill:hover, .spark-btn:hover { transform: none; }
  .brand-mark, .hero, .card, .auth-story, .auth-card, .post-read, .piece, .emoji-pop {
    animation: none;
  }
}
