:root {
  color-scheme: light;
  --bg: #f8f7f3;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --text: #171717;
  --subtext: #6b6b70;
  --separator: rgba(60, 60, 67, 0.18);
  --blue: #007aff;
  --green: #2f8f64;
  --orange: #d86f36;
  --purple: #7a5ce0;
  --shadow: 0 18px 50px rgba(22, 22, 24, 0.12);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 16% 6%, rgba(254, 210, 121, 0.24), transparent 27rem),
    linear-gradient(180deg, #fbfaf7 0%, var(--bg) 42%, #f0f3f6 100%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
  background: rgba(248, 247, 243, 0.72);
  overflow-x: hidden;
}

.nav-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 8px;
  align-items: center;
  padding: calc(10px + var(--safe-top)) 18px 10px;
  min-height: calc(70px + var(--safe-top));
  background: rgba(248, 247, 243, 0.78);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-bottom: 1px solid rgba(60, 60, 67, 0.08);
}

.nav-title {
  min-width: 0;
  text-align: center;
}

.nav-title span {
  display: block;
  color: var(--subtext);
  font-size: 12px;
  line-height: 16px;
}

.nav-title h1 {
  margin: 0;
  font-size: 19px;
  line-height: 25px;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: rgba(255, 255, 255, 0.62);
  border-radius: 50%;
}

.nav-icon svg,
.tab svg,
.card-icon svg,
.stat svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hidden {
  display: none !important;
}

.main {
  min-height: calc(100vh - 152px);
  padding: 18px 16px calc(98px + var(--safe-bottom));
}

.hero {
  border-radius: 28px;
  min-height: 184px;
  padding: 22px;
  color: #fff;
  background: linear-gradient(135deg, #47756a, #e6a45d);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -18px -54px 38%;
  height: 160px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px 999px 0 0;
  transform: rotate(-11deg);
}

.hero h2 {
  position: relative;
  margin: 0 0 8px;
  font-size: 32px;
  line-height: 36px;
  letter-spacing: 0;
  max-width: 11ch;
}

.hero p {
  position: relative;
  margin: 0;
  font-size: 15px;
  line-height: 21px;
  opacity: 0.9;
}

.hero-actions,
.panel-actions {
  position: relative;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.action-btn {
  min-height: 42px;
  border-radius: 999px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #171717;
  background: rgba(255, 255, 255, 0.78);
  font-weight: 650;
}

.action-btn.primary {
  color: #fff;
  background: rgba(23, 23, 23, 0.86);
}

.action-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 26px 2px 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 22px;
  line-height: 28px;
}

.section-title span {
  color: var(--subtext);
  font-size: 13px;
}

.trip-list,
.memory-grid,
.day-strip,
.timeline {
  display: grid;
  gap: 12px;
}

.trip-card,
.panel,
.timeline-card,
.day-button,
.empty {
  background: var(--surface);
  backdrop-filter: blur(22px) saturate(1.35);
  -webkit-backdrop-filter: blur(22px) saturate(1.35);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 10px 32px rgba(18, 18, 19, 0.08);
}

.trip-card {
  min-height: 126px;
  border-radius: 22px;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 78px;
  gap: 14px;
  text-align: left;
  color: inherit;
}

.trip-card h3,
.timeline-card h3,
.panel h3 {
  margin: 0;
  font-size: 18px;
  line-height: 24px;
  letter-spacing: 0;
}

.trip-card p,
.timeline-card p,
.panel p,
.empty p {
  margin: 5px 0 0;
  color: var(--subtext);
  font-size: 14px;
  line-height: 20px;
}

.cover-mark {
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.92);
  font-weight: 800;
  font-size: 25px;
}

.theme-sage { background: linear-gradient(135deg, #58796d, #c7d8a5); }
.theme-coral { background: linear-gradient(135deg, #cd6f48, #f0c06b); }
.theme-ink { background: linear-gradient(135deg, #2e5e82, #8fb4cf); }
.theme-plum { background: linear-gradient(135deg, #7150a5, #d698b4); }

.meta-row,
.stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(118, 118, 128, 0.13);
  color: #3a3a3c;
  font-size: 13px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 14px;
}

.stat {
  min-height: 78px;
  border-radius: 18px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.6);
}

.stat b {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.stat span {
  color: var(--subtext);
  font-size: 12px;
}

.day-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 1px 2px 10px;
  scrollbar-width: none;
}

.day-strip::-webkit-scrollbar {
  display: none;
}

.day-button {
  flex: 0 0 76px;
  min-height: 76px;
  border-radius: 20px;
  color: inherit;
  background: rgba(255, 255, 255, 0.6);
}

.day-button.active {
  background: #171717;
  color: #fff;
}

.day-button b,
.day-button span {
  display: block;
}

.day-button b {
  font-size: 20px;
  margin-bottom: 3px;
}

.day-button span {
  font-size: 12px;
  opacity: 0.72;
}

.panel {
  border-radius: 24px;
  padding: 16px;
}

.import-note {
  margin-top: 12px;
  border-radius: 18px;
  padding: 12px;
  color: #22533f;
  background: rgba(47, 143, 100, 0.12);
  font-size: 13px;
  line-height: 19px;
}

.import-note strong {
  display: block;
  color: #143f30;
  margin-bottom: 3px;
}

.map-shell {
  min-height: 286px;
  border-radius: 24px;
  overflow: hidden;
  position: relative;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 10px 32px rgba(18, 18, 19, 0.08);
}

.map-canvas {
  height: 286px;
  width: 100%;
}

.map-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--subtext);
  background:
    linear-gradient(135deg, rgba(0, 122, 255, 0.08), transparent),
    rgba(255, 255, 255, 0.78);
}

.map-empty h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 18px;
}

.map-empty p {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
}

.leaflet-container {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

.leaflet-popup-content {
  margin: 10px 12px;
  line-height: 18px;
}

.timeline {
  position: relative;
  gap: 14px;
}

.timeline-row {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: start;
}

.time {
  color: var(--subtext);
  font-size: 13px;
  padding-top: 18px;
  text-align: right;
}

.timeline-card {
  border-radius: 20px;
  padding: 14px;
  position: relative;
}

.timeline-card::before {
  content: "";
  position: absolute;
  left: -18px;
  top: 23px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 5px rgba(0, 122, 255, 0.13);
}

.timeline-row:not(:last-child) .timeline-card::after {
  content: "";
  position: absolute;
  left: -15px;
  top: 36px;
  width: 2px;
  height: calc(100% + 18px);
  background: rgba(60, 60, 67, 0.16);
}

.timeline-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.card-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.type-place .card-icon { color: #126a55; background: rgba(48, 150, 111, 0.14); }
.type-food .card-icon { color: #b25327; background: rgba(216, 111, 54, 0.15); }
.type-transport .card-icon { color: #006edb; background: rgba(0, 122, 255, 0.14); }
.type-hotel .card-icon { color: #6c47c7; background: rgba(122, 92, 224, 0.14); }
.type-note .card-icon { color: #595959; background: rgba(118, 118, 128, 0.14); }

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.mini-btn {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--blue);
  background: rgba(0, 122, 255, 0.1);
}

.mini-btn.danger {
  color: #d70015;
  background: rgba(215, 0, 21, 0.08);
}

.empty {
  border-radius: 24px;
  padding: 28px 18px;
  text-align: center;
}

.empty h3 {
  margin: 0;
  font-size: 20px;
}

.tab-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 6;
  width: min(520px, 100vw);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: rgba(249, 249, 249, 0.84);
  backdrop-filter: blur(28px) saturate(1.5);
  -webkit-backdrop-filter: blur(28px) saturate(1.5);
  border-top: 1px solid var(--separator);
}

.tab {
  min-height: 56px;
  color: #8e8e93;
  background: transparent;
  border-radius: 16px;
  display: grid;
  place-items: center;
  gap: 2px;
}

.tab span {
  font-size: 11px;
}

.tab.active {
  color: var(--blue);
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 9;
  background: rgba(0, 0, 0, 0.28);
}

.sheet {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(520px, 100vw);
  padding: 8px 16px calc(18px + var(--safe-bottom));
  border-radius: 28px 28px 0 0;
  background: rgba(250, 250, 250, 0.94);
  backdrop-filter: blur(28px) saturate(1.45);
  -webkit-backdrop-filter: blur(28px) saturate(1.45);
  box-shadow: 0 -24px 70px rgba(0, 0, 0, 0.18);
}

.grabber {
  width: 38px;
  height: 5px;
  border-radius: 999px;
  margin: 0 auto 8px;
  background: rgba(60, 60, 67, 0.28);
}

.sheet-head {
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  align-items: center;
  margin-bottom: 12px;
}

.sheet-head h2 {
  text-align: center;
  margin: 0;
  font-size: 17px;
}

.text-btn {
  min-height: 44px;
  color: var(--blue);
  background: transparent;
  text-align: left;
}

.text-btn.primary {
  text-align: right;
  font-weight: 700;
}

.form-stack {
  display: grid;
  gap: 10px;
  max-height: min(70vh, 620px);
  overflow-y: auto;
  padding-bottom: 6px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--subtext);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(118, 118, 128, 0.12);
  color: var(--text);
  padding: 13px 14px;
  min-height: 48px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(0, 122, 255, 0.55);
  background: rgba(255, 255, 255, 0.9);
}

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

.memory-grid {
  grid-template-columns: 1fr 1fr;
}

.memory-tile {
  min-height: 156px;
  border-radius: 22px;
  padding: 14px;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: end;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow);
}

.memory-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 18%, rgba(0, 0, 0, 0.42));
}

.memory-tile h3,
.memory-tile p {
  position: relative;
  margin: 0;
}

.memory-tile h3 {
  font-size: 17px;
}

.memory-tile p {
  font-size: 12px;
  opacity: 0.86;
}

@media (min-width: 760px) {
  body {
    padding: 28px 0;
  }

  .app-shell {
    min-height: calc(100vh - 56px);
    border-radius: 34px;
    box-shadow: 0 30px 90px rgba(23, 23, 23, 0.13);
  }

  .tab-bar {
    border-radius: 0 0 34px 34px;
  }
}

@media (max-width: 360px) {
  .main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .two-col,
  .stats {
    grid-template-columns: 1fr;
  }
}
