:root {
  --bg: #0f1419;
  --surface: #1a222c;
  --border: #2c3642;
  --text: #e8edf2;
  --muted: #8b9aab;
  --accent: #c9a227;
  --accent-dim: #8f7520;
  --danger: #c44c4c;
  --font-body: Helvetica, Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-body);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(201, 162, 39, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(44, 54, 66, 0.5), transparent);
  pointer-events: none;
  z-index: -1;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(26, 34, 44, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header h1 {
  margin: 0;
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}

.site-header .site-title-link {
  color: inherit;
  text-decoration: none;
}

.site-header .site-title-link:hover {
  color: var(--accent);
}

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

.site-header nav a {
  font-size: 0.9rem;
  color: var(--muted);
}

.site-header nav a:hover {
  color: var(--accent);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.page-title {
  font-size: 1.75rem;
  margin: 0 0 0.5rem;
}

.page-lead {
  color: var(--muted);
  margin: 0 0 1.75rem;
  max-width: 42rem;
}

.car-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.car-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  text-decoration: none;
  color: inherit;
}

.car-card:hover,
.car-card:focus-visible {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
  outline: none;
}

.car-card:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

.car-card-image-wrap {
  aspect-ratio: 4 / 3;
  background: var(--border);
  overflow: hidden;
}

.car-card-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.car-card-image-wrap .placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1rem;
  text-align: center;
}

.car-card-body {
  padding: 1rem;
}

.car-card-body h2 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.car-card-body .meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.breadcrumb {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

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

.breadcrumb a:hover {
  color: var(--accent);
}

.detail-hero {
  margin-bottom: 1.5rem;
}

.detail-hero img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.detail-notes {
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.gallery a {
  display: block;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}

.gallery a:hover {
  border-color: var(--accent-dim);
}

.gallery img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  vertical-align: middle;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.message {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.message.error {
  background: rgba(196, 76, 76, 0.15);
  border: 1px solid rgba(196, 76, 76, 0.4);
  color: #f0a8a8;
}

.message.success {
  background: rgba(80, 160, 120, 0.15);
  border: 1px solid rgba(80, 160, 120, 0.35);
  color: #9dd4b8;
}

.form-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  max-width: 520px;
  margin-bottom: 1.5rem;
}

.form-panel h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

/* Wider panel so admin photo rows are not squeezed below thumbnail size */
.form-panel--photos {
  max-width: min(960px, 100%);
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.field textarea {
  min-height: 4rem;
  resize: vertical;
}

.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--accent-dim);
  background: var(--accent);
  color: var(--bg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  filter: brightness(1.05);
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border-color: var(--border);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(196, 76, 76, 0.5);
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
}

.admin-photo-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.admin-photo-row.is-dragging {
  opacity: 0.45;
}

.admin-photo-row.drag-over-before {
  box-shadow: inset 0 3px 0 0 var(--accent);
}

.admin-photo-row.drag-over-after {
  box-shadow: inset 0 -3px 0 0 var(--accent);
}

.photo-drag-handle {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 2px;
  padding: 0.35rem 0.25rem;
  cursor: grab;
  color: var(--muted);
  user-select: none;
  touch-action: none;
}

.photo-drag-handle:active {
  cursor: grabbing;
}

.photo-drag-handle .grip-col {
  font-size: 0.65rem;
  line-height: 0.55;
  letter-spacing: 0;
}

.admin-photo-batch {
  margin-bottom: 0.75rem;
}

.admin-photo-batch-actions {
  flex-wrap: wrap;
  margin-bottom: 0;
}

.admin-photo-row .photo-select-cell {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.admin-photo-row .photo-select-cell label {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
  cursor: pointer;
  user-select: none;
}

.admin-photo-row .photo-select-cell input {
  margin: 0;
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.admin-photo-row .anchor-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}

.admin-photo-row .anchor-pick label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  margin: 0;
  text-align: center;
  max-width: 4rem;
  line-height: 1.2;
}

.admin-photo-row .anchor-pick input {
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

.admin-photo-row img {
  width: 162px;
  height: 122px;
  flex-shrink: 0;
  min-width: 162px;
  object-fit: cover;
  border-radius: 4px;
}

.admin-photo-row span {
  flex: 1;
  font-size: 0.85rem;
  color: var(--muted);
  word-break: break-all;
}

.status-text {
  font-size: 0.85rem;
  color: var(--muted);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.25rem;
}

@media (max-width: 640px) {
  main {
    padding: 1rem;
  }

  .form-panel {
    max-width: 100%;
    padding: 1rem;
  }

  .admin-photo-row {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.5rem 0.65rem;
    padding: 0.75rem 0;
  }

  .admin-photo-row .anchor-pick {
    flex-direction: row;
    align-items: center;
    gap: 0.35rem;
  }

  .admin-photo-row .anchor-pick label {
    max-width: none;
    text-align: left;
  }

  .admin-photo-row img {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    aspect-ratio: 4 / 3;
    flex: 1 1 100%;
  }

  .admin-photo-row span {
    flex: 1 1 100%;
    min-width: 0;
  }

  .admin-photo-row > .btn-danger {
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
}

.photo-viewer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 1rem 0 2rem;
  min-height: min(75vh, 720px);
}

.photo-viewer-arrow {
  flex-shrink: 0;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  line-height: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color 0.15s, background 0.15s;
}

.photo-viewer-arrow-icon {
  width: 2rem;
  height: 2rem;
  display: block;
}

.photo-viewer-arrow:hover:not(:disabled) {
  border-color: var(--accent-dim);
  background: rgba(201, 162, 39, 0.12);
}

.photo-viewer-arrow:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.photo-viewer-frame {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  max-width: calc(100% - 7rem);
}

.photo-viewer-frame img {
  max-width: 100%;
  max-height: min(70vh, 680px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.photo-viewer-counter {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

@media (max-width: 540px) {
  .photo-viewer {
    flex-wrap: wrap;
    min-height: auto;
  }

  .photo-viewer-arrow {
    width: 3rem;
    height: 3rem;
  }

  .photo-viewer-arrow-icon {
    width: 1.65rem;
    height: 1.65rem;
  }

  .photo-viewer-frame {
    order: -1;
    flex-basis: 100%;
    max-width: 100%;
  }
}
