:root {
  color-scheme: light;
  --ink: #252824;
  --muted: #6d736b;
  --paper: #fcfcf8;
  --sand: #f3f2ec;
  --sand-deep: #dedfd6;
  --accent: #78866d;
  --accent-dark: #4f5d49;
  --terracotta: #b56f4f;
  --white: #fff;
  --danger: #9a3f3f;
  --shadow: 0 20px 60px rgba(45, 52, 43, .12);
  --soft-shadow: 0 10px 30px rgba(45, 52, 43, .09);
  --radius: 24px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--sand); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(181, 111, 79, .1), transparent 28rem),
    radial-gradient(circle at 95% 20%, rgba(120, 134, 109, .15), transparent 32rem),
    var(--sand);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background: var(--sand);
  transition: opacity .38s ease, visibility .38s ease;
}

.splash.is-hidden { opacity: 0; visibility: hidden; }
.splash__logo { width: 126px; animation: breathe 1.4s ease-in-out infinite; filter: drop-shadow(0 16px 28px rgba(79, 93, 73, .18)); }
.splash__brand { font-family: Georgia, serif; font-size: 1.35rem; letter-spacing: .12em; color: var(--accent-dark); }
@keyframes breathe { 50% { transform: scale(1.04); opacity: .88; } }

.app { min-height: 100vh; }
.shell { width: min(1240px, calc(100% - 34px)); margin: 0 auto; padding: 22px 0 60px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 70px;
  margin-bottom: 34px;
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand img { width: 44px; height: 44px; }
.brand__name { font-family: Georgia, serif; font-size: 1.45rem; letter-spacing: .04em; }
.brand__tag { display: block; margin-top: 1px; color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.topbar__right { display: flex; align-items: center; gap: 12px; }
.account { color: var(--muted); font-size: .9rem; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  color: var(--white);
  background: var(--accent);
  box-shadow: 0 8px 20px rgba(79, 93, 73, .2);
  text-decoration: none;
  font-weight: 700;
  transition: transform .16s ease, background .16s ease;
}
.button:hover { transform: translateY(-1px); background: var(--accent-dark); }
.button:disabled { cursor: wait; opacity: .6; transform: none; }
.button--soft { color: var(--accent-dark); background: rgba(120, 134, 109, .13); box-shadow: none; }
.button--soft:hover { background: rgba(120, 134, 109, .21); }
.button--plain { color: var(--muted); background: transparent; box-shadow: none; }
.button--plain:hover { color: var(--ink); background: rgba(46, 37, 39, .06); }
.button--small { min-height: 37px; padding: 8px 13px; font-size: .86rem; }
.button--status { color: #7a4b37; background: rgba(181, 111, 79, .12); }
.button--status:hover { color: #633824; background: rgba(181, 111, 79, .2); }
.button.is-selection-active { color: var(--white); background: var(--accent-dark); }
.button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 28px 18px; }
.auth-card {
  width: min(460px, 100%);
  padding: 42px;
  border: 1px solid rgba(79, 93, 73, .11);
  border-radius: 32px;
  background: rgba(252, 252, 248, .92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.auth-logo { display: block; width: 82px; margin: 0 auto 16px; }
.auth-card h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(2rem, 7vw, 2.7rem); font-weight: 500; text-align: center; }
.auth-card .lead { margin: 9px 0 30px; color: var(--muted); text-align: center; line-height: 1.5; }

.form { display: grid; gap: 18px; }
.field { display: grid; gap: 7px; }
.field label { font-size: .86rem; font-weight: 750; color: #484d47; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid #d3d6cd;
  border-radius: 14px;
  padding: 13px 14px;
  color: var(--ink);
  background: var(--white);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field textarea { min-height: 94px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(120, 134, 109, .14); }
.form-error { min-height: 22px; margin: 0; color: var(--danger); font-size: .88rem; }
.form .button { width: 100%; margin-top: 4px; }
.form-hint { color: var(--muted); font-size: .79rem; line-height: 1.45; }

.hero { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin: 0 0 26px; }
.eyebrow { margin: 0 0 8px; color: var(--terracotta); font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.hero h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(2rem, 6vw, 3.5rem); font-weight: 500; line-height: 1.08; }
.hero__sub { max-width: 650px; margin: 10px 0 0; color: var(--muted); line-height: 1.6; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 10px; }

.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 22px; color: var(--muted); font-size: .9rem; }
.breadcrumbs button { padding: 4px 0; border: 0; color: var(--accent-dark); background: transparent; }
.breadcrumbs span { opacity: .55; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr)); gap: 22px; }
.photo-grid { grid-template-columns: repeat(auto-fill, minmax(min(235px, 100%), 1fr)); }

.card {
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--paper);
  box-shadow: var(--soft-shadow);
  text-align: left;
  transition: transform .2s ease, box-shadow .2s ease;
}
button.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.card__image { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: var(--sand-deep); }
.photo-card .card__image { aspect-ratio: 4 / 5; }
.photo-card--clean { display: block; width: 100%; }
.photo-card--clean .card__image { border-radius: inherit; }
.photo-card-wrap { position: relative; min-width: 0; }
.photo-card-wrap .photo-card { height: 100%; }
.card__image picture { display: block; width: 100%; height: 100%; }
.card__image img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .45s ease, opacity .2s ease; }
button.card:hover .card__image img { transform: scale(1.025); }
.card__empty { display: grid; place-items: center; height: 100%; color: var(--muted); }
.card__empty img { width: 64px; height: 64px; object-fit: contain; opacity: .5; }
.card__body { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 76px; padding: 16px 18px; }
.card__title { overflow: hidden; font-weight: 750; text-overflow: ellipsis; }
.card__meta { display: block; margin-top: 4px; color: var(--muted); font-size: .79rem; font-weight: 500; }
.card__arrow { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: var(--accent-dark); background: rgba(120, 134, 109, .13); }
.stack-badge { position: absolute; top: 13px; right: 13px; display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 999px; color: var(--white); background: rgba(37, 40, 36, .78); backdrop-filter: blur(10px); font-size: .76rem; font-weight: 800; }
.stack-badge::before, .stack-badge::after { content: ''; width: 11px; height: 14px; border: 1.5px solid currentColor; border-radius: 3px; }
.stack-badge::after { position: absolute; margin-left: -3px; margin-top: -3px; opacity: .55; }
.favorite-button {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.42);
  border-radius: 50%;
  color: var(--white);
  background: rgba(37, 40, 36, .56);
  box-shadow: 0 5px 18px rgba(20,24,20,.18);
  backdrop-filter: blur(10px);
  transition: transform .16s ease, color .16s ease, background .16s ease;
}
.favorite-button:hover { transform: scale(1.06); background: rgba(37, 40, 36, .76); }
.favorite-button svg { width: 22px; height: 22px; fill: transparent; stroke: currentColor; stroke-width: 1.8; transition: fill .16s ease; }
.favorite-button.is-active { color: #f4c3ae; background: rgba(65, 42, 33, .78); }
.favorite-button.is-active svg { fill: currentColor; }
.favorite-button--display { pointer-events: none; }
.photo-grid.can-select:not(.is-selecting) .favorite-button,
.photo-grid.favorites-view .favorite-button { display: none; }
.photo-grid.is-selecting .photo-card-wrap { cursor: pointer; }
.photo-grid.is-selecting .photo-card { outline: 3px solid transparent; outline-offset: -3px; transform: scale(.985); box-shadow: none; }
.photo-grid.is-selecting .photo-card-wrap.is-favorite .photo-card { outline-color: #c58364; box-shadow: 0 10px 28px rgba(79, 55, 44, .22); }
.photo-grid.is-selecting .favorite-button { pointer-events: none; }
.photo-grid.is-selecting .photo-card-wrap:not(.is-favorite) .card__image img { opacity: .78; }

.selection-bar {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 35;
  width: min(720px, calc(100% - 34px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 14px 16px 14px 21px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 22px;
  color: var(--white);
  background: rgba(37, 40, 36, .94);
  box-shadow: 0 18px 50px rgba(25, 30, 25, .3);
  backdrop-filter: blur(14px);
  transform: translateX(-50%);
}
.selection-bar[hidden] { display: none; }
.selection-bar__summary { display: grid; gap: 3px; }
.selection-bar__summary strong { font-size: .95rem; }
.selection-bar__summary span { color: rgba(255,255,255,.65); font-size: .77rem; }
.selection-bar__actions { display: flex; flex: none; gap: 8px; }
.selection-bar .button--soft { color: var(--white); background: rgba(255,255,255,.12); }
.selection-bar .button--soft:hover { background: rgba(255,255,255,.2); }
body.selection-active .shell { padding-bottom: 145px; }

.notice { margin: 0 0 28px; padding: 22px 24px; border-left: 4px solid var(--terracotta); border-radius: 4px 18px 18px 4px; background: rgba(252, 252, 248, .76); color: #4b504a; line-height: 1.65; }
.notice h1, .notice h2, .notice h3 { margin: 0 0 8px; font-family: Georgia, serif; }
.notice p { margin: 5px 0; }

.empty { padding: 70px 28px; border-radius: 28px; background: rgba(252, 252, 248, .76); text-align: center; }
.empty img { width: 80px; opacity: .72; }
.empty h2 { margin: 16px 0 8px; font-family: Georgia, serif; font-weight: 500; font-size: 1.8rem; }
.empty p { max-width: 520px; margin: 0 auto; color: var(--muted); line-height: 1.6; }

.admin-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(310px, .85fr); gap: 24px; align-items: start; }
.panel { padding: 25px; border-radius: var(--radius); background: rgba(252, 252, 248, .88); box-shadow: var(--soft-shadow); }
.panel h2 { margin: 0 0 6px; font-family: Georgia, serif; font-size: 1.55rem; font-weight: 500; }
.panel__intro { margin: 0 0 22px; color: var(--muted); line-height: 1.5; }
.client-list { display: grid; gap: 12px; }
.client { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px; border: 1px solid var(--sand-deep); border-radius: 16px; background: var(--white); }
.client__avatar { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; color: var(--accent-dark); background: var(--sand); font-family: Georgia, serif; font-size: 1.2rem; }
.client__info { min-width: 0; flex: 1; }
.client__name { display: block; overflow: hidden; font-weight: 800; text-overflow: ellipsis; }
.client__folder { display: block; overflow: hidden; margin-top: 3px; color: var(--muted); font-size: .78rem; text-overflow: ellipsis; }
.client__actions { display: flex; flex: none; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.client.is-paused { border-color: rgba(181, 111, 79, .28); background: #faf7f3; }
.status-pill { display: inline-flex; margin-left: 7px; padding: 4px 8px; border-radius: 999px; color: var(--accent-dark); background: rgba(120, 134, 109, .14); font-size: .67rem; font-weight: 800; vertical-align: 1px; }
.status-pill.is-paused { color: #824a33; background: rgba(181, 111, 79, .15); }

.favorites-group { margin-top: 42px; }
.favorites-group:first-of-type { margin-top: 8px; }
.favorites-group__heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 17px; }
.favorites-group__heading .eyebrow { margin-bottom: 5px; }
.favorites-group__heading h2 { margin: 0; font-family: Georgia, serif; font-size: clamp(1.55rem, 4vw, 2.15rem); font-weight: 500; }

.preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: -14px 0 28px; padding: 12px 14px 12px 19px; border: 1px solid rgba(120, 134, 109, .22); border-radius: 18px; color: var(--accent-dark); background: rgba(225, 229, 218, .72); }
.preview-bar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lightbox { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; color: var(--white); background: rgba(20, 24, 20, .96); }
.lightbox--single { grid-template-rows: auto minmax(0, 1fr); }
.lightbox__top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 18px; }
.lightbox__title { min-width: 0; }
.lightbox__title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox__title span { color: rgba(255,255,255,.65); font-size: .82rem; }
.lightbox__actions { display: flex; align-items: center; gap: 8px; }
.lightbox__actions .button--soft { color: var(--white); background: rgba(255,255,255,.12); }
.lightbox__actions .button--soft:hover { background: rgba(255,255,255,.2); }
.icon-button { width: 43px; height: 43px; display: grid; place-items: center; border: 0; border-radius: 50%; color: var(--white); background: rgba(255,255,255,.1); }
.icon-button:hover { background: rgba(255,255,255,.2); }
.icon-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.lightbox__favorite svg { fill: transparent; transition: fill .16s ease; }
.lightbox__favorite.is-active { color: #f4c3ae; background: rgba(181,111,79,.22); }
.lightbox__favorite.is-active svg { fill: currentColor; }
.lightbox__stage { position: relative; min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 8px 72px; }
.lightbox--single .lightbox__stage { padding-top: 22px; padding-bottom: 32px; }
.lightbox__image { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; user-select: none; }
.lightbox__nav { position: absolute; top: 50%; width: 48px; height: 56px; margin-top: -28px; border: 0; border-radius: 16px; color: var(--white); background: rgba(255,255,255,.1); font-size: 1.7rem; }
.lightbox__nav:hover { background: rgba(255,255,255,.2); }
.lightbox__nav--prev { left: 16px; }
.lightbox__nav--next { right: 16px; }
.lightbox__thumbs { display: flex; justify-content: center; gap: 9px; overflow-x: auto; padding: 13px 18px 18px; }
.lightbox__thumb { flex: none; width: 62px; height: 62px; padding: 2px; border: 2px solid transparent; border-radius: 11px; background: transparent; opacity: .62; }
.lightbox__thumb.is-active { border-color: #aebc9f; opacity: 1; }
.lightbox__thumb img { width: 100%; height: 100%; border-radius: 7px; object-fit: cover; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 80; max-width: min(520px, calc(100% - 32px)); padding: 12px 18px; border-radius: 999px; color: var(--white); background: #2f342f; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, 15px); transition: .25s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); }

.loading-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 22px; }
.skeleton { height: 320px; border-radius: var(--radius); background: linear-gradient(100deg, rgba(255,255,255,.45) 30%, rgba(255,255,255,.9) 50%, rgba(255,255,255,.45) 70%); background-size: 300% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -300% 0; } }

@media (max-width: 780px) {
  .shell { width: min(100% - 24px, 1240px); padding-top: 12px; }
  .topbar { margin-bottom: 25px; }
  .brand__tag, .account { display: none; }
  .hero { align-items: start; flex-direction: column; }
  .hero__actions { width: 100%; }
  .hero__actions .button { flex: 1; }
  .admin-grid { grid-template-columns: 1fr; }
  .client { align-items: flex-start; flex-wrap: wrap; }
  .client__actions { width: 100%; }
  .client__actions .button { flex: 1; }
  .favorites-group__heading { align-items: start; }
  .selection-bar { bottom: 12px; align-items: stretch; flex-direction: column; gap: 11px; padding: 14px; border-radius: 20px; }
  .selection-bar__summary { text-align: center; }
  .selection-bar__actions { width: 100%; }
  .selection-bar__actions .button { flex: 1; }
  .preview-bar { align-items: stretch; flex-direction: column; margin-top: -8px; }
  .preview-bar span { white-space: normal; }
  .auth-card { padding: 32px 24px; }
  .lightbox__stage { padding: 8px 48px; }
  .lightbox__top { padding: 10px; }
  .lightbox__actions .button--soft { width: 43px; min-width: 43px; padding: 0; overflow: hidden; font-size: 0; }
  .lightbox__actions .button--soft svg { width: 20px; }
  .lightbox__nav { width: 38px; }
  .lightbox__nav--prev { left: 5px; }
  .lightbox__nav--next { right: 5px; }
}

@media (max-width: 520px) {
  .favorites-link, .topbar [data-logout] { width: 43px; min-width: 43px; padding: 0; }
  .favorites-link span, .topbar [data-logout] span { display: none; }
  .favorites-group__heading { flex-direction: column; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .photo-grid .favorite-button { top: 8px; left: 8px; width: 36px; height: 36px; }
  .photo-grid .favorite-button svg { width: 19px; height: 19px; }
  .photo-grid .stack-badge { top: 8px; right: 8px; padding: 6px 8px; font-size: .66rem; }
  .photo-grid .stack-badge::before, .photo-grid .stack-badge::after { width: 9px; height: 12px; }
  .photo-grid.is-selecting .photo-card { outline-width: 2px; outline-offset: -2px; }
}

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