:root {
  /* Palette: ink, paper, copper, moss */
  --ink: #111318;
  --ink-soft: #191c23;
  --ink-raised: #1f2430;
  --ink-border: rgba(255, 248, 238, 0.09);
  --ink-border-strong: rgba(255, 248, 238, 0.18);
  --paper: #f6f1e8;
  --paper-muted: #c9c2b5;
  --paper-dim: #928b80;
  --copper: #d47a4a;
  --copper-deep: #b86234;
  --copper-soft: rgba(212, 122, 74, 0.14);
  --copper-glow: rgba(212, 122, 74, 0.28);
  --moss: #6abf8a;
  --moss-soft: rgba(106, 191, 138, 0.14);
  --danger: #e06b6b;
  --danger-soft: rgba(224, 107, 107, 0.12);

  --radius: 20px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --transition: 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
  --font-display: "Instrument Serif", Georgia, serif;
  --font-body: "DM Sans", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--paper);
  background: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Background atmosphere */
.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% -10%, rgba(212, 122, 74, 0.13), transparent 65%),
    radial-gradient(ellipse 50% 40% at 85% 10%, rgba(106, 191, 138, 0.06), transparent 60%),
    linear-gradient(180deg, #14171d 0%, var(--ink) 40%);
}
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.page {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 32px 0 80px;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 0 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--copper), #e8a070);
  display: grid;
  place-items: center;
  color: #1a1008;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(212, 122, 74, 0.35);
}
.brand-name {
  font-size: 17px;
  letter-spacing: -0.02em;
}
.brand-name span { color: var(--paper-muted); font-weight: 400; }

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-link {
  padding: 10px 16px;
  font-size: 14px;
  color: var(--paper-muted);
  text-decoration: none;
  border-radius: 10px;
  transition: color var(--transition), background var(--transition);
}
.nav-link:hover { color: var(--paper); background: rgba(255,255,255,0.04); }
.nav-link.active { color: var(--paper); }
.nav-link.admin-link {
  margin-left: 8px;
  border: 1px solid var(--ink-border-strong);
  color: var(--paper);
}
.nav-link.admin-link:hover {
  border-color: rgba(212, 122, 74, 0.5);
  background: var(--copper-soft);
}

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  padding: 24px 0 72px;
  max-width: 860px;
}
.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--copper);
  letter-spacing: 0.01em;
}
.hero-kicker::before {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--copper);
}
.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(48px, 7.5vw, 88px);
  line-height: 0.96;
  letter-spacing: -0.035em;
  font-weight: 400;
  text-wrap: balance;
}
.hero h1 em {
  font-style: italic;
  color: var(--copper);
}
.hero-lead {
  margin: 8px 0 0;
  max-width: 580px;
  font-size: 17px;
  line-height: 1.7;
  color: var(--paper-muted);
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible {
  outline: 2px solid var(--copper);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--copper);
  color: #1a1008;
  box-shadow: 0 10px 30px rgba(212, 122, 74, 0.3);
}
.btn-primary:hover {
  background: #e08656;
  box-shadow: 0 14px 36px rgba(212, 122, 74, 0.38);
}
.btn-ghost {
  background: transparent;
  color: var(--paper);
  border-color: var(--ink-border-strong);
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255, 248, 238, 0.3);
}
.btn-sm {
  padding: 9px 14px;
  font-size: 13px;
  border-radius: 9px;
  gap: 6px;
}
.btn-danger {
  background: var(--danger-soft);
  color: #f0a0a0;
  border-color: rgba(224, 107, 107, 0.2);
}
.btn-danger:hover { background: rgba(224, 107, 107, 0.2); }
.btn-full { width: 100%; }

.btn svg { flex-shrink: 0; }

/* Section heading */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--ink-border);
}
.section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.section-head p {
  margin: 0;
  max-width: 380px;
  color: var(--paper-muted);
  font-size: 15px;
  line-height: 1.6;
  text-align: right;
}

/* Product grid */
.products-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

/* Product card */
.product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 28px;
  background: linear-gradient(180deg, rgba(255, 248, 238, 0.035) 0%, transparent 40%), var(--ink-soft);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  overflow: hidden;
}
.product-card:hover {
  transform: translateY(-3px);
  border-color: var(--ink-border-strong);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.product-card.featured {
  border-color: rgba(212, 122, 74, 0.35);
  background: linear-gradient(180deg, rgba(212, 122, 74, 0.07) 0%, transparent 35%), var(--ink-soft);
}
.product-card.featured:hover {
  box-shadow: 0 24px 70px rgba(212, 122, 74, 0.12), 0 20px 60px rgba(0,0,0,0.3);
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}
.card-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 100px;
  color: var(--paper-muted);
  background: rgba(255, 248, 238, 0.05);
  border: 1px solid var(--ink-border);
}
.product-card.featured .card-badge {
  color: var(--copper);
  background: var(--copper-soft);
  border-color: rgba(212, 122, 74, 0.25);
}
.card-category {
  font-size: 12px;
  color: var(--paper-dim);
  letter-spacing: 0.01em;
}

.card-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 32px;
  line-height: 1.1;
  font-weight: 400;
  letter-spacing: -0.02em;
}
.card-desc {
  margin: 0 0 28px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--paper-muted);
  min-height: 72px;
}

/* Price */
.price-block {
  padding: 20px 0;
  margin-bottom: 24px;
  border-top: 1px solid var(--ink-border);
  border-bottom: 1px solid var(--ink-border);
}
.price-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.price-current {
  font-size: 44px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--paper);
}
.price-original {
  font-size: 20px;
  color: var(--paper-dim);
  text-decoration: line-through;
  text-decoration-color: rgba(146, 139, 128, 0.7);
}
.price-period {
  font-size: 14px;
  color: var(--paper-dim);
  font-weight: 400;
  margin-left: 2px;
}
.discount-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #1a1008;
  background: var(--copper);
  border-radius: 6px;
}
.discount-tag .tag-label {
  font-weight: 500;
  opacity: 0.85;
}

/* Features */
.feature-list {
  list-style: none;
  padding: 0;
  margin: 0 0 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}
.feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
  line-height: 1.55;
  color: #ddd7cc;
}
.feature-check {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--moss-soft);
  color: var(--moss);
}
.feature-check svg { width: 12px; height: 12px; }
.product-card.featured .feature-check {
  background: var(--copper-soft);
  color: var(--copper);
}

.card-action { margin-top: auto; }
.card-action .btn { width: 100%; }
.card-footnote {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--paper-dim);
  text-align: center;
  line-height: 1.5;
}

/* Footer */
.site-footer {
  margin-top: 72px;
  padding-top: 28px;
  border-top: 1px solid var(--ink-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
  color: var(--paper-dim);
}
.site-footer a {
  color: var(--paper-muted);
  text-decoration: none;
}
.site-footer a:hover { color: var(--paper); }
.footer-links { display: flex; gap: 20px; }

/* ===== Admin styles ===== */
.admin-page .page { width: min(1280px, calc(100% - 48px)); }

.admin-hero {
  padding: 16px 0 40px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--ink-border);
  margin-bottom: 32px;
}
.admin-hero h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.admin-hero p {
  margin: 0;
  color: var(--paper-muted);
  font-size: 15px;
  max-width: 560px;
  line-height: 1.6;
}
.admin-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.admin-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.panel {
  background: var(--ink-soft);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--ink-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.panel-header .count {
  font-size: 12px;
  color: var(--paper-dim);
  background: rgba(255,255,255,0.05);
  padding: 4px 10px;
  border-radius: 100px;
}
.panel-body { padding: 20px 24px; }

/* Product list in admin */
.admin-product-list {
  display: flex;
  flex-direction: column;
}
.admin-product-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 24px;
  border: 0;
  border-bottom: 1px solid var(--ink-border);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: background var(--transition);
}
.admin-product-item:last-child { border-bottom: 0; }
.admin-product-item:hover { background: rgba(255,255,255,0.02); }
.admin-product-item.active {
  background: var(--copper-soft);
  box-shadow: inset 3px 0 0 var(--copper);
}
.admin-item-info { flex: 1; min-width: 0; }
.admin-item-name {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-item-meta {
  font-size: 12px;
  color: var(--paper-dim);
  display: flex;
  gap: 8px;
  align-items: center;
}
.pill {
  display: inline-flex;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 100px;
  background: rgba(255,255,255,0.06);
  color: var(--paper-muted);
}
.pill.free { background: var(--moss-soft); color: var(--moss); }
.pill.discount { background: var(--copper-soft); color: var(--copper); }

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.form-group.full { grid-column: span 2; }
.form-group label, .form-label {
  font-size: 13px;
  font-weight: 500;
  color: #ddd7cc;
}
.form-hint {
  font-size: 12px;
  color: var(--paper-dim);
  line-height: 1.5;
  margin-top: -2px;
}
.field {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--paper);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--ink-border-strong);
  border-radius: 10px;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.field::placeholder { color: #7a756d; }
.field:focus {
  outline: none;
  border-color: rgba(212, 122, 74, 0.6);
  box-shadow: 0 0 0 3px rgba(212, 122, 74, 0.12);
  background: rgba(0, 0, 0, 0.28);
}
textarea.field {
  resize: vertical;
  min-height: 88px;
  line-height: 1.6;
}
select.field {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23928b80' stroke-width='2'%3E%3Cpath d='M3 5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.field-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.field-row .field { flex: 1; }
.field-row .field.small { flex: 0 0 140px; }

/* Toggle / checkbox */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(0,0,0,0.15);
  border: 1px solid var(--ink-border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  color: #ddd7cc;
}
.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--copper);
  cursor: pointer;
  margin: 0;
}

.form-divider {
  grid-column: span 2;
  height: 1px;
  background: var(--ink-border);
  margin: 4px 0;
}
.form-section-title {
  grid-column: span 2;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--paper-dim);
  margin: 4px 0 -4px;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--ink-border);
}
.form-actions-left, .form-actions-right {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Status toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  background: #262b36;
  color: var(--paper);
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
  border: 1px solid var(--ink-border-strong);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform 250ms ease, opacity 250ms ease;
  z-index: 100;
}
.toast.show {
  transform: translateY(0);
  opacity: 1;
}
.toast.success { border-color: rgba(106, 191, 138, 0.4); }
.toast.error { border-color: rgba(224, 107, 107, 0.4); }

/* Responsive */
@media (max-width: 1020px) {
  .products-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-layout { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .page { width: min(100% - 32px, 1180px); padding-top: 24px; }
  .site-header { flex-direction: column; align-items: flex-start; padding-bottom: 40px; gap: 16px; }
  .header-nav { width: 100%; flex-wrap: wrap; }
  .hero { padding-bottom: 56px; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .section-head p { text-align: left; max-width: none; }
  .products-grid { grid-template-columns: 1fr; }
  .card-desc { min-height: 0; }
  .site-footer { flex-direction: column; align-items: flex-start; }
  .admin-hero { flex-direction: column; align-items: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full, .form-divider, .form-section-title { grid-column: span 1; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions-left, .form-actions-right { width: 100%; }
  .form-actions-left .btn, .form-actions-right .btn { flex: 1; }
  .field-row { flex-direction: column; }
  .field-row .field.small { flex: 1; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
