/* ── Startwise Magic Library – Styles v2.0 – Mobile first ─────────────────── */

/* ── CSS Variables ───────────────────────────────────────────────────────────── */
:root {
  --c-primary:       #7431ca;
  --c-primary-light: #a96df4;
  --c-primary-dark:  #5a23a8;
  --c-pink:          #e86690;
  --c-yellow:        #ffd66f;
  --c-cream:         #fffbf5;
  --c-bg:            #fbf7f0;
  --c-text:          #24174b;
  --c-muted:         #6c6475;
  --c-border:        rgba(105,76,124,.12);
  --c-white:         #ffffff;
  --c-success:       #2ecc71;
  --c-error:         #e05a7a;
  --shadow-sm:       0 4px 12px rgba(86,63,103,.08);
  --shadow-md:       0 12px 30px rgba(86,63,103,.10);
  --shadow-lg:       0 24px 60px rgba(86,63,103,.14);
  --radius-sm:       10px;
  --radius-md:       16px;
  --radius-lg:       24px;
  --radius-pill:     999px;
  --font-display:    "Playfair Display", Georgia, serif;
  --font-body:       "Nunito", "Inter", Arial, sans-serif;
  --header-h:        72px;
}

/* ── Reset ────────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font-body);
  color: var(--c-text); background: #fbf7f0;
  overflow-x: hidden; min-height: 100vh;
}
button, input, select, textarea { font: inherit; }
img { max-width: 100%; display: block; }
a { color: inherit; }
ul { padding: 0; margin: 0; list-style: none; }

/* ── Global hidden utility ────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Views ───────────────────────────────────────────────────────────────────── */
.view { display: none; min-height: 100vh; }
.view.active { display: block; }

/* ── Background decorations (fixed, always visible) ─────────────────────────── */
.bg-deco-layer {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden;
  background:
    radial-gradient(circle at 8% 18%,  rgba(255,220,139,.55), transparent 24%),
    radial-gradient(circle at 90% 10%, rgba(225,242,255,.9),  transparent 30%),
    radial-gradient(circle at 18% 88%, rgba(255,224,233,.62), transparent 26%),
    linear-gradient(118deg, #fffbf5 0%, #fff9fb 52%, #f7fcff 100%);
}
.bg-orb {
  position: absolute; border-radius: 999px; filter: blur(22px); opacity: .35;
}
.orb-1 { width: 260px; height: 260px; background: #ffd77a; left: -70px; top: 130px; }
.orb-2 { width: 280px; height: 280px; background: #cbeefe; right: -80px; top: 70px; }
.orb-3 { width: 240px; height: 240px; background: #ffcddf; left: 14%; bottom: 5%; }
.spark { position: absolute; color: #f1bf4e; font-size: 24px; opacity: .65; animation: twinkle 3s ease-in-out infinite; }
.s-1 { top: 29%; left: 2%; }
.s-2 { top: 20%; left: 45%; animation-delay: .8s; }
.s-3 { right: 6%; bottom: 12%; animation-delay: 1.4s; }
@keyframes twinkle { 50% { transform: scale(1.25) rotate(12deg); opacity: 1; } }

/* .dream-bokeh-layer superseded by .bg-deco-layer */
.dream-bokeh {
  position: absolute;
  left: var(--x); top: var(--y);
  width: var(--s); height: var(--s);
  border-radius: 50%;
  opacity: .18;
  animation: bokeh-float var(--d) ease-in-out var(--delay) infinite alternate;
  filter: blur(6px);
}
.bokeh-pink     { background: #ffb5c8; }
.bokeh-cream    { background: #ffe8a0; }
.bokeh-lavender { background: #d4b0f5; }
.bokeh-blue     { background: #aad4f5; }
@keyframes bokeh-float { 0% { transform: translateY(0) scale(1); } 100% { transform: translateY(-14px) scale(1.06); } }

/* .magic-fireflies superseded by .bg-deco-layer */
.magic-firefly {
  position: absolute;
  left: var(--x); top: var(--y);
  width: var(--s); height: var(--s);
  opacity: .55;
  animation: firefly-drift var(--d) ease-in-out var(--delay) infinite alternate;
}
@keyframes firefly-drift {
  0%   { transform: translate(0, 0) scale(1); opacity: .55; }
  50%  { opacity: .85; }
  100% { transform: translate(8px, -12px) scale(1.12); opacity: .4; }
}

/* ── Loading overlay ─────────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,251,245,.75); backdrop-filter: blur(8px);
}
.loading-overlay.hidden { display: none; }
.loading-card {
  background: var(--c-white); border-radius: var(--radius-lg);
  padding: 36px 48px; text-align: center;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.loading-spinner {
  width: 48px; height: 48px; border-radius: 50%;
  border: 4px solid var(--c-primary-light); border-top-color: var(--c-primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-card p { margin: 0; font-weight: 800; color: var(--c-muted); font-size: 15px; }

/* ── Toast ───────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 300; padding: 13px 22px; border-radius: var(--radius-pill);
  font-weight: 800; font-size: 14px; max-width: min(560px, calc(100vw - 32px));
  text-align: center; box-shadow: var(--shadow-md);
  transition: opacity .25s;
}
.toast.hidden { display: none; }
.toast-success { background: #edfff2; border: 2px solid #80d493; color: #1e5c30; }
.toast-error   { background: #fff0f4; border: 2px solid #e86690; color: #7a2d45; }
.toast-info    { background: #fff8ec; border: 2px solid var(--c-yellow); color: #6a4b1b; }

/* ── Site header ─────────────────────────────────────────────────────────────── */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 20px;
  margin: 12px 16px 0;
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.88);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
  position: relative; z-index: 10;
}
.brand { text-decoration: none; color: var(--c-text); display: grid; gap: 3px; flex-shrink: 0; }
.brand-word {
  display: flex; align-items: center;
  font-size: 22px; font-weight: 900; letter-spacing: .16em; line-height: 1;
}
.brand-word img { width: 30px; height: 30px; object-fit: contain; margin: 0 3px; }
.brand small {
  text-transform: uppercase; letter-spacing: .46em; font-size: 10px;
  font-weight: 800; margin-left: 28px; color: var(--c-muted);
}
.main-nav { display: none; }
.header-login, .account-pill {
  height: 42px; padding: 0 18px;
  border: 1px solid rgba(132,87,191,.18);
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,.7);
  color: var(--c-primary); font-weight: 800; font-size: 14px;
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.header-login img, .account-pill img { width: 20px; height: 20px; object-fit: contain; }
.account-pill em { font-style: normal; color: var(--c-muted); font-size: 11px; }
.back-link {
  border: 0; background: transparent; color: var(--c-primary);
  font-weight: 800; cursor: pointer; font-size: 14px; padding: 0;
}

/* ── Hero (landing) ──────────────────────────────────────────────────────────── */
.hero {
  position: relative; overflow: hidden;
  padding: 32px 20px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 24px;
}
/* Mobile: login card sits directly below copy so it's visible without scrolling */
.hero-copy         { order: 1; }
.hero-access-panel { order: 2; }
.hero-art          { order: 3; }
.fcloud {
  position: absolute; pointer-events: none; z-index: 1;
  animation: cloud-drift linear infinite;
}
.fc1 { width: 110px; top:  4%; left: -5%;  animation-duration: 32s; animation-delay:  0s; opacity: .7; }
.fc2 { width:  90px; top: 10%; right: 2%;  animation-duration: 28s; animation-delay: -6s; opacity: .6; }
.fc3 { width:  70px; top:  2%; left: 30%;  animation-duration: 35s; animation-delay: -3s; opacity: .5; }
.fc4 { width: 100px; top: 18%; right: 12%; animation-duration: 30s; animation-delay: -9s; opacity: .55; }
.fc5 { width:  80px; top:  6%; left: 55%;  animation-duration: 36s; animation-delay: -2s; opacity: .45; }
.fc6 { width:  60px; top: 14%; left: 15%;  animation-duration: 29s; animation-delay: -5s; opacity: .5; }
@keyframes cloud-drift { 0% { transform: translateX(0); } 50% { transform: translateX(18px); } 100% { transform: translateX(0); } }

.hero-copy { text-align: center; position: relative; z-index: 3; max-width: 560px; }
.hero-copy h1 {
  font-family: var(--font-display);
  font-size: clamp(32px, 8vw, 56px);
  line-height: 1.1; font-weight: 700;
  letter-spacing: -.02em; margin: 0;
}
.hero-copy h1 span { color: #d8668c; }
.hero-copy > p {
  max-width: 480px; margin: 16px auto 0;
  font-size: 16px; line-height: 1.55; color: var(--c-muted); font-weight: 600;
}
.hero-offers {
  display: flex; gap: 10px; margin-top: 24px;
  justify-content: center; flex-wrap: wrap;
}
.hero-offers article {
  flex: 1; min-width: 140px; max-width: 200px;
  min-height: 60px; padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm); background: rgba(255,255,255,.78);
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-sm);
}
.hero-offers img { width: 36px; height: 36px; object-fit: contain; }
.hero-offers strong, .hero-offers small { display: block; }
.hero-offers strong { font-size: 13px; font-weight: 900; }
.hero-offers small  { margin-top: 3px; color: var(--c-muted); font-size: 11px; }
.short-note {
  display: flex; align-items: center; gap: 12px; margin-top: 20px;
  justify-content: center;
}
.short-note img { width: 44px; height: 44px; object-fit: contain; flex-shrink: 0; }
.short-note span { max-width: 320px; font-size: 14px; line-height: 1.5; color: var(--c-muted); font-weight: 700; }
.hero-cta-row { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }

/* Hero art */
.hero-art {
  width: 100%; max-width: 360px; position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: center;
}
.hero-art img { width: 100%; height: auto; object-fit: contain; border-radius: 12px; }

/* Access / login card */
.hero-access-panel { width: 100%; max-width: 440px; position: relative; z-index: 5; }
.access-card {
  border-radius: var(--radius-lg); background: rgba(255,255,255,.92);
  border: 1px solid var(--c-border); box-shadow: var(--shadow-lg);
  padding: 52px 28px 30px; text-align: center;
  backdrop-filter: blur(14px); position: relative;
}
.access-star {
  position: absolute; top: -30px; left: 50%; transform: translateX(-50%);
  width: 76px; height: 76px; border-radius: 999px;
  background: radial-gradient(circle, #fff9d8, #ffe68c 60%, #fffdf5);
  display: grid; place-items: center;
  box-shadow: 0 0 0 8px rgba(255,224,126,.22), 0 12px 24px rgba(230,173,61,.18);
}
.access-star img { width: 50px; height: 50px; object-fit: contain; }
.access-card h2 {
  font-family: var(--font-display); font-size: 28px; line-height: 1.1; margin: 0;
}
.access-card > p { max-width: 300px; margin: 14px auto 22px; color: var(--c-muted); line-height: 1.5; font-weight: 650; font-size: 14px; }

/* ── Buttons ──────────────────────────────────────────────────────────────────── */
.btn-primary {
  height: 56px; border-radius: var(--radius-sm);
  border: 0; background: linear-gradient(180deg, var(--c-primary-light), var(--c-primary));
  color: var(--c-white); font-size: 15px; font-weight: 900; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 10px 24px rgba(116,49,202,.28), inset 0 1px 0 rgba(255,255,255,.3);
  transition: transform .14s, box-shadow .14s;
  text-decoration: none;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(116,49,202,.34); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  height: 48px; border-radius: var(--radius-sm);
  border: 1.5px solid rgba(116,49,202,.3); background: rgba(255,255,255,.78);
  color: var(--c-primary); font-size: 14px; font-weight: 800; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .14s, border-color .14s;
}
.btn-secondary:hover { transform: translateY(-1px); border-color: var(--c-primary); }
.btn-full  { width: 100%; }
.btn-sm    { height: 38px; font-size: 13px; padding: 0 16px; }
.btn-hero  { min-width: 160px; padding: 0 22px; }
.btn-subscribe {
  height: 38px; padding: 0 16px; border-radius: var(--radius-pill);
  border: 0; background: var(--c-yellow); color: #7a4b00; font-weight: 900; font-size: 13px; cursor: pointer;
  white-space: nowrap; flex-shrink: 0;
}
.btn-sub-renew { margin-top: 16px; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.email-form { display: flex; flex-direction: column; gap: 10px; }
.input-wrap {
  height: 52px; display: flex; align-items: center; gap: 12px;
  border: 1.5px solid var(--c-border); border-radius: var(--radius-sm);
  background: var(--c-white); padding: 0 14px;
}
.input-wrap:focus-within { border-color: var(--c-primary-light); }
.input-wrap img { width: 18px; height: 18px; object-fit: contain; flex-shrink: 0; }
.input-wrap input { border: 0; outline: 0; flex: 1; color: var(--c-text); font-size: 15px; background: transparent; }
.btn-primary .btn-text-default { pointer-events: none; }
.divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: #b0a8b5; font-size: 13px; }
.divider span { height: 1px; background: #e5dee8; flex: 1; }
.divider em { font-style: normal; }
.secure-note { display: block; margin-top: 16px; color: #a49bab; font-size: 12px; font-weight: 700; }
.field-error { color: var(--c-error); font-size: 13px; font-weight: 700; margin-top: 4px; }
.field-error.hidden { display: none; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 800; color: #5e5666; }
.form-group input,
.form-group select,
.form-group textarea {
  height: 48px; border: 1.5px solid var(--c-border); border-radius: var(--radius-sm);
  background: var(--c-white); padding: 0 14px; outline: 0; color: var(--c-text);
  font-size: 14px; font-weight: 600;
}
.form-group textarea { height: auto; padding: 12px 14px; resize: vertical; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--c-primary-light);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.req { color: var(--c-error); }
.section-label { font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; color: var(--c-muted); margin: 20px 0 12px; }
.btn-row { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.btn-row .btn-primary { flex: 1; }
.btn-row .btn-secondary { flex: 0 0 auto; }
.center-link { display: block; text-align: center; margin-top: 12px; }

/* Toggle checkbox */
.toggle-check {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  padding: 12px 0; font-weight: 700; font-size: 14px;
}
.toggle-check input { width: 20px; height: 20px; cursor: pointer; accent-color: var(--c-primary); }
.toggle-indicator { display: none; }

/* Chip multi-select */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip {
  height: 36px; padding: 0 14px; border-radius: var(--radius-pill);
  border: 1.5px solid var(--c-border); background: var(--c-white);
  color: var(--c-text); font-size: 13px; font-weight: 700; cursor: pointer;
  transition: all .14s;
}
.chip.selected, .chip:hover {
  background: var(--c-primary); color: var(--c-white); border-color: var(--c-primary);
}

/* Consent group */
.consent-group { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.consent-label {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13px; line-height: 1.5; font-weight: 700; cursor: pointer;
}
.consent-label input { margin-top: 2px; width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--c-primary); }
.consent-label a { color: var(--c-primary); text-decoration: underline; }

/* ── Feature row ─────────────────────────────────────────────────────────────── */
.feature-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px; padding: 24px 20px;
  margin: 0 16px 24px;
  border-top: 1px solid var(--c-border);
}
.feature-row article { display: flex; align-items: flex-start; gap: 12px; }
.feature-row img { width: 44px; height: 44px; object-fit: contain; flex-shrink: 0; }
.feature-row strong { display: block; font-weight: 900; font-size: 13px; }
.feature-row p { margin: 4px 0 0; color: var(--c-muted); font-size: 12px; line-height: 1.4; }

/* ── Register view ───────────────────────────────────────────────────────────── */
.register-wrap {
  display: flex; justify-content: center; padding: 24px 16px 40px;
  min-height: calc(100vh - var(--header-h) - 24px);
}
.register-card {
  width: 100%; max-width: 560px; background: rgba(255,255,255,.9);
  border-radius: var(--radius-lg); border: 1px solid var(--c-border);
  box-shadow: var(--shadow-md); padding: 32px 24px;
  backdrop-filter: blur(12px);
}
.reg-progress {
  display: flex; align-items: center; justify-content: center;
  gap: 0; margin-bottom: 28px;
}
.prog-step {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  flex: 0 0 auto;
}
.prog-step span {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--c-border); background: var(--c-white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 14px; color: var(--c-muted);
  transition: all .2s;
}
.prog-step em { font-style: normal; font-size: 11px; font-weight: 700; color: var(--c-muted); }
.prog-step.active span { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-white); }
.prog-step.active em  { color: var(--c-primary); }
.prog-step.completed span { background: #d4f5dc; border-color: #7dc98a; color: #2e6540; }
.prog-line { flex: 1; height: 2px; background: var(--c-border); min-width: 32px; max-width: 60px; }
.reg-step { display: none; }
.reg-step.active { display: block; }
.reg-step-header h2 { font-family: var(--font-display); font-size: 24px; margin: 0 0 4px; }
.reg-step-header { margin-bottom: 20px; }
.step-sub { margin: 0; color: var(--c-muted); font-size: 13px; font-weight: 700; }

/* ── Library view ────────────────────────────────────────────────────────────── */
.library-header { margin-bottom: 4px; }
/* On mobile the search bar lives below the filter strip, not in the header */
.lib-search-wrap {
  flex: 1; max-width: 300px;
  display: none;            /* hidden on mobile — shown at 640px+ */
  align-items: center; gap: 10px; height: 42px;
  border: 1.5px solid var(--c-border); border-radius: var(--radius-pill);
  background: var(--c-white); padding: 0 14px;
}
.lib-search-wrap:focus-within { border-color: var(--c-primary-light); }
.lib-search-wrap img { width: 18px; height: 18px; flex-shrink: 0; }
.lib-search-wrap input { border: 0; outline: 0; flex: 1; font-size: 14px; background: transparent; }

/* Mobile inline search (below filter strip) */
.mobile-search-wrap {
  display: flex; align-items: center; gap: 10px; height: 44px;
  border: 1.5px solid var(--c-border); border-radius: var(--radius-pill);
  background: var(--c-white); padding: 0 16px;
  margin: 0 16px 4px;
}
.mobile-search-wrap:focus-within { border-color: var(--c-primary-light); }
.mobile-search-wrap img { width: 18px; height: 18px; flex-shrink: 0; }
.mobile-search-wrap input { border: 0; outline: 0; flex: 1; font-size: 14px; background: transparent; }

/* Mobile filter strip */
.mobile-filter-strip {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.mobile-filter-strip::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0; height: 34px; padding: 0 14px;
  border-radius: var(--radius-pill); border: 1.5px solid var(--c-border);
  background: var(--c-white); color: var(--c-text); font-size: 13px; font-weight: 700;
  cursor: pointer; white-space: nowrap; transition: all .14s;
}
.filter-chip.active, .filter-chip:hover {
  background: var(--c-primary); color: var(--c-white); border-color: var(--c-primary);
}

/* Library shell */
.library-shell { padding: 0 16px 32px; display: flex; flex-direction: column; gap: 16px; }
.sidebar { display: none; }  /* hidden on mobile, shown desktop */

/* Library main */
.library-main { flex: 1; min-width: 0; }
.library-hero-bar {
  display: flex; flex-direction: column; gap: 14px; padding: 14px 0 16px;
  border-bottom: 1px solid var(--c-border); margin-bottom: 16px;
}
.library-hero-bar h1 { font-family: var(--font-display); font-size: 28px; margin: 0; color: var(--c-text); }
.library-hero-bar > div > p { font-size: 14px; color: var(--c-muted); margin: 6px 0 0; font-weight: 600; }

/* Magic Plus banner */
.magic-plus-banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 18px; border-radius: var(--radius-md);
  background: linear-gradient(135deg, #fffbef, #fff5ff);
  border: 1px solid rgba(255,214,111,.6);
  box-shadow: var(--shadow-sm);
}
.magic-plus-banner.sub-active { background: linear-gradient(135deg, #f0fff4, #eafff6); border-color: rgba(80,200,100,.3); }
.magic-plus-banner img { width: 32px; height: 32px; flex-shrink: 0; }
.magic-plus-banner > div { flex: 1; }
.magic-plus-banner strong { display: block; font-weight: 900; font-size: 14px; }
.magic-plus-banner p { margin: 3px 0 0; font-size: 12px; color: var(--c-muted); }
.badge-active-sub {
  background: #d4f5e2; color: #1e5c30; padding: 4px 12px;
  border-radius: var(--radius-pill); font-weight: 900; font-size: 12px;
}

/* Library controls */
.library-controls {
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px;
}
.lib-count-wrap p { margin: 0; color: var(--c-muted); font-size: 13px; font-weight: 700; }
.breadcrumb { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.crumb-btn {
  border: 1px solid rgba(116,49,202,.16); background: var(--c-white);
  color: var(--c-primary); border-radius: var(--radius-pill);
  padding: 6px 12px; font-weight: 800; font-size: 12px; cursor: pointer;
}
.crumb-sep { color: var(--c-muted); font-size: 12px; }

/* Resource grid */
.resource-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

/* Resource card */
.resource-card {
  border: 1px solid var(--c-border); border-radius: var(--radius-md);
  background: rgba(255,255,255,.88); overflow: hidden;
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
  transition: transform .14s, box-shadow .14s;
}
.resource-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.resource-card.locked { opacity: .92; }
.card-top {
  height: 120px; position: relative;
  background: linear-gradient(135deg, #fff0f5, #f3efff);
  flex-shrink: 0;
}
.resource-card:nth-child(2n)   .card-top { background: linear-gradient(135deg, #ffd3c3, #fff1ee); }
.resource-card:nth-child(3n)   .card-top { background: linear-gradient(135deg, #eef8ff, #fff5ef); }
.resource-card:nth-child(4n)   .card-top { background: linear-gradient(135deg, #ffeef5, #fff8ea); }
.resource-card:nth-child(5n)   .card-top { background: linear-gradient(135deg, #f0f8ff, #eafff3); }
.card-icon {
  position: absolute; bottom: -20px; left: 14px;
  width: 48px; height: 48px; border-radius: 50%; background: var(--c-white);
  display: grid; place-items: center; box-shadow: var(--shadow-sm); z-index: 1;
}
.card-icon img { width: 30px; height: 30px; object-fit: contain; }
.card-badge {
  position: absolute; top: 10px; right: 12px;
  border-radius: var(--radius-pill); padding: 4px 10px; font-weight: 900; font-size: 11px;
}
.badge-free       { background: #d4f5e2; color: #1e5c30; }
.badge-unlocked   { background: #d4e8f5; color: #1e3d5c; }
.badge-premium    { background: #f5e7fb; color: var(--c-primary-dark); }
.badge-subscriber { background: #fffbe0; color: #7a5a00; }
.card-body { padding: 28px 14px 10px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.card-tag { font-size: 11px; font-weight: 700; color: var(--c-muted); background: #f0ebf8; padding: 2px 8px; border-radius: 6px; }
.resource-card h3 { margin: 0; font-size: 15px; line-height: 1.3; font-weight: 900; }
.resource-card p  { margin: 0; color: var(--c-muted); font-size: 13px; line-height: 1.5; font-weight: 600; }
.card-meta { font-size: 11px; color: var(--c-muted); font-weight: 700; margin-top: auto; }
.card-price { font-size: 13px; font-weight: 800; color: var(--c-primary); margin: 0; }
.free-price { color: #2e8c4a; }
.subscriber-price { color: #7a5a00; font-size: 12px; }
.card-actions { padding: 10px 14px 14px; display: flex; justify-content: flex-end; }
.card-btn {
  height: 36px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1.5px solid rgba(116,49,202,.24); background: var(--c-white);
  color: var(--c-primary); font-weight: 900; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .14s;
}
.card-btn img { width: 16px; height: 16px; object-fit: contain; }
.card-btn:hover { background: var(--c-primary); color: var(--c-white); border-color: var(--c-primary); }
.btn-unlock, .btn-subscribe-item {
  background: linear-gradient(180deg, #a96df4, var(--c-primary));
  color: var(--c-white); border: 0;
}
.btn-download:hover { background: #2e8c4a; border-color: #2e8c4a; }
.empty-card { justify-content: center; align-items: center; padding: 40px 20px; text-align: center; opacity: .7; }

/* Card thumbnail support */
.card-thumb {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  border-radius: inherit;
}
.card-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 52px; line-height: 1;
  opacity: .55;
}

/* Charming empty state */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 56px 24px 48px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty-state .es-emoji { font-size: 56px; line-height: 1; margin-bottom: 4px; }
.empty-state h3 { font-family: var(--font-display); font-size: 22px; margin: 0; color: var(--c-text); }
.empty-state p  { margin: 0; color: var(--c-muted); font-size: 14px; font-weight: 600; max-width: 280px; }
.empty-state .btn-secondary { margin-top: 8px; }
.file-card .card-top { background: linear-gradient(135deg, #e8f8ff, #f3efff); }

/* Inline message */
.inline-message {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-weight: 700; font-size: 14px; margin-bottom: 14px;
  background: #fff8ec; border: 1.5px solid var(--c-yellow); color: #6a4b1b;
}
.inline-message.hidden { display: none; }
.message-info    { background: #fff8ec; border-color: var(--c-yellow);  color: #6a4b1b; }
.message-success { background: #edfff2; border-color: #80d493;          color: #2e6540; }
.message-error   { background: #fff0f4; border-color: var(--c-error);   color: #7a2d45; }

/* ── Account view ────────────────────────────────────────────────────────────── */
.account-wrap { padding: 24px 16px 40px; max-width: 860px; margin: 0 auto; }
.account-page-header { margin-bottom: 24px; }
.account-page-header h1 { font-family: var(--font-display); font-size: 28px; margin: 0; }
.account-page-header p  { margin: 6px 0 0; color: var(--c-muted); font-size: 14px; }

/* Tabs */
.account-tabs {
  display: flex; gap: 0; overflow-x: auto; padding-bottom: 2px;
  border-bottom: 2px solid var(--c-border); margin-bottom: 24px;
  scrollbar-width: none;
  /* Fade right edge to hint scrollability on mobile */
  -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
  mask-image: linear-gradient(to right, black 85%, transparent 100%);
}
.account-tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  flex-shrink: 0; height: 40px; padding: 0 12px;
  border: 0; border-bottom: 2px solid transparent; margin-bottom: -2px;
  background: transparent; color: var(--c-muted); font-weight: 800; font-size: 13px;
  cursor: pointer; transition: color .14s, border-color .14s;
  white-space: nowrap;
}
.tab-btn.active { color: var(--c-primary); border-bottom-color: var(--c-primary); }
.tab-pane       { display: none; }
.tab-pane.active{ display: block; }
.account-section { background: rgba(255,255,255,.82); border-radius: var(--radius-md); padding: 24px; border: 1px solid var(--c-border); box-shadow: var(--shadow-sm); }
.account-section h2 { font-family: var(--font-display); font-size: 22px; margin: 0 0 18px; }
.account-section h3 { font-size: 15px; margin: 20px 0 12px; }

/* Profile grid */
.profile-grid { display: grid; gap: 12px; margin-bottom: 20px; }
.profile-field { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--c-border); }
.profile-field span { font-size: 13px; color: var(--c-muted); font-weight: 700; flex-shrink: 0; }
.profile-field strong { font-size: 14px; text-align: right; word-break: break-all; }

/* Data list */
.data-list { display: flex; flex-direction: column; gap: 10px; }
.data-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--c-bg); border: 1px solid var(--c-border); gap: 12px;
}
.data-row > div { display: flex; flex-direction: column; gap: 4px; }
.data-row strong { font-size: 14px; font-weight: 900; }
.data-row span   { font-size: 12px; color: var(--c-muted); }
.badge-status { font-size: 11px; font-weight: 900; padding: 3px 10px; border-radius: 6px; background: #f0ebf8; color: var(--c-primary-dark); flex-shrink: 0; }
.text-muted { color: var(--c-muted); font-size: 12px; }
.text-success { color: #2e8c4a; }
.empty-state { color: var(--c-muted); font-size: 14px; padding: 20px 0; text-align: center; }
.text-btn { border: 0; background: transparent; color: var(--c-primary); font-weight: 800; font-size: 12px; cursor: pointer; padding: 0; }
.btn-receipt-dl { flex-shrink: 0; }

/* Subscription card */
.sub-status-card {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 18px; border-radius: var(--radius-md); margin-bottom: 20px;
}
.active-sub   { background: linear-gradient(135deg, #f0fff4, #f7fffc); border: 1px solid #80d493; }
.inactive-sub { background: linear-gradient(135deg, #fff8ec, #fffbf5); border: 1px solid var(--c-yellow); }
.sub-icon { font-size: 28px; flex-shrink: 0; }
.sub-status-card strong { display: block; font-weight: 900; font-size: 15px; margin-bottom: 4px; }
.sub-status-card p { margin: 0 0 4px; font-size: 13px; color: var(--c-muted); }
.sub-features ul { padding-left: 0; display: flex; flex-direction: column; gap: 6px; }
.sub-features li { font-size: 14px; font-weight: 700; color: var(--c-text); }

/* Support form */
.support-form-toggle { margin-top: 24px; border: 1px solid var(--c-border); border-radius: var(--radius-md); }
.support-form-toggle > summary {
  padding: 14px 18px; cursor: pointer; font-weight: 800; font-size: 14px; color: var(--c-primary);
  list-style: none;
}
.support-form-toggle > summary::-webkit-details-marker { display: none; }
.support-form-toggle > form { padding: 0 18px 18px; display: flex; flex-direction: column; gap: 14px; }

/* ── Payment result views ────────────────────────────────────────────────────── */
.payment-result-wrap {
  display: flex; justify-content: center; align-items: flex-start;
  padding: 32px 16px 48px; min-height: calc(100vh - var(--header-h) - 24px);
}
.payment-success-card, .payment-failed-card {
  width: 100%; max-width: 520px; text-align: center;
  background: rgba(255,255,255,.92); border-radius: var(--radius-lg);
  border: 1px solid var(--c-border); box-shadow: var(--shadow-lg);
  padding: 40px 24px 32px; backdrop-filter: blur(12px);
}
.payment-success-card h2 { font-family: var(--font-display); font-size: 26px; margin: 0 0 8px; }
.payment-success-card > p, .payment-failed-card > p { color: var(--c-muted); font-size: 14px; margin: 0 0 20px; font-weight: 600; }
.payment-failed-card h2  { font-family: var(--font-display); font-size: 26px; margin: 0 0 8px; color: var(--c-error); }

.result-icon {
  width: 80px; height: 80px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 900; margin: 0 auto 20px;
}
.success-icon { background: radial-gradient(circle, #fffbe0, #d4f5e2 60%); color: var(--c-success); }
.failed-icon  { background: #fff0f4; color: var(--c-error); }

.receipt-box {
  background: var(--c-bg); border: 1.5px solid var(--c-border);
  border-radius: var(--radius-md); padding: 18px 20px;
  margin: 16px 0; text-align: left;
}
.receipt-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 8px 0; border-bottom: 1px solid var(--c-border); gap: 12px;
}
.receipt-row:last-child { border-bottom: 0; }
.receipt-row span   { font-size: 13px; color: var(--c-muted); font-weight: 700; flex-shrink: 0; }
.receipt-row strong { font-size: 13px; font-weight: 900; word-break: break-all; text-align: right; }
.receipt-status strong { color: var(--c-success); font-size: 14px; }
.receipt-placeholder { text-align: center; color: var(--c-muted); font-size: 13px; padding: 12px 0; margin: 0; }
.access-note {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12px; color: var(--c-muted); font-weight: 700; margin: 12px 0;
  background: #fff8ec; border-radius: var(--radius-sm); padding: 10px 12px; text-align: left;
}
.access-note img { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.failed-note { font-size: 13px; color: var(--c-muted); font-weight: 700; margin: 0 0 20px; }
.payment-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.receipt-action-row { display: flex; gap: 10px; }
.receipt-action-row .btn-secondary { flex: 1; }


/* ═══════════════════════════════════════════════════════════════════════════════
   TABLET – 640px+
   ══════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 640px) {
  .site-header { padding: 16px 28px; margin: 14px 20px 0; }
  .brand-word { font-size: 26px; }
  .brand-word img { width: 34px; height: 34px; }
  .main-nav { display: flex; gap: 32px; align-items: center; }
  /* Show search in header, hide mobile inline search */
  .lib-search-wrap { display: flex; }
  .mobile-search-wrap { display: none; }
  .main-nav a { text-decoration: none; color: #30283d; font-size: 14px; font-weight: 700; padding: 8px 0; position: relative; }
  .main-nav a.active { color: var(--c-primary); }
  .main-nav a.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--c-primary); }

  .hero { padding: 40px 28px 28px; flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 28px; align-items: flex-start; }
  .hero-copy { text-align: left; flex: 0 1 420px; order: unset; }
  .hero-offers { justify-content: flex-start; }
  .short-note  { justify-content: flex-start; }
  .hero-cta-row { justify-content: flex-start; }
  .hero-art { flex: 0 1 320px; max-width: 320px; order: unset; }
  .hero-access-panel { flex: 0 0 400px; order: unset; }

  .feature-row { grid-template-columns: repeat(4, 1fr); padding: 24px 28px; margin: 0 20px 24px; }
  .resource-grid { grid-template-columns: repeat(2, 1fr); }
  .library-shell { padding: 0 20px 40px; }
  .account-wrap  { padding: 28px 24px 48px; }
  .register-card { padding: 36px 36px; }
  .payment-result-wrap { padding: 40px 28px 60px; }
  .payment-success-card, .payment-failed-card { padding: 48px 36px 40px; }
}


/* ═══════════════════════════════════════════════════════════════════════════════
   DESKTOP – 1024px+
   ══════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
  .site-header { padding: 18px 36px; margin: 16px 32px 0; border-radius: 20px; }
  .brand-word { font-size: 28px; }
  .main-nav { gap: 44px; }
  .header-login, .account-pill { height: 46px; padding: 0 24px; }

  .hero {
    flex-direction: row; flex-wrap: nowrap;
    max-width: min(1400px, calc(100% - 64px)); margin: 0 auto;
    align-items: center; padding: 32px 0 20px; gap: 24px;
    justify-content: space-between;
  }
  .hero-copy { flex: 0 0 auto; width: 38%; text-align: left; padding-left: 40px; }
  .hero-copy h1 { font-size: clamp(40px, 3.8vw, 68px); }
  .hero-art { flex: 0 0 auto; width: 32%; max-width: none; }
  .hero-access-panel { flex: 0 0 auto; width: 27%; max-width: 400px; }
  .access-card { padding: 60px 32px 32px; }
  .access-card h2 { font-size: 30px; }
  .hero-cta-row { display: none; }  /* CTAs live in the access card on desktop */

  .mobile-filter-strip { display: none; }

  .feature-row { max-width: min(1400px, calc(100% - 64px)); margin: 0 auto 20px; padding: 20px 40px 16px; }

  .library-shell {
    max-width: min(1400px, calc(100% - 64px)); margin: 0 auto;
    padding: 0 32px 48px;
    display: grid; grid-template-columns: 260px 1fr; gap: 32px;
  }

  .sidebar {
    display: block; align-self: start; position: sticky; top: 20px;
    background: rgba(255,255,255,.78); border: 1px solid var(--c-border);
    border-radius: var(--radius-md); padding: 20px 12px;
    box-shadow: var(--shadow-sm);
  }
  .sidebar h3 { margin: 8px 4px 10px; display: flex; align-items: center; gap: 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); }
  .sidebar h3 img { width: 18px; height: 18px; }
  .sidebar h3:not(:first-child) { margin-top: 20px; border-top: 1px solid var(--c-border); padding-top: 16px; }
  .sb-btn {
    width: 100%; height: 38px; border: 0; background: transparent; border-radius: 8px;
    color: #5a5268; display: flex; align-items: center; gap: 10px;
    padding: 0 10px; font-weight: 700; font-size: 13px; text-align: left; cursor: pointer;
    margin-bottom: 3px; transition: background .12s, color .12s;
  }
  .sb-btn.active, .sb-btn:hover { background: #f0e7fb; color: var(--c-primary); }
  .sb-btn img { width: 18px; height: 18px; object-fit: contain; flex-shrink: 0; }

  .library-hero-bar {
    flex-direction: row; align-items: center; justify-content: space-between;
    flex-wrap: wrap;
  }
  .library-hero-bar h1 { font-size: 40px; }

  .resource-grid { grid-template-columns: repeat(3, 1fr); gap: 18px; }
  .card-top { height: 140px; }
  .card-icon { width: 52px; height: 52px; bottom: -22px; }
  .card-icon img { width: 32px; height: 32px; }
  .card-body { padding: 32px 16px 10px; }
  .resource-card h3 { font-size: 16px; }
}

/* ── Large desktop 1280px+ ───────────────────────────────────────────────────── */
@media (min-width: 1280px) {
  .hero-copy h1 { font-size: clamp(46px, 4.2vw, 74px); }
  .resource-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .access-card h2 { font-size: 34px; }
}

/* ── Footer ──────────────────────────────────────────────────────────────────── */
.site-footer {
  margin: 24px 16px 20px;
  border-top: 1px solid var(--c-border);
  padding: 28px 0 8px;
}
.footer-inner {
  display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center;
}
.footer-brand { display: flex; flex-direction: column; gap: 3px; align-items: center; }
.footer-brand .brand-word {
  font-size: 18px; font-weight: 900; letter-spacing: .14em; display: flex; align-items: center; gap: 4px;
}
.footer-brand .brand-word img { width: 22px; height: 22px; object-fit: contain; }
.footer-brand small { font-size: 10px; font-weight: 800; letter-spacing: .42em; text-transform: uppercase; color: var(--c-muted); }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 20px; justify-content: center; }
.footer-links a {
  font-size: 13px; font-weight: 700; color: var(--c-muted); text-decoration: none;
  transition: color .14s;
}
.footer-links a:hover { color: var(--c-primary); }
.footer-copy { margin: 0; font-size: 12px; color: var(--c-muted); opacity: .7; font-weight: 600; }

/* ── Print styles (receipt) ──────────────────────────────────────────────────── */
@media print {
  .ambient-bg, .dream-bokeh-layer, .magic-fireflies,
  .site-header, .sidebar, .mobile-filter-strip,
  .payment-actions, .access-note, .toast, .loading-overlay { display: none !important; }
  body { background: white; }
  .payment-result-wrap { padding: 0; }
  .payment-success-card { box-shadow: none; border: none; }
  .receipt-box { border: 1px solid #ccc; }
}
