:root {
  color: #1b2b3a;
  background: #f6f8fa;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --navy: #102a43;
  --navy-deep: #091d2f;
  --blue: #2474d2;
  --blue-dark: #185ba9;
  --line: #d9e2ec;
  --muted: #64788a;
  --surface: #fff;
  --danger: #b42318;
  --shadow: 0 18px 55px rgb(16 42 67 / 0.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid #62a8ff;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: var(--navy);
  background: white;
  border-radius: 8px;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px clamp(20px, 5vw, 72px);
  color: white;
  background: var(--navy);
  box-shadow: 0 3px 16px rgb(9 29 47 / 0.22);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: white;
}
.brand svg { width: 34px; height: 34px; fill: #62a8ff; }
.brand svg path + path { fill: white; }
.brand span { display: flex; align-items: baseline; gap: 6px; }
.brand strong { letter-spacing: .08em; font-size: 1.05rem; }
.brand small { color: #b9d7f5; font-weight: 700; }
.brand-button { padding: 5px; border: 0; background: none; cursor: pointer; }

.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.user-email { max-width: 260px; overflow: hidden; color: #dcecff; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; }
.header-notice { max-width: 330px; padding: 7px 10px; color: #5c1a14; border-radius: 7px; background: #ffe5e2; font-size: .78rem; line-height: 1.3; }

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: wait; }
.button-primary { color: white; background: var(--blue); }
.button-primary:hover:not(:disabled) { background: var(--blue-dark); }
.button-secondary { color: var(--blue-dark); border-color: #b9d3ef; background: #edf6ff; }
.button-quiet { min-height: 38px; color: white; border-color: rgb(255 255 255 / .28); background: transparent; }
.button-quiet:hover { background: rgb(255 255 255 / .1); }
.button-wide { width: 100%; margin-top: 8px; }
.button-viewer { min-height: 38px; color: white; border-color: rgb(255 255 255 / .28); text-decoration: none; }

.auth-page {
  display: grid;
  min-height: calc(100vh - 72px);
  place-items: center;
  padding: 48px 20px;
  background:
    radial-gradient(circle at 16% 18%, rgb(36 116 210 / .11), transparent 34%),
    linear-gradient(160deg, #f9fbfd 0%, #eef4f8 100%);
}
.auth-card { width: min(100%, 470px); padding: clamp(28px, 6vw, 48px); border: 1px solid #e2e8ee; border-radius: 20px; background: white; box-shadow: var(--shadow); }
.eyebrow { margin: 0 0 10px; color: var(--blue-dark); font-size: .75rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, p { overflow-wrap: anywhere; }
h1 { margin: 0; color: var(--navy); font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.02; letter-spacing: -.04em; }
.auth-card h1 { font-size: clamp(2rem, 7vw, 3rem); }
.intro { margin: 20px 0 28px; color: var(--muted); font-size: 1.05rem; line-height: 1.65; }
label { color: var(--navy); font-size: .88rem; font-weight: 700; }
input[type="email"] { width: 100%; min-height: 48px; margin-top: 7px; padding: 10px 13px; color: #162c40; border: 1px solid #b9c7d3; border-radius: 8px; background: white; }
input[type="email"]:focus { border-color: var(--blue); }
.notice { margin-top: 18px; padding: 13px 15px; border-radius: 9px; color: #19486f; background: #eaf5ff; line-height: 1.45; }
.notice[data-tone="success"] { color: #17633a; background: #eaf8f0; }
.notice[data-tone="warning"] { color: #7a4a00; background: #fff4d6; }
.notice[data-tone="error"] { color: #8d231b; background: #ffebe9; }
.text-button { padding: 5px 2px; color: var(--blue-dark); border: 0; background: transparent; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.auth-card > .text-button { display: block; margin: 18px auto 0; }

.hero { display: grid; height: 280px; place-items: center; overflow: hidden; padding: 10px; background: #081a29; }
.hero img { display: block; width: auto; max-width: 100%; height: 260px; object-fit: contain; }
.content-shell { width: min(100% - 40px, 1240px); margin: 0 auto; padding: clamp(42px, 7vw, 84px) 0; }
.narrow-shell { max-width: 980px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.section-heading > p { margin: 0 0 5px; color: var(--muted); font-weight: 650; }
.section-heading h1 { font-size: clamp(2.2rem, 6vw, 4.3rem); }

.album-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(16px, 3vw, 30px); }
.album-card { overflow: hidden; padding: 0; text-align: left; border: 0; border-radius: 14px; background: white; box-shadow: 0 8px 28px rgb(16 42 67 / .10); cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
.album-card:hover { transform: translateY(-4px); box-shadow: 0 15px 38px rgb(16 42 67 / .16); }
.album-cover { display: grid; aspect-ratio: 4 / 3; place-items: center; overflow: hidden; color: var(--muted); background: #e9eff4; }
.album-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.album-card:hover img { transform: scale(1.025); }
.empty-album-mark { font-size: .88rem; font-weight: 700; letter-spacing: .03em; }
.album-label { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 18px 20px 20px; }
.album-label strong { color: var(--navy); font-size: 1.3rem; }
.album-label small { color: var(--muted); }

.back-button { margin-bottom: 34px; padding: 7px 0; color: var(--blue-dark); border: 0; background: transparent; font-weight: 750; cursor: pointer; }
.back-button span { margin-right: 6px; font-size: 1.2em; }
.photo-group + .photo-group { margin-top: 48px; }
.photo-group h2 { margin: 0 0 16px; color: var(--navy); font-size: 1.15rem; }
.photo-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.photo-tile { aspect-ratio: 4 / 3; min-height: 130px; overflow: hidden; padding: 0; border: 0; border-radius: 6px; background: #dfe7ee; cursor: zoom-in; }
.photo-tile img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease, filter .25s ease; }
.photo-tile:hover img { transform: scale(1.025); filter: brightness(1.03); }
.empty-state, .error-panel { padding: 34px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: white; text-align: center; }
.error-panel p { margin: 0 0 16px; }
.loading { color: var(--muted); }

.admin-form, .user-row { display: flex; align-items: end; gap: 16px; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.admin-form { margin-bottom: 18px; border-color: #b9d3ef; background: #f3f8fd; }
.form-field { min-width: 200px; }
.grow { flex: 1; }
.check-field { display: flex; min-height: 44px; align-items: center; gap: 6px; white-space: nowrap; }
.check-field input { width: 18px; height: 18px; accent-color: var(--blue); }
.user-list { display: grid; gap: 10px; margin-top: 26px; }
.user-row input[type="email"] { margin-top: 4px; }
.row-actions { display: flex; align-items: center; gap: 12px; }
.danger { color: var(--danger); }

.viewer { width: 100vw; max-width: none; height: 100vh; max-height: none; margin: 0; padding: 0; color: white; border: 0; background: rgb(5 14 23 / .97); }
.viewer::backdrop { background: #050e17; }
.viewer[open] { display: grid; grid-template-rows: auto 1fr; }
.viewer-bar { z-index: 2; display: flex; min-height: 76px; align-items: center; justify-content: space-between; gap: 20px; padding: 12px clamp(16px, 3vw, 38px); background: rgb(5 14 23 / .72); }
.viewer-bar h2 { margin: 0; font-size: 1rem; }
.viewer-bar p { margin: 3px 0 0; color: #b8c9d8; font-size: .84rem; }
.viewer-actions { display: flex; align-items: center; gap: 12px; }
.icon-button { display: grid; width: 44px; height: 44px; place-items: center; padding: 0; color: white; border: 0; background: transparent; font-size: 2rem; line-height: 1; cursor: pointer; }
.viewer-stage { position: relative; display: grid; min-height: 0; place-items: center; padding: 16px 70px 32px; }
.viewer-stage img { display: block; max-width: 100%; max-height: calc(100vh - 124px); object-fit: contain; }
.viewer-nav { position: absolute; top: 50%; display: grid; width: 48px; height: 64px; place-items: center; color: white; border: 1px solid rgb(255 255 255 / .22); border-radius: 9px; background: rgb(255 255 255 / .08); font-size: 2.6rem; cursor: pointer; transform: translateY(-50%); }
.viewer-nav:hover:not(:disabled) { background: rgb(255 255 255 / .18); }
.viewer-nav:disabled { opacity: .2; cursor: default; }
.viewer-nav.previous { left: 14px; }
.viewer-nav.next { right: 14px; }

@media (max-width: 860px) {
  .site-header { align-items: flex-start; }
  .header-actions { flex-wrap: wrap; }
  .user-email { width: 100%; max-width: 100%; text-align: right; }
  .album-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .admin-form, .user-row { align-items: stretch; flex-direction: column; }
  .form-field { width: 100%; }
  .check-field { min-height: 32px; }
  .row-actions { flex-wrap: wrap; }
}

@media (max-width: 580px) {
  .site-header { min-height: 64px; padding: 10px 14px; }
  .brand svg { width: 30px; height: 30px; }
  .user-email { display: none; }
  .header-notice { position: fixed; top: 70px; right: 12px; left: 12px; max-width: none; box-shadow: 0 5px 18px rgb(9 29 47 / .18); }
  .header-actions { gap: 6px; }
  .button-quiet { min-height: 36px; padding: 8px 10px; font-size: .8rem; }
  .content-shell { width: min(100% - 28px, 1240px); padding: 40px 0 58px; }
  .hero { height: 220px; }
  .hero img { height: 200px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .album-grid { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
  .photo-tile { min-height: 105px; border-radius: 3px; }
  .viewer-bar { align-items: flex-start; }
  .viewer-bar > div:first-child { min-width: 0; }
  .viewer-bar h2 { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .button-viewer { padding: 8px 10px; font-size: .78rem; }
  .viewer-stage { padding: 10px 52px 20px; }
  .viewer-nav { width: 40px; height: 54px; }
  .viewer-nav.previous { left: 6px; }
  .viewer-nav.next { right: 6px; }
}

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

#login-view { min-height: 100vh; }
.folder-trail { margin-bottom: 24px; color: var(--muted); line-height: 2; overflow-wrap: anywhere; }
.folder-trail [aria-current="page"] { color: var(--navy); text-decoration: none; }
.folder-grid { margin-bottom: 32px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
