:root {
  color-scheme: light dark;
  --bg: #eef1f6;
  --surface: #f8f9fb;
  --surface-strong: #ffffff;
  --text: #161b24;
  --muted: #626b79;
  --line: #ccd3df;
  --accent: #174eb6;
  --accent-soft: #dce7fb;
  --shadow: 0 20px 60px rgb(39 55 86 / 14%);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111722;
    --surface: #171f2d;
    --surface-strong: #1e2838;
    --text: #edf2fa;
    --muted: #a9b2c1;
    --line: #354155;
    --accent: #79a7ff;
    --accent-soft: #20375f;
    --shadow: 0 20px 60px rgb(2 7 15 / 35%);
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; color: var(--text); background: var(--bg); font-family: Arial, Helvetica, sans-serif; }
button, a { font: inherit; }
a { color: inherit; }

.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 28px;
  min-height: 76px; padding: 14px clamp(20px, 5vw, 76px); border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}
.site-header p { margin: 0; color: var(--muted); font-size: 14px; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; letter-spacing: .16em; font-size: 14px; }
.brand b { font-weight: 800; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: #f7f9fd; background: var(--accent); font-weight: 800; letter-spacing: 0; }

main { width: min(1480px, calc(100% - 40px)); margin: 0 auto; padding: clamp(46px, 8vw, 100px) 0 90px; }
.intro { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 40px; }
.intro h1 { max-width: 760px; margin: 0; font-size: clamp(42px, 7vw, 92px); line-height: .92; letter-spacing: -.055em; }
.intro p { max-width: 620px; margin: 22px 0 0; color: var(--muted); font-size: clamp(16px, 1.7vw, 21px); line-height: 1.45; }
.project-count { display: grid; justify-items: end; padding-bottom: 4px; }
.project-count strong { font-size: clamp(44px, 5vw, 72px); line-height: .8; color: var(--accent); }
.project-count span { margin-top: 10px; color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 54px 0 26px; }
.filters button, .preview-button, .download-button, .icon-button {
  border: 1px solid var(--line); color: var(--text); background: var(--surface); cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease;
}
.filters button { min-height: 42px; padding: 9px 17px; border-radius: 999px; }
.filters button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
button:hover, .download-button:hover { border-color: var(--accent); }
button:active, .download-button:active { transform: translateY(1px); }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.gallery { display: grid; grid-template-columns: repeat(12, 1fr); gap: 22px; }
.project { grid-column: span 6; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.project:first-child { grid-column: span 8; }
.project:nth-child(2) { grid-column: span 4; }
.project-image-button { display: block; width: 100%; padding: 0; border: 0; background: var(--surface-strong); cursor: zoom-in; }
.project-image-wrap { display: grid; place-items: center; aspect-ratio: 2.35 / 1; padding: clamp(14px, 2vw, 30px); background: var(--surface-strong); overflow: hidden; }
.project-image-wrap img { display: block; width: 100%; height: 100%; object-fit: contain; transition: transform 220ms ease; }
.project-image-button:hover img { transform: scale(1.012); }
.image-error { display: grid; place-items: center; min-height: 180px; padding: 20px; color: var(--muted); text-align: center; }
.project-info { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 20px 22px 22px; border-top: 1px solid var(--line); }
.project-info h2 { margin: 0 0 8px; font-size: clamp(18px, 2vw, 25px); line-height: 1.1; letter-spacing: -.025em; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font-size: 13px; }
.status { color: var(--accent); font-weight: 700; }
.actions { display: flex; flex-shrink: 0; gap: 8px; }
.preview-button, .download-button { display: inline-grid; place-items: center; min-height: 42px; padding: 9px 15px; border-radius: 10px; text-decoration: none; white-space: nowrap; }
.download-button { border-color: var(--accent); color: #f7f9fd; background: #174eb6; }

.empty, .error { padding: 60px 24px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); text-align: center; }
footer { display: flex; justify-content: space-between; gap: 20px; padding: 26px clamp(20px, 5vw, 76px); border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

dialog { width: min(95vw, 1600px); max-width: none; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(9 14 24 / 72%); }
.dialog-shell { padding: 18px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.dialog-head h2 { margin: 0; font-size: clamp(20px, 3vw, 32px); }
.icon-button { width: 44px; height: 44px; border-radius: 10px; font-size: 30px; line-height: 1; }
.dialog-image-wrap { display: grid; place-items: center; max-height: 72vh; padding: 14px; border-radius: 12px; background: var(--surface-strong); overflow: auto; }
.dialog-image-wrap img { display: block; max-width: 100%; max-height: 68vh; object-fit: contain; }
.dialog-shell > .download-button { margin-top: 14px; }

@media (max-width: 900px) {
  .site-header p { display: none; }
  .intro { grid-template-columns: 1fr; align-items: start; }
  .project-count { justify-items: start; }
  .gallery { grid-template-columns: 1fr; }
  .project, .project:first-child, .project:nth-child(2) { grid-column: 1; }
}
@media (max-width: 620px) {
  main { width: min(100% - 24px, 1480px); padding-top: 42px; }
  .site-header { min-height: 66px; }
  .project-image-wrap { aspect-ratio: 1.8 / 1; padding: 10px; }
  .project-info { display: grid; align-items: start; padding: 17px; }
  .actions { width: 100%; }
  .actions > * { flex: 1; }
  footer { display: grid; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
