:root {
  --paper: #f7f1e8;
  --paper-2: #fffaf2;
  --ink: #17201d;
  --muted: #6d716b;
  --line: rgba(23, 32, 29, .13);
  --forest: #314d45;
  --forest-2: #163a35;
  --berry: #7a3e58;
  --copper: #a76543;
  --gold: #c89b4b;
  --blue: #315d73;
  --danger: #a43d3d;
  --ok: #2f7a50;
  --shadow: 0 18px 60px rgba(23, 32, 29, .12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  background:
    linear-gradient(120deg, rgba(49, 77, 69, .08), transparent 32rem),
    linear-gradient(280deg, rgba(122, 62, 88, .08), transparent 30rem),
    var(--paper);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
.button {
  border: 0;
  border-radius: var(--radius);
  background: var(--forest);
  color: #fff;
  padding: .8rem 1rem;
  min-height: 42px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  box-shadow: 0 10px 24px rgba(49, 77, 69, .18);
}

button:hover,
.button:hover {
  background: var(--forest-2);
}

button.ghost,
.button.ghost {
  background: transparent;
  color: var(--forest);
  border: 1px solid var(--line);
  box-shadow: none;
}

.button.small {
  min-height: 36px;
  padding: .55rem .75rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 242, .82);
  color: var(--ink);
  padding: .78rem .82rem;
  font: inherit;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(49, 77, 69, .14);
}

label {
  display: grid;
  gap: .38rem;
  color: var(--muted);
  font-size: .92rem;
  font-weight: 700;
}

.check {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: .55rem;
}

.check input {
  width: auto;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .35;
  background-image: radial-gradient(rgba(23, 32, 29, .08) 1px, transparent 1px);
  background-size: 18px 18px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

.topbar {
  position: sticky;
  z-index: 5;
  top: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: .85rem clamp(1rem, 3vw, 2rem);
  backdrop-filter: blur(18px);
  background: rgba(247, 241, 232, .84);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  font-size: 1.1rem;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--paper-2);
  font-weight: 900;
  letter-spacing: 0;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  flex-wrap: wrap;
}

.nav a {
  color: var(--muted);
  padding: .55rem .7rem;
  border-radius: var(--radius);
  font-weight: 720;
  font-size: .92rem;
}

.nav a:hover {
  background: rgba(49, 77, 69, .08);
  color: var(--ink);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 800;
}

.user-chip form {
  margin: 0;
}

.icon-button {
  min-height: 34px;
  padding: .45rem .65rem;
  box-shadow: none;
  background: rgba(23, 32, 29, .08);
  color: var(--ink);
}

.shell {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.shell.wide {
  width: min(1320px, calc(100% - 2rem));
}

.hero,
.dashboard-hero,
.setup-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr);
  gap: clamp(1rem, 4vw, 3rem);
  align-items: center;
  min-height: 330px;
  padding: clamp(1.5rem, 4vw, 3rem) 0;
}

.hero.compact {
  grid-template-columns: 1fr;
  min-height: 220px;
}

.eyebrow {
  margin: 0 0 .35rem;
  color: var(--berry);
  text-transform: uppercase;
  letter-spacing: .11em;
  font-size: .72rem;
  font-weight: 900;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  max-width: 13ch;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.45rem, 7vw, 5.5rem);
  line-height: .93;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 .55rem;
  font-size: 1.25rem;
  line-height: 1.15;
}

p {
  margin: 0 0 1rem;
}

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

.hero-actions,
.timer-controls,
.row-between,
.stats-inline {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  align-items: center;
}

.row-between {
  justify-content: space-between;
}

.garden {
  min-height: 280px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 30% 20%, rgba(200, 155, 75, .26), transparent 8rem),
    linear-gradient(145deg, #e8d9c4, #fdf9f0);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.garden span {
  position: absolute;
  width: 22px;
  height: 70px;
  bottom: calc(18px + (var(--d) % 4) * 7px);
  left: calc(8% + (var(--d) * 5.2%));
  border-radius: 99px 99px 4px 4px;
  background: linear-gradient(var(--gold), var(--forest));
  transform: rotate(calc((var(--d) - 7) * 4deg));
  opacity: .76;
}

.garden strong {
  position: relative;
  font-size: 5rem;
  font-family: Georgia, serif;
}

.garden em {
  position: relative;
  color: var(--muted);
  margin-top: 6rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .85rem;
  margin: 1rem 0 1.2rem;
}

.metric,
.panel,
.auth-card,
.book-card,
.circle-card,
.note-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 242, .78);
  box-shadow: 0 14px 40px rgba(23, 32, 29, .08);
}

.metric {
  padding: 1rem;
}

.metric span {
  display: block;
  font-size: clamp(1.7rem, 5vw, 3rem);
  line-height: 1;
  font-family: Georgia, serif;
  color: var(--forest);
}

.metric small {
  color: var(--muted);
  font-weight: 800;
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.panel {
  padding: 1.15rem;
}

.panel-head,
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin: 0 0 1rem;
}

.section-head h1 {
  font-size: clamp(2rem, 6vw, 4.4rem);
}

.panel-head a {
  color: var(--forest);
  font-weight: 850;
}

.book-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 1rem;
  align-items: center;
}

.cover {
  min-height: 150px;
  border-radius: var(--radius);
  display: block;
  border: 1px solid rgba(23, 32, 29, .16);
  background: linear-gradient(145deg, var(--forest), var(--gold));
  box-shadow: inset 0 0 0 8px rgba(255, 250, 242, .2), var(--shadow);
}

.cover.big {
  min-height: 390px;
}

.cover.jardin { background: linear-gradient(145deg, #25483d, #bdd19d); }
.cover.mareas { background: linear-gradient(145deg, #1f5268, #83c0b1); }
.cover.cartografia { background: linear-gradient(145deg, #704d2f, #d3b272); }
.cover.relojes { background: linear-gradient(145deg, #27364e, #c99c55); }
.cover.faro { background: linear-gradient(145deg, #792f41, #f2d16b); }
.cover.aurora { background: linear-gradient(145deg, #47376d, #7cc5a5); }

.progress {
  height: 9px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(23, 32, 29, .1);
  margin: .55rem 0 .3rem;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--forest), var(--gold));
}

.cards,
.library-grid,
.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.library-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.book-card {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 1rem;
  padding: .8rem;
}

.book-card .cover {
  min-height: 190px;
}

.mini-form {
  display: grid;
  grid-template-columns: 78px minmax(110px, 1fr) auto;
  gap: .45rem;
  margin-top: .7rem;
}

.mini-form input,
.mini-form select,
.mini-form button {
  min-height: 38px;
  padding: .45rem;
}

.auth-card {
  width: min(460px, 100%);
  margin: 8vh auto;
  padding: 1.4rem;
}

.stack {
  display: grid;
  gap: .85rem;
}

.notice {
  padding: .85rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(49, 77, 69, .1);
  color: var(--forest-2);
  font-weight: 750;
}

.notice.danger {
  background: rgba(164, 61, 61, .12);
  color: var(--danger);
}

.notice.success {
  background: rgba(47, 122, 80, .12);
  color: var(--ok);
}

.notice.info {
  background: rgba(49, 93, 115, .12);
  color: var(--blue);
}

.book-detail {
  display: grid;
  grid-template-columns: minmax(220px, 340px) minmax(0, 1fr);
  gap: 2rem;
  align-items: center;
  margin-bottom: 1rem;
}

blockquote {
  margin: .55rem 0;
  padding-left: .9rem;
  border-left: 3px solid var(--gold);
  color: var(--forest-2);
  font-family: Georgia, serif;
}

.note-stream {
  display: grid;
  gap: .8rem;
}

.note-card,
.circle-card {
  padding: 1rem;
}

.feed-card {
  display: grid;
  gap: .75rem;
}

.feed-author {
  display: flex;
  gap: .7rem;
  align-items: center;
}

.mini-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

.inline-actions form {
  margin: 0;
}

.inline-actions button {
  min-height: 34px;
  padding: .45rem .65rem;
  box-shadow: none;
}

.search-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .7rem;
  margin-bottom: 1rem;
}

.search-results {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.timeline {
  display: grid;
  gap: .8rem;
  margin-top: 1rem;
}

.timeline-item {
  border-left: 3px solid var(--forest);
  background: rgba(255, 250, 242, .62);
  padding: .85rem 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.timeline-item.is-unread {
  border-left-color: var(--berry);
  background: rgba(122, 62, 88, .08);
}

.spoiler-text {
  filter: blur(5px);
  transition: filter .18s ease;
  cursor: help;
}

.spoiler-text:hover {
  filter: none;
}

.reader-room {
  min-height: 70vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  gap: 1rem;
  align-items: center;
}

#timer {
  font-size: clamp(5rem, 17vw, 12rem);
  max-width: none;
}

.tool-grid {
  align-items: stretch;
}

.tool .result,
.quote-card {
  margin-top: .85rem;
  min-height: 88px;
  border-radius: var(--radius);
  border: 1px dashed rgba(23, 32, 29, .22);
  padding: 1rem;
  background: rgba(247, 241, 232, .75);
}

.quote-card {
  font-family: Georgia, serif;
  font-size: 1.12rem;
}

.profile-card {
  text-align: center;
}

.avatar {
  width: 94px;
  height: 94px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  color: white;
  display: grid;
  place-items: center;
  font-size: 2.4rem;
  font-family: Georgia, serif;
  box-shadow: var(--shadow);
}

.stats-inline {
  justify-content: center;
}

.stats-inline span,
.badges span {
  display: inline-flex;
  border-radius: 99px;
  padding: .45rem .65rem;
  background: rgba(49, 77, 69, .1);
  color: var(--forest-2);
  font-weight: 800;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: .65rem .4rem;
  text-align: left;
  vertical-align: top;
}

.modal {
  width: min(560px, calc(100% - 2rem));
  border: 0;
  border-radius: var(--radius);
  padding: 1.1rem;
  background: var(--paper-2);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(23, 32, 29, .45);
  backdrop-filter: blur(4px);
}

.close {
  justify-self: end;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  box-shadow: none;
}

.setup-body {
  background:
    radial-gradient(circle at 80% 15%, rgba(200, 155, 75, .22), transparent 22rem),
    linear-gradient(135deg, rgba(49, 77, 69, .16), transparent 32rem),
    var(--paper);
}

.setup-shell {
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0;
}

.setup-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 242, .82);
  padding: 1rem;
}

.check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .65rem 0;
  border-bottom: 1px solid var(--line);
}

.check-row:last-child {
  border-bottom: 0;
}

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

.bad {
  color: var(--danger);
}

.install-form {
  display: grid;
  gap: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .9rem;
}

.span-2 {
  grid-column: span 2;
}

.install-button {
  justify-self: end;
}

.success-panel {
  text-align: center;
}

code {
  border-radius: 5px;
  background: rgba(23, 32, 29, .08);
  padding: .1rem .25rem;
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .nav {
    justify-content: start;
  }

  .hero,
  .dashboard-hero,
  .setup-hero,
  .reader-room,
  .book-detail,
  .grid.two {
    grid-template-columns: 1fr;
  }

  .stats-grid,
  .cards,
  .library-grid,
  .tool-grid,
  .search-results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .shell,
  .shell.wide,
  .setup-shell {
    width: min(100% - 1rem, 100%);
    padding-top: 1rem;
  }

  h1 {
    font-size: clamp(2.2rem, 14vw, 3.4rem);
  }

  .stats-grid,
  .cards,
  .library-grid,
  .tool-grid,
  .search-results,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .search-bar {
    grid-template-columns: 1fr;
  }

  .book-card,
  .book-row {
    grid-template-columns: 1fr;
  }

  .book-card .cover,
  .cover.big {
    min-height: 260px;
  }

  .mini-form {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .section-head {
    align-items: start;
    flex-direction: column;
  }

  .span-2 {
    grid-column: auto;
  }

  #timer {
    font-size: clamp(4.5rem, 22vw, 7rem);
  }
}

/* Premium visual system v0.4
   Local assets live in assets/premium so shared hosting does not need CDNs. */
body {
  background:
    linear-gradient(90deg, rgba(247, 241, 232, .94), rgba(247, 241, 232, .72)),
    image-set(url("premium/backdrops/backdrop-editorial-01.png") 1x);
  background-size: cover;
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  background-image: url("premium/textures/texture-paper-01.png");
  background-size: 900px 900px;
  mix-blend-mode: multiply;
  z-index: -1;
}

.topbar {
  border-bottom-color: rgba(23, 32, 29, .1);
  box-shadow: 0 12px 36px rgba(23, 32, 29, .08);
}

.brand-mark {
  background:
    linear-gradient(145deg, rgba(255,255,255,.18), transparent),
    var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14), 0 10px 24px rgba(23,32,29,.16);
}

.brand span:last-child {
  font-size: 1.08rem;
  letter-spacing: 0;
}

.nav a {
  position: relative;
  border: 1px solid transparent;
}

.nav a:hover {
  border-color: rgba(49, 77, 69, .12);
  box-shadow: 0 8px 22px rgba(23, 32, 29, .08);
}

.page-login .topbar,
.page-register .topbar,
.page-forgot .topbar,
.page-reset .topbar {
  background: rgba(255, 250, 242, .68);
}

.page-login .shell,
.page-register .shell,
.page-forgot .shell,
.page-reset .shell {
  width: min(1180px, calc(100% - 2rem));
}

.page-login .auth-card,
.page-register .auth-card,
.page-forgot .auth-card,
.page-reset .auth-card {
  margin: clamp(2rem, 8vh, 6rem) 0 clamp(2rem, 8vh, 6rem) auto;
  padding: clamp(1.25rem, 3vw, 2rem);
  min-height: 520px;
  display: grid;
  align-content: center;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 250, 242, .96), rgba(247, 241, 232, .9)),
    url("premium/textures/texture-paper-02.png");
  background-size: cover, 680px;
  box-shadow: 0 30px 90px rgba(23, 32, 29, .22);
}

.page-login .auth-card::before,
.page-register .auth-card::before,
.page-forgot .auth-card::before,
.page-reset .auth-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 9px;
  background: linear-gradient(var(--forest), var(--gold), var(--berry));
}

.page-login .auth-card::after,
.page-register .auth-card::after {
  content: "Lectura social, biblioteca inteligente y comunidad sin spoilers";
  position: absolute;
  right: 1.1rem;
  bottom: 1rem;
  width: min(260px, 55%);
  color: rgba(23, 32, 29, .42);
  font: 800 .78rem/1.35 Inter, system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.page-login .shell::before,
.page-register .shell::before {
  content: "";
  position: fixed;
  left: clamp(1rem, 5vw, 7rem);
  bottom: clamp(2rem, 9vh, 7rem);
  width: min(470px, 38vw);
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  background: url("premium/covers/cover-premium-01.png") center / cover no-repeat;
  box-shadow: 0 38px 90px rgba(23, 32, 29, .28);
  transform: rotate(-3deg);
  pointer-events: none;
}

.page-register .shell::before {
  background-image: url("premium/covers/cover-premium-05.png");
}

.hero,
.dashboard-hero,
.reader-room {
  background:
    linear-gradient(135deg, rgba(255,250,242,.72), rgba(247,241,232,.42)),
    url("premium/textures/texture-paper-03.png");
  background-size: cover, 980px;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 12px;
  padding-inline: clamp(1rem, 3vw, 2rem);
  box-shadow: 0 24px 70px rgba(23,32,29,.12);
}

.panel,
.metric,
.note-card,
.circle-card,
.book-card,
.auth-card {
  backdrop-filter: blur(16px);
}

.panel:hover,
.book-card:hover,
.circle-card:hover,
.note-card:hover {
  transform: translateY(-2px);
  transition: transform .18s ease, box-shadow .18s ease;
  box-shadow: 0 22px 58px rgba(23, 32, 29, .12);
}

.cover {
  background-size: cover;
  background-position: center;
}

.cover.jardin { background-image: url("premium/covers/cover-premium-01.png"); }
.cover.mareas { background-image: url("premium/covers/cover-premium-02.png"); }
.cover.cartografia { background-image: url("premium/covers/cover-premium-03.png"); }
.cover.relojes { background-image: url("premium/covers/cover-premium-04.png"); }
.cover.faro { background-image: url("premium/covers/cover-premium-05.png"); }
.cover.aurora { background-image: url("premium/covers/cover-premium-06.png"); }

.garden {
  background:
    linear-gradient(145deg, rgba(255,250,242,.22), rgba(49,77,69,.26)),
    url("premium/backdrops/backdrop-editorial-03.png") center / cover no-repeat;
  color: #fffaf2;
  text-shadow: 0 2px 16px rgba(23,32,29,.35);
}

.garden em {
  color: rgba(255,250,242,.82);
}

.reader-room {
  background:
    linear-gradient(90deg, rgba(23,32,29,.62), rgba(23,32,29,.18)),
    url("premium/backdrops/backdrop-editorial-05.png") center / cover no-repeat;
  color: #fffaf2;
}

.reader-room .panel {
  color: var(--ink);
}

.feed-card,
.timeline-item {
  background:
    linear-gradient(135deg, rgba(255,250,242,.9), rgba(247,241,232,.76)),
    url("premium/textures/texture-paper-02.png");
  background-size: cover, 720px;
}

.setup-hero {
  background:
    linear-gradient(90deg, rgba(247,241,232,.92), rgba(247,241,232,.66)),
    url("premium/backdrops/backdrop-editorial-02.png") center / cover no-repeat;
  border-radius: 12px;
  padding-inline: clamp(1rem, 3vw, 2rem);
}

.setup-card,
.success-panel {
  backdrop-filter: blur(14px);
}

@media (max-width: 980px) {
  .page-login .shell::before,
  .page-register .shell::before {
    display: none;
  }

  .page-login .auth-card,
  .page-register .auth-card,
  .page-forgot .auth-card,
  .page-reset .auth-card {
    margin-inline: auto;
    min-height: auto;
  }
}
