:root {
  --ink: #151515;
  --muted: #6f716d;
  --paper: #faf8f3;
  --panel: #ffffff;
  --line: #ded9cf;
  --accent: #9b3d2e;
  --accent-strong: #70291f;
  --sage: #74856a;
  --shadow: 0 18px 50px rgba(20, 20, 20, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.brand {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.label {
  margin: 0 0 0.5rem;
  color: var(--sage);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.access-screen {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 2rem;
  padding: 2rem;
  background:
    linear-gradient(rgba(250, 248, 243, 0.72), rgba(250, 248, 243, 0.9)),
    url("https://images.unsplash.com/photo-1519741497674-611481863552?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.access-panel {
  align-self: center;
  width: min(100%, 430px);
  padding: 2rem;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(222, 217, 207, 0.8);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.access-panel h1 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: clamp(1.85rem, 5.4vw, 3.35rem);
  line-height: 0.95;
  letter-spacing: 0;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: manual;
}

.access-panel label {
  display: block;
  margin: 1.6rem 0 0.45rem;
  font-weight: 700;
}

.access-panel > input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.85rem 0.9rem;
  background: rgba(255, 255, 255, 0.82);
}

.access-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.access-panel .access-row {
  margin-top: 1.6rem;
}

.access-row input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.85rem 0.9rem;
  background: var(--panel);
}

.access-row button {
  border-radius: 6px;
  padding: 0.85rem 1.1rem;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.access-row button:hover {
  background: var(--accent-strong);
}

.access-help {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.error {
  min-height: 1.35rem;
  color: #b3261e;
  font-weight: 700;
}

.hero {
  position: relative;
  min-height: 68vh;
  overflow: hidden;
  background: #222;
}

.hero img {
  width: 100%;
  height: 100%;
  min-height: 68vh;
  object-fit: cover;
  display: block;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(1.2rem, 4vw, 3rem);
  color: #fff;
  background: linear-gradient(rgba(0, 0, 0, 0.36), rgba(0, 0, 0, 0.1) 45%, rgba(0, 0, 0, 0.62));
}

.hero h1 {
  max-width: 940px;
  margin: 0;
  font-family: Georgia, serif;
  font-size: clamp(3rem, 11vw, 8.5rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.hero p:last-child {
  margin: 0.75rem 0 0;
  font-size: clamp(1rem, 2vw, 1.35rem);
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: rgba(250, 248, 243, 0.94);
  backdrop-filter: blur(12px);
}

.scene-tabs,
.actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  overflow-x: auto;
}

.tab,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.45rem;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.55rem 0.8rem;
  color: var(--ink);
  background: transparent;
  font-weight: 800;
}

.tab-count {
  min-width: 1.45rem;
  padding: 0.14rem 0.38rem;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(21, 21, 21, 0.07);
  font-size: 0.78rem;
  line-height: 1.1;
}

.tab-count.has-favorites {
  color: #fff;
  background: var(--accent);
}

.tab.active,
.icon-button.active {
  border-color: var(--line);
  background: var(--panel);
}

.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 2.45rem;
  max-width: 18rem;
  overflow: hidden;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.62);
  font-size: 0.88rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-grid {
  position: relative;
  padding: 0.75rem;
}

.photo-tile {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  margin: 0;
  overflow: hidden;
  border-radius: 6px;
  background: #e9e3d8;
}

.photo-tile img {
  width: 100%;
  display: block;
}

.favorite-button,
.tile-download,
.tile-crown,
.tile-hide,
.tile-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0.35rem 0.9rem rgba(20, 20, 20, 0.2);
  transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.favorite-button {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
}

.favorite-button.active {
  color: #fff;
  background: var(--accent);
}

.image-number-tag {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  padding: 0.3rem 0.45rem;
  border-radius: 4px;
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
  font-size: 0.76rem;
  font-weight: 800;
}

.tile-remove,
.remove-button {
  border-radius: 6px;
  font-weight: 800;
}

.tile-remove {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
}

.tile-client-actions {
  position: absolute;
  bottom: 0.6rem;
  left: 50%;
  display: flex;
  gap: 0.4rem;
  transform: translateX(-50%);
}

.tile-crown,
.tile-hide {
  font-weight: 800;
}

.favorite-button svg,
.tile-download svg,
.tile-crown svg,
.tile-hide svg,
.tile-remove svg {
  width: 1.1rem;
  height: 1.1rem;
}

.favorite-button:hover,
.tile-download:hover,
.tile-crown:hover,
.tile-hide:hover,
.tile-remove:hover {
  transform: scale(1.08);
  background: rgba(255, 255, 255, 0.86);
}

.favorite-button.active,
.tile-crown.active,
.tile-hide.active {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0.35rem 0.9rem rgba(20, 20, 20, 0.2), inset 0 0 0 0.12rem currentColor;
}

.tile-hide.active {
  color: var(--sage);
}

.tile-remove {
  color: var(--accent);
}

.tile-remove:hover {
  color: var(--accent-strong);
}

.tile-crown.active:hover,
.tile-hide.active:hover,
.favorite-button.active:hover {
  background: var(--panel);
}

.tile-download,
.download-button {
  border-radius: 6px;
  font-weight: 800;
  text-decoration: none;
}

.tile-download {
  position: absolute;
  left: 0.6rem;
  bottom: 0.6rem;
}

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.7rem;
  padding: 0.72rem 1rem;
}

.tile-download:hover,
.download-button:hover {
  color: var(--sage);
}

.tile-remove:hover,
.remove-button:hover {
  color: var(--accent-strong);
}

dialog {
  width: min(100vw, 1180px);
  max-width: none;
  height: min(100vh, 850px);
  max-height: none;
  padding: 0;
  border: 0;
  background: #10100f;
  color: #fff;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.82);
}

#lightboxImage {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4rem 1rem 5.5rem;
}

.close-button,
.lightbox-nav {
  position: absolute;
  z-index: 3;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

.close-button {
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
}

.lightbox-nav {
  top: 50%;
  width: 2.9rem;
  height: 2.9rem;
  transform: translateY(-50%);
  font-size: 2rem;
}

.previous {
  left: 1rem;
}

.next {
  right: 1rem;
}

dialog footer {
  position: absolute;
  inset: auto 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem clamp(1rem, 3vw, 2rem);
  background: linear-gradient(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.55));
}

.dialog-actions {
  display: flex;
  gap: 0.4rem;
}

.dialog-actions > button,
.dialog-actions > .download-button {
  height: 2.1rem;
  min-height: 2.1rem;
  padding: 0.45rem 0.7rem;
  border-radius: 5px;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.82rem;
  line-height: 1;
}

#lightboxFavorite {
  color: #fff;
  background: var(--accent);
}

#lightboxFavorite:hover {
  background: var(--accent-strong);
}

#lightboxRemove {
  color: #fff;
  background: rgba(179, 38, 30, 0.9);
}

#lightboxRemove:hover {
  background: #8b241a;
}

.success {
  min-height: 1.35rem;
  color: var(--sage);
  font-weight: 700;
}

.admin-page {
  min-height: 100vh;
  padding: 2rem;
  background: var(--paper);
}

.admin-panel {
  width: min(100%, 430px);
  margin: 10vh auto 0;
  padding: 2rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.admin-panel h1 {
  margin: 0.5rem 0 1.5rem;
  font-family: Georgia, serif;
  font-size: 1.9rem;
}

.admin-panel label {
  display: block;
  margin: 0 0 0.45rem;
  font-weight: 700;
}

.admin-panel input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.85rem 0.9rem;
  background: var(--paper);
}

.admin-content {
  max-width: 1200px;
  margin: 0 auto;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.admin-card {
  margin-bottom: 2rem;
  padding: 1.5rem clamp(1rem, 3vw, 2rem);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.admin-card h2 {
  margin: 0 0 1.25rem;
  font-family: Georgia, serif;
  font-size: 1.5rem;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 1.25rem;
}

.admin-form label {
  margin: 0.9rem 0 0.4rem;
  font-weight: 700;
}

.admin-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem 0.85rem;
  background: var(--paper);
}

.admin-form .access-row {
  grid-column: 1 / -1;
  grid-template-columns: auto;
  justify-content: start;
  margin-top: 1.25rem;
}

.admin-form .error,
.admin-form .success {
  grid-column: 1 / -1;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}

.admin-table th,
.admin-table td {
  padding: 0.6rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.admin-table input {
  width: 100%;
  min-width: 8rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  background: var(--paper);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-width: 15rem;
}

.row-action-button {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.32rem 0.55rem;
  color: var(--ink);
  background: var(--paper);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.row-action-button:hover {
  border-color: var(--sage);
  background: var(--panel);
}

.row-action-button.danger {
  border-color: transparent;
  color: #fff;
  background: rgba(179, 38, 30, 0.9);
}

.row-action-button.danger:hover {
  background: #8b241a;
}

.row-status {
  display: block;
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  font-weight: 700;
}

.row-status.error {
  color: #b3261e;
}

.row-status.success {
  color: var(--sage);
}

.folder-results {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.folder-result {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.folder-name {
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.4rem;
}

.folder-path-small,
.folder-id-small {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
  word-break: break-all;
}

.copy-path-button {
  display: inline-block;
  margin-top: 0.6rem;
  padding: 0.5rem 0.9rem;
  border-radius: 4px;
  color: #fff;
  background: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
}

.copy-path-button:hover {
  background: var(--accent-strong);
}