:root {
  color-scheme: dark;
  --accent: #4d7ea6;
  --bg: #10161d;
  --bg2: #151e28;
  --panel: #18232e;
  --panel2: #202d39;
  --line: #31414e;
  --text: #e3e9ee;
  --muted: #a3afb9;
  --radius: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input { font: inherit; }

.photo-topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 6px 18px;
  border-bottom: 1px solid var(--line);
  background: #0c1218;
}

.photo-brand { display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--text); font-size: 17px; font-weight: 700; letter-spacing: .3px; }
.photo-brand img { display: block; width: 72px; height: 48px; flex: 0 0 auto; object-fit: contain; border-radius: 6px; background: #fff; }
.photo-tabs { display: flex; align-items: center; justify-self: center; gap: 8px; }
.nav-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.nav-tab:hover, .nav-tab.active { border-color: #315f80; background: #315f80; color: #fff; text-decoration: none; }
.photo-actions { display: flex; justify-self: end; gap: 8px; }
.nav-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-weight: 600;
}
.nav-button:hover { border-color: var(--accent); background: var(--panel2); text-decoration: none; }

.gallery { width: min(1440px, 100%); margin: 0 auto; padding: 22px; }
.gallery-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.eyebrow { margin: 0 0 5px; color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
h1 { margin: 0; font-size: 24px; line-height: 1.2; }
.gallery-description { margin: 6px 0 0; color: var(--muted); }
.photo-search { width: min(100%, 360px); flex: 0 1 360px; }
.photo-search input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: var(--panel2);
  color: var(--text);
}
.photo-search input:focus { border-color: var(--accent); }
.folder-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 2px 12px; color: var(--muted); }
.folder-crumb { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); cursor: pointer; }
.folder-crumb:hover, .folder-crumb[aria-current="page"] { border-color: var(--accent); color: #fff; }
.folder-crumb.current { font-weight: 700; }
.folder-separator { color: var(--muted); }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 10px; margin-bottom: 14px; }
.folder-card { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 12px; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); text-align: left; cursor: pointer; box-shadow: var(--shadow); }
.folder-card:hover { border-color: var(--accent); background: var(--panel2); }
.folder-icon { grid-row: span 2; padding: 7px 9px; border-radius: 7px; background: var(--panel2); color: var(--accent); font-size: 11px; font-weight: 700; }
.folder-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-card small { color: var(--muted); }
.gallery-meta { display: flex; justify-content: space-between; gap: 12px; margin: 0 2px 10px; color: var(--muted); font-size: 12.5px; }
.gallery-meta p { margin: 0; }
.gallery-meta p.error { color: #ff929b; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 12px; }
.photo-card {
  display: block;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  text-align: left;
  cursor: zoom-in;
  box-shadow: var(--shadow);
  transition: border-color .15s ease, background-color .15s ease;
}
.photo-card:hover { border-color: var(--accent); background: var(--panel2); }
.photo-card:focus-visible, .folder-card:focus-visible, .folder-crumb:focus-visible, .dialog-close:focus-visible, .dialog-caption a:focus-visible, .photo-search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.photo-card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #000; }
.photo-card span { display: block; overflow: hidden; padding: 9px 12px 10px; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.empty-gallery { grid-column: 1 / -1; margin: 0; padding: 32px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--muted); text-align: center; }

.photo-dialog {
  position: relative;
  width: min(1100px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 28px 100px rgba(0, 0, 0, .7);
}
.photo-dialog::backdrop { background: rgba(3, 7, 11, .84); }
.photo-dialog > img { display: block; width: 100%; max-height: calc(100dvh - 130px); object-fit: contain; border-radius: 6px; }
.dialog-close { position: absolute; z-index: 1; top: 22px; right: 22px; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.35); border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; font-size: 26px; line-height: 1; }
.dialog-caption { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-top: 11px; }
.dialog-caption p { overflow: hidden; margin: 0; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.dialog-caption a { flex: 0 0 auto; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); color: var(--text); font-weight: 600; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }

@media (max-width: 900px) {
  .photo-topbar { display: flex; flex-wrap: wrap; gap: 8px; }
  .photo-tabs { order: 3; justify-self: auto; width: 100%; margin-top: 2px; }
  .photo-tabs .nav-tab { flex: 1; }
  .photo-actions { margin-left: auto; }
}

@media (max-width: 700px) {
  .photo-topbar { padding: 10px 12px; }
  .photo-brand { gap: 8px; font-size: 15px; }
  .photo-brand img { width: 64px; height: 46px; }
  .nav-button { padding: 7px 9px; font-size: 12px; }
  .gallery { padding: 10px; }
  .gallery-head { align-items: stretch; flex-direction: column; gap: 14px; padding: 16px; }
  .photo-search { flex: auto; width: 100%; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .photo-card span { padding: 8px 9px; font-size: 12px; }
  .photo-dialog { padding: 10px; }
  .dialog-close { top: 15px; right: 15px; }
}

@media (max-width: 380px) {
  .photo-topbar { padding-right: 8px; padding-left: 8px; }
  .photo-brand { font-size: 13px; }
  .photo-brand img { width: 56px; height: 42px; }
  .nav-tab { padding: 8px 10px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
