/* ---------- Tokens ---------- */
:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f1efe9;
  --ink: #17191f;
  --muted: #5f6675;
  --line: #e4e1d8;
  --accent: #3355e0;
  --accent-ink: #ffffff;
  --accent-soft: #e8ecfd;
  --ok: #1f8a3b;
  --ok-soft: #e2f5e7;
  --warn: #a15c07;
  --warn-soft: #fdf0d9;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 8px 24px rgba(20, 24, 40, .06);
  --shadow-hover: 0 2px 4px rgba(20, 24, 40, .06), 0 14px 34px rgba(20, 24, 40, .12);
  --max: 1120px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216;
    --surface: #181b21;
    --surface-2: #20242c;
    --ink: #eceef3;
    --muted: #9aa2b2;
    --line: #2a2f39;
    --accent: #7c93ff;
    --accent-ink: #0d1020;
    --accent-soft: #212850;
    --ok: #5fd07a;
    --ok-soft: #173321;
    --warn: #f0b45a;
    --warn-soft: #3a2a10;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, .5), 0 14px 34px rgba(0, 0, 0, .45);
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.015em; }
p { margin: 0 0 1em; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Header ---------- */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.brand { font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand span { color: var(--muted); font-weight: 500; }
.nav { display: flex; gap: 18px; font-size: .94rem; }
.nav a { color: var(--muted); }
.nav a:hover { color: var(--ink); text-decoration: none; }

/* ---------- Hero ---------- */
.hero { padding: 56px 0 28px; }
.hero h1 { font-size: clamp(2rem, 4.6vw, 3.1rem); max-width: 18ch; }
.hero p { color: var(--muted); font-size: 1.12rem; max-width: 56ch; margin-top: 14px; }

/* ---------- Controls ---------- */
.controls { display: grid; gap: 14px; margin: 8px 0 22px; }
.control-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.search { position: relative; flex: 1 1 260px; }
.search input { width: 100%; }
input[type=text], input[type=search], input[type=url], input[type=number], input[type=date], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; min-height: 44px;
}
textarea { width: 100%; min-height: 96px; resize: vertical; }
select { padding-right: 32px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-size: .9rem; cursor: pointer; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; min-height: 36px;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip small { opacity: .7; margin-left: 4px; }
.result-count { color: var(--muted); font-size: .92rem; }

/* ---------- Grid + cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 22px; padding-bottom: 64px; }
.card {
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease; color: inherit;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); text-decoration: none; }
.card .thumb { aspect-ratio: 16 / 10; background: var(--surface-2); overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card h3 { font-size: 1.18rem; }
.card .tagline { color: var(--muted); font-size: .96rem; margin: 0; flex: 1; }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.empty { text-align: center; color: var(--muted); padding: 60px 0 90px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
  white-space: nowrap;
}
.badge.free { background: var(--ok-soft); color: var(--ok); }
.badge.paid { background: var(--accent-soft); color: var(--accent); }
.badge.status-beta, .badge.status-soon { background: var(--warn-soft); color: var(--warn); }
.badge.featured { background: #fff2c9; color: #7a5600; }
@media (prefers-color-scheme: dark) { .badge.featured { background: #3b3010; color: #f3cf6a; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  font: inherit; font-weight: 600; font-size: .95rem; padding: 11px 18px; min-height: 44px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .88rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Detail view ---------- */
.back { display: inline-block; margin: 26px 0 14px; color: var(--muted); font-size: .94rem; }
.detail-head { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 26px; }
.detail-head .icon { width: 96px; height: 96px; border-radius: 22px; overflow: hidden; flex: none; box-shadow: var(--shadow); }
.detail-head .icon img { width: 100%; height: 100%; object-fit: cover; }
.detail-head .titles { flex: 1 1 320px; min-width: 0; }
.detail-head h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin-bottom: 8px; }
.detail-head .tagline { color: var(--muted); font-size: 1.1rem; margin-bottom: 14px; }
.detail-head .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 32px; padding-bottom: 72px; align-items: start; }
@media (max-width: 880px) { .detail-layout { grid-template-columns: 1fr; } }
.section { margin-bottom: 36px; }
.section h2 { font-size: 1.3rem; margin-bottom: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.sidebar { display: grid; gap: 18px; position: sticky; top: 18px; }
@media (max-width: 880px) { .sidebar { position: static; } }
.sidebar h3 { font-size: 1rem; margin-bottom: 10px; }
.price { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.price small { font-size: .9rem; font-weight: 500; color: var(--muted); }
.link-list { display: grid; gap: 8px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .92rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; }

.prose p { color: var(--ink); }
.features { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 22px; }
.features li { position: relative; padding-left: 28px; }
.features li::before {
  content: ""; position: absolute; left: 0; top: .28em; width: 18px; height: 18px; border-radius: 50%;
  background: var(--ok-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 10.5l3 3 6-6.5' fill='none' stroke='%231f8a3b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/14px no-repeat;
}

/* ---------- Gallery ---------- */
.gallery-main { display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); cursor: zoom-in; aspect-ratio: 16 / 10; }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.gallery-caption { color: var(--muted); font-size: .9rem; margin: 8px 2px 0; min-height: 1.4em; }
.thumbs { display: flex; gap: 10px; margin-top: 12px; overflow-x: auto; padding-bottom: 6px; }
.thumbs button { flex: none; width: 112px; aspect-ratio: 16 / 10; padding: 0; border-radius: 10px; overflow: hidden; border: 2px solid transparent; cursor: pointer; background: var(--surface-2); opacity: .75; }
.thumbs button[aria-current=true] { border-color: var(--accent); opacity: 1; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(8, 10, 16, .92); display: none; align-items: center; justify-content: center; padding: 24px; }
.lightbox.open { display: flex; }
.lightbox figure { margin: 0; max-width: min(1200px, 100%); max-height: 100%; display: grid; gap: 10px; justify-items: center; }
.lightbox img { max-height: calc(100vh - 120px); max-width: 100%; border-radius: 10px; }
.lightbox figcaption { color: #d5d9e4; font-size: .95rem; text-align: center; }
.lb-btn { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0; width: 48px; height: 48px; border-radius: 50%; font-size: 1.5rem; cursor: pointer; }
.lb-btn:hover { background: rgba(255,255,255,.22); }
.lb-close { top: 18px; right: 18px; }
.lb-prev { left: 18px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 18px; top: 50%; transform: translateY(-50%); }

/* ---------- Testimonials ---------- */
.quotes { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.quote { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.quote blockquote { margin: 0 0 12px; font-size: 1rem; }
.quote cite { font-style: normal; font-size: .9rem; color: var(--muted); }
.quote.placeholder { border-style: dashed; background: transparent; color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-size: .92rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; }

/* ---------- Admin form ---------- */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; padding-bottom: 72px; align-items: start; }
@media (max-width: 960px) { .form-layout { grid-template-columns: 1fr; } }
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.form-card + .form-card { margin-top: 18px; }
.form-card h2 { font-size: 1.1rem; margin-bottom: 14px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: .92rem; }
.field .hint { color: var(--muted); font-size: .84rem; }
.field input, .field select, .field textarea { width: 100%; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .two { grid-template-columns: 1fr; } }
pre.out {
  background: #0f1218; color: #d8dcea; border-radius: 12px; padding: 16px; overflow: auto;
  font: .82rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; max-height: 420px; margin: 0 0 12px; white-space: pre-wrap; word-break: break-word;
}
.notice { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 12px 14px; font-size: .9rem; margin-bottom: 14px; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.sticky { position: sticky; top: 18px; }
@media (max-width: 960px) { .sticky { position: static; } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
