:root {
  color-scheme: light;
  --ink: #222321;
  --muted: #6d716b;
  --line: #d7d8d0;
  --paper: #f7f4ec;
  --panel: #fffdf8;
  --green: #236c5f;
  --blue: #265f8e;
  --rose: #a94354;
  --gold: #b07c2a;
  --lavender: #6f6088;
  --shadow: 0 18px 60px rgba(29, 33, 30, 0.18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
}

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

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  min-height: 100vh;
}

.map-stage {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background: #d9e2dc;
}

.topbar {
  position: absolute;
  z-index: 20;
  top: 24px;
  left: 28px;
  right: 28px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.kicker,
.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 42px;
  line-height: 1.02;
  font-weight: 760;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(34, 35, 33, 0.14);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.82);
  box-shadow: 0 8px 24px rgba(35, 41, 36, 0.1);
  backdrop-filter: blur(14px);
  font-size: 20px;
  line-height: 1;
}

.map-canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #d9e2dc;
}

.leaflet-control-attribution {
  font-size: 11px;
}

.leaflet-popup-content {
  margin: 10px 12px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.map-fallback {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.hint-chip {
  position: absolute;
  left: 28px;
  bottom: 24px;
  z-index: 20;
  max-width: min(360px, calc(100% - 56px));
  padding: 12px 14px;
  border: 1px solid rgba(34, 35, 33, 0.14);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.76);
  box-shadow: 0 12px 36px rgba(35, 41, 36, 0.1);
  backdrop-filter: blur(14px);
  font-size: 13px;
}

.panel {
  z-index: 30;
  display: flex;
  flex-direction: column;
  max-height: 100vh;
  border-left: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.95);
  box-shadow: var(--shadow);
}

.panel-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 48px;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  font-weight: 650;
}

.tab:last-child {
  border-right: 0;
}

.tab.active {
  color: var(--ink);
  background: #f0ede4;
}

.tab-panel {
  display: none;
  min-height: 0;
  overflow: auto;
  padding: 24px;
}

.tab-panel.active {
  display: block;
}

.panel-heading h2 {
  margin: 0 0 18px;
  font-size: 24px;
  line-height: 1.22;
}

.filters,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.secondary-btn,
.primary-btn {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 13px;
  color: var(--ink);
  background: #fffaf1;
  font-size: 14px;
  font-weight: 650;
}

.secondary-btn.active {
  color: white;
  border-color: var(--green);
  background: var(--green);
}

.secondary-btn.danger {
  color: var(--rose);
}

.delete-btn {
  min-height: 36px;
  margin-top: 10px;
  border-radius: 6px;
  border: 1px solid var(--rose);
  padding: 0 12px;
  color: var(--rose);
  background: rgba(169, 67, 84, 0.08);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.delete-btn:hover {
  background: rgba(169, 67, 84, 0.15);
}

.admin-box {
  display: grid;
  gap: 12px;
}

.admin-post-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 15px;
  display: grid;
  gap: 10px;
}

.admin-post-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 1.25;
}

.post-body {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
  margin: 0;
}

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

.approve-btn {
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid #236c5f;
  padding: 0 12px;
  color: #236c5f;
  background: rgba(35, 108, 95, 0.08);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.approve-btn:hover {
  background: rgba(35, 108, 95, 0.15);
}

.reject-btn {
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid #6d716b;
  padding: 0 12px;
  color: #6d716b;
  background: rgba(109, 113, 107, 0.08);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.reject-btn:hover {
  background: rgba(109, 113, 107, 0.15);
}

.primary-btn {
  width: 100%;
  min-height: 46px;
  color: white;
  border-color: var(--green);
  background: var(--green);
}

.story-list,
.mine-list,
.stack {
  display: grid;
  gap: 12px;
}

.story-card,
.mine-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.story-card.selected {
  border-color: rgba(38, 95, 142, 0.45);
  box-shadow: 0 0 0 2px rgba(38, 95, 142, 0.12);
}

.story-card.expanded {
  background: #fff7e8;
  box-shadow: 0 10px 22px rgba(38, 95, 142, 0.1);
}

.story-card.expanded .story-button {
  padding-bottom: 10px;
}

.story-card.expanded .story-button p {
  display: none;
}

.story-expanded {
  display: grid;
  gap: 12px;
  padding: 0 16px 16px;
}

.story-expanded p {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.72;
  white-space: pre-wrap;
}

.story-expanded dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding-top: 2px;
}

.story-expanded dl div {
  min-width: 0;
  padding-top: 10px;
  border-top: 1px solid rgba(38, 95, 142, 0.16);
}

.story-expanded dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.story-expanded dd {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.story-button {
  width: 100%;
  border: 0;
  padding: 16px;
  text-align: left;
  background: transparent;
}

.story-button strong,
.mine-card h3 {
  display: block;
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 1.25;
}

.story-button p,
.mine-body,
.about-copy p,
.microcopy {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.story-topline {
  display: block;
  margin-bottom: 8px;
  color: var(--blue);
  font-size: 12px;
  line-height: 1.3;
  font-weight: 720;
}

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

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fffaf1;
}

select:disabled {
  color: rgba(39, 37, 32, 0.72);
  background: #f0eadf;
  cursor: not-allowed;
  opacity: 1;
}

input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--green);
}

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

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.coords {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.manual-location-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.manual-location-toggle span {
  color: var(--ink);
}

.microcopy,
.status-line {
  margin: 0;
}

.status-line {
  min-height: 20px;
  color: var(--green);
  font-size: 14px;
  line-height: 1.4;
}

.auth-box,
.auth-form {
  display: grid;
  gap: 12px;
}

.auth-box {
  margin-bottom: 18px;
}

.auth-form {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.wide {
  width: 100%;
}

.mine-card {
  display: grid;
  gap: 14px;
  padding: 15px;
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.account-row strong {
  display: block;
  font-size: 18px;
  line-height: 1.2;
}

.hidden {
  display: none;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .map-stage {
    min-height: 52vh;
  }

  .panel {
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .topbar {
    left: 18px;
    right: 18px;
    top: 18px;
  }

  h1 {
    font-size: 34px;
  }

}

@media (max-width: 560px) {
  .field-grid,
  .coords {
    grid-template-columns: 1fr;
  }

  .tab-panel {
    padding: 18px;
  }

  .topbar {
    align-items: center;
  }

  .kicker {
    display: none;
  }
}

/* ── Feedback modal ─────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--panel);
  border-radius: 10px;
  padding: 24px;
  max-width: 480px;
  width: 92%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-size: 18px;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
}

.modal-close:hover {
  color: var(--ink);
}

/* ── Map legend ────────────────────────────────────── */
.map-legend {
  background: var(--panel);
  padding: 12px;
  border-radius: 6px;
  font-size: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  max-width: 140px;
}

.legend-title {
  margin: 0 0 8px;
  font-weight: 650;
  font-size: 13px;
  color: var(--ink);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  color: var(--muted);
}

.legend-dot {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid #fffdf8;
}
