:root {
  --font-brand: "Unbounded", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
  --radius: 14px;
  --nav-h: 68px;
  --top-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --shadow: 0 12px 40px color-mix(in srgb, var(--ink) 8%, transparent);
  --motion: 220ms cubic-bezier(.2, .8, .2, 1);
}

/* ——— Themes ——— */
[data-theme="minimal"] {
  --bg: #f3f0ea;
  --bg-2: #ebe6dc;
  --surface: rgba(255, 252, 247, 0.86);
  --ink: #1c1916;
  --muted: #6b645c;
  --accent: #0f6b5c;
  --accent-ink: #f7fffc;
  --danger: #b42318;
  --line: rgba(28, 25, 22, 0.1);
  --hero-grad: radial-gradient(120% 80% at 10% 0%, #d9efe8 0%, transparent 55%),
               linear-gradient(160deg, #f7f3ec 0%, #e7e2d7 100%);
  --visual: linear-gradient(135deg, #1c1916 0%, #0f6b5c 55%, #c4a574 100%);
}

[data-theme="dark_minimal"] {
  --bg: #0e0f11;
  --bg-2: #17191d;
  --surface: rgba(24, 26, 30, 0.92);
  --ink: #eceae6;
  --muted: #9a968e;
  --accent: #7dd3be;
  --accent-ink: #06241d;
  --danger: #ff7b72;
  --line: rgba(255, 255, 255, 0.1);
  --hero-grad: radial-gradient(100% 70% at 90% 10%, #1a3a34 0%, transparent 50%),
               linear-gradient(165deg, #12141a 0%, #0a0b0d 100%);
  --visual: linear-gradient(145deg, #7dd3be 0%, #1b2430 60%, #0e0f11 100%);
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

[data-theme="barbie"] {
  --bg: #ffe4ef;
  --bg-2: #ffd0e0;
  --surface: rgba(255, 246, 250, 0.9);
  --ink: #3b1024;
  --muted: #8a4a66;
  --accent: #e2186d;
  --accent-ink: #fff7fb;
  --danger: #9f1239;
  --line: rgba(59, 16, 36, 0.12);
  --hero-grad: radial-gradient(90% 70% at 0% 0%, #ffb6d0 0%, transparent 50%),
               linear-gradient(150deg, #ffeaf2 0%, #ffd2e4 100%);
  --visual: linear-gradient(140deg, #ff4f9a 0%, #ff9ec4 45%, #ffe4ef 100%);
}

[data-theme="strict"] {
  --bg: #f5f5f5;
  --bg-2: #e8e8e8;
  --surface: #ffffff;
  --ink: #111111;
  --muted: #555555;
  --accent: #111111;
  --accent-ink: #ffffff;
  --danger: #8b0000;
  --line: #111111;
  --radius: 2px;
  --hero-grad: linear-gradient(180deg, #ffffff 0%, #f0f0f0 100%);
  --visual: repeating-linear-gradient(90deg, #111 0 2px, transparent 2px 28px),
            linear-gradient(180deg, #111 0%, #333 100%);
  --shadow: none;
  --font-brand: "Unbounded", "Times New Roman", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--hero-grad), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea {
  font: inherit;
  color: inherit;
}

.app-shell {
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  position: relative;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--top-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  border-bottom: 1px solid var(--line);
}

.brand, .brand-hero {
  font-family: var(--font-brand);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.brand { font-size: 1rem; font-weight: 700; }
.brand-hero {
  font-size: clamp(2.4rem, 10vw, 3.4rem);
  margin: 0.2rem 0 0.6rem;
  line-height: 1.05;
  animation: rise 700ms var(--motion) both;
}

.content { padding: 12px 16px 24px; }

.page-title {
  font-family: var(--font-brand);
  font-size: 1.55rem;
  margin: 0 0 0.25rem;
  letter-spacing: 0.02em;
}
.page-sub, .lead, .hint, .muted { color: var(--muted); }
.page-sub { margin: 0 0 1.2rem; }
.lead { margin: 0 0 1.5rem; line-height: 1.45; }
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--muted);
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 1rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  animation: fade-up 420ms var(--motion) both;
}

.stack-form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field span { font-size: 0.85rem; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 55%, white);
  border-radius: calc(var(--radius) - 4px);
  padding: 12px 14px;
  outline: none;
  transition: border-color var(--motion), box-shadow var(--motion);
}
[data-theme="dark_minimal"] .field input,
[data-theme="dark_minimal"] .field select,
[data-theme="dark_minimal"] .field textarea {
  background: var(--bg-2);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.code-input {
  letter-spacing: 0.35em;
  font-size: 1.35rem;
  text-align: center;
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--motion), background var(--motion), opacity var(--motion);
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn-ghost {
  background: transparent;
  border: none;
  color: var(--muted);
  padding-left: 0;
  padding-right: 0;
  justify-content: flex-start;
}
.btn-sm { padding: 8px 12px; font-size: 0.9rem; }
.btn.danger, .danger { color: var(--danger); }
.btn-row, .fab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.fab-row {
  position: sticky;
  bottom: calc(var(--nav-h) + var(--safe-b) + 8px);
  padding-top: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 1rem;
}

.category-grid {
  display: grid;
  gap: 10px;
}
.category-tile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform var(--motion), border-color var(--motion);
  animation: fade-up 500ms var(--motion) both;
}
.category-tile:nth-child(2) { animation-delay: 40ms; }
.category-tile:nth-child(3) { animation-delay: 80ms; }
.category-tile:nth-child(4) { animation-delay: 120ms; }
.category-tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.cat-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--bg-2);
  font-size: 1.4rem;
}
[data-theme="strict"] .cat-icon { border-radius: 0; border: 1px solid var(--ink); }
.cat-meta { display: grid; gap: 2px; }
.cat-meta strong { font-size: 1.05rem; }
.cat-meta small { color: var(--muted); }

.entry-list { display: grid; gap: 12px; }
.entry-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  animation: fade-up 400ms var(--motion) both;
}
.entry-item.is-done { opacity: 0.72; }
.entry-photo {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-2);
}
.entry-photo img { width: 100%; height: 100%; object-fit: cover; }
.entry-item:not(:has(.entry-photo)) { grid-template-columns: 1fr; }
.entry-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}
.entry-title { font-weight: 700; line-height: 1.3; }
.entry-desc {
  margin: 6px 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}
.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.82rem;
}
.badge {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-2);
}
[data-theme="strict"] .badge { border-radius: 0; }
.entry-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.star-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  transition: transform var(--motion), color var(--motion);
}
.star-btn.is-on { color: #e8b923; transform: scale(1.1); }
[data-theme="barbie"] .star-btn.is-on { color: #e2186d; }

.filter-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
}
.filter-tabs a {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  white-space: nowrap;
  font-size: 0.9rem;
}
.filter-tabs a.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
[data-theme="strict"] .filter-tabs a { border-radius: 0; }

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(520px, 100%);
  height: calc(var(--nav-h) + var(--safe-b));
  padding: 8px 8px calc(8px + var(--safe-b));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  z-index: 30;
}
.nav-item {
  display: grid;
  place-items: center;
  gap: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.is-active { color: var(--accent); }
[data-theme="strict"] .nav-item.is-active { color: var(--ink); }

.auth-hero {
  min-height: calc(100dvh - var(--top-h) - 24px);
  display: grid;
  gap: 18px;
  align-content: center;
}
.auth-panel { position: relative; z-index: 1; }
.auth-visual {
  height: 160px;
  border-radius: var(--radius);
  background: var(--visual);
  box-shadow: var(--shadow);
  animation: drift 8s ease-in-out infinite alternate;
}
[data-theme="strict"] .auth-visual { border: 2px solid var(--ink); }

.theme-picker { border: none; padding: 0; margin: 0; }
.theme-picker legend {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.theme-option {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
}
.theme-option input { position: absolute; opacity: 0; }
.theme-option.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.theme-swatch {
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.theme-minimal .theme-swatch { background: linear-gradient(135deg, #f3f0ea, #0f6b5c); }
.theme-dark_minimal .theme-swatch { background: linear-gradient(135deg, #0e0f11, #7dd3be); }
.theme-barbie .theme-swatch { background: linear-gradient(135deg, #ffe4ef, #e2186d); }
.theme-strict .theme-swatch { background: linear-gradient(135deg, #fff, #111); }

.pay-card .price-tag {
  font-family: var(--font-brand);
  font-size: 2.4rem;
  margin: 0 0 8px;
}
.plain-list { margin: 0 0 16px; padding-left: 1.1rem; color: var(--muted); }
.plain-list li { margin: 4px 0; }
.preview {
  margin-top: 8px;
  max-height: 160px;
  border-radius: 10px;
  object-fit: cover;
}
.dropzone {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg-2);
}
.empty-state, .empty {
  text-align: center;
  padding: 36px 12px;
  color: var(--muted);
}
.debug-hint {
  padding: 10px 12px;
  background: var(--bg-2);
  border-radius: 8px;
  border: 1px dashed var(--line);
}

.toast-stack {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(480px, calc(100% - 24px));
  z-index: 50;
  display: grid;
  gap: 8px;
}
.toast {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.92rem;
  animation: fade-up 300ms var(--motion) both;
  box-shadow: var(--shadow);
}
.toast-error, .toast-warning { background: var(--danger); color: #fff; }
.toast-success { background: var(--accent); color: var(--accent-ink); }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes drift {
  from { filter: saturate(1) brightness(1); transform: scale(1); }
  to { filter: saturate(1.15) brightness(1.05); transform: scale(1.02); }
}

@media (min-width: 720px) {
  .app-shell { max-width: 640px; }
  .bottom-nav, .topbar { max-width: 640px; }
  .category-grid { grid-template-columns: 1fr 1fr; }
}
