/* Design direction: an exhibition catalogue in a darkened hall. Warm
   near-black ground, soft ivory type, and a single red accent taken from
   the silkscreen prints themselves - the artworks carry the colour, the
   interface stays quiet.
   Fonts are loaded from layout.html (Cormorant for display, Onest for
   text - both with full Cyrillic). */

:root {
  --bg: #0e0d0c;
  --bg-raised: #181614;
  --bg-card: #1d1b18;
  --line: #2a2723;
  --line-strong: #433e37;
  --text: #eee9e1;
  --text-dim: #b3aa9d;
  --text-faint: #857d72;
  --accent: #d9544a;
  --accent-rgb: 217, 84, 74;
  --accent-soft: rgba(217, 84, 74, 0.1);
  --hover-tint: rgba(255, 255, 255, 0.06);
  --shadow: 0 24px 48px -24px rgba(0, 0, 0, 0.8), 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-art: 0 34px 70px -26px rgba(0, 0, 0, 0.95), 0 8px 18px -8px rgba(0, 0, 0, 0.6);
  --radius: 4px;
  --serif: 'Cormorant', 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans: 'Onest', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --header-h: 84px;
}

* { box-sizing: border-box; }

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  /* Faint paper grain behind everything (never over the artworks). */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 0.95 0 0 0 0 0.9 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main { flex: 1 0 auto; width: 100%; }

::selection { background: var(--accent); color: #fff; }

a { color: inherit; text-decoration: none; }

img { max-width: 100%; display: block; }

figure { margin: 0; }

h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 48px);
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.85rem;
  transition: top 0.2s var(--ease);
}

.skip-link:focus { top: 12px; }

/* Entrance motion: a short rise + fade, staggered within a group. */

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.reveal { animation: rise 0.9s var(--ease) both; }
.reveal:nth-child(2) { animation-delay: 0.08s; }
.reveal:nth-child(3) { animation-delay: 0.16s; }
.reveal:nth-child(4) { animation-delay: 0.24s; }
.reveal:nth-child(5) { animation-delay: 0.32s; }

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(14, 13, 12, 0.78);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease, background-color 0.3s ease;
}

.site-header.is-scrolled { border-bottom-color: var(--line); }

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

.brand-mark {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.4s var(--ease);
}

.brand:hover .brand-mark { transform: scale(1.35); }

.site-nav {
  display: flex;
  align-items: center;
  gap: 32px;
}

.site-nav > a {
  position: relative;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-dim);
  padding: 6px 0;
  transition: color 0.2s ease;
}

.site-nav > a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s var(--ease);
}

.site-nav > a:hover { color: var(--text); }
.site-nav > a:hover::after,
.site-nav > a.active::after { transform: scaleX(1); }
.site-nav > a.active { color: var(--text); }

.lang-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.lang-switch a {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  transition: color 0.2s ease, background-color 0.2s ease;
}

.lang-switch a:hover { color: var(--text); }
.lang-switch a.active { background: var(--text); color: var(--bg); }

/* Shared type pieces */

.eyebrow {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 22px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
}

.eyebrow::before {
  content: '';
  width: 36px;
  height: 1px;
  background: currentColor;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.35);
  padding-bottom: 2px;
  transition: border-color 0.2s ease, gap 0.25s var(--ease);
}

.text-link:hover { border-color: var(--accent); gap: 10px; }

.count {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
}

/* Hero (home page) */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 48px;
  padding: clamp(40px, 8vw, 110px) 0 clamp(56px, 8vw, 120px);
}

.hero.hero-with-portrait {
  grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
  gap: clamp(40px, 6vw, 96px);
  align-items: end;
}

.hero-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(3.4rem, 8.4vw, 8.4rem);
  line-height: 0.9;
  letter-spacing: -0.025em;
  margin: 0 0 clamp(28px, 4vw, 44px);
}

.hero-lede {
  max-width: 58ch;
  margin: 0 0 40px;
}

.hero-lede p {
  margin: 0 0 14px;
  color: var(--text-dim);
  font-size: 1.05rem;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-cta,
.button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 15px 28px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.92rem;
  font-weight: 500;
  transition: background-color 0.25s ease, transform 0.25s var(--ease), box-shadow 0.25s ease;
}

.hero-cta span { transition: transform 0.3s var(--ease); }

.hero-cta:hover {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 14px 30px -12px rgba(var(--accent-rgb), 0.55);
}

.hero-cta:hover span { transform: translateY(3px); }
.hero-cta:active { transform: scale(0.98); }

.hero-portrait {
  position: relative;
  max-width: 420px;
  justify-self: end;
  width: 100%;
}

/* A hairline "mount" offset behind the portrait, like a print in a
   passe-partout. */
.hero-portrait::before {
  content: '';
  position: absolute;
  inset: 22px 22px -22px -22px;
  border: 1px solid var(--line-strong);
}

.hero-portrait img {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  box-shadow: var(--shadow-art);
}

/* Section heading on the home page, above the series grid */

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding-top: 22px;
  margin-bottom: 36px;
  border-top: 1px solid var(--line-strong);
}

.section-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 3.6vw, 3rem);
  line-height: 1;
  letter-spacing: -0.015em;
}

/* Breadcrumbs */

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 28px 0 0;
  font-size: 0.84rem;
  color: var(--text-faint);
}

.breadcrumbs a {
  color: var(--text-dim);
  transition: color 0.2s ease;
}

.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs .sep { color: var(--line-strong); }

/* Section intro (category pages) */

.section-intro {
  display: grid;
  gap: 16px;
  padding: clamp(28px, 5vw, 56px) 0 clamp(36px, 5vw, 64px);
  margin-bottom: clamp(32px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
}

.section-intro h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.6rem, 6vw, 5.2rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.section-intro > p {
  margin: 0;
  max-width: 62ch;
  color: var(--text-dim);
}

/* Eyebrow above the title: artwork count after a short accent rule. */
.section-intro .count {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section-intro .count::before {
  content: "";
  width: 32px;
  height: 1px;
  background: currentColor;
}

/* Description under a hairline, spanning the full width of the page. */
.section-intro-text {
  margin-top: clamp(12px, 2vw, 24px);
  padding-top: clamp(20px, 2.5vw, 28px);
  border-top: 1px solid var(--line);
  color: var(--text-dim);
  font-size: clamp(1rem, 0.3vw + 0.95rem, 1.08rem);
  line-height: 1.75;
  text-wrap: pretty;
  hyphens: auto;
}

.section-intro-text p { margin: 0; }
.section-intro-text p + p { margin-top: 1em; }

.section-intro-text p:first-child::first-letter {
  float: left;
  margin: 0.08em 0.14em 0 0;
  font-family: var(--serif);
  font-size: 3.5em;
  font-weight: 500;
  line-height: 0.8;
  color: var(--text);
}

/* Series (folder) cards: image on top, catalogue-style caption below */

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: clamp(36px, 4vw, 56px) clamp(20px, 3vw, 40px);
  padding-bottom: clamp(56px, 7vw, 96px);
}

.folder-card {
  display: block;
  animation: rise 0.9s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 90ms + 0.2s);
}

.folder-card .piece-frame {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
  transition: box-shadow 0.5s var(--ease), transform 0.5s var(--ease);
}

.folder-card .piece-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1.1s var(--ease);
}

.folder-card:hover .piece-frame {
  transform: translateY(-6px);
  box-shadow: var(--shadow-art);
}

.folder-card:hover .piece-frame img { transform: scale(1.05); }

.folder-caption {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 14px;
  align-items: baseline;
  padding-top: 20px;
}

.folder-index {
  grid-row: span 2;
  font-size: 0.78rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.folder-caption h3 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.75rem;
  line-height: 1.1;
  letter-spacing: -0.01em;
  transition: color 0.25s ease;
}

.folder-card:hover .folder-caption h3 { color: var(--accent); }

.folder-count {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--text-faint);
}

/* A lone series (e.g. the only one on the home page) gets a feature
   layout instead of a single narrow card stranded in a wide grid. */
@media (min-width: 900px) {
  .folder-card:only-child {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
    gap: clamp(40px, 6vw, 96px);
    align-items: end;
  }

  .folder-card:only-child .piece-frame { aspect-ratio: 16 / 10; }

  .folder-card:only-child .folder-caption {
    padding: 0 0 12px;
    border-top: 1px solid var(--line);
    padding-top: 24px;
  }

  .folder-card:only-child .folder-caption h3 {
    font-size: clamp(2.2rem, 3.4vw, 3.2rem);
  }
}

.piece-frame .no-cover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.2rem;
}

/* Artwork tiles (justified rows, see app.js) */

.piece-card {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
  transition: box-shadow 0.45s var(--ease), transform 0.45s var(--ease);
}

.piece-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-art);
}

.piece-frame {
  position: relative;
  overflow: hidden;
  line-height: 0;
}

.piece-frame img {
  display: block;
  width: 100%;
  transition: transform 1s var(--ease);
}

.piece-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 36px 18px 16px;
  color: #fff;
  background: linear-gradient(to top, rgba(20, 14, 10, 0.78), rgba(20, 14, 10, 0));
}

.piece-caption h3 {
  margin: 0 0 2px;
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1.15;
}

.piece-caption span {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.75);
  font-variant-numeric: tabular-nums;
}

/* No-JS fallback: plain wrapping rows at a fixed height. app.js upgrades
   this to a justified layout (.js-masonry below) that fills each row
   edge-to-edge with no empty space and no cropping. */
.art-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  padding: 0 0 clamp(56px, 7vw, 96px);
}

.art-tile {
  flex: 0 0 auto;
  height: 340px;
  animation: fade 0.8s ease both;
}

.art-tile .piece-frame {
  height: 100%;
  width: auto;
}

.art-tile .piece-frame img {
  height: 100%;
  width: auto;
}

@media (max-width: 820px) {
  .art-tile { height: 260px; }
}

@media (max-width: 480px) {
  .art-tile { height: 210px; }
}

/* Once app.js measures the grid, tiles are absolutely positioned in full
   justified rows: each row's pieces are scaled together (width and height
   in lockstep) so the row's edges land exactly on the container's edges,
   with no gap and no cropping. */
.art-grid.js-masonry {
  position: relative;
  display: block;
  padding: 0 0 clamp(56px, 7vw, 96px);
  box-sizing: content-box;
  transition: height 0.2s ease;
}

.art-grid.js-masonry .art-tile {
  position: absolute;
  top: 0;
  left: 0;
  transition: left 0.25s ease, top 0.25s ease, width 0.25s ease, height 0.25s ease,
    box-shadow 0.45s var(--ease), transform 0.45s var(--ease);
}

.art-tile:hover .piece-frame img { transform: scale(1.03); }

.art-tile .piece-caption {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.4s var(--ease);
}

.art-tile:hover .piece-caption,
.art-tile:focus-visible .piece-caption {
  opacity: 1;
  transform: none;
}

@media (hover: none) {
  .art-tile .piece-caption { opacity: 1; transform: none; }
}

.empty-state {
  padding: 80px 0 120px;
  text-align: center;
  color: var(--text-faint);
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.5rem;
}

/* Artwork detail page */

.artwork-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: clamp(32px, 4vw, 64px);
  padding: 24px 0 clamp(64px, 8vw, 110px);
  align-items: start;
}

.artwork-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 360px;
  padding: clamp(24px, 5vw, 72px);
  background: var(--bg-raised);
}

.artwork-stage img {
  max-height: 76vh;
  width: auto;
  height: auto;
  margin: 0 auto;
  box-shadow: var(--shadow-art);
  animation: fade 0.6s ease both;
}

.stage-nav {
  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-top: -24px;
  border-radius: 50%;
  background: rgba(14, 13, 12, 0.7);
  border: 1px solid var(--line-strong);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--text);
  box-shadow: 0 6px 18px -8px rgba(0, 0, 0, 0.7);
  opacity: 0.75;
  transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease, transform 0.25s var(--ease);
}

.stage-nav svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.artwork-stage:hover .stage-nav { opacity: 1; }
.stage-nav:hover { background: var(--text); color: var(--bg); }
.stage-nav:active { transform: scale(0.94); }
.stage-nav.prev { left: 16px; }
.stage-nav.next { right: 16px; }
.stage-nav.disabled { display: none; }

.artwork-info {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  padding-top: 8px;
}

.artwork-info h1 {
  margin: 0 0 28px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.2rem, 3.4vw, 3rem);
  line-height: 1;
  letter-spacing: -0.015em;
}

.artwork-meta {
  margin: 0 0 24px;
  border-top: 1px solid var(--line-strong);
}

.artwork-meta div {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

.artwork-meta dt { color: var(--text-faint); }
.artwork-meta dd { margin: 0; font-variant-numeric: tabular-nums; }

.artwork-info .description {
  color: var(--text-dim);
  font-size: 0.98rem;
  line-height: 1.7;
  white-space: pre-line;
}

/* Buttons that swap the main stage photo to an artwork's extra photo(s) -
   an alternate angle or detail shot - and back. See .extra-photo-btn in
   app.js. */
.extra-photo-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.extra-photo-btn {
  font-family: var(--sans);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.extra-photo-btn:hover { border-color: var(--text); }
.extra-photo-btn:active { transform: scale(0.98); }
.extra-photo-btn.is-active { background: var(--text); border-color: var(--text); color: var(--bg); }

.back-link {
  display: inline-flex;
  gap: 8px;
  margin-top: 36px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-dim);
  transition: color 0.2s ease, gap 0.25s var(--ease);
}

.back-link:hover { color: var(--accent); gap: 12px; }

/* About page */

.about-page {
  max-width: 760px;
  padding: clamp(40px, 7vw, 96px) 0 clamp(64px, 8vw, 110px);
}

.about-page.with-portrait {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(40px, 7vw, 110px);
  align-items: start;
  max-width: none;
}

.about-portrait {
  position: sticky;
  top: calc(var(--header-h) + 32px);
}

.about-portrait img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  box-shadow: var(--shadow-art);
}

.about-page h1 {
  margin: 0 0 40px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(3rem, 6vw, 5.6rem);
  line-height: 0.92;
  letter-spacing: -0.025em;
}

.about-bio {
  max-width: 62ch;
}

.about-bio p {
  margin: 0 0 20px;
  font-size: 1.06rem;
  line-height: 1.75;
  color: var(--text-dim);
}

.about-bio p:first-child::first-letter {
  float: left;
  margin: 6px 10px 0 -2px;
  font-family: var(--serif);
  font-size: 5.1rem;
  font-weight: 500;
  line-height: 0.72;
  color: var(--accent);
}

.contact-list {
  list-style: none;
  margin: 48px 0 0;
  padding: 0;
  max-width: 62ch;
  border-top: 1px solid var(--line-strong);
}

.contact-list li {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}

.contact-list span { color: var(--text-faint); }

.contact-list a {
  justify-self: start;
  overflow-wrap: anywhere;
  transition: color 0.2s ease;
}

.contact-list a:hover { color: var(--accent); }

/* 404 */

.not-found {
  padding: clamp(64px, 12vw, 160px) 0;
  text-align: center;
}

.not-found-code {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(6rem, 18vw, 13rem);
  font-weight: 500;
  line-height: 0.85;
  color: var(--accent);
}

.not-found h1 {
  margin: 16px 0 40px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
}

/* Admin panel */

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  padding: 12px 0 28px;
}

.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
}

.admin-card h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.2rem;
  margin: 0 0 16px;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.admin-form select,
.admin-form input[type="text"],
.admin-form input[type="email"],
.admin-form input[type="file"],
.admin-form textarea {
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}

.admin-form textarea {
  resize: vertical;
  line-height: 1.5;
}

.admin-form select:focus,
.admin-form input:focus,
.admin-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.admin-form button {
  align-self: flex-start;
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.admin-form button:hover { opacity: 0.85; }

.admin-fieldset {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0;
  padding: 16px 16px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-hint {
  margin: -4px 0 0;
  font-size: 0.76rem;
  color: var(--text-faint);
}

.admin-fieldset legend {
  padding: 0 6px;
  font-size: 0.76rem;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.admin-flash {
  margin: 12px 0 0;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--accent-soft);
  border: 1px solid rgba(var(--accent-rgb), 0.4);
  color: var(--text);
}

.admin-flash.is-error {
  background: rgba(217, 84, 74, 0.12);
  border-color: rgba(217, 84, 74, 0.45);
}

.admin-tree-card {
  margin-bottom: 40px;
}

.admin-tree-empty {
  color: var(--text-faint);
  font-style: italic;
}

.admin-tree,
.admin-tree ul {
  list-style: none;
  margin: 0;
  padding: 0 0 0 20px;
}

.admin-tree {
  padding-left: 0;
}

/* A move action redirects back with #<row id> so the browser lands on the
   row that moved instead of the top of the page. The sticky header would
   otherwise cover the top sliver of that row. */
.admin-tree > li,
.admin-image-item {
  scroll-margin-top: 92px;
}

.admin-tree-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}

.admin-tree-title { color: var(--text); }
.admin-tree-count { color: var(--text-faint); font-size: 0.8rem; white-space: nowrap; }

.admin-tree-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-image-list {
  list-style: none;
  margin: 0;
  padding: 0 0 4px 20px;
}

.admin-image-item {
  border-bottom: 1px dashed var(--line);
  padding: 6px 0;
}

.admin-image-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.86rem;
  color: var(--text-dim);
}

.admin-image-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-inline-form { margin: 0; }

.admin-move-btn {
  font-family: var(--sans);
  font-size: 0.78rem;
  line-height: 1;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.admin-move-btn:hover:not(:disabled) {
  background: var(--hover-tint);
  color: var(--text);
}

.admin-move-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.admin-meta-toggle {
  margin-top: 4px;
}

.admin-meta-toggle summary {
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--accent);
  list-style: none;
}

.admin-meta-toggle summary::-webkit-details-marker { display: none; }

.admin-meta-form {
  padding: 12px 0 8px 4px;
}

.admin-meta-form label {
  font-size: 0.78rem;
}

.admin-meta-form input,
.admin-meta-form textarea {
  font-size: 0.85rem;
  padding: 7px 10px;
}

.admin-meta-form button {
  font-size: 0.78rem;
  padding: 7px 16px;
}

.admin-delete-btn {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: #e8837a;
  background: transparent;
  border: 1px solid rgba(var(--accent-rgb), 0.4);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.admin-delete-btn:hover {
  background: rgba(var(--accent-rgb), 0.14);
  color: #f0a8a0;
}

.admin-extra-photo-list {
  list-style: none;
  margin: 12px 0;
  padding: 0 0 0 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-extra-photo-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.admin-extra-photo-item img {
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.admin-cover-preview {
  margin: 4px 0;
}

.admin-cover-preview img {
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.admin-layout-link {
  padding: 6px 0 10px 20px;
  font-size: 0.82rem;
}

.admin-layout-link a { color: var(--accent); }

.admin-layout-badge {
  margin-left: 10px;
  font-size: 0.72rem;
  color: var(--text-faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
}

/* Free-form layout editor (/admin/layout/...) */

.admin-layout-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin: 4px 0 18px;
}

.admin-layout-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-dim);
  cursor: pointer;
}

.admin-layout-toolbar button {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 9px 20px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.admin-layout-toolbar button:hover { opacity: 0.85; }

#layout-arrange-btn {
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line);
}

.admin-layout-status {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.admin-layout-status.is-error { color: #f0a8a0; }

.layout-canvas {
  position: relative;
  width: 100%;
  background: var(--bg-raised);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 40px;
  /* Height is set by JS from the arranged tiles; this is just a sane
     minimum before any layout runs. */
  min-height: 200px;
}

.layout-tile {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.layout-tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.layout-tile.is-dragging,
.layout-tile.is-resizing {
  cursor: grabbing;
  z-index: 5;
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.layout-tile.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.layout-tile-label {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 5px 8px 4px;
  font-size: 0.72rem;
  color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,0.78), rgba(0,0,0,0));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.layout-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 50%, var(--accent) 50%) content-box;
  border: 3px solid transparent;
}

/* Smart alignment guides: thin lines that flash across the canvas while
   dragging a tile, marking where its edge/center lines up with another
   tile's edge/center. Purely visual - the snapping itself happens in JS. */
.layout-guide {
  position: absolute;
  display: none;
  background: #ff4d9e;
  pointer-events: none;
  z-index: 10;
}

.layout-guide-v {
  top: 0;
  bottom: 0;
  width: 1px;
}

.layout-guide-h {
  left: 0;
  right: 0;
  height: 1px;
}

/* Text blocks on a free-form layout. The same typography in the editor
   and on the public site, so what the admin places is what visitors see;
   font-size is set by JS in canvas-width units, font-family by the
   data-font rules below. */
.layout-text-content,
.art-grid .art-text {
  line-height: 1.3;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.art-grid .art-text { display: none; }

.art-grid.custom-layout .art-text {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
}

.layout-tile.layout-text {
  border: none;
  border-radius: 0;
  background: none;
  overflow: visible;
  outline: 1px dashed var(--line-strong);
}

.layout-tile.layout-text.is-selected,
.layout-tile.layout-text.is-dragging,
.layout-tile.layout-text.is-resizing { outline: none; }

.layout-tile.layout-text.is-editing { cursor: text; }

.layout-text-content[contenteditable] {
  user-select: text;
  outline: none;
}

/* Selection rectangle drawn by dragging across empty canvas. */
.layout-marquee {
  position: absolute;
  display: none;
  border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  pointer-events: none;
  z-index: 12;
}

/* Spacing hint: a small label showing the gap (in px) to the nearest tile
   sharing a row or column, centered on that gap while dragging. */
.layout-gap-label {
  position: absolute;
  display: none;
  transform: translate(-50%, -50%);
  background: #ff4d9e;
  color: #1a0a12;
  font: 600 11px/1 var(--sans);
  padding: 2px 6px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 11;
}

/* Right-click menu on a layout tile, offering "align row" (or "center"
   for a tile with no row-mates). Positioned by JS at the click point. */
.layout-context-menu {
  position: fixed;
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 4px;
  z-index: 50;
}

.layout-context-menu-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font: 500 0.85rem var(--sans);
  text-align: left;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.layout-context-menu-item:hover { background: var(--bg-raised); }

.layout-context-menu-separator {
  border-top: 1px solid var(--line);
  margin: 4px 0;
}

/* Text toolbar (font, bold, italic) floating above the selected text
   block(s) in the layout editor - positioned by JS. */
.layout-text-toolbar {
  position: absolute;
  display: none;
  align-items: center;
  gap: 8px;
  z-index: 13;
  padding: 4px 4px 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font: 600 0.7rem var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}

.layout-text-toolbar select {
  font-size: 1rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
}

/* Bold/italic toggles on the text toolbar. */
.layout-text-style-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-raised);
  color: var(--text);
  font: 1rem var(--serif);
  text-transform: none;
  cursor: pointer;
}
.layout-text-style-bold { font-weight: 700; }
.layout-text-style-italic { font-style: italic; }
.layout-text-style-btn:hover { border-color: var(--line-strong); }
.layout-text-style-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* A text block's style; its font-family comes from the [data-font] rules
   generated from TextFonts (internal/gallery/fonts.go) in layout.html. */
[data-bold="1"] { font-weight: 700; }
[data-italic="1"] { font-style: italic; }

/* Public gallery: custom (freeform) layout, applied by app.js from each
   tile's data-x/y/w/h attributes instead of the automatic justified-row
   algorithm. */
.art-grid.custom-layout {
  position: relative;
  display: block;
  padding: 8px 0 40px;
}

.art-grid.custom-layout .art-tile {
  position: absolute;
  top: 0;
  left: 0;
  height: auto;
}

.art-grid.custom-layout .art-tile .piece-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.art-grid.custom-layout .art-tile .piece-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Footer */

.site-footer {
  margin-top: auto;
  padding: clamp(48px, 6vw, 80px) 0 32px;
  border-top: 1px solid var(--line);
}

.footer-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding-bottom: clamp(40px, 5vw, 64px);
}

.footer-contact {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.footer-label {
  font-size: 0.8rem;
  color: var(--text-faint);
}

.footer-contact ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
}

.footer-contact a {
  font-size: 0.95rem;
  font-weight: 500;
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 2px;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.footer-contact a:hover { color: var(--accent); border-color: var(--accent); }

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--text-faint);
}

/* Responsive */

@media (max-width: 900px) {
  .hero.hero-with-portrait { grid-template-columns: 1fr; align-items: start; }
  .hero-portrait { justify-self: start; max-width: 340px; }
  .hero-portrait::before { display: none; }
  .artwork-view { grid-template-columns: 1fr; }
  .artwork-info { position: static; }
  .about-page.with-portrait { grid-template-columns: 1fr; }
  .about-portrait { position: static; max-width: 360px; }
}

@media (max-width: 640px) {
  :root { --header-h: 64px; }
  .brand { font-size: 1.3rem; gap: 10px; }
  .brand-mark { width: 9px; height: 9px; }
  .site-nav { gap: 18px; }
  .site-nav > a { font-size: 0.85rem; }
  .artwork-stage { margin: 0 calc(-1 * clamp(16px, 4vw, 48px)); min-height: 240px; }
  .stage-nav { width: 40px; height: 40px; margin-top: -20px; }
  .stage-nav.prev { left: 10px; }
  .stage-nav.next { right: 10px; }
  .contact-list li { grid-template-columns: 1fr; gap: 2px; }
}

/* Narrow phones: the name and the nav no longer fit on one line, so the
   header stacks into two rows. */
@media (max-width: 520px) {
  .site-header .container {
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 8px;
    height: auto;
    padding-top: 12px;
    padding-bottom: 10px;
  }
  .site-nav { justify-content: space-between; }
  .site-nav > a { padding: 2px 0; }
  html { scroll-padding-top: 110px; }
}

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