:root {
  /* Near-black, ivory and warm greys, with a single rust accent used sparingly. */
  --bg: #080808;
  --bg-2: #121211;
  --line: rgba(242, 240, 236, 0.08);
  --line-2: rgba(242, 240, 236, 0.15);
  --text: #f2f0ec;
  --muted: #8f8b85;
  --dim: #55514c;
  --rust: #a8502a;
  --accent: var(--rust);
  --serif: "Playfair", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--text); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, select { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
kbd { font-family: var(--sans); font-size: 0.7rem; border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.7rem 1.25rem; border-radius: 999px; font-size: 0.8rem; font-weight: 500;
  letter-spacing: 0.02em; border: 1px solid transparent; cursor: pointer;
  transition: background 0.3s, color 0.3s, border-color 0.3s, transform 0.3s var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--text); color: var(--bg); }
.btn.primary:hover { background: #ffffff; color: var(--bg); }
.btn.ghost { border-color: var(--line-2); color: var(--text); }
.btn.ghost:hover { border-color: var(--text); }
.btn.small { padding: 0.5rem 1rem; }

/* ---------- Gallery ---------- */
.gallery { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem clamp(1rem, 4vw, 3rem); background: rgba(10, 10, 10, 0.8);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.6rem; font-family: var(--serif); font-size: 1.15rem; }
.brand-mark {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--rust);
}

.intro { padding: clamp(4rem, 10vw, 8rem) clamp(1rem, 4vw, 3rem) 3rem; max-width: 1400px; margin: 0 auto; width: 100%; }
.eyebrow { display: flex; align-items: center; gap: 0.9rem; font-size: 0.72rem; letter-spacing: 0.32em; text-transform: uppercase; color: var(--dim); margin-bottom: 1.5rem; }
.eyebrow::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--rust); flex-shrink: 0; }
.intro h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(2.6rem, 7vw, 5.5rem); line-height: 1; letter-spacing: -0.02em; }
.intro h1 em { color: var(--dim); }
.lead { max-width: 560px; margin-top: 1.75rem; color: var(--muted); line-height: 1.7; font-weight: 300; }

.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr));
  gap: clamp(1.25rem, 3vw, 2.5rem); padding: 1rem clamp(1rem, 4vw, 3rem) 5rem;
  max-width: 1400px; margin: 0 auto; width: 100%; flex: 1;
}

.card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px; overflow: hidden;
  display: flex; flex-direction: column; transition: border-color 0.4s, transform 0.6s var(--ease);
  animation: rise 0.8s var(--ease) both;
}
.card:nth-child(2) { animation-delay: 0.08s; }
.card:nth-child(3) { animation-delay: 0.16s; }
.card:nth-child(4) { animation-delay: 0.24s; }
.card:hover { border-color: var(--line-2); transform: translateY(-4px); }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }

.card-media { position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden; background: #000; }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 1.2s var(--ease), opacity 0.6s; opacity: 0.88; }
.card:hover .card-media img { transform: scale(1.05); opacity: 1; }
.card-media::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.55), transparent 50%); }
.card-num, .card-lang {
  position: absolute; z-index: 1; top: 1rem; font-size: 0.7rem; letter-spacing: 0.15em;
  padding: 0.35rem 0.7rem; border-radius: 999px; background: rgba(0,0,0,0.45); backdrop-filter: blur(8px);
}
.card-num { left: 1rem; }
.card-lang { right: 1rem; }
.card-hover {
  position: absolute; z-index: 1; left: 1.25rem; bottom: 1.1rem; font-size: 0.85rem; font-weight: 500;
  opacity: 0; transform: translateY(8px); transition: all 0.5s var(--ease);
}
.card:hover .card-hover { opacity: 1; transform: none; }

.card-body { padding: 1.5rem 1.5rem 1.6rem; display: flex; flex-direction: column; gap: 0.6rem; flex: 1; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card-head h2 { font-family: var(--serif); font-weight: 400; font-size: 1.6rem; letter-spacing: -0.01em; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: auto; padding-top: 1.1rem; }

/* ---------- Custom template / contact ---------- */
.custom { scroll-margin-top: 90px; padding: 0 clamp(1rem, 4vw, 3rem) 6rem; max-width: 1400px; margin: 0 auto; width: 100%; }
.custom-inner {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 1.1fr 1fr; align-items: center; gap: clamp(2rem, 5vw, 4.5rem);
  padding: clamp(1.5rem, 5vw, 4rem); border-radius: 28px;
  background:
    radial-gradient(circle at 0% 0%, rgba(242,240,236,0.05), transparent 45%),
    radial-gradient(circle at 100% 100%, rgba(255,255,255,0.05), transparent 50%),
    var(--bg-2);
  border: 1px solid var(--line-2);
}
.custom h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(2rem, 4.5vw, 3.4rem); line-height: 1.05; letter-spacing: -0.02em; }
.custom h2 em { color: var(--dim); }
.custom .lead { margin-top: 1.25rem; }

.custom-list { list-style: none; display: grid; gap: 1.4rem; }
.custom-list li { display: flex; gap: 0.9rem; align-items: flex-start; }
.custom-list strong { display: block; font-weight: 500; font-size: 0.95rem; }
.custom-list span:not(.custom-icon) { display: block; color: var(--muted); font-size: 0.85rem; line-height: 1.55; margin-top: 0.15rem; font-weight: 300; }
.custom-icon {
  flex-shrink: 0; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  color: var(--text); background: transparent; border: 1px solid var(--line-2);
}

.custom-contacts { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2.25rem; }
.custom-contacts a {
  display: flex; flex-direction: column; gap: 0.15rem; padding: 0.75rem 1.1rem; border-radius: 14px;
  border: 1px solid var(--line-2); font-size: 0.88rem; transition: border-color 0.25s, background 0.25s;
}
.custom-contacts a:hover { border-color: var(--text); background: rgba(242,240,236,0.04); }
.custom-contacts small { font-size: 0.65rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }

@media (max-width: 900px) {
  .custom-inner { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .custom-inner { border-radius: 20px; }
}

.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem;
  padding: 1.5rem clamp(1rem, 4vw, 3rem); border-top: 1px solid var(--line); color: var(--muted); font-size: 0.78rem;
}

/* ---------- Viewer ---------- */
.viewer { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.toolbar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem;
  padding: 0.6rem 1rem; border-bottom: 1px solid var(--line); background: var(--bg); position: relative; z-index: 2;
}
.toolbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: 0.6; transition: background 0.4s;
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 0.4rem; }
.tb-right { justify-content: flex-end; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: none; border: 1px solid transparent; color: var(--muted); cursor: pointer; transition: all 0.2s;
}
.icon-btn:hover { color: var(--text); background: var(--bg-2); border-color: var(--line); }

.select-wrap { position: relative; }
.select-wrap::after {
  content: ""; position: absolute; right: 0.8rem; top: 50%; width: 6px; height: 6px; pointer-events: none;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: translateY(-70%) rotate(45deg);
}
.select-wrap select {
  appearance: none; -webkit-appearance: none; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 0.5rem 2.2rem 0.5rem 0.9rem; font-family: var(--serif); font-size: 0.95rem; cursor: pointer; min-width: 200px;
}
.select-wrap select:focus { outline: none; border-color: var(--accent); }

.devices { display: flex; gap: 2px; padding: 3px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; }
.devices button {
  display: flex; align-items: center; gap: 0.4rem; background: none; border: 0; border-radius: 9px;
  padding: 0.4rem 0.75rem; font-size: 0.75rem; color: var(--muted); cursor: pointer; transition: all 0.2s;
}
.devices button:hover { color: var(--text); }
.devices button[aria-checked="true"] { background: var(--text); color: var(--bg); }

.size-label { font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 0.4rem; white-space: nowrap; }

.stage {
  flex: 1; position: relative; display: grid; place-items: center; overflow: hidden;
  background-color: #070707;
  background-image: radial-gradient(circle, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 22px 22px;
}
.frame-wrap { position: relative; transition: width 0.5s var(--ease); }
.frame-wrap.device {
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 0 0 1px var(--line-2), 0 30px 80px rgba(0,0,0,0.55);
}
.frame-wrap iframe { display: block; border: 0; background: #fff; transform-origin: 0 0; }

.loader {
  position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10,10,9,0.85);
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.loader.show { opacity: 1; }
.loader span {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .toolbar { grid-template-columns: 1fr auto; }
  .devices { grid-column: 1 / -1; order: 3; justify-self: center; }
  .devices button span, .size-label { display: none; }
  .select-wrap select { min-width: 0; max-width: 46vw; }
}
@media (max-width: 520px) {
  .card-body { padding: 1.25rem; }
}
