/* =========================
   Base
========================= */
html, body {
  margin: 0;
  height: 100%;
  font-family: sans-serif;
  overflow-x: hidden;
}

.hidden { display:none; }

/* =========================
   App layout
========================= */
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* =========================
   Top bar
========================= */
#topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #111;
  color: white;
  position: sticky;
  top: 0;
  z-index: 1200;
}

.topbar-brand,
.hoardly-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.pill {
  flex-shrink: 0;
  align-self: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  line-height: 1;
  white-space: nowrap;
  transform: var(--pill-transform, none);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.pill:hover {
  transform: var(--pill-hover-transform, var(--pill-transform, none));
}

.topbar-brand {
  position: absolute;
  left: 50%;
  --pill-transform: translateX(-50%);
  --pill-hover-transform: translateX(-50%) translateY(-1px);
  padding-left: 10px;
  background: rgba(255, 255, 255, 0.08);
}

.topbar-brand:hover,
.hoardly-badge:hover {
  background: rgba(255, 255, 255, 0.14);
}

.topbar-brand {
  color: white;
}

.hoardly-badge {
  justify-content: center;
  align-self: center;
  margin: 0 0 18px;
  padding: 0 14px 0 12px;
  background: rgba(17, 17, 17, 0.06);
  color: #111;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.hoardly-badge-logo,
.topbar-brand-logo {
  display: block;
  width: auto;
  height: 20px;
}

.topbar-brand-logo {
  height: 20px;
}

.hoardly-badge-logo {
  height: 24px;
}

.topbar-brand-text {
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.topbar-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.topbar-back:hover {
  background: rgba(255, 255, 255, 0.18);
}

.topbar-back {
  color: white;
}

.topbar-back .icon {
  color: white;
}

.icon {
  display: block;
  width: auto;
  height: 1em;
  flex-shrink: 0;
}

.icon-back {
  height: 0.95em;
}

.icon-menu {
  height: 1rem;
}

.icon-check {
  height: 1.15rem;
}

.icon-panel-close {
  height: 1rem;
}

.mobile-toggle {
  color: white;
}

.panel-close {
  color: #666;
}

.topbar-title {
  margin: 0;
  min-width: 0;
  flex: 1 1 auto;
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================
   Main layout (sidebar + map)
========================= */
#main {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* =========================
   Sidebar (location list)
========================= */
#sidebar {
  width: 250px;
  min-width: 250px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid #ddd;
  padding: 10px;
  background: #fafafa;
}

#sidebar-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.sidebar-section {
  margin-bottom: 14px;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 2px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  margin: 0 0 8px;
  color: inherit;
}

.sidebar-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #666;
}

.sidebar-section-toggle {
  margin-left: 8px;
  color: #888;
  font-size: 0.8rem;
  line-height: 1;
}

.sidebar-section.collapsed .sidebar-section-header {
  margin-bottom: 0;
}

.sidebar-section-list[hidden] {
  display: none;
}

/* sidebar items */
.sidebar-item {
  padding: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-item-title {
  flex: 1;
  display: inline-block;
}

.sidebar-item-checkbox-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.75rem;
}

.sidebar-item-checkbox {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-item:hover {
  background: #eee;
}

#sidebar-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

/* Search input styling */
.search-input {
  width: 100%;
  padding: .5rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  font-size: 1rem;
  box-sizing: border-box;
}

.completion-filter {
  display: flex;
  gap: 4px;
}

.completion-filter-btn {
  flex: 1;
  padding: 0.35rem 0.25rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: white;
  font-size: 0.75rem;
  cursor: pointer;
  color: #333;
}

.completion-filter-btn:hover {
  background: #eee;
}

.completion-filter-btn.active {
  background: #111;
  border-color: #111;
  color: white;
}

.sidebar-progress {
  flex-shrink: 0;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(17, 17, 17, 0.08);
}

.sidebar-sync {
  flex-shrink: 0;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

.sidebar-sync-actions {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.sidebar-sync-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #666;
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.sidebar-sync-link:hover {
  color: #111;
}

.sidebar-sync-upload {
  display: flex;
  align-items: center;
  flex: 1 1 0;
}

.sidebar-sync-upload .sidebar-sync-link {
  display: flex;
  cursor: pointer;
  user-select: none;
}

.sidebar-sync-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sidebar-progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar-progress-bar {
  height: 6px;
  border-radius: 999px;
  background: #ececec;
  overflow: hidden;
}

.sidebar-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: #111;
  transition: width 0.2s ease;
}

/* =========================
   Map
========================= */
#map {
  flex: 1;
  position: relative;
  min-width: 0;
  min-height: 0;
}

/* =========================
   Floating detail panel
========================= */
#panel {
  position: absolute;
  right: 20px;
  bottom: 20px;
  width: min(360px, calc(100vw - 40px));
  max-height: calc(100% - 120px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid rgba(17, 17, 17, 0.08);
  border-radius: 16px;
  padding: 0;
  display: none;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
  z-index: 1000;
}

.panel-placeholder {
  padding: 20px;
}

.panel-placeholder-title {
  margin: 0 0 6px;
  font-size: 1.1rem;
  font-weight: 700;
}

.panel-placeholder-text {
  margin: 0;
  color: #666;
  line-height: 1.5;
  font-size: 0.95rem;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(17, 17, 17, 0.06);
}

.panel-header-text {
  min-width: 0;
}

.panel-title {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.3;
}

.panel-description {
  margin: 6px 0 0;
  color: #555;
  font-size: 0.9rem;
  line-height: 1.5;
}

.panel-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: #f3f3f3;
  color: #444;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}

.panel-close .icon {
  margin: 0 auto;
}

.panel-close:hover {
  background: #e6e6e6;
}

.panel-progress {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(17, 17, 17, 0.06);
}

.panel-progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.panel-progress-bar {
  height: 6px;
  border-radius: 999px;
  background: #ececec;
  overflow: hidden;
}

.panel-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: #111;
  transition: width 0.2s ease;
}

.panel-empty {
  margin: 0;
  padding: 18px;
  color: #666;
  font-size: 0.95rem;
  line-height: 1.5;
}

.thing-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px 18px;
}

.thing-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border: 1px solid rgba(17, 17, 17, 0.1);
  border-radius: 12px;
  background: #fafafa;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.thing-card:hover {
  border-color: rgba(17, 17, 17, 0.18);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

.thing-card.done {
  background: #f4faf5;
  border-color: rgba(34, 120, 60, 0.25);
}

.thing-card-check {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border: 2px solid #bbb;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.thing-card.done .thing-card-check {
  border-color: #2a8f4a;
  background: #2a8f4a;
}

.thing-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.thing-card-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: #111;
  line-height: 1.3;
}

.thing-card.done .thing-card-title {
  color: #2a6b3f;
}

.thing-card-desc {
  font-size: 0.9rem;
  color: #555;
  line-height: 1.45;
}

.thing-card-note {
  margin: 0;
  font-size: 0.82rem;
  color: #666;
  line-height: 1.45;
}

.thing-card-note-label {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.07);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #444;
}

.sidebar-item.selected {
  background: #111;
  color: white;
}

/* Landing page */
#landing {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.18), transparent 34%),
    radial-gradient(circle at 85% 15%, rgba(255, 255, 255, 0.12), transparent 24%),
    linear-gradient(180deg, #0f1116 0%, #141823 42%, #eef1f6 42%, #eef1f6 100%);
  color: #111;
}

.landing-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 44px;
}

.landing-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 22px;
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    linear-gradient(180deg, rgba(17, 17, 17, 0.95), rgba(17, 17, 17, 0.82));
  color: white;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.24);
}

.landing-hero::after {
  content: "";
  position: absolute;
  inset: auto -10% -35% auto;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
}

.landing-brand {
  position: static;
  left: auto;
  --pill-transform: none;
  --pill-hover-transform: translateY(-1px);
  justify-self: start;
  margin: 0;
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.landing-hero-copy {
  max-width: 960px;
}

.landing-eyebrow,
.landing-panel-kicker {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.68);
}

.landing-hero h1 {
  margin: 0;
  font-size: clamp(2.7rem, 5vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.landing-lede {
  max-width: 56ch;
  margin: 16px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 1.05rem;
  line-height: 1.7;
}

.landing-main {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.landing-panel {
  padding: 26px;
  border-radius: 24px;
  border: 1px solid rgba(17, 17, 17, 0.08);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 18px 50px rgba(15, 17, 22, 0.08);
  backdrop-filter: blur(12px);
}

.landing-panel-header {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.landing-panel-heading {
  display: grid;
  gap: 6px;
}

.landing-panel-heading h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2.4vw, 2rem);
  line-height: 1.08;
}

.landing-panel-heading .landing-panel-kicker {
  color: #6b7280;
}

.landing-panel-note {
  margin: 0;
  max-width: 50ch;
  color: #4b5563;
  line-height: 1.65;
}

.landing-search-wrap {
  display: grid;
  gap: 6px;
  max-width: 560px;
  margin-bottom: 1rem;
}

.landing-search-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #6b7280;
}

.landing-search {
  width: 100%;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(17, 17, 17, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #111;
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  box-shadow: 0 8px 24px rgba(15, 17, 22, 0.06);
}

.landing-search::placeholder {
  color: #8a94a6;
}

.landing-search:focus {
  border-color: rgba(17, 17, 17, 0.24);
  box-shadow: 0 0 0 4px rgba(17, 17, 17, 0.08), 0 8px 24px rgba(15, 17, 22, 0.08);
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.map-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  min-height: 220px;
  padding: 24px;
  border-radius: 22px;
  border: 1px solid rgba(17, 17, 17, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.96));
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.map-card::before {
  content: "";
  position: absolute;
  inset: -30% -20% auto auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(17, 17, 17, 0.08) 0%, rgba(17, 17, 17, 0) 72%);
  pointer-events: none;
}

.map-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 42px rgba(15, 17, 22, 0.12);
  border-color: rgba(17, 17, 17, 0.14);
}

.map-card h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.15;
}

.map-card p {
  margin: 10px 0 0;
  color: #52606d;
  line-height: 1.6;
}

.map-card-action {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: #111;
  color: white;
  font-weight: 600;
  font-size: 0.95rem;
}

.landing-empty {
  margin-top: 16px;
  padding: 18px 20px;
  border-radius: 18px;
  background: rgba(17, 17, 17, 0.04);
  color: #4b5563;
  border: 1px dashed rgba(17, 17, 17, 0.14);
}

.error-message {
  max-width: 840px;
  margin: 6px 0 0;
  padding: 16px 18px;
  background: #ffe8e8;
  border: 1px solid #f2c1c1;
  color: #8b1f1f;
  border-radius: 14px;
}

.sidebar-item.selected:hover {
  background: #222;
}

.mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  padding: 0 14px 0 12px;
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.mobile-toggle:hover {
  background: rgba(255, 255, 255, 0.18);
}

.mobile-toggle-label {
  display: inline-block;
  white-space: nowrap;
}

.mobile-toggle .icon {
  display: block;
  flex: 0 0 auto;
  width: 0.95rem;
  height: 0.95rem;
}

@media (max-width: 900px) {
  #main {
    position: relative;
  }

  #sidebar {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 1100;
    width: min(88vw, 340px);
    min-width: min(88vw, 340px);
    transform: translateX(-100%);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    box-shadow: none;
  }

  body.mobile-sidebar-open #sidebar {
    transform: translateX(0);
    box-shadow: 16px 0 40px rgba(0, 0, 0, 0.18);
  }

  #map {
    width: 100%;
  }

  .mobile-toggle {
    display: inline-flex;
    order: -1;
    margin-right: auto;
  }

  #panel {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-height: 58vh;
    border-radius: 18px 18px 16px 16px;
  }

  .panel-header,
  .panel-progress,
  .thing-cards {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 640px) {
  #landing {
    background: linear-gradient(180deg, #0f1116 0%, #141823 38%, #eef1f6 38%, #eef1f6 100%);
  }

  .landing-shell {
    padding: 16px 14px 28px;
  }

  .landing-hero {
    padding: 22px;
    border-radius: 22px;
    gap: 18px;
  }

  .landing-hero h1 {
    font-size: clamp(2.1rem, 11vw, 3rem);
  }

  .landing-lede {
    font-size: 1rem;
  }

  .landing-panel {
    padding: 18px;
    border-radius: 20px;
  }

  .landing-panel-note {
    max-width: none;
  }

  #topbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "menu brand back"
      "title title title";
    gap: 8px 10px;
    padding: 10px;
  }

  .mobile-toggle {
    grid-area: menu;
    justify-self: start;
  }

  .topbar-back {
    grid-area: back;
    justify-self: end;
  }

  .topbar-title {
    grid-area: title;
    order: initial;
    flex: initial;
    width: 100%;
    font-size: 0.95rem;
  }

  .topbar-brand {
    grid-area: brand;
    position: static;
    left: auto;
    --pill-transform: none;
    --pill-hover-transform: translateY(-1px);
    justify-self: center;
    width: auto;
    gap: 8px;
    justify-content: flex-start;
    color: white;
  }

  .topbar-brand {
    padding-right: 10px;
  }

  #sidebar {
    width: min(92vw, 320px);
    min-width: min(92vw, 320px);
  }

  #panel {
    max-height: 68vh;
    left: 8px;
    right: 8px;
    bottom: 8px;
  }

  #landing {
    padding: 24px 14px 32px;
  }

  .hero {
    margin-bottom: 20px;
    text-align: left;
  }

  .hero .hoardly-badge {
    margin-bottom: 12px;
  }

  .hero h1 {
    font-size: clamp(1.9rem, 8vw, 2.6rem);
  }

  .landing-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .map-card {
    min-height: 0;
    padding: 18px;
  }
}
