:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-raised: #fefdfb;
  --border: #e8e4dc;
  --border-strong: #d4cfc4;
  --text: #1a1814;
  --text-muted: #6b6560;
  --text-subtle: #9a948c;
  --accent: #c45c26;
  --accent-hover: #a84d1f;
  --accent-soft: #fdf0e8;
  --accent-green: #2d6a4f;
  --accent-green-soft: #e8f5ef;
  --shadow-sm: 0 1px 2px rgba(26, 24, 20, 0.06);
  --shadow-md: 0 4px 16px rgba(26, 24, 20, 0.08);
  --shadow-lg: 0 12px 40px rgba(26, 24, 20, 0.12);
  --radius: 12px;
  --radius-lg: 20px;
  --font: 'DM Sans', system-ui, sans-serif;
  --font-display: 'Instrument Serif', Georgia, serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Header */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-inner {
  max-width: 100%;
  margin: 0 auto;
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-sm {
  padding: 0.4375rem 0.875rem;
  font-size: 0.8125rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}

.logo-mark {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.125rem;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 400;
}

/* Buttons */
.btn {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 0.5rem;
  padding: 0.525rem 1.125rem;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--border-strong);
}

.btn-danger {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.btn-danger:hover {
  background: #fee2e2;
}

.btn-lg {
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  width: 100%;
  justify-content: center;
}

/* Main */
.main {
  flex: 1;
  max-width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  width: 100%;
}

.view {
  display: none;
  animation: fadeIn 0.25s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hero */
.hero {
  margin-bottom: 2rem;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 400;
  line-height: 1.15;
  margin-bottom: 0.5rem;
}

.hero h1 em {
  font-style: italic;
  color: var(--accent);
}

.hero p {
  color: var(--text-muted);
  font-size: 1.0625rem;
  max-width: 520px;
}

.swtich em {
  font-style: italic;
  color: var(--accent);
}
.switch p {
  color: var(--text-muted);
  font-weight: 200;
  font-size: 1.625rem;
  max-width: 520px;
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.category-pill {
  padding: 0.4375rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.category-pill:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.category-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.select {
  padding: 0.5rem 2rem 0.5rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.875rem;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6560' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.625rem center;
  appearance: none;
  cursor: pointer;
}

.select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Listings Grid */
.listings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.listing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}

.listing-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.listing-card-image {
  aspect-ratio: 16 / 10;
  background: var(--bg);
  overflow: hidden;
  position: relative;
}

.listing-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.listing-card-image .placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: linear-gradient(135deg, var(--accent-soft), var(--accent-green-soft));
}

.listing-card-body {
  padding: 1rem 1.125rem 1.125rem;
}

.listing-card-category {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 0.375rem;
}

.listing-card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.listing-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.listing-card-price {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--accent-green);
}

.listing-card-location {
  font-size: 0.8125rem;
  color: var(--text-subtle);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.listing-card-date {
  font-size: 0.75rem;
  color: var(--text-subtle);
  margin-top: 0.5rem;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-state.hidden {
  display: none;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.hidden {
  display: none !important;
}

/* Back Link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: none;
  border: none;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 1.5rem;
  padding: 0;
  transition: color 0.15s;
}

.back-link:hover {
  color: var(--accent);
}

/* Detail View */
.detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

@media (max-width: 768px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

.detail-image {
  aspect-ratio: 4 / 3;
  background: var(--bg);
  overflow: hidden;
}

.detail-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-image .placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  background: linear-gradient(135deg, var(--accent-soft), var(--accent-green-soft));
}

.detail-info {
  padding: 2rem;
  display: flex;
  flex-direction: column;
}

.detail-category {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.detail-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

.detail-price {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent-green);
  margin-bottom: 1rem;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.detail-meta span {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.detail-description {
  flex: 1;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 1.5rem;
  white-space: pre-wrap;
}

.detail-contact {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.detail-contact h4 {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
  margin-bottom: 0.75rem;
}

.contact-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  margin-bottom: 0.375rem;
}

.contact-row:last-child {
  margin-bottom: 0;
}

.detail-actions {
  display: flex;
  gap: 0.75rem;
}

/* Form */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 640px;
  box-shadow: var(--shadow-md);
}

.form-card h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 400;
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  color: var(--text);
}

.optional {
  font-weight: 400;
  color: var(--text-subtle);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.9375rem;
  background: var(--surface-raised);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 540px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .header-inner {
    flex-wrap: wrap;
  }

  .search-bar {
    order: 3;
    max-width: 100%;
    width: 100%;
  }
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-subtle);
  background: var(--surface);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  transition: transform 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Auth Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 24, 20, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 1rem;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-subtle);
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

.modal-close:hover {
  color: var(--text);
}

.modal-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.modal-tab {
  flex: 1;
  padding: 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.modal-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.auth-form.hidden {
  display: none;
}

.form-error {
  color: #b91c1c;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.demo-hint {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-subtle);
  margin-top: 1rem;
}

/* Image Upload */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-area:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.upload-icon {
  font-size: 2rem;
}

.upload-hint {
  font-size: 0.75rem;
  color: var(--text-subtle);
}

.upload-preview {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius);
  object-fit: cover;
}

.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

.error-msg {
  text-align: center;
  color: #b91c1c;
  padding: 2rem;
}

@media (max-width: 540px) {
  .user-name {
    display: none;
  }

  .header-actions {
    gap: 0.375rem;
  }
}
