:root {
  --bg: #101311;
  --surface: #181c19;
  --surface-2: #202521;
  --line: #303730;
  --text: #f4f3ec;
  --muted: #a6ada4;
  --accent: #d6ff65;
  --accent-dark: #1a2408;
  --danger: #ff7b72;
  --radius: 18px;
  --shadow: 0 22px 55px rgb(0 0 0 / 24%);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 18% 0%, #1c261a 0, transparent 31rem), var(--bg); font: 15px/1.6 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, .button { -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
h1, h2, p { margin-top: 0; }
h1 { max-width: 900px; margin-bottom: .4rem; font-size: clamp(2.1rem, 6vw, 4.7rem); line-height: .98; letter-spacing: -.055em; font-weight: 650; }
h2 { margin-bottom: .35rem; font-size: 1.15rem; line-height: 1.25; }

.site-header { width: min(1400px, calc(100% - 40px)); height: 80px; margin: auto; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { width: 18px; height: 18px; border: 4px solid var(--accent); border-radius: 50% 50% 50% 12%; transform: rotate(-12deg); }
.main-nav { display: flex; align-items: center; gap: clamp(12px, 3vw, 28px); color: var(--muted); }
.main-nav a:hover, .nav-button:hover { color: var(--text); }
.main-nav form { margin: 0; }
.nav-button { padding: 0; color: var(--muted); background: none; border: 0; cursor: pointer; }
.page-shell { width: min(1400px, calc(100% - 40px)); min-height: calc(100vh - 150px); margin: 0 auto; padding: clamp(42px, 7vw, 90px) 0 80px; }
.site-footer { width: min(1400px, calc(100% - 40px)); margin: auto; padding: 24px 0 34px; display: flex; justify-content: space-between; color: #70786f; border-top: 1px solid var(--line); font-size: .82rem; }
.eyebrow { margin-bottom: 12px; color: var(--accent); font-size: .73rem; font-weight: 750; letter-spacing: .15em; text-transform: uppercase; }
.lead { max-width: 720px; color: var(--muted); font-size: 1.05rem; }
.meta { color: #7f887e; font-size: .8rem; }
.panel { background: linear-gradient(145deg, rgb(255 255 255 / 2%), transparent), var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.button { min-height: 42px; padding: 9px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--text); background: var(--surface-2); border: 1px solid #3a423a; border-radius: 999px; cursor: pointer; font-weight: 650; line-height: 1.2; transition: transform .15s, border-color .15s, background .15s; }
.button:hover { transform: translateY(-1px); border-color: #657062; }
.button-primary { color: #11170a; background: var(--accent); border-color: var(--accent); }
.button-primary:hover { background: #e1ff91; border-color: #e1ff91; }
.button-danger { color: #ffd4d1; background: #351b1b; border-color: #69312f; }
.button-small { min-height: 34px; padding: 6px 12px; font-size: .8rem; }
.button-wide { width: 100%; }
.back-link { display: inline-block; margin-bottom: 25px; color: var(--muted); font-size: .85rem; }
.back-link:hover { color: var(--text); }
.page-heading { margin-bottom: clamp(32px, 5vw, 62px); display: flex; align-items: end; justify-content: space-between; gap: 30px; }
.page-heading h1 { margin-bottom: 0; }
.gallery-heading .lead { margin-top: 18px; margin-bottom: 0; }
.heading-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.count-label { color: var(--muted); }
.flash { margin: -24px 0 32px; padding: 12px 16px; border: 1px solid; border-radius: 12px; }
.flash-success { color: #dbffaa; background: #19290f; border-color: #3b5a24; }
.flash-error, .form-error { color: #ffd1cf; background: #341b1b; border-color: #6a3431; }

.auth-layout { min-height: 65vh; display: grid; grid-template-columns: 1.25fr minmax(320px, .75fr); gap: clamp(45px, 10vw, 150px); align-items: center; }
.auth-intro h1 { max-width: 720px; }
.auth-intro > p:last-child { max-width: 570px; color: var(--muted); font-size: 1.15rem; }
.auth-card { max-width: 480px; width: 100%; padding: clamp(28px, 4vw, 48px); display: grid; gap: 22px; }
.auth-card h2 { font-size: 2rem; letter-spacing: -.04em; }
label { display: grid; gap: 7px; color: #d8ddd6; font-weight: 650; }
input, textarea, select { width: 100%; padding: 12px 14px; color: var(--text); background: #111411; border: 1px solid #3a413a; border-radius: 10px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(214 255 101 / 10%); }
textarea { resize: vertical; }
label small, .form-hint { color: var(--muted); font-weight: 400; }
.form-error { padding: 11px 14px; border: 1px solid #6a3431; border-radius: 10px; }
.form-card { max-width: 680px; margin: 0 auto; padding: clamp(24px, 5vw, 48px); display: grid; gap: 24px; }
.form-actions { display: flex; gap: 10px; margin-top: 5px; }

.gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(16px, 2vw, 28px); }
.gallery-card { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: transform .2s, border-color .2s; }
.gallery-card:hover { transform: translateY(-4px); border-color: #586254; }
.gallery-cover { position: relative; aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; overflow: hidden; background: radial-gradient(circle at 70% 20%, #50622a, transparent 40%), linear-gradient(135deg, #273124, #161a16); }
.gallery-cover::before { content: ''; width: 25%; aspect-ratio: 1; border: 2px solid rgb(214 255 101 / 35%); border-radius: 50% 50% 50% 16%; transform: rotate(25deg); }
.gallery-cover.has-image::before { display: none; }
.gallery-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.gallery-card:hover img { transform: scale(1.025); }
.image-count { position: absolute; right: 12px; bottom: 12px; padding: 5px 10px; background: rgb(12 15 12 / 78%); border: 1px solid rgb(255 255 255 / 12%); border-radius: 999px; backdrop-filter: blur(10px); font-size: .75rem; }
.gallery-card-body { min-height: 150px; padding: 22px; display: flex; flex-direction: column; }
.gallery-card-body h2 { font-size: 1.35rem; }
.gallery-card-body p { margin-bottom: 16px; color: var(--muted); display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.gallery-card-body .meta { margin-top: auto; }
.empty-state { max-width: 760px; margin: 30px auto; padding: clamp(50px, 8vw, 90px) 30px; text-align: center; }
.empty-state p { max-width: 520px; margin: 0 auto 22px; color: var(--muted); }
.empty-icon { width: 54px; height: 54px; margin: 0 auto 20px; display: grid; place-items: center; color: var(--accent); background: var(--accent-dark); border-radius: 50%; font-size: 2rem; }
.empty-state.compact { padding: 40px 25px; }

.photo-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.photo-tile { position: relative; aspect-ratio: 1; padding: 0; overflow: hidden; background: var(--surface); border: 0; border-radius: 9px; cursor: zoom-in; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s, filter .3s; }
.photo-tile:hover img, .photo-tile:focus img { transform: scale(1.035); filter: brightness(1.08); }
.photo-tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.photo-number { position: absolute; left: 9px; bottom: 7px; color: white; text-shadow: 0 1px 5px black; font-size: .66rem; opacity: .8; }
.lightbox[hidden] { display: none; }
.lightbox { position: fixed; z-index: 20; inset: 0; display: grid; grid-template-columns: 70px 1fr 70px; align-items: center; background: rgb(5 7 5 / 95%); backdrop-filter: blur(15px); }
.lightbox figure { max-width: calc(100vw - 180px); max-height: calc(100vh - 80px); margin: auto; display: grid; gap: 10px; justify-items: center; }
.lightbox figure img { max-width: 100%; max-height: calc(100vh - 115px); object-fit: contain; }
.lightbox figcaption { color: var(--muted); font-size: .82rem; }
.lightbox-close, .lightbox-nav { color: white; background: rgb(255 255 255 / 8%); border: 1px solid rgb(255 255 255 / 14%); border-radius: 50%; cursor: pointer; }
.lightbox-close { position: absolute; z-index: 2; top: 20px; right: 20px; width: 44px; height: 44px; font-size: 1.7rem; }
.lightbox-nav { width: 48px; height: 48px; margin: auto; font-size: 2rem; }
.no-scroll { overflow: hidden; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.stat-card { min-height: 230px; padding: 28px; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
a.stat-card:hover { border-color: #596453; }
.stat-number { margin-bottom: 8px; color: var(--accent); font-size: clamp(3rem, 8vw, 6rem); line-height: 1; letter-spacing: -.07em; }
.stat-card > span:nth-child(2) { font-size: 1.1rem; font-weight: 700; }
.stat-card small { margin-top: auto; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 17px 20px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
tbody tr:last-child td { border-bottom: 0; }
.table-actions, .row-actions { display: flex; justify-content: end; gap: 8px; }
.table-actions form { margin: 0; }
.tag, .role { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: .7rem; }
.tag { margin-left: 5px; color: var(--accent); background: var(--accent-dark); }
.role-admin { color: #e4ffa1; background: #273514; }
.role-user { color: #b5c4ff; background: #1c2744; }
.admin-gallery-list { display: grid; gap: 14px; }
.admin-gallery-row { padding: 22px 24px; display: flex; align-items: center; justify-content: space-between; gap: 25px; box-shadow: none; }
.admin-gallery-row p { margin-bottom: 5px; color: var(--muted); }
.admin-gallery-row h2 a:hover { color: var(--accent); }
.upload-panel { margin-bottom: 36px; padding: 22px; display: flex; align-items: center; gap: 20px; box-shadow: none; }
.upload-panel > div { margin-right: auto; }
.upload-panel h2, .upload-panel p { margin-bottom: 0; }
.upload-panel p { color: var(--muted); font-size: .82rem; }
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-picker span { min-height: 42px; padding: 9px 16px; display: flex; align-items: center; background: var(--surface-2); border: 1px dashed #5c675a; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.file-picker:focus-within span { outline: 2px solid var(--accent); }
.admin-photo-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.admin-photo { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.admin-photo > img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.admin-photo > div { padding: 9px; display: grid; gap: 5px; }
.admin-photo span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .72rem; }
.admin-photo form { margin: 0; }
.text-danger { padding: 0; color: var(--danger); background: transparent; border: 0; cursor: pointer; font-size: .72rem; }
.danger-zone { margin-top: 70px; padding: 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: #211716; border-color: #57302d; box-shadow: none; }
.danger-zone h2, .danger-zone p { margin-bottom: 0; }
.danger-zone p { color: #bb9a96; }
.error-page { min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.error-page h1 { font-size: clamp(2.5rem, 7vw, 5rem); }
.error-page > p:not(.error-code) { margin-bottom: 25px; color: var(--muted); }
.error-code { margin-bottom: 0; color: var(--accent); font-size: 1rem; letter-spacing: .2em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 1000px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
  .photo-grid { grid-template-columns: repeat(4, 1fr); }
  .admin-photo-grid { grid-template-columns: repeat(4, 1fr); }
  .auth-layout { grid-template-columns: 1fr 1fr; gap: 40px; }
}
@media (max-width: 720px) {
  .site-header, .page-shell, .site-footer { width: min(100% - 28px, 1400px); }
  .site-header { height: 68px; }
  .page-shell { padding: 40px 0 60px; }
  .main-nav { gap: 13px; font-size: .83rem; }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-intro { padding-top: 20px; }
  .auth-card { max-width: none; }
  .page-heading { align-items: flex-start; flex-direction: column; margin-bottom: 35px; }
  .gallery-heading .heading-actions { width: 100%; }
  .gallery-grid { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: repeat(2, 1fr); gap: 7px; }
  .lightbox { grid-template-columns: 52px 1fr 52px; }
  .lightbox figure { max-width: calc(100vw - 115px); }
  .lightbox-nav { width: 40px; height: 40px; }
  .stat-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 180px; }
  .admin-gallery-row, .danger-zone, .upload-panel { align-items: stretch; flex-direction: column; }
  .row-actions { justify-content: start; }
  .upload-panel > div { margin-right: 0; }
  .admin-photo-grid { grid-template-columns: repeat(2, 1fr); }
  .file-picker span { justify-content: center; }
  .site-footer { gap: 15px; flex-direction: column; }
}
@media (max-width: 430px) {
  .brand span:last-child { display: none; }
  .gallery-card-body { min-height: 130px; }
  .heading-actions { flex-wrap: wrap; }
  .lightbox { grid-template-columns: 44px 1fr 44px; }
  .lightbox figure { max-width: calc(100vw - 94px); }
  .lightbox-nav { width: 36px; height: 36px; }
}
