* {
  box-sizing: border-box;
}

:root {
  --bg: #1a1411;
  --panel: rgba(30, 22, 18, 0.9);
  --panel-strong: #241b16;
  --line: rgba(255, 232, 209, 0.14);
  --text: #f5efe7;
  --muted: #c6b3a0;
  --accent: #f28b42;
  --accent-2: #74b49b;
  --paper: #f7f0df;
  --shadow: rgba(0, 0, 0, 0.35);
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(242, 139, 66, 0.12), transparent 28%),
    radial-gradient(circle at bottom right, rgba(116, 180, 155, 0.1), transparent 24%),
    linear-gradient(160deg, #16100d, #221913 52%, #120d0b);
  color: var(--text);
  font-family: Inter, sans-serif;
}

body {
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1400px, calc(100vw - 24px));
  margin: 12px auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(43, 31, 25, 0.96), rgba(29, 21, 17, 0.92));
  box-shadow: 0 20px 50px var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-family: "Space Mono", monospace;
}

.topbar h1 {
  margin: 0;
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(2.2rem, 4vw, 4rem);
  line-height: 0.95;
  letter-spacing: 0.02em;
}

.topbar-copy {
  max-width: 34rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.5;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(380px, 0.8fr);
  gap: 16px;
  margin-top: 16px;
  min-height: calc(100vh - 132px);
}

.map-panel,
.side-panel,
.panel,
.post-form,
.closet-results {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 20px 50px var(--shadow);
}

.map-panel {
  overflow: hidden;
  min-height: 70vh;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 70vh;
}

.side-panel {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tab,
.submit-btn,
#closet-search {
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.tab {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-weight: 700;
}

.tab.is-active {
  background: linear-gradient(135deg, var(--accent), #e56b2f);
  color: #1c110d;
}

.panel {
  display: none;
  padding: 14px;
  overflow: hidden;
}

.panel.is-active {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  min-height: 0;
}

.post-form {
  padding: 14px;
  background: linear-gradient(180deg, rgba(44, 32, 26, 0.96), rgba(28, 20, 16, 0.92));
}

.post-form,
.closet-results {
  overflow: hidden;
}

.field-grid,
.coords-grid {
  display: grid;
  gap: 12px;
}

.field-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.coords-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 8px;
}

label span {
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 88px;
}

input::placeholder,
textarea::placeholder {
  color: rgba(245, 239, 231, 0.4);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(242, 139, 66, 0.7);
  box-shadow: 0 0 0 3px rgba(242, 139, 66, 0.16);
}

.submit-btn,
#closet-search {
  background: linear-gradient(135deg, var(--accent), #ffb26b);
  color: #1c110d;
  font-weight: 800;
}

.submit-btn:hover,
#closet-search:hover,
.tab:hover {
  transform: translateY(-1px);
}

.subscribe-form {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(41, 29, 24, 0.96), rgba(25, 18, 14, 0.92));
}

#subscribe-button {
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 800;
  color: #1c110d;
  background: linear-gradient(135deg, var(--accent-2), #9fd1bd);
}

#subscribe-status {
  margin: 0;
}

.map-actions {
  display: grid;
  gap: 8px;
}

#use-location-btn {
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 800;
  color: #1c110d;
  background: linear-gradient(135deg, #9fd1bd, #74b49b);
}

#use-location-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.feed-posts {
  display: grid;
  gap: 14px;
  overflow: auto;
  padding-right: 4px;
  max-height: 100%;
}

.post-card {
  background: var(--paper);
  color: #201811;
  border-radius: 18px;
  padding: 12px 12px 14px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
  transform: rotate(var(--rotation, 0deg));
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.tape {
  width: 88px;
  height: 22px;
  margin: -22px auto 8px;
  border-radius: 8px;
  background: rgba(242, 139, 66, 0.7);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.16);
}

.post-photo {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  background: #1b1410;
}

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

.flash-timestamp {
  position: absolute;
  right: 10px;
  bottom: 10px;
  font-family: "Space Mono", monospace;
  font-size: 0.82rem;
  color: #ff8b36;
  text-shadow: 0 0 6px rgba(255, 139, 54, 0.45);
}

.post-copy {
  padding-top: 12px;
}

.post-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
  margin-bottom: 8px;
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
}

.username {
  font-weight: 700;
}

.post-type {
  color: #7b5c46;
  text-transform: uppercase;
}

.caption {
  margin: 0 0 10px;
  font-size: 0.98rem;
  line-height: 1.45;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(36, 27, 22, 0.08);
  font-size: 0.8rem;
  font-weight: 700;
}

.badge.is-fit {
  background: rgba(116, 180, 155, 0.16);
}

.badge.is-local {
  background: rgba(242, 139, 66, 0.16);
}

.badge.is-swap {
  background: rgba(164, 121, 255, 0.14);
}

.location {
  margin-top: 10px;
  color: #6b5648;
  font-size: 0.85rem;
  font-family: "Space Mono", monospace;
}

.closet-tools {
  display: grid;
  gap: 10px;
}

.closet-results {
  flex: 1;
  min-height: 0;
  padding: 14px;
  background: rgba(255, 255, 255, 0.04);
  overflow: auto;
}

.placeholder {
  margin: 0;
  color: var(--muted);
}

.closet-summary h3 {
  margin: 0 0 6px;
  font-family: "Archivo Black", sans-serif;
}

.inventory-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.inventory-item {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #1e1713;
  color: #fff;
}

.leaflet-popup-content {
  margin: 12px 14px;
  font-family: Inter, sans-serif;
}

@media (max-width: 1000px) {
  .topbar,
  .layout {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar {
    align-items: start;
  }

  .layout {
    min-height: auto;
  }

  .map-panel,
  #map {
    min-height: 50vh;
  }

  .field-grid,
  .coords-grid,
  .inventory-list {
    grid-template-columns: 1fr;
  }
}
