:root {
  --ink: #181632;
  --deep: #211b46;
  --night: #30285f;
  --sun: #f88949;
  --apricot: #ffd49b;
  --rose: #dc6376;
  --sage: #62b7a5;
  --paper: #fff8ef;
  --paper-soft: rgba(255, 248, 239, 0.9);
  --mist: rgba(255, 255, 255, 0.58);
  --line: rgba(33, 27, 70, 0.16);
  --shadow: 0 18px 48px rgba(19, 14, 46, 0.24);
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 14%, rgba(255, 212, 155, 0.56), transparent 28%),
    radial-gradient(circle at 86% 18%, rgba(98, 183, 165, 0.32), transparent 23%),
    linear-gradient(150deg, #201b44 0%, #51356d 38%, #d86761 66%, #ffd49b 100%);
  overflow: hidden;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  width: min(100vw, 430px);
  height: min(100dvh, 920px);
  min-height: 680px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom));
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(34, 28, 76, 0.92) 0%, rgba(91, 57, 103, 0.9) 34%, rgba(245, 136, 73, 0.72) 100%),
    var(--deep);
  box-shadow: var(--shadow);
  isolation: isolate;
}

.sky-glow,
.stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sky-glow {
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 212, 155, 0.58), transparent 18%),
    radial-gradient(circle at 50% 118%, rgba(255, 248, 239, 0.78), transparent 38%);
  opacity: 0.82;
  z-index: -2;
}

.stars {
  background-image:
    radial-gradient(circle, rgba(255, 248, 239, 0.92) 0 1px, transparent 1.6px),
    radial-gradient(circle, rgba(255, 212, 155, 0.7) 0 1px, transparent 1.8px);
  background-position:
    18px 28px,
    2px 16px;
  background-size:
    54px 74px,
    86px 92px;
  opacity: 0.38;
  z-index: -1;
}

.topbar,
.orbit-strip,
.filter-row,
.bottom-nav {
  position: relative;
  z-index: 2;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--paper);
}

.eyebrow {
  margin: 0 0 4px;
  color: rgba(255, 248, 239, 0.66);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.55rem, 7vw, 2.15rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  color: var(--paper);
  font-size: 1.15rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.icon-button,
.ghost-button,
.nav-item,
.filter-chip,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--deep);
  background: var(--paper);
  box-shadow: 0 10px 24px rgba(24, 22, 50, 0.16);
}

.icon-button.dark {
  color: var(--paper);
  background: rgba(255, 255, 255, 0.12);
}

.icon-button svg,
.nav-item svg,
.ghost-button svg,
.primary-button svg {
  width: 19px;
  height: 19px;
  stroke-width: 2.2;
}

.orbit-strip {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
  padding: 12px;
  color: var(--paper);
  border: 1px solid rgba(255, 248, 239, 0.22);
  border-radius: 8px;
  background: rgba(255, 248, 239, 0.11);
  backdrop-filter: blur(18px);
}

.mini-planet {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background:
    linear-gradient(150deg, #ffd49b 0%, #f88949 45%, #dc6376 100%);
  box-shadow: inset -8px -10px 18px rgba(33, 27, 70, 0.2), 0 10px 24px rgba(24, 22, 50, 0.14);
}

.mini-planet::before {
  content: "";
  position: absolute;
  inset: 25px -8px auto;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 248, 239, 0.55);
  transform: rotate(-14deg);
}

.mini-planet span {
  position: absolute;
  right: 13px;
  top: 13px;
  width: 9px;
  height: 20px;
  border-radius: 9px 9px 0 0;
  background: var(--sage);
  transform: rotate(25deg);
}

.mini-planet span::after {
  content: "";
  position: absolute;
  left: -6px;
  top: -7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--rose);
  box-shadow: 7px 2px 0 rgba(220, 99, 118, 0.86);
}

.orbit-title {
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.35;
}

.orbit-meta {
  margin-top: 4px;
  color: rgba(255, 248, 239, 0.68);
  font-size: 0.78rem;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.filter-chip {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(255, 248, 239, 0.2);
  border-radius: 999px;
  color: rgba(255, 248, 239, 0.82);
  background: rgba(255, 248, 239, 0.1);
  font-size: 0.82rem;
  font-weight: 750;
  backdrop-filter: blur(16px);
}

.filter-chip.is-active {
  color: var(--deep);
  background: var(--paper);
  border-color: transparent;
}

.view {
  min-height: 0;
  overflow: hidden;
  display: none;
}

.view.is-active {
  display: block;
}

.view-map {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 248, 239, 0.2);
  background: rgba(255, 248, 239, 0.18);
}

#memoryMap {
  width: 100%;
  height: 100%;
  min-height: 360px;
  background: #ecd7be;
}

.leaflet-container {
  font-family: inherit;
}

.leaflet-tile {
  filter: saturate(0.68) sepia(0.16) hue-rotate(334deg) contrast(0.95);
}

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

.leaflet-popup-content-wrapper {
  border-radius: 8px;
  overflow: hidden;
  padding: 0;
}

.leaflet-popup-content {
  margin: 0;
  min-width: 190px;
}

.popup-card img {
  display: block;
  width: 100%;
  height: 116px;
  object-fit: cover;
}

.popup-card div {
  padding: 10px;
  border-top: 4px solid var(--owner-color, var(--rose));
  color: var(--ink);
  background: var(--paper);
}

.popup-card strong {
  display: block;
  margin-bottom: 3px;
  font-size: 0.92rem;
}

.popup-card span {
  color: rgba(24, 22, 50, 0.68);
  font-size: 0.76rem;
}

.memory-marker {
  width: 54px;
  height: 54px;
  border: 4px solid var(--owner-color, var(--paper));
  border-radius: 50% 50% 50% 12px;
  background-size: cover;
  background-position: center;
  box-shadow: 0 10px 22px rgba(24, 22, 50, 0.28);
  transform: rotate(-45deg);
}

.memory-marker span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(255, 212, 155, 0.12);
  transform: rotate(45deg);
}

.memory-marker.is-stack {
  box-shadow:
    -6px 6px 0 rgba(255, 248, 239, 0.82),
    0 10px 22px rgba(24, 22, 50, 0.28);
}

.memory-marker-count {
  position: absolute;
  right: -7px;
  top: -7px;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  color: var(--paper);
  border: 2px solid var(--paper);
  border-radius: 999px;
  background: var(--rose);
  font-size: 0.72rem;
  line-height: 1;
  transform: rotate(45deg);
}

.place-popup {
  min-width: 238px;
  color: var(--ink);
  background: var(--paper);
}

.place-popup header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border-bottom: 1px solid rgba(33, 27, 70, 0.12);
}

.place-popup header strong,
.place-popup header span {
  min-width: 0;
}

.place-popup header span {
  flex: 0 0 auto;
  color: rgba(24, 22, 50, 0.62);
  font-size: 0.74rem;
}

.place-popup-list {
  display: grid;
  max-height: 260px;
  overflow: auto;
}

.place-popup-list button {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 9px;
  align-items: center;
  min-width: 0;
  padding: 8px 10px;
  color: var(--ink);
  border-left: 4px solid var(--owner-color, var(--rose));
  background: var(--paper);
  text-align: left;
}

.place-popup-list button + button {
  border-top: 1px solid rgba(33, 27, 70, 0.08);
}

.place-popup-list img {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
}

.place-popup-list span,
.place-popup-list b,
.place-popup-list small {
  min-width: 0;
}

.place-popup-list b,
.place-popup-list small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.place-popup-list b {
  font-size: 0.86rem;
}

.place-popup-list small {
  margin-top: 3px;
  color: rgba(24, 22, 50, 0.62);
  font-size: 0.72rem;
}

.map-floating {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 9px 10px;
  color: var(--paper);
  border: 1px solid rgba(255, 248, 239, 0.18);
  border-radius: 8px;
  background: rgba(33, 27, 70, 0.72);
  backdrop-filter: blur(18px);
  z-index: 700;
}

.map-floating > div {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 0.78rem;
  font-weight: 750;
}

.pin-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--sage);
  box-shadow: 0 0 0 5px rgba(98, 183, 165, 0.18);
}

.ghost-button {
  gap: 5px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--paper);
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.75rem;
  font-weight: 800;
}

.album-grid,
.timeline-list {
  height: 100%;
  overflow: auto;
  padding: 2px 0 96px;
  scrollbar-width: none;
}

.album-grid::-webkit-scrollbar,
.timeline-list::-webkit-scrollbar {
  display: none;
}

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

.photo-card {
  position: relative;
  overflow: hidden;
  width: 100%;
  padding: 0;
  text-align: left;
  border: 3px solid var(--owner-color, rgba(255, 248, 239, 0.38));
  border-radius: 8px;
  background: rgba(255, 248, 239, 0.16);
  box-shadow: 0 12px 26px rgba(24, 22, 50, 0.18);
}

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

.photo-card::after {
  content: "";
  position: absolute;
  inset: 38% 0 0;
  background: linear-gradient(180deg, transparent, rgba(24, 22, 50, 0.72));
}

.photo-caption {
  position: absolute;
  inset: auto 10px 10px;
  z-index: 1;
  color: var(--paper);
}

.photo-caption strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
}

.photo-caption span {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255, 248, 239, 0.76);
  font-size: 0.72rem;
}

.owner-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--deep);
  background: rgba(255, 248, 239, 0.88);
  font-size: 0.7rem;
  font-weight: 850;
}

.owner-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--owner-color, var(--rose));
}

.timeline-list {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 12px;
  min-height: 116px;
  padding: 10px;
  border: 1px solid rgba(255, 248, 239, 0.18);
  border-left: 5px solid var(--owner-color, rgba(255, 248, 239, 0.36));
  border-radius: 8px;
  background: rgba(255, 248, 239, 0.88);
  cursor: pointer;
}

.timeline-item img {
  width: 86px;
  height: 96px;
  object-fit: cover;
  border-radius: 6px;
}

.timeline-text {
  min-width: 0;
}

.timeline-text time {
  color: var(--rose);
  font-size: 0.72rem;
  font-weight: 850;
}

.timeline-text h3 {
  margin: 5px 0 3px;
  overflow: hidden;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.22;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-text p {
  display: -webkit-box;
  overflow: hidden;
  color: rgba(24, 22, 50, 0.72);
  font-size: 0.78rem;
  line-height: 1.45;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.timeline-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: rgba(24, 22, 50, 0.54);
  font-size: 0.72rem;
  font-weight: 750;
}

.view-message {
  min-height: 0;
}

.message-board {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  height: 100%;
  min-height: 0;
}

.message-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 62px;
  padding: 12px 14px;
  color: var(--paper);
  border: 1px solid rgba(255, 248, 239, 0.22);
  border-radius: 8px;
  background: rgba(33, 27, 70, 0.58);
  text-align: left;
  backdrop-filter: blur(18px);
}

.message-toggle span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.message-toggle strong,
.message-toggle small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-toggle strong {
  font-size: 1rem;
}

.message-toggle small {
  color: rgba(255, 248, 239, 0.72);
  font-size: 0.74rem;
  font-weight: 750;
}

.message-toggle svg {
  flex: 0 0 auto;
  transition: transform 160ms ease;
}

.message-board.is-collapsed {
  grid-template-rows: auto 0fr;
}

.message-board.is-collapsed .message-toggle svg {
  transform: rotate(180deg);
}

.message-board.is-collapsed .message-panel {
  opacity: 0;
  pointer-events: none;
}

.message-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
  overflow: hidden;
  opacity: 1;
  transition: opacity 160ms ease;
}

.message-compose-toggle {
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(255, 248, 239, 0.22);
  border-radius: 8px;
  color: var(--paper);
  background: rgba(33, 27, 70, 0.42);
  font-size: 0.82rem;
  font-weight: 850;
}

.message-compose-toggle svg {
  transition: transform 160ms ease;
}

.message-form {
  grid-row: 2;
  display: none;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 248, 239, 0.22);
  border-radius: 8px;
  background: rgba(255, 248, 239, 0.88);
}

.message-board.is-compose-open .message-form {
  display: grid;
}

.message-board.is-compose-open .message-compose-toggle svg {
  transform: rotate(180deg);
}

.message-form label {
  display: grid;
  gap: 6px;
  color: var(--deep);
  font-size: 0.75rem;
  font-weight: 850;
}

.message-form select,
.message-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
}

.message-form select {
  height: 38px;
  padding: 0 10px;
}

.message-form textarea {
  min-height: 76px;
  padding: 9px 10px;
  resize: vertical;
}

.message-photo-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.message-photo-preview {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 96px;
  overflow: hidden;
  border: 1px dashed rgba(33, 27, 70, 0.24);
  border-radius: 8px;
  color: rgba(24, 22, 50, 0.56);
  background: rgba(255, 255, 255, 0.46);
}

.message-photo-preview img {
  width: 100%;
  height: 142px;
  display: block;
  object-fit: cover;
}

.message-photo-preview audio,
.message-photo-preview video {
  width: 100%;
}

.message-photo-preview video {
  max-height: 160px;
  background: #111;
  object-fit: contain;
}

.message-photo-preview small {
  font-size: 0.72rem;
  font-weight: 750;
}

.message-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.message-actions .primary-button,
.message-actions .secondary-button {
  min-height: 38px;
  padding: 0 14px;
}

.message-list {
  grid-row: 3;
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-bottom: 96px;
  scrollbar-width: none;
}

.message-list::-webkit-scrollbar {
  display: none;
}

.message-item,
.message-empty {
  border-radius: 8px;
  background: rgba(255, 248, 239, 0.9);
  box-shadow: 0 12px 26px rgba(24, 22, 50, 0.14);
}

.message-item {
  padding: 12px;
  border-left: 5px solid var(--owner-color, var(--rose));
}

.message-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.message-item-head .owner-badge {
  position: static;
  color: var(--deep);
  background: rgba(255, 255, 255, 0.72);
}

.message-item-head time {
  flex: 0 0 auto;
  color: rgba(24, 22, 50, 0.52);
  font-size: 0.72rem;
  font-weight: 750;
}

.message-item p {
  margin-top: 10px;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-image-button {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 0;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(33, 27, 70, 0.08);
}

.message-image-button img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
}

.message-attachment {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(33, 27, 70, 0.08);
}

.message-attachment span {
  overflow: hidden;
  color: rgba(24, 22, 50, 0.68);
  font-size: 0.72rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-attachment audio,
.message-attachment video {
  width: 100%;
}

.message-attachment video {
  max-height: 280px;
  border-radius: 6px;
  background: #111;
  object-fit: contain;
}

.message-replies {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-left: 10px;
  border-left: 2px solid rgba(33, 27, 70, 0.12);
}

.message-reply {
  display: grid;
  gap: 5px;
  padding: 9px;
  border-radius: 8px;
  background: rgba(33, 27, 70, 0.06);
}

.message-reply div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.message-reply strong {
  color: var(--ink);
  font-size: 0.76rem;
}

.message-reply time {
  color: rgba(24, 22, 50, 0.5);
  font-size: 0.68rem;
  font-weight: 750;
}

.message-reply p {
  margin: 0;
  font-size: 0.82rem;
}

.message-reply > button {
  justify-self: end;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  color: rgba(24, 22, 50, 0.64);
  background: rgba(33, 27, 70, 0.08);
  font-size: 0.68rem;
  font-weight: 850;
}

.message-reply-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 248, 239, 0.78);
}

.message-reply-form span {
  color: rgba(24, 22, 50, 0.62);
  font-size: 0.72rem;
  font-weight: 850;
}

.message-reply-form textarea {
  width: 100%;
  min-height: 58px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  resize: vertical;
}

.message-reply-form div {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.message-item-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.message-item-actions button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--deep);
  background: rgba(33, 27, 70, 0.08);
  font-size: 0.72rem;
  font-weight: 850;
}

.message-item-actions svg {
  width: 15px;
  height: 15px;
}

.message-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 28px 18px;
  color: rgba(24, 22, 50, 0.62);
  text-align: center;
}

.message-empty svg {
  color: var(--rose);
}

.message-empty strong {
  color: var(--ink);
}

.message-empty span {
  font-size: 0.78rem;
}

.bottom-nav {
  display: grid;
  grid-template-columns: 1fr 1fr 58px 1fr 1fr;
  gap: 8px;
  align-items: center;
  min-height: 70px;
  margin-top: 12px;
  padding: 8px;
  border: 1px solid rgba(255, 248, 239, 0.2);
  border-radius: 999px;
  background: rgba(33, 27, 70, 0.72);
  backdrop-filter: blur(18px);
}

.nav-item {
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  height: 50px;
  border-radius: 999px;
  color: rgba(255, 248, 239, 0.72);
  background: transparent;
  font-size: 0.68rem;
  font-weight: 800;
}

.nav-item.is-active {
  color: var(--deep);
  background: var(--paper);
}

.nav-add {
  height: 54px;
  color: var(--deep);
  background: linear-gradient(140deg, var(--apricot), var(--sun));
  box-shadow: 0 10px 24px rgba(248, 137, 73, 0.32);
}

.nav-add svg {
  width: 22px;
  height: 22px;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(11, 9, 29, 0.46);
  backdrop-filter: blur(5px);
}

.add-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  width: min(100vw, 430px);
  max-height: min(88dvh, 780px);
  padding: 9px 16px max(18px, env(safe-area-inset-bottom));
  overflow: auto;
  color: var(--paper);
  border-radius: 8px 8px 0 0;
  background:
    linear-gradient(180deg, rgba(48, 40, 95, 0.98), rgba(33, 27, 70, 0.98)),
    var(--deep);
  box-shadow: 0 -22px 48px rgba(11, 9, 29, 0.34);
  transform: translate(-50%, 110%);
  transition: transform 180ms ease;
}

.add-sheet.is-open {
  transform: translate(-50%, 0);
}

.picker-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) auto;
  gap: 12px;
  width: min(100vw, 430px);
  height: min(82dvh, 720px);
  padding: 16px 16px max(18px, env(safe-area-inset-bottom));
  color: var(--paper);
  border-radius: 8px 8px 0 0;
  background:
    linear-gradient(180deg, rgba(48, 40, 95, 0.98), rgba(33, 27, 70, 0.98)),
    var(--deep);
  box-shadow: 0 -22px 48px rgba(11, 9, 29, 0.34);
  transform: translate(-50%, 110%);
  transition: transform 180ms ease;
}

.picker-sheet.is-open {
  transform: translate(-50%, 0);
}

.picker-title,
.picker-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.picker-map {
  min-height: 320px;
  overflow: hidden;
  border: 1px solid rgba(255, 248, 239, 0.2);
  border-radius: 8px;
  background: #ecd7be;
}

.picker-actions p {
  min-width: 0;
  color: rgba(255, 248, 239, 0.72);
  font-size: 0.78rem;
  font-weight: 750;
}

.picker-actions .primary-button {
  flex: 0 0 148px;
}

.detail-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 45;
  width: min(100vw, 430px);
  max-height: min(88dvh, 760px);
  overflow: hidden;
  color: var(--paper);
  border-top: 5px solid var(--owner-color, var(--rose));
  border-radius: 8px 8px 0 0;
  background:
    linear-gradient(180deg, rgba(48, 40, 95, 0.98), rgba(33, 27, 70, 0.98)),
    var(--deep);
  box-shadow: 0 -22px 48px rgba(11, 9, 29, 0.34);
  transform: translate(-50%, 110%);
  transition: transform 180ms ease;
}

.detail-sheet.is-open {
  transform: translate(-50%, 0);
}

.detail-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
}

.detail-image {
  display: block;
  width: 100%;
  height: min(52dvh, 420px);
  object-fit: cover;
  cursor: zoom-in;
  background: rgba(255, 248, 239, 0.16);
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 220ms ease, visibility 220ms;
  align-items: center;
  justify-content: center;
  padding: max(18px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: rgba(8, 7, 18, 0.88);
}

.image-viewer.is-open {
  display: flex;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.image-viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
}

.image-viewer-close {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 101;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.94);
  background: rgba(255, 255, 255, 0.16);
  font-size: 2rem;
  line-height: 1;
  backdrop-filter: blur(10px);
}

body.is-viewing-image {
  overflow: hidden;
}

.detail-content {
  display: grid;
  gap: 9px;
  padding: 14px 16px max(18px, env(safe-area-inset-bottom));
}

.detail-content .owner-badge {
  position: static;
  justify-self: start;
  color: var(--deep);
}

.detail-content h2 {
  font-size: 1.25rem;
  line-height: 1.18;
}

.detail-meta {
  color: rgba(255, 248, 239, 0.72);
  font-size: 0.82rem;
  font-weight: 800;
}

.detail-note {
  color: rgba(255, 248, 239, 0.86);
  font-size: 0.92rem;
  line-height: 1.55;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 900;
}

.secondary-button {
  color: var(--paper);
  border: 1px solid rgba(255, 248, 239, 0.22);
  background: rgba(255, 255, 255, 0.1);
}

.danger-button {
  color: var(--paper);
  background: rgba(220, 99, 118, 0.8);
}

.secondary-button svg,
.danger-button svg {
  width: 18px;
  height: 18px;
}

.profile-sheet {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 50;
  width: min(calc(100vw - 28px), 390px);
  padding: 18px;
  color: var(--paper);
  border: 1px solid rgba(255, 248, 239, 0.2);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(48, 40, 95, 0.98), rgba(33, 27, 70, 0.98)),
    var(--deep);
  box-shadow: 0 22px 60px rgba(11, 9, 29, 0.42);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -46%) scale(0.98);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.profile-sheet.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.profile-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.profile-form label {
  display: grid;
  gap: 6px;
}

.profile-form label > span {
  color: rgba(255, 248, 239, 0.75);
  font-size: 0.76rem;
  font-weight: 850;
}

.profile-form input {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(255, 248, 239, 0.18);
  border-radius: 8px;
  outline: 0;
  color: var(--paper);
  background: rgba(255, 255, 255, 0.1);
  padding: 10px 12px;
}

.profile-form input::placeholder {
  color: rgba(255, 248, 239, 0.42);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: rgba(255, 248, 239, 0.34);
}

.sheet-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.memory-form {
  display: grid;
  gap: 12px;
}

.memory-form label {
  display: grid;
  gap: 6px;
}

.memory-form label > span,
.photo-picker > span:last-child {
  color: rgba(255, 248, 239, 0.75);
  font-size: 0.76rem;
  font-weight: 800;
}

.memory-form input,
.memory-form select,
.memory-form textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255, 248, 239, 0.18);
  border-radius: 8px;
  outline: 0;
  color: var(--paper);
  background: rgba(255, 255, 255, 0.1);
  padding: 10px 12px;
}

.memory-form input::placeholder,
.memory-form textarea::placeholder {
  color: rgba(255, 248, 239, 0.42);
}

.memory-form textarea {
  min-height: 82px;
  resize: vertical;
}

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

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

.color-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 248, 239, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.color-control > span {
  min-width: 0;
  color: rgba(255, 248, 239, 0.75);
  font-size: 0.76rem;
  font-weight: 850;
}

.color-input {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
}

.color-input input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.color-input span {
  display: block;
  width: 34px;
  height: 34px;
  border: 2px solid rgba(255, 248, 239, 0.8);
  border-radius: 50%;
  box-shadow: 0 8px 18px rgba(11, 9, 29, 0.2);
}

.coordinate-row {
  display: grid;
  gap: 10px;
}

.map-pick-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid rgba(255, 248, 239, 0.2);
  border-radius: 999px;
  color: var(--paper);
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.82rem;
  font-weight: 850;
}

.map-pick-button svg {
  width: 18px;
  height: 18px;
}

.photo-picker {
  grid-template-columns: 86px 1fr;
  align-items: center;
  min-height: 86px;
  padding: 10px;
  border: 1px dashed rgba(255, 248, 239, 0.32);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.photo-picker input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-preview {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  overflow: hidden;
  border-radius: 8px;
  color: var(--deep);
  background: var(--paper);
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.primary-button {
  gap: 8px;
  min-height: 48px;
  border-radius: 999px;
  color: var(--deep);
  background: linear-gradient(140deg, var(--apricot), var(--sun));
  font-size: 0.95rem;
  font-weight: 900;
  box-shadow: 0 14px 30px rgba(248, 137, 73, 0.28);
}

@media (min-width: 720px) {
  body {
    display: grid;
    place-items: center;
    min-height: 100dvh;
    padding: 28px;
  }

  .app-shell {
    border-radius: 28px;
  }
}

@media (max-width: 360px) {
  .app-shell {
    padding-inline: 10px;
  }

  .orbit-strip {
    grid-template-columns: 48px 1fr;
  }

  .mini-planet {
    width: 48px;
    height: 48px;
  }

  .album-grid {
    grid-auto-rows: 184px;
  }

  .color-settings,
  .form-grid {
    gap: 8px;
  }

  .picker-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .picker-actions .primary-button {
    flex: 0 0 auto;
    width: 100%;
  }
}

/* Practical UI pass: quieter, denser, and closer to a real mobile album app. */
:root {
  --ink: #211f2d;
  --deep: #2d2942;
  --night: #49425f;
  --sun: #ec7f48;
  --apricot: #f8c27a;
  --rose: #c85667;
  --sage: #3f9f91;
  --paper: #fffaf3;
  --surface: #fffdf8;
  --surface-2: #f7efe5;
  --muted: #77707f;
  --line: rgba(33, 31, 45, 0.12);
  --shadow: 0 14px 36px rgba(45, 41, 66, 0.16);
}

body {
  background:
    linear-gradient(180deg, rgba(248, 194, 122, 0.22), rgba(248, 194, 122, 0) 32%),
    #ede6dc;
}

.app-shell {
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  padding: max(14px, env(safe-area-inset-top)) 14px max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #fbf2e7 0%, #f8efe5 44%, #f1e6dc 100%);
  color: var(--ink);
}

.sky-glow,
.stars {
  display: none;
}

.topbar {
  min-height: 48px;
  color: var(--ink);
}

.eyebrow {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

h1 {
  font-size: clamp(1.42rem, 6vw, 1.86rem);
  line-height: 1.12;
}

.icon-button {
  width: 40px;
  height: 40px;
  color: var(--paper);
  background: var(--deep);
  box-shadow: 0 8px 18px rgba(45, 41, 66, 0.16);
}

.orbit-strip {
  grid-template-columns: 42px 1fr;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.82);
  box-shadow: 0 8px 20px rgba(45, 41, 66, 0.06);
  backdrop-filter: none;
}

.mini-planet {
  width: 42px;
  height: 42px;
  background: linear-gradient(150deg, #f8c27a 0%, #ec7f48 58%, #c85667 100%);
  box-shadow: inset -6px -8px 14px rgba(45, 41, 66, 0.14);
}

.mini-planet::before {
  inset: 19px -5px auto;
  height: 5px;
  opacity: 0.72;
}

.mini-planet span {
  right: 9px;
  top: 10px;
  width: 7px;
  height: 15px;
}

.mini-planet span::after {
  left: -4px;
  top: -5px;
  width: 10px;
  height: 10px;
  box-shadow: 5px 1px 0 rgba(200, 86, 103, 0.82);
}

.orbit-title {
  font-size: 0.86rem;
}

.orbit-meta {
  color: var(--muted);
  font-size: 0.74rem;
}

.filter-row {
  gap: 6px;
  margin: 10px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.74);
}

.filter-chip {
  min-height: 32px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 0.78rem;
  backdrop-filter: none;
}

.filter-chip.is-active {
  color: var(--paper);
  background: var(--deep);
  box-shadow: 0 6px 14px rgba(45, 41, 66, 0.12);
}

.view-map {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

#memoryMap {
  min-height: 390px;
  background: #eadfce;
}

.leaflet-tile {
  filter: saturate(0.78) sepia(0.08) contrast(0.96);
}

.memory-marker {
  width: 48px;
  height: 48px;
  border-width: 3px;
  box-shadow: 0 8px 18px rgba(45, 41, 66, 0.22);
}

.map-floating {
  left: 8px;
  right: 8px;
  bottom: 8px;
  padding: 8px 10px;
  color: var(--paper);
  border: 0;
  background: rgba(45, 41, 66, 0.86);
  backdrop-filter: none;
}

.album-grid,
.timeline-list {
  padding: 0 0 92px;
}

.album-grid {
  grid-auto-rows: 184px;
  gap: 9px;
}

.photo-card {
  border-width: 2px;
  background: var(--surface);
  box-shadow: 0 10px 20px rgba(45, 41, 66, 0.1);
}

.photo-card::after {
  inset: 44% 0 0;
  background: linear-gradient(180deg, transparent, rgba(33, 31, 45, 0.72));
}

.owner-badge {
  top: 7px;
  left: 7px;
  min-height: 24px;
  padding: 0 7px;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.9);
  font-size: 0.66rem;
}

.photo-caption {
  inset: auto 9px 9px;
}

.timeline-list {
  gap: 8px;
}

.timeline-item {
  grid-template-columns: 76px 1fr;
  min-height: 102px;
  padding: 9px;
  border-color: var(--line);
  background: rgba(255, 253, 248, 0.86);
  box-shadow: 0 8px 18px rgba(45, 41, 66, 0.07);
}

.timeline-item img {
  width: 76px;
  height: 84px;
}

.timeline-text time {
  color: var(--rose);
}

.timeline-text h3 {
  color: var(--ink);
  font-size: 0.94rem;
}

.timeline-text p,
.timeline-meta {
  color: var(--muted);
}

.bottom-nav {
  min-height: 64px;
  margin-top: 10px;
  padding: 7px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.92);
  box-shadow: 0 10px 26px rgba(45, 41, 66, 0.12);
  backdrop-filter: none;
}

.nav-item {
  height: 48px;
  color: var(--muted);
}

.nav-item.is-active {
  color: var(--paper);
  background: var(--deep);
}

.nav-add {
  height: 52px;
  color: var(--paper);
  background: var(--sun);
  box-shadow: 0 8px 18px rgba(236, 127, 72, 0.22);
}

.sheet-backdrop {
  background: rgba(33, 31, 45, 0.44);
  backdrop-filter: blur(3px);
}

.add-sheet,
.picker-sheet,
.detail-sheet,
.profile-sheet {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 -18px 42px rgba(45, 41, 66, 0.18);
}

.add-sheet,
.picker-sheet,
.detail-sheet {
  border-radius: 12px 12px 0 0;
}

.profile-sheet {
  border-color: var(--line);
}

.sheet-title h2,
.picker-title h2,
.detail-content h2 {
  color: var(--ink);
}

.icon-button.dark {
  color: var(--ink);
  background: rgba(45, 41, 66, 0.08);
}

.sheet-handle {
  background: rgba(45, 41, 66, 0.22);
}

.memory-form label > span,
.photo-picker > span:last-child,
.profile-form label > span,
.color-control > span {
  color: var(--muted);
}

.memory-form input,
.memory-form select,
.memory-form textarea,
.profile-form input {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(45, 41, 66, 0.04);
}

.memory-form input::placeholder,
.memory-form textarea::placeholder,
.profile-form input::placeholder {
  color: rgba(119, 112, 127, 0.62);
}

.photo-picker,
.color-control,
.map-pick-button {
  border-color: var(--line);
  background: rgba(45, 41, 66, 0.04);
}

.map-pick-button {
  color: var(--deep);
}

.primary-button {
  color: var(--paper);
  background: var(--deep);
  box-shadow: 0 10px 24px rgba(45, 41, 66, 0.14);
}

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

.memory-form > .form-grid label:nth-child(3) {
  grid-column: 1 / -1;
}

.detail-image {
  background: var(--surface-2);
}

.detail-meta,
.detail-note,
.picker-actions p {
  color: var(--muted);
}

.detail-content .owner-badge {
  color: var(--ink);
  background: var(--surface-2);
}

.secondary-button {
  color: var(--deep);
  border-color: var(--line);
  background: rgba(45, 41, 66, 0.05);
}

.danger-button {
  background: #c85667;
}

@media (min-width: 720px) {
  .app-shell {
    border-radius: 24px;
  }
}

@media (max-width: 380px) {
  .album-grid {
    grid-auto-rows: 168px;
  }

  .detail-actions {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 900px) and (orientation: landscape) {
  body {
    overflow: hidden;
  }

  .app-shell {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    min-height: 0;
    margin: 0;
    padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
      max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
    display: grid;
    grid-template-columns: minmax(300px, min(430px, 34vw)) minmax(0, 1fr);
    grid-template-rows: auto auto auto 1fr auto;
    gap: 12px 16px;
    border-radius: 0;
  }

  .topbar,
  .orbit-strip,
  .filter-row,
  .bottom-nav {
    grid-column: 1;
  }

  .topbar {
    align-self: start;
  }

  .orbit-strip {
    margin-top: 0;
  }

  .filter-row {
    margin: 0;
  }

  .bottom-nav {
    align-self: end;
    margin-top: 0;
  }

  .view {
    grid-column: 2;
    grid-row: 1 / -1;
    min-height: 0;
    height: 100%;
  }

  .view-message {
    display: block;
    grid-column: 1;
    grid-row: 4;
    height: 100%;
    overflow: hidden;
  }

  .view-message.is-active {
    display: block;
  }

  .view-map {
    height: 100%;
  }

  #memoryMap {
    height: 100%;
    min-height: 0;
  }

  .map-floating {
    right: auto;
    max-width: min(520px, calc(100% - 16px));
  }

  .album-grid,
  .timeline-list,
  .message-list {
    height: 100%;
    padding-bottom: 0;
    overflow: auto;
  }

  .message-board {
    height: 100%;
  }

  .message-toggle {
    min-height: 52px;
    padding: 10px 12px;
    color: var(--ink);
    border-color: var(--line);
    background: rgba(255, 253, 248, 0.9);
    backdrop-filter: none;
  }

  .message-toggle small {
    color: var(--muted);
  }

  .message-panel {
    min-height: 0;
  }

  .message-form {
    padding: 10px;
  }

  .message-form textarea {
    min-height: 68px;
  }

  .message-photo-preview {
    min-height: 76px;
  }

  .message-photo-preview img {
    height: 104px;
  }

  .album-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: minmax(190px, 1fr);
  }

  .timeline-list {
    max-width: 760px;
    margin: 0 auto;
  }

  .timeline-item {
    grid-template-columns: 116px 1fr;
    min-height: 132px;
  }

  .timeline-item img {
    width: 116px;
    height: 112px;
  }

  .add-sheet,
  .picker-sheet,
  .detail-sheet {
    left: auto;
    right: 0;
    bottom: 0;
    top: 0;
    width: min(430px, 42vw);
    height: 100dvh;
    max-height: none;
    border-radius: 12px 0 0 12px;
    transform: translateX(110%);
  }

  .add-sheet.is-open,
  .picker-sheet.is-open,
  .detail-sheet.is-open {
    transform: translateX(0);
  }

  .picker-sheet {
    width: min(620px, 54vw);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .picker-map {
    min-height: 0;
  }

  .detail-image {
    height: min(48dvh, 380px);
  }
}

@media (min-width: 1180px) and (orientation: landscape) {
  .album-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Together-cities layer and manager. */
.city-layer-control {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 700;
  display: flex;
  align-items: stretch;
  width: min(244px, calc(100% - 64px));
  min-height: 50px;
  overflow: hidden;
  border: 1px solid rgba(33, 31, 45, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 8px 20px rgba(45, 41, 66, 0.14);
}

.city-layer-manage {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 7px 8px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.city-layer-manage > svg {
  width: 21px;
  height: 21px;
  color: var(--sun);
}

.city-layer-manage > span {
  display: grid;
  min-width: 0;
}

.city-layer-manage strong,
.city-layer-manage small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.city-layer-manage strong {
  font-size: 0.78rem;
}

.city-layer-manage small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 750;
}

.city-layer-switch {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  flex: 0 0 62px;
  min-width: 0;
  padding: 5px 7px;
  border-left: 1px solid var(--line);
  cursor: pointer;
}

.city-layer-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.city-layer-switch > span {
  position: relative;
  width: 34px;
  height: 19px;
  border-radius: 999px;
  background: rgba(119, 112, 127, 0.34);
  transition: background 150ms ease;
}

.city-layer-switch > span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fffdf8;
  box-shadow: 0 2px 5px rgba(45, 41, 66, 0.2);
  transition: transform 150ms ease;
}

.city-layer-switch input:checked + span {
  background: var(--sage);
}

.city-layer-switch input:checked + span::after {
  transform: translateX(15px);
}

.city-layer-switch input:focus-visible + span {
  outline: 2px solid var(--deep);
  outline-offset: 2px;
}

.city-layer-switch em {
  color: var(--muted);
  font-size: 0.58rem;
  font-style: normal;
  font-weight: 800;
}

.city-layer-control.is-layer-hidden .city-layer-manage > svg {
  color: var(--muted);
}

.visited-city-tooltip {
  color: var(--ink);
  border: 0;
  border-radius: 6px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 6px 16px rgba(45, 41, 66, 0.16);
  font-size: 0.74rem;
  font-weight: 850;
}

.visited-city-popup {
  display: grid;
  grid-template-columns: 9px 1fr;
  column-gap: 8px;
  min-width: 142px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--surface);
}

.visited-city-popup > span {
  grid-row: 1 / 3;
  align-self: stretch;
  border-radius: 999px;
  background: var(--city-color, var(--sun));
}

.visited-city-popup strong,
.visited-city-popup small {
  min-width: 0;
}

.visited-city-popup strong {
  font-size: 0.88rem;
}

.visited-city-popup small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.7rem;
}

.city-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 46;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 12px;
  width: min(100vw, 430px);
  height: min(84dvh, 760px);
  padding: 9px 16px max(18px, env(safe-area-inset-bottom));
  overflow: hidden;
  color: var(--ink);
  border-radius: 12px 12px 0 0;
  background: var(--surface);
  box-shadow: 0 -18px 42px rgba(45, 41, 66, 0.2);
  transform: translate(-50%, 110%);
  transition: transform 180ms ease;
}

.city-sheet.is-open {
  transform: translate(-50%, 0);
}

.city-sheet .sheet-handle {
  margin-bottom: 0;
  background: rgba(45, 41, 66, 0.22);
}

.city-sheet .sheet-title {
  margin-bottom: 0;
}

.city-sheet .sheet-title h2 {
  color: var(--ink);
}

.city-sheet-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  padding: 0 2px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.city-sheet-summary b {
  color: var(--ink);
  font-size: 1rem;
}

.city-boundary-status {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.city-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.city-form label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.city-form label > span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
}

.city-form select,
.city-form input[type="date"] {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 32px 8px 10px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: 0;
  background: var(--surface);
}

.city-form select:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(63, 159, 145, 0.14);
}

.city-form select:disabled {
  color: rgba(119, 112, 127, 0.64);
}

.city-date-field {
  grid-column: 1 / -1;
}

.city-form .primary-button {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 42px;
}

.city-form .primary-button:disabled {
  opacity: 0.48;
  cursor: default;
}

.visited-city-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding: 1px 2px 6px;
}

.visited-city-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  min-height: 56px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-left: 4px solid var(--city-color, var(--sun));
  border-radius: 8px;
  background: var(--surface);
}

.visited-city-focus {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-width: 0;
  padding: 9px 10px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.visited-city-focus > span:last-child {
  display: grid;
  min-width: 0;
}

.visited-city-focus strong,
.visited-city-focus small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visited-city-focus strong {
  font-size: 0.86rem;
}

.visited-city-focus small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.68rem;
}

.visited-city-swatch {
  width: 22px;
  height: 22px;
  border: 5px solid color-mix(in srgb, var(--city-color) 24%, white);
  border-radius: 50%;
  background: var(--city-color);
}

.visited-city-remove {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--muted);
  border-radius: 50%;
  background: transparent;
}

.visited-city-remove:hover,
.visited-city-remove:focus-visible {
  color: var(--rose);
  background: rgba(200, 86, 103, 0.1);
}

.visited-city-remove svg {
  width: 17px;
  height: 17px;
}

.city-empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 132px;
  color: var(--muted);
  border: 1px dashed rgba(119, 112, 127, 0.32);
  border-radius: 8px;
  background: rgba(247, 239, 229, 0.54);
  text-align: center;
}

.city-empty-state svg {
  width: 26px;
  height: 26px;
  color: var(--sun);
}

.city-empty-state strong {
  font-size: 0.82rem;
}

@media (max-width: 380px) {
  .city-layer-control {
    width: min(226px, calc(100% - 58px));
  }

  .city-layer-manage {
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 5px;
    padding-inline: 6px;
  }

  .city-layer-switch {
    flex-basis: 56px;
  }

  .city-form {
    grid-template-columns: 1fr;
  }

  .city-form .primary-button {
    grid-column: 1;
  }
}

@media (min-width: 900px) and (orientation: landscape) {
  .city-sheet {
    left: auto;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(430px, 42vw);
    height: 100dvh;
    border-radius: 12px 0 0 12px;
    transform: translateX(110%);
  }

  .city-sheet.is-open {
    transform: translateX(0);
  }
}

.add-sheet,
.detail-sheet,
.picker-sheet,
.city-sheet {
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.view.is-active {
  animation: view-arrive 200ms ease-out both;
}

.memory-marker {
  animation: marker-arrive 240ms ease-out;
}

.nav-item,
.primary-button,
.icon-button,
.filter-chip {
  transition: background-color 180ms ease, color 180ms ease, opacity 180ms ease;
  touch-action: manipulation;
}

.primary-button:disabled {
  opacity: 0.65;
  cursor: progress;
}

.primary-button[aria-busy="true"] svg {
  animation: busy-pulse 900ms ease-in-out infinite alternate;
}

@keyframes view-arrive {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes marker-arrive {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes busy-pulse {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
