:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --border: #e3e2df;
  --text: #1a1a18;
  --text-muted: #6b6a66;
  --overlay: rgba(0, 0, 0, 0.85);
  --tile-size: 210px;
}

@media (min-width: 900px) {
  :root {
    --tile-size: 270px;
  }
}

:root[data-theme="dark"] {
  --bg: #171715;
  --surface: #221f1f;
  --border: #3a3836;
  --text: #f2f1ee;
  --text-muted: #a6a49f;
  --overlay: rgba(0, 0, 0, 0.92);
}

* {
  box-sizing: border-box;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

body {
  margin: 0;
  overscroll-behavior-x: none;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.topbar__heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar__count {
  font-size: 14px;
  color: var(--text-muted);
}

.topbar__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  transition: background-color 0.2s ease;
}

body.site-mode-travel .topbar__actions {
  background: #dceefc;
}

body.site-mode-photo .topbar__actions {
  background: #ead9fb;
}

:root[data-theme="dark"] body.site-mode-travel .topbar__actions {
  background: rgba(55, 138, 218, 0.16);
}

:root[data-theme="dark"] body.site-mode-photo .topbar__actions {
  background: rgba(155, 77, 224, 0.18);
}

.site-mode-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.site-mode-badge:hover {
  opacity: 0.85;
}

.site-mode-badge[hidden] {
  display: none;
}

.site-mode-badge--travel {
  background: #378ada;
  color: #fff;
}

.site-mode-badge--photo {
  background: #9b4de0;
  color: #fff;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover {
  border-color: var(--text-muted);
}

.icon-btn[hidden] {
  display: none;
}

@media (max-width: 480px) {
  .topbar {
    padding: 12px 16px;
  }

  .topbar__actions {
    gap: 6px;
    padding: 6px 8px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
  }

  .icon-btn svg {
    width: 18px;
    height: 18px;
  }
}

.icon-btn--danger {
  color: #b3261e;
  border-color: #b3261e;
}

.icon-btn--danger:hover {
  background: #b3261e;
  color: #fff;
}

.dropzone {
  margin: 16px 24px 0;
  padding: 24px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  text-align: center;
}

.dropzone--active {
  border-color: var(--text-muted);
  background: var(--surface);
}

.dropzone__text {
  margin: 0 0 12px;
  color: var(--text-muted);
}

.dropzone__actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.dropzone__status {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--text-muted);
  min-height: 20px;
}

.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}

.btn:hover {
  border-color: var(--text-muted);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--danger:disabled:hover {
  background: none;
  color: #b3261e;
}

.btn--danger {
  color: #b3261e;
  border-color: #b3261e;
}

.btn--danger:hover {
  background: #b3261e;
  color: #fff;
}

.btn--primary {
  background: #378ada;
  border-color: #378ada;
  color: #fff;
}

.btn--primary:hover {
  background: #2c6fb0;
  border-color: #2c6fb0;
}

.icon-btn--active {
  border-color: #378ada;
  color: #378ada;
}

.icon-btn--admin-on {
  background: #c62828;
  border-color: #c62828;
  color: #fff;
}

.icon-btn--admin-hint {
  background: #f3b0ab;
  border-color: #f3b0ab;
  color: #5c1a1a;
}

.icon-btn--admin-authenticated {
  background: #f3b0ab;
  border-color: #f3b0ab;
  color: #5c1a1a;
}

.form-error {
  font-size: 13px;
  color: #c62828;
  margin: 8px 0 0;
}

.form-error[hidden] {
  display: none;
}

.form-status--ok {
  color: #2e7d32;
}

#admin-pin-input {
  width: 100%;
  margin-top: 4px;
  letter-spacing: 4px;
  font-size: 18px;
  text-align: center;
}

.admin-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 24px 0;
}

.admin-tools[hidden] {
  display: none;
}

.filter-wrap {
  position: relative;
}

.filter-panel {
  position: absolute;
  top: 44px;
  right: 0;
  min-width: 220px;
  max-width: 280px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 50;
}

.filter-panel[hidden] {
  display: none;
}

.filter-panel__empty {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.filter-panel .btn {
  width: 100%;
  margin-top: 8px;
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.country-picker-list {
  max-height: 320px;
  overflow-y: auto;
  margin-top: 12px;
}

.incoming-photos-progress {
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  margin: 8px 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.incoming-photos-progress[hidden] {
  display: none;
}

.incoming-photos-progress li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.incoming-photos-progress li:last-child {
  border-bottom: none;
}

.incoming-photos-progress__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.incoming-photos-progress__status {
  flex-shrink: 0;
  color: var(--text-muted);
}

.incoming-photos-progress li.incoming-photos-progress--ok .incoming-photos-progress__status {
  color: #2e7d32;
}

.incoming-photos-progress li.incoming-photos-progress--fail .incoming-photos-progress__status {
  color: #c62828;
}

.tag-chip {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}

.tag-chip:hover {
  border-color: var(--text-muted);
}

.tag-chip--active {
  background: #378ada;
  border-color: #378ada;
  color: #fff;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay);
  padding: 16px;
  z-index: 200;
}

.modal[hidden] {
  display: none;
}

.modal__panel {
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
  border-radius: 12px;
  background: var(--surface);
}

.modal__title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
}

.modal__row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.tag-manager-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tag-manager-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.events-panel {
  min-width: 260px;
  max-width: 320px;
}

.tile-size-panel {
  min-width: 180px;
}

.platform-config-panel {
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.platform-config-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.platform-config-option--disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.platform-config-mode {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.platform-config-separator {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--border);
  margin: 0;
}

.platform-config-danger {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.platform-config-danger__title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #b3261e;
}

.platform-config-danger .btn--danger {
  width: 100%;
}

.tile-size-slider {
  width: 100%;
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.events-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 320px;
  overflow-y: auto;
}

.events-list[hidden] {
  display: none;
}

.event-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.event-row__checkbox {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
}

.event-row__select {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
}

.event-row__select:hover {
  border-color: var(--text-muted);
}

.event-row__select--active {
  background: #378ada;
  border-color: #378ada;
  color: #fff;
}

.event-row__name {
  display: block;
  font-weight: 600;
}

.event-row__dates {
  display: block;
  font-size: 12px;
  opacity: 0.8;
}

.events-panel .btn {
  width: 100%;
  margin-top: 8px;
}

.events-bulk-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.events-bulk-actions[hidden] {
  display: none;
}

.events-bulk-actions .btn {
  flex: 1;
  width: auto;
  margin-top: 0;
  font-size: 12px;
  padding: 8px 6px;
}

.events-bulk-actions .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
}

.form-field:first-of-type {
  margin-top: 0;
}

.form-field label,
.form-field__label {
  font-size: 13px;
  color: var(--text-muted);
}

.form-field textarea.input {
  resize: vertical;
  font-family: inherit;
}

.radio-row {
  display: flex;
  gap: 16px;
  font-size: 13px;
  margin-bottom: 4px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  margin-top: 12px;
}

.radio-row label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text);
}

.bulk-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 24px 0;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.bulk-actions[hidden] {
  display: none;
}

.bulk-actions__count {
  font-size: 14px;
  color: var(--text-muted);
  margin-right: auto;
}

.active-filters-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 24px 0;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.active-filters-bar[hidden] {
  display: none;
}

.active-filters-bar__label {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.active-filters-bar .tag-chips {
  flex: 1;
}

#active-filters-reset {
  margin-left: auto;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-size), 1fr));
  gap: 8px;
  padding: 16px 24px 32px;
}

.tile {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
}

@media (min-width: 360px) {
  .tile--hero {
    grid-column: span 2;
    grid-row: span 2;
  }
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tile__delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  background: rgba(0, 0, 0, 0.55);
  border-color: transparent;
  color: #fff;
}

.tile--selected {
  outline: 3px solid #378ada;
  outline-offset: -3px;
}

.tile__select {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  margin: 0;
  cursor: pointer;
}

.lightbox__delete {
  position: absolute;
  top: 16px;
  right: 64px;
  background: rgba(0, 0, 0, 0.45);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.lightbox__delete:hover {
  background: rgba(0, 0, 0, 0.65);
  border-color: rgba(255, 255, 255, 0.5);
}

.lightbox {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay);
  z-index: 100;
}

.lightbox[hidden] {
  display: none;
}

.lightbox__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 85vw;
  max-height: 85vh;
}

.lightbox__meta-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 28px;
}

.lightbox__meta-btn {
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
  cursor: pointer;
}

.lightbox__meta-btn:hover {
  background: rgba(0, 0, 0, 0.65);
  border-color: rgba(255, 255, 255, 0.5);
}

.lightbox__meta-btn[hidden] {
  display: none;
}

.lightbox__meta-btn--event {
  margin-left: auto;
}

.lightbox__meta-btn--country {
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lightbox__image {
  max-width: 85vw;
  max-height: 65vh;
  border-radius: 4px;
  display: block;
}

.lightbox__tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 85vw;
}

.lightbox__tag {
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

.lightbox__tag:hover {
  background: rgba(0, 0, 0, 0.65);
  border-color: rgba(255, 255, 255, 0.5);
}

.lightbox__close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.45);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.lightbox__close:hover {
  background: rgba(0, 0, 0, 0.65);
  border-color: rgba(255, 255, 255, 0.5);
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  background: rgba(0, 0, 0, 0.45);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.lightbox__nav:hover {
  background: rgba(0, 0, 0, 0.65);
  border-color: rgba(255, 255, 255, 0.5);
}

.lightbox__nav--prev {
  left: 16px;
}

.lightbox__nav--next {
  right: 16px;
}

.map-view[hidden] {
  display: none;
}

.map-view {
  padding: 16px 24px 8px;
}

.country-highlight {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 24px 0;
}

.country-highlight[hidden] {
  display: none;
}

.country-highlight__svg {
  width: 100%;
  max-width: 180px;
  height: 130px;
  display: block;
}

.country-highlight__path {
  fill: #c62828;
  stroke: var(--bg);
  stroke-width: 0.5;
}

.country-highlight__label {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.world-map {
  max-width: 1100px;
  margin: 0 auto;
}

.world-map svg {
  width: 100%;
  height: auto;
  display: block;
}

.world-map__country {
  fill: var(--border);
  stroke: var(--bg);
  stroke-width: 0.5;
}

.world-map__country--active {
  fill: #378ada;
  cursor: pointer;
}

.map-country-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 16px 24px 0;
}

.map-country-list[hidden] {
  display: none;
}

.map-country-chip {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  opacity: 0.6;
  cursor: pointer;
  font-size: 13px;
}

.map-country-chip:hover {
  border-color: var(--text-muted);
  color: var(--text);
  opacity: 1;
}

.map-country-chip--active {
  background: #378ada;
  border-color: #378ada;
  color: #fff;
  opacity: 1;
}

.world-map__country--active:hover {
  fill: #2a6fb0;
}

.world-map__country--selected {
  fill: #c62828;
}
