:root {
  --ink: #1a1a1a;
  --ink-soft: #5a5a5a;
  --paper: #ffffff;
  --bg: #f7f6f3;
  --border: #e3e0d9;
  --accent: #1f5c4d;
  --accent-soft: #e7f0ec;
  --danger: #b3261e;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  margin: 0;
  padding: 0;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

a {
  color: var(--accent);
}

h1,
h2 {
  line-height: 1.2;
}

/* --- Header / footer shell --- */

/* .site-header is a full-width band (background/border only); its actual
   content sits in .site-header-inner, constrained to the same max-width
   content column every other section uses (hero, footer, filter form).
   Without this, the brand/logo sits flush against the raw browser edge
   on a wide screen while everything below it is centered in a narrower
   column - it reads as "too far left" relative to the rest of the page. */
.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
}

.site-header .brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
  text-decoration: none;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.95rem;
}

.site-header nav a[href^="tel:"] {
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
}

/* Below this width, brand + nav squeezed onto one row started wrapping
   mid-word (a longer business name splitting across two lines, the phone
   number folding onto a third) - genuinely broken, not just tight. Give
   the brand its own row, full width, and let nav wrap cleanly beneath it
   instead of everything fighting for the same horizontal space. */
@media (max-width: 640px) {
  .site-header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }

  .site-header nav {
    width: 100%;
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }
}

.site-footer {
  color: var(--ink-soft);
  font-size: 0.9rem;
  padding: 3rem 1.5rem 2rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

.site-footer-grid {
  max-width: 72rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
}

.site-footer-grid p {
  margin: 0.2rem 0;
}

.site-footer-brand {
  color: var(--ink);
  font-weight: 700;
}

.site-footer a {
  color: var(--ink-soft);
}

.site-footer-copyright {
  max-width: 72rem;
  margin: 2rem auto 0;
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

.narrow {
  max-width: 40rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* --- Public: hero + listing grid --- */

.hero {
  max-width: 72rem;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 2rem;
  text-align: center;
}

.hero h1 {
  font-size: 3rem;
  margin: 0 0 0.6rem;
  letter-spacing: -0.01em;
}

.hero p {
  color: var(--ink-soft);
  margin: 0 auto;
  font-size: 1.1rem;
  max-width: 40rem;
}

.filter-form {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.5rem 1.5rem;
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.filter-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.filter-form input,
.filter-form select {
  font: inherit;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  width: 8rem;
}

.filter-form button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.6rem 1.1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.filter-clear {
  font-size: 0.85rem;
  align-self: center;
}

.empty-state a {
  font-weight: 600;
}

.empty-state {
  max-width: 72rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  color: var(--ink-soft);
}

.listing-grid {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.pagination {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
}

.page-link:hover {
  border-color: var(--accent);
}

.page-current {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}

.coming-soon-section {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.coming-soon-section h2 {
  font-size: 1.3rem;
  margin: 0 0 1rem;
}

.coming-soon-section .listing-grid {
  padding: 0;
  max-width: none;
}

.listing-card {
  display: block;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--ink);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.listing-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.listing-card-photo {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--accent-soft);
}

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

.listing-card-photo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.listing-card-photo-placeholder.large {
  aspect-ratio: 16 / 9;
}

.listing-card-body {
  padding: 1rem 1.1rem 1.2rem;
}

.listing-card-price {
  margin: 0 0 0.15rem;
  font-size: 1.25rem;
  font-weight: 700;
}

.listing-card-price span {
  font-weight: 400;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.listing-card-address {
  margin: 0;
  font-weight: 600;
}

.listing-card-location {
  margin: 0.15rem 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.listing-card-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  margin: 0.65rem 0 0;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.listing-card-spec {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.listing-card-spec svg {
  flex: none;
  color: var(--accent);
}

.listing-card-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem;
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s ease;
}

.listing-card:hover .listing-card-cta {
  background: color-mix(in srgb, var(--accent) 85%, black);
}

.status-badge {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--paper);
  color: var(--ink);
}

.listing-detail-header .status-badge,
.admin-table .status-badge {
  position: static;
  display: inline-block;
}

.status-available {
  background: #e3f3ea;
  color: #1f6d43;
}

.status-coming_soon {
  background: #e4eefc;
  color: #1d5fa8;
}

.status-pending {
  background: #fdf1dc;
  color: #96650b;
}

.status-occupied,
.status-unavailable {
  background: #f1eee9;
  color: var(--ink-soft);
}

/* --- Public: listing detail --- */

.listing-detail {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
}

.back-link {
  text-decoration: none;
  font-size: 0.9rem;
}

.gallery-empty {
  margin: 1rem 0 1.5rem;
  border-radius: var(--radius);
  overflow: hidden;
}

/* --- Gallery viewer: thumbnail rail + main photo --- */

.gallery-viewer {
  display: flex;
  flex-direction: column-reverse;
  gap: 0.6rem;
  margin: 1rem 0 1.5rem;
}

.gallery-thumbs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.gallery-thumb-list {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  overflow-x: auto;
  scroll-behavior: smooth;
  /* Hide the native scrollbar - the up/down (here, left/right) buttons
     are the intended way to move the rail. */
  scrollbar-width: none;
}
.gallery-thumb-list::-webkit-scrollbar {
  display: none;
}

.gallery-thumb {
  flex: 0 0 auto;
  width: 4.5rem;
  height: 3.4rem;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  background: none;
  cursor: pointer;
  opacity: 0.7;
}

.gallery-thumb.active {
  border-color: var(--accent);
  opacity: 1;
}

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

.gallery-thumb-nav {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
}

.gallery-main {
  display: block;
  position: relative;
  width: 100%;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
  background: var(--accent-soft);
}

.gallery-main img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.gallery-expand-hint {
  position: absolute;
  bottom: 0.6rem;
  right: 0.6rem;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
}

@media (min-width: 720px) {
  .gallery-viewer {
    flex-direction: row;
  }
  .gallery-thumbs {
    flex-direction: column;
    flex: 0 0 5.5rem;
  }
  .gallery-thumb-list {
    flex-direction: column;
    overflow-x: visible;
    overflow-y: auto;
  }
  .gallery-thumb {
    width: 100%;
    height: 4rem;
  }
  .gallery-main {
    flex: 1;
  }
}

/* --- Lightbox: full-screen zoom/pan viewer --- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

/* The [hidden] attribute is how gallery.js toggles this - without this
   rule, the plain ".lightbox" display below would win the cascade over
   the UA stylesheet's "[hidden] { display: none }" and the (invisible,
   fully transparent-looking) lightbox would still sit on top of the page
   intercepting every click even while "closed". */
.lightbox:not([hidden]) {
  display: flex;
}

body.lightbox-open {
  overflow: hidden;
}

.lightbox-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  /* Keeps a real, non-zero layout box (for the zoom/pan pointer math)
     even before the photo loads or if it fails to load. */
  min-width: min(90vw, 60vh);
  min-height: 60vh;
  object-fit: contain;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  border: none;
  cursor: pointer;
  border-radius: 50%;
}

.lightbox-close {
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.5rem;
  line-height: 1;
}

.lightbox-prev,
.lightbox-next {
  top: 50%;
  transform: translateY(-50%);
  width: 3rem;
  height: 3rem;
  font-size: 1.75rem;
}

.lightbox-prev {
  left: 1rem;
}

.lightbox-next {
  right: 1rem;
}

.listing-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
}

.listing-detail-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.6rem;
}

.listing-detail-location {
  margin: 0;
  color: var(--ink-soft);
}

.listing-detail-price {
  text-align: right;
}

.listing-detail-price p {
  margin: 0.4rem 0 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.listing-detail-price span {
  font-weight: 400;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.fact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.fact-grid dt {
  font-size: 0.8rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.fact-grid dd {
  margin: 0.2rem 0 0;
  font-weight: 600;
}

.listing-description h2 {
  font-size: 1.1rem;
}

.listing-description p {
  white-space: pre-wrap;
  color: var(--ink-soft);
}

/* --- Admin --- */

.admin-main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.admin-main.narrow {
  max-width: 40rem;
}

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

.admin-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toolbar-checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-right: 0.5rem;
}

body.hide-city-column .city-col {
  display: none;
}

.admin-section {
  margin-bottom: 2.5rem;
}

.admin-section h2 {
  font-size: 1.05rem;
  margin: 0 0 0.75rem;
}

.admin-section h2 .hint {
  font-weight: 400;
}

.button {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.button-secondary {
  background: var(--paper);
  color: var(--accent);
  border: 1px solid var(--border);
}

.link-button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}

.link-button.danger {
  color: var(--danger);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.admin-table th {
  background: var(--bg);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table-actions {
  display: flex;
  gap: 0.75rem;
  white-space: nowrap;
}

.drag-col {
  width: 2.5rem;
}

.thumb-col {
  width: 3.5rem;
}

.listing-thumb {
  width: 3rem;
  height: 3rem;
  border-radius: 6px;
  object-fit: cover;
  display: block;
  background: var(--bg);
}

.listing-thumb-empty {
  border: 1px dashed var(--border);
}

.drag-handle {
  cursor: grab;
  display: inline-block;
  font-size: 1.1rem;
  color: var(--ink-soft);
  /* Critical for touch: without this, iOS Safari treats a finger-drag on
     the handle as a page scroll instead of firing pointermove here. */
  touch-action: none;
  user-select: none;
}

#available-body tr.dragging {
  cursor: grabbing;
  background: var(--accent-soft);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

/* Prevent text selection anywhere on the page while a drag is in
   progress - fast pointer moves can otherwise select surrounding text. */
body.dragging-active {
  user-select: none;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  flex: 1;
}

.admin-form input,
.admin-form select,
.admin-form textarea {
  font: inherit;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--ink);
  background: var(--paper);
}

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-row label.short {
  flex: 0 1 140px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-form h2 {
  font-size: 1rem;
  margin: 0.5rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.color-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.color-input-row input[type="text"] {
  flex: 1;
}

.color-input-row input[type="color"] {
  padding: 0;
  width: 2.5rem;
  height: 2.2rem;
  border-radius: 6px;
}

#logo-preview {
  max-width: 200px;
  max-height: 80px;
  object-fit: contain;
  margin: -0.5rem 0 0;
}

.brand-logo {
  max-height: 2rem;
  vertical-align: middle;
}

.site-footer-secondary,
.site-footer-social {
  margin-top: 0.6rem;
  font-size: 0.85rem;
}

.site-footer-social a {
  display: inline-flex;
  margin-right: 0.75rem;
  color: var(--ink-soft);
}

.site-footer-social a:hover {
  color: var(--accent);
}

.form-actions button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

#photos-section {
  margin-top: 2rem;
}

.photo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.photo-item {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.photo-item.dragging {
  background: var(--accent-soft);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.photo-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 4px;
}

.photo-drag-handle {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  border-radius: 6px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.add-photo-form {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.add-photo-form label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.add-photo-form input {
  font: inherit;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.add-photo-form button {
  background: var(--ink);
  color: white;
  border: none;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  cursor: pointer;
}

.hint {
  color: var(--ink-soft);
  font-size: 0.85rem;
}
