/* ========== Variables ========== */
:root {
  --bg: #0a0f1a;
  --bg-alt: #101830;
  --surface: #141d33;
  --border: #223154;
  --text: #f2f1df;
  --text-dim: #cac9b3;
  --text-muted: #8b96ab;
  --accent: #7289a6;
  --accent-hover: #8fa3c2;
  --brand-navy: #022873;
  --brand-navy-alt: #023373;
  --success: #3ecf8e;
  --radius: 6px;
  --max-width: 1180px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Anton', var(--font);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main { flex: 1; }

a { color: inherit; text-decoration: none; }

img { max-width: 100%; display: block; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: .3px;
  text-transform: uppercase;
  margin: 0 0 .5em;
}

p { margin: 0 0 1em; color: var(--text-muted); }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ========== Header / Nav ========== */
.site-header {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 84px;
}

.logo {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text);
}
.logo-img { height: 52px; width: auto; display: block; }

.main-nav > ul {
  list-style: none;
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.main-nav > ul > li { position: relative; }

.main-nav a {
  display: block;
  padding: 12px 14px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: .85rem;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-radius: var(--radius);
  transition: color .15s, background .15s;
}

.main-nav > ul > li > a:hover,
.main-nav > ul > li.active > a {
  color: var(--text);
  background: var(--surface);
}

.has-dropdown .dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  list-style: none;
  margin: 6px 0 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 12px 28px rgba(0,0,0,.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity .15s, transform .15s, visibility .15s;
}

.has-dropdown:hover .dropdown,
.has-dropdown:focus-within .dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown a { padding: 10px 12px; border-radius: 4px; font-size: .8rem; }
.dropdown a:hover { background: var(--bg-alt); color: var(--text); }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}
.nav-toggle span {
  width: 22px;
  height: 2px;
  background: var(--text);
  display: block;
}

/* ========== Buttons ========== */
.btn {
  display: inline-block;
  padding: 12px 22px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--brand-navy);
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: .5px;
  text-transform: uppercase;
  font-size: .9rem;
  border: none;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--accent-hover); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--accent); background: var(--surface); }
.btn-sm { padding: 8px 14px; font-size: .78rem; }
.btn-danger { background: #c0392b; color: #fff; }
.btn-danger:hover { background: #e74c3c; }

/* ========== Hero ========== */
.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--brand-navy) 0%, var(--bg) 75%);
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid var(--border);
  padding: 380px 0;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero .container { width: 100%; }
.hero-video {
  position: absolute;
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  transform: translate(-50%, -50%);
  object-fit: cover;
  z-index: 0;
}
.hero-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(135deg, rgba(2,40,115,.2) 0%, rgba(10,15,26,.3) 75%);
}
@media (prefers-reduced-motion: reduce) {
  .hero-video { display: none; }
}

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .6s ease, transform .6s ease;
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}
.hero .container { position: relative; z-index: 3; width: 100%; }
.hero-kicker {
  font-family: var(--font-display);
  font-size: .85rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text);
  margin: 0 0 24px;
}
.hero-kicker-jp {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  letter-spacing: 1px;
}
.hero h1 {
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  letter-spacing: .5px;
  margin-bottom: .3em;
}
.hero p { font-size: 1.15rem; max-width: 560px; margin: 0 auto 1.5em; }
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.page-header {
  padding: 56px 0 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}

section { padding: 64px 0; }
section.alt { background: var(--bg-alt); }

.section-head { text-align: center; margin-bottom: 40px; }

/* ========== Cards / Grid ========== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: box-shadow .15s, transform .15s;
}
.card:hover { box-shadow: 0 12px 28px rgba(0,0,0,.4); transform: translateY(-2px); }
.card > a { display: block; }

.card-media {
  position: relative;
  aspect-ratio: 4/3;
  background: var(--bg-alt);
  overflow: hidden;
}
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-media-badge { position: absolute; top: 10px; left: 10px; z-index: 1; }
.card-media.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: .85rem;
}

.card-body { padding: 18px; flex: 1; display: flex; flex-direction: column; }
.card-body h3 { font-size: 1.15rem; margin-bottom: 4px; }
.card-meta { font-size: .85rem; color: var(--text-muted); margin-bottom: 12px; }
.card-price { font-family: var(--font-display); font-size: 1.3rem; font-weight: 400; color: var(--text); margin-bottom: 14px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tag {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--text-muted);
}
.tag.sold { background: var(--brand-navy); border-color: var(--brand-navy); color: var(--text); }
.tag.coming-soon { background: #e6b43c; border-color: #e6b43c; color: var(--bg); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

/* ========== Forms ========== */
.form-grid { display: grid; gap: 18px; max-width: 640px; }
.form-row { display: grid; gap: 6px; }
.form-row.two-col { grid-template-columns: 1fr 1fr; gap: 18px; }
label { font-size: .85rem; font-weight: 600; color: var(--text-muted); }
input, textarea, select {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .95rem;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 120px; }

.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: .9rem;
}
.alert-success { background: rgba(62,207,142,.12); border: 1px solid var(--success); color: var(--success); }
.alert-error { background: rgba(224,67,43,.12); border: 1px solid #e0432b; color: #ff8a75; }

/* ========== Detail page ========== */
.car-detail { display: grid; grid-template-columns: 1.3fr 1fr; gap: 48px; }
.car-gallery-main {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 10px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 560px;
}
.car-gallery-main img { width: 100%; height: auto; max-height: 560px; object-fit: contain; display: block; }
.gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(10,15,26,.6);
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.gallery-arrow:hover { background: var(--accent); color: var(--brand-navy); }
.gallery-arrow-prev { left: 12px; }
.gallery-arrow-next { right: 12px; }

/* True masonry: columns flow naturally so each photo keeps its own aspect
   ratio (no cropping), rather than being forced into a fixed grid cell. */
.gallery-collage {
  column-count: 3;
  column-gap: 12px;
}
.collage-item {
  break-inside: avoid;
  margin-bottom: 12px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  cursor: zoom-in;
}
.collage-item img { width: 100%; height: auto; display: block; }

.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(10,15,26,.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  cursor: zoom-out;
}
.lightbox-overlay img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius);
  cursor: default;
}
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.1);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-close:hover { background: var(--accent); color: var(--brand-navy); }

.calculator-wrap { position: relative; max-width: 520px; margin: 0 auto; }
.calculator { position: relative; }
.calc-rate-badge {
  position: absolute;
  top: 0;
  left: 100%;
  margin-left: 20px;
  width: 170px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.calc-rate-eyebrow {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-size: .72rem;
  color: var(--text);
  margin-bottom: 8px;
}
.calc-rate-value { font-size: 1.15rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.calc-rate-status { font-size: .72rem; color: var(--text-muted); }

@media (max-width: 900px) {
  .calc-rate-badge {
    position: static;
    width: auto;
    margin: 0 0 20px;
  }
}
.calc-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.calc-table td { padding: 12px 18px; border-bottom: 1px solid var(--border); font-size: .92rem; color: var(--text-dim); }
.calc-table tr:last-child td { border-bottom: none; }
.calc-table .calc-value { text-align: right; color: var(--text); font-weight: 600; }
.calc-table .calc-total td { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .5px; color: var(--text); font-size: 1rem; background: var(--bg-alt); }
.calc-table .calc-total .calc-value { color: var(--text); font-size: 1.2rem; }
.calc-footnotes { list-style: none; padding: 0; margin: 20px 0 0; font-size: .78rem; color: var(--text-muted); }
.calc-footnotes li { margin-bottom: 4px; }
.car-gallery-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.car-gallery-thumbs img { width: 76px; height: 56px; object-fit: cover; border-radius: 4px; cursor: pointer; border: 2px solid transparent; }
.car-gallery-thumbs img.active { border-color: var(--accent); }
.spec-list { list-style: none; padding: 0; margin: 0 0 24px; }
.spec-list li {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: .92rem;
}
.spec-list li span:first-child { color: var(--text-muted); }

/* ========== Footer ========== */
.site-footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  margin-top: 60px;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
.footer-brand p { margin: 4px 0 0; font-size: .85rem; }
.footer-nav { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-nav a { color: var(--text-muted); font-size: .9rem; }
.footer-nav a:hover { color: var(--text); }
.footer-copy { width: 100%; font-size: .78rem; color: var(--text-muted); margin: 0; text-align: center; }

/* ========== Admin ========== */
.admin-shell { display: flex; min-height: calc(100vh - 0px); }
.admin-sidebar {
  width: 220px;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  flex-shrink: 0;
}
.admin-sidebar .logo { display: block; padding: 0 20px 20px; }
.admin-sidebar nav a {
  display: block;
  padding: 12px 20px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: .9rem;
}
.admin-sidebar nav a:hover, .admin-sidebar nav a.active { color: var(--text); background: var(--surface); }
.admin-main { flex: 1; padding: 32px 40px; max-width: 1100px; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 18px; margin-bottom: 32px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card .num { font-family: var(--font-display); font-size: 2.1rem; font-weight: 400; }
.stat-card .label { color: var(--text-muted); font-size: .85rem; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: .9rem; }
th { color: var(--text-muted); text-transform: uppercase; font-size: .72rem; letter-spacing: .5px; }
th a { color: var(--text-muted); }
th a:hover, th a.active-sort { color: var(--text); }
th a .sort-arrow { font-size: .65rem; color: var(--accent); }
tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 8px; }

.status-pill { padding: 4px 10px; border-radius: 20px; font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.status-pill.available { background: rgba(62,207,142,.15); color: var(--success); }
.status-pill.sold { background: rgba(114,137,166,.18); color: var(--accent); }
.status-pill.coming_soon { background: rgba(230,180,60,.18); color: #e6b43c; }
.status-pill.new { background: rgba(62,207,142,.15); color: var(--success); }
.status-pill.read { background: var(--bg-alt); color: var(--text-muted); }
.status-pill.replied { background: rgba(90,120,255,.15); color: #7d95ff; }

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
}
.login-box .logo { display: block; text-align: center; margin-bottom: 24px; font-size: 1.6rem; }

.photo-upload-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-top: 10px; }
.photo-upload-grid .existing-photo {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
}
.photo-upload-grid[data-reorder] .existing-photo { cursor: grab; }
.photo-upload-grid[data-reorder] .existing-photo.dragging { opacity: .4; }
.photo-upload-grid[data-reorder] .existing-photo img { -webkit-user-drag: none; user-drag: none; }
.photo-upload-grid .existing-photo img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.photo-upload-grid .existing-photo .cover-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.photo-upload-grid .existing-photo .remove-photo {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,.7);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}
.photo-upload-grid .existing-photo .remove-photo:hover { background: var(--accent); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.photo-upload-grid .existing-photo label {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 5px 8px;
  font-size: .72rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.photo-upload-grid .existing-photo label.cover-radio { border-top: none; }
.photo-upload-grid .existing-photo label input { width: auto; }

/* ========== Responsive ========== */
@media (max-width: 860px) {
  .car-detail { grid-template-columns: 1fr; }
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; padding: 12px 0; }
  .admin-sidebar nav { display: flex; overflow-x: auto; }
  .admin-main { padding: 24px; }
}

@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .main-nav {
    position: absolute;
    top: 84px;
    left: 0;
    right: 0;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    display: none;
  }
  .main-nav.open { display: block; }
  .main-nav > ul { flex-direction: column; padding: 12px; gap: 2px; }
  .has-dropdown .dropdown {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    display: none;
    border: none;
    background: var(--bg);
    margin: 0 0 0 12px;
  }
  .has-dropdown.open .dropdown { display: block; }
  .form-row.two-col { grid-template-columns: 1fr; }
  .gallery-collage { column-count: 2; }
}
