:root {
  --bg: #f4efe7;
  --bg-soft: #fffaf2;
  --surface: #fffdf8;
  --surface-alt: #f7f1e7;
  --text: #2f241b;
  --muted: #6d5f52;
  --accent: #16697a;
  --accent-strong: #0f4f5c;
  --warning: #a64b2a;
  --border: #d9cfc2;
  --shadow: 0 10px 24px rgba(34, 27, 20, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "PT Sans", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, #fff8ee 0%, transparent 40%),
    radial-gradient(circle at 90% 20%, #e4f2ef 0%, transparent 38%),
    linear-gradient(140deg, #efe5d7 0%, #f8f4ec 50%, #f0e7dc 100%);
  line-height: 1.45;
}

a {
  color: var(--accent);
}

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

.app-header {
  padding: 24px 28px 14px;
}

.title {
  margin: 0;
  font-family: "PT Serif", Georgia, serif;
  font-size: clamp(1.55rem, 2.6vw, 2.2rem);
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
}

.page {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
  padding: 0 24px 24px;
}

.panel {
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(3px);
}

.map-panel {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
}

.map-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-alt) 68%, transparent);
}

.map-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.edit-mode-on {
  background: #1c7f3c;
}

.edit-mode-off {
  background: var(--accent);
}

#map {
  width: 100%;
  flex: 1;
  min-height: 500px;
}

.panel-inner {
  padding: 16px;
}

.list-panel {
  display: flex;
  flex-direction: column;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.count-badge {
  min-width: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 4px 10px;
  text-align: center;
  font-weight: 700;
  background: var(--surface-alt);
}

.categories-legend {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.legend-item {
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface-alt);
  font-size: 0.84rem;
}

.legend-color {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.section-title {
  margin: 0;
  font-family: "PT Serif", Georgia, serif;
  font-size: 1.35rem;
}

.help {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.status {
  margin: 12px 0 0;
  min-height: 1.2em;
  font-size: 0.93rem;
  color: var(--accent-strong);
}

.status.error {
  color: var(--warning);
}

.status.ok {
  color: #1c7f3c;
}

.status.empty {
  color: var(--muted);
}

.place-form {
  display: grid;
  gap: 11px;
  margin-top: 14px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  line-height: 1;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
}

.add-dialog {
  border: 0;
  width: min(560px, calc(100% - 28px));
  border-radius: 16px;
  padding: 0;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 24px 55px rgba(20, 15, 12, 0.35);
}

.add-dialog::backdrop {
  background: rgba(36, 29, 22, 0.5);
  backdrop-filter: blur(2px);
}

.add-dialog .place-form {
  margin: 0;
  padding: 16px;
}

.auth-dialog {
  width: min(500px, calc(100% - 28px));
}

.new-category-fields {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 10px;
  background: color-mix(in srgb, var(--surface-alt) 60%, transparent);
}

.field {
  display: grid;
  gap: 6px;
}

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

label {
  font-size: 0.9rem;
  color: var(--muted);
}

input,
select,
textarea,
button {
  font-family: inherit;
  font-size: 0.95rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  padding: 10px 11px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 60%, white);
  box-shadow: 0 0 0 3px rgba(22, 105, 122, 0.16);
}

.hint {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  padding: 0;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.secondary-btn {
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.places-list {
  margin-top: 12px;
  max-height: 66vh;
  overflow: auto;
  padding-right: 4px;
}

.place-item {
  border: 1px solid var(--border);
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  padding: 10px;
  margin-bottom: 9px;
}

.place-item-title {
  margin: 0;
  font-weight: 700;
  font-size: 0.98rem;
}

.place-category {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.79rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 3px 8px;
  background: #f4f0ea;
}

.place-category-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.place-item-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.place-item-actions {
  margin-top: 8px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.place-item-link {
  font-size: 0.88rem;
  text-decoration: none;
  padding: 4px 7px;
  border-radius: 8px;
  background: #e8f3f1;
}

.map-popup {
  min-width: 210px;
}

.map-popup-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.map-popup-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.map-popup-category {
  margin: 7px 0;
}

.leaflet-tooltip.place-hover-tooltip {
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(35, 28, 22, 0.18);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  color: var(--text);
  padding: 8px 10px;
}

.hover-card {
  min-width: 190px;
  max-width: 280px;
}

.hover-title {
  font-weight: 700;
  margin: 0;
}

.hover-category {
  margin-top: 7px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 7px;
}

.hover-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.pin-wrapper {
  width: 28px;
  height: 40px;
  position: relative;
}

.pin-dot {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.92);
  position: absolute;
  left: 0;
  top: 0;
}

.pin-center {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  left: 10px;
  top: 10px;
}

.pin-select {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.leaflet-bottom {
  transform: translateY(1cm);
}

.place-card-wrapper {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.place-card {
  width: min(860px, 100%);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.place-card-content {
  padding: 18px;
}

.place-card-title {
  margin: 0;
  font-family: "PT Serif", Georgia, serif;
  font-size: clamp(1.4rem, 2.5vw, 2.1rem);
}

.place-card-address {
  margin: 8px 0 0;
  color: var(--muted);
}

.place-card-description {
  margin: 14px 0 0;
  white-space: pre-line;
}

.place-card-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 15px;
  margin-top: 16px;
}

.place-card-image {
  width: 100%;
  min-height: 220px;
  max-height: 420px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #ece5db;
}

.placeholder {
  width: 100%;
  min-height: 220px;
  border-radius: 14px;
  border: 1px dashed var(--border);
  background: repeating-linear-gradient(
    45deg,
    #f6efe4,
    #f6efe4 10px,
    #eee4d7 10px,
    #eee4d7 20px
  );
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 16px;
}

.meta-box {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-alt);
  padding: 12px;
}

.meta-box h2 {
  margin: 0;
  font-size: 1.05rem;
  font-family: "PT Serif", Georgia, serif;
}

.meta-row {
  margin-top: 10px;
}

.meta-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.meta-value {
  display: block;
  margin-top: 2px;
  word-break: break-word;
}

.back-link {
  display: inline-block;
  margin-top: 16px;
  text-decoration: none;
  font-weight: 700;
}

.loading {
  color: var(--muted);
}

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

  .map-panel {
    min-height: 65vh;
  }

  #map {
    min-height: 420px;
  }

  .places-list {
    max-height: none;
  }
}

@media (max-width: 780px) {
  .app-header {
    padding: 18px 16px 10px;
  }

  .page {
    padding: 0 12px 12px;
    gap: 12px;
  }

  .map-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .field.inline {
    grid-template-columns: 1fr;
  }

  .place-card-grid {
    grid-template-columns: 1fr;
  }

  .panel-inner,
  .place-card-content {
    padding: 14px;
  }

  .actions {
    flex-wrap: wrap;
  }

  .add-dialog {
    width: calc(100% - 14px);
  }
}
