:root {
  --paper: #fcfaf7;
  --paper-deep: #f5f0eb;
  --ink: #282421;
  --muted: #817970;
  --line: #e7dfd7;
  --berry: #a65d68;
  --berry-dark: #81424c;
  --berry-soft: #f4e9eb;
  --sage: #66776b;
  --sage-dark: #4c5d52;
  --sage-soft: #eaf0eb;
  --white: #ffffff;
  --danger: #a23f46;
  --shadow: 0 18px 52px rgba(69, 54, 45, 0.08);
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Noto Sans SC",
    "Helvetica Neue", Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

body.sheet-open {
  overflow: hidden;
}

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

button {
  color: inherit;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--berry);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.16em;
  line-height: 1.2;
}

.text-button,
.icon-button,
.shuffle-button,
.nav-button,
.add-button,
.sheet-close,
.type-option,
.image-picker,
.remove-image,
.detail-actions button,
.filter-chip {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.primary-button,
.secondary-button,
.danger-button,
.save-button {
  min-height: 48px;
  appearance: none;
  border: 0;
  border-radius: 15px;
  cursor: pointer;
  font-weight: 650;
}

.primary-button {
  width: 100%;
  background: var(--ink);
  color: var(--white);
  box-shadow: 0 8px 22px rgba(40, 36, 33, 0.14);
}

.secondary-button {
  padding: 0 18px;
  border: 1px solid var(--line);
  background: var(--white);
}

.danger-button {
  padding: 0 18px;
  background: var(--danger);
  color: var(--white);
}

.save-button {
  min-width: 62px;
  min-height: 38px;
  padding: 0 13px;
  background: var(--berry);
  color: var(--white);
  border-radius: 12px;
}

.save-button:disabled,
.primary-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.auth-view {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: calc(36px + var(--safe-top)) 24px calc(36px + var(--safe-bottom));
  background: var(--paper);
}

.auth-card {
  width: min(100%, 390px);
}

.brand-mark {
  position: relative;
  width: 55px;
  height: 36px;
  margin-bottom: 30px;
}

.brand-mark span {
  position: absolute;
  top: 4px;
  width: 31px;
  height: 31px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.brand-mark span:first-child {
  left: 0;
  color: var(--berry);
}

.brand-mark span:last-child {
  right: 0;
  color: var(--sage);
}

.auth-card h1,
.app-header h1,
.section-heading h2,
.archive-intro h2,
.settings-page h2,
.type-sheet h2,
.sheet-header h2,
.confirm-dialog h2 {
  font-family: var(--serif);
  font-weight: 650;
}

.auth-card h1 {
  margin: 0;
  font-size: clamp(42px, 13vw, 58px);
  letter-spacing: -0.06em;
  line-height: 1.05;
}

.auth-copy {
  max-width: 310px;
  margin: 18px 0 42px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.8;
}

.login-form > label {
  display: block;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 650;
}

.token-field,
.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.token-field input {
  width: 100%;
  height: 54px;
  padding: 0 72px 0 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 16px;
}

.token-field .text-button {
  position: absolute;
  right: 8px;
  min-width: 52px;
  height: 40px;
  color: var(--muted);
  font-size: 13px;
}

.login-form .primary-button {
  margin-top: 12px;
}

.form-error {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

.privacy-note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.app-view {
  min-height: 100vh;
  min-height: 100svh;
  padding-bottom: calc(136px + var(--safe-bottom));
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: calc(64px + var(--safe-top));
  padding: calc(10px + var(--safe-top)) 20px 10px;
  border-bottom: 1px solid rgba(231, 223, 215, 0.74);
  background: rgba(252, 250, 247, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.app-header h1 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -0.04em;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

.app-main {
  width: min(100%, 720px);
  margin: 0 auto;
  padding-top: var(--safe-top);
}

.app-view.page-header-visible .app-main {
  padding-top: 0;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.search-panel {
  padding: 18px 20px 2px;
}

.search-panel > label {
  display: block;
  margin-bottom: 9px;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 650;
}

.search-field svg {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.search-field input {
  width: 100%;
  height: 48px;
  padding: 0 66px 0 43px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  color: var(--ink);
  font-size: 16px;
}

.search-field .text-button {
  position: absolute;
  right: 8px;
  height: 38px;
  color: var(--muted);
  font-size: 13px;
}

.random-section,
.archive-section,
.settings-page,
.map-page {
  padding: 30px 20px 0;
}

.home-page {
  padding: 30px 0 24px;
}

.home-intro {
  padding: 0 20px 8px;
}

.home-intro > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.home-shelf {
  margin-top: 34px;
}

.home-shelf + .home-shelf {
  margin-top: 42px;
}

.home-shelf-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  padding: 0 20px;
}

.home-shelf-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.04em;
}

.home-see-all {
  min-height: 36px;
  appearance: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--berry-dark);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.home-rail {
  display: grid;
  padding: 0 20px 8px;
  grid-auto-flow: column;
  grid-auto-columns: min(76vw, 300px);
  gap: 12px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-padding-inline: 20px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.home-rail::-webkit-scrollbar {
  display: none;
}

.home-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 21px;
  background: var(--white);
  cursor: pointer;
  scroll-snap-align: start;
}

.home-card:active {
  transform: scale(0.995);
}

.home-card-image,
.home-card-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
}

.home-card-image {
  display: block;
  object-fit: cover;
  background: var(--paper-deep);
}

.home-card-placeholder {
  display: grid;
  place-items: center;
  border-bottom: 1px solid var(--line);
}

.home-card-placeholder.movie {
  background: #f7edef;
  color: var(--berry-dark);
}

.home-card-placeholder.place {
  background: #edf2ee;
  color: var(--sage-dark);
}

.home-card-placeholder span {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 23px;
}

.home-card-body {
  min-height: 116px;
  padding: 15px 16px 17px;
}

.home-card-meta {
  display: flex;
  min-height: 24px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}

.home-card-meta .planned-badge {
  min-height: 22px;
}

.home-card h3 {
  display: -webkit-box;
  overflow: hidden;
  margin: 7px 0 0;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.home-card-body > p {
  overflow: hidden;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-rail-empty,
.home-rail-skeleton {
  width: min(82vw, 320px);
  min-height: 250px;
  scroll-snap-align: start;
}

.home-rail-empty {
  display: grid;
  padding: 26px;
  place-content: center;
  justify-items: center;
  border: 1px dashed #d9cec4;
  border-radius: 21px;
  text-align: center;
}

.home-rail-empty > span {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 13px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--sage);
  font-family: var(--serif);
  font-size: 20px;
}

.home-rail-empty strong {
  font-family: var(--serif);
  font-size: 17px;
}

.home-rail-empty button {
  margin-top: 14px;
  appearance: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--berry-dark);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.home-rail-skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 21px;
  background: var(--paper-deep);
}

.section-heading,
.archive-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading h2,
.archive-intro h2,
.settings-page h2 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -0.04em;
}

.shuffle-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
  color: var(--berry-dark);
  font-size: 12px;
  font-weight: 650;
}

.shuffle-button svg {
  width: 17px;
  height: 17px;
}

.random-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--white);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.random-card-image {
  width: 100%;
  aspect-ratio: 16 / 11;
  object-fit: cover;
  background: var(--paper-deep);
}

.random-card-body {
  padding: 18px 19px 20px;
}

.memory-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.memory-kind,
.planned-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  letter-spacing: 0;
}

.memory-kind.movie {
  background: var(--berry-soft);
  color: var(--berry-dark);
}

.memory-kind.place {
  background: var(--sage-soft);
  color: var(--sage-dark);
}

.planned-badge {
  background: #f2eee6;
  color: #746856;
}

.random-card h3,
.memory-card h3,
.detail-body h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 650;
  letter-spacing: -0.035em;
}

.random-card h3 {
  font-size: 29px;
  line-height: 1.23;
}

.memory-quote {
  margin: 12px 0 0;
  color: #5c544d;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.65;
}

.memory-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 12px;
}

.memory-facts span {
  position: relative;
}

.memory-facts span + span::before {
  position: absolute;
  left: -7px;
  content: "·";
}

.random-empty,
.feed-empty {
  padding: 34px 24px;
  border: 1px dashed #d9cec4;
  border-radius: 22px;
  text-align: center;
}

.random-empty {
  background: var(--paper);
}

.random-empty .empty-symbol,
.feed-empty .empty-symbol {
  display: grid;
  width: 46px;
  height: 46px;
  margin: 0 auto 16px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--berry);
  font-family: var(--serif);
  font-size: 23px;
}

.random-empty h3,
.feed-empty h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
}

.random-empty p,
.feed-empty p {
  margin: 9px auto 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.archive-section {
  padding-top: 32px;
}

.archive-count {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.filter-chips {
  display: flex;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.58);
}

.filter-chip {
  min-width: 46px;
  min-height: 33px;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 12px;
}

.filter-chip.active {
  background: var(--ink);
  color: var(--white);
}

.memory-feed {
  position: relative;
  padding-bottom: 10px;
}

.memory-feed.timeline::before {
  position: absolute;
  top: 14px;
  bottom: 22px;
  left: 60px;
  width: 1px;
  background: #d9d0c8;
  content: "";
}

.memory-day-group {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 26px;
  padding: 10px 0 18px;
}

.memory-day-group::before {
  position: absolute;
  z-index: 1;
  top: 18px;
  left: 56px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--berry);
  border-radius: 50%;
  background: var(--paper);
  content: "";
}

.memory-date {
  display: block;
  align-self: start;
  padding-top: 1px;
  color: var(--ink);
  font-style: normal;
  text-align: right;
}

.memory-date > span {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 3px;
  white-space: nowrap;
}

.memory-date strong {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.07em;
  line-height: 0.95;
}

.memory-date em {
  color: #5f5750;
  font-size: 11px;
  font-style: normal;
  font-weight: 650;
}

.memory-date small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.02em;
}

.memory-day-cards {
  min-width: 0;
}

.memory-card {
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--white);
  cursor: pointer;
}

.memory-day-cards .memory-card:last-child {
  margin-bottom: 0;
}

.memory-card:active,
.random-card:active {
  transform: scale(0.995);
}

.memory-card-image {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--paper-deep);
}

.memory-card-body {
  padding: 16px 17px 17px;
}

.memory-card.no-image.movie {
  border-left: 3px solid var(--berry);
  background: #fffafb;
}

.memory-card.no-image.place {
  border-left: 3px solid var(--sage);
  background: #fbfdfb;
}

.memory-card h3 {
  display: -webkit-box;
  overflow: hidden;
  font-size: 22px;
  line-height: 1.28;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.memory-card .memory-quote {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 9px;
  font-size: 14px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.load-more {
  display: block;
  width: 100%;
  margin: 5px 0 26px;
}

.settings-page {
  padding-top: 38px;
}

.map-page {
  padding-top: 38px;
}

.map-page-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 29px;
  font-weight: 650;
  letter-spacing: -0.045em;
}

.map-summary {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 0 13px;
}

.map-filter-chips {
  display: flex;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--white);
}

.map-filter-chip {
  min-width: 49px;
  min-height: 34px;
  appearance: none;
  padding: 0 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.map-filter-chip.active {
  background: var(--ink);
  color: var(--white);
}

.year-filter select {
  min-height: 42px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  color: var(--ink);
  font-size: 12px;
}

.footprint-map-card {
  position: relative;
  overflow: hidden;
  padding: 10px 10px 14px;
  border: 1px solid var(--line);
  border-radius: 23px;
  background: #f8f5f1;
}

.footprint-map {
  position: relative;
  display: block;
  width: 100%;
  height: 300px;
  min-height: 300px;
  overflow: hidden;
  border-radius: 16px;
}

.footprint-map svg {
  fill: initial;
  stroke: initial;
  stroke-width: initial;
  stroke-linecap: initial;
  stroke-linejoin: initial;
}

.footprint-map .jvm-container {
  touch-action: pan-y pinch-zoom;
}

.footprint-map .jvm-region {
  transition: fill 160ms ease;
}

.footprint-map .jvm-marker {
  cursor: pointer;
  transform-box: fill-box;
  transform-origin: center;
  animation: marker-in 430ms ease both;
  transition: filter 160ms ease, opacity 160ms ease;
}

.footprint-map .jvm-marker.is-selected {
  filter: drop-shadow(0 0 2px rgba(37, 34, 31, 0.8)) drop-shadow(0 2px 4px rgba(37, 34, 31, 0.24));
}

.footprint-map .jvm-marker:focus-visible {
  outline: none;
  filter: drop-shadow(0 0 3px rgba(145, 68, 94, 0.95));
}

.footprint-map .jvm-zoom-btn {
  display: grid;
  width: 31px;
  height: 31px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(208, 199, 190, 0.9);
  border-radius: 10px;
  background: rgba(255, 253, 250, 0.94);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 500;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(45, 39, 35, 0.07);
}

.footprint-map .jvm-zoom-btn.jvm-zoomin {
  top: 12px;
  left: 12px;
}

.footprint-map .jvm-zoom-btn.jvm-zoomout {
  top: 49px;
  left: 12px;
}

.jvm-tooltip {
  padding: 7px 9px;
  border: 1px solid rgba(208, 199, 190, 0.9);
  border-radius: 9px;
  background: rgba(39, 35, 32, 0.94);
  color: #fffdf9;
  font-family: var(--sans);
  font-size: 11px;
  line-height: 1.35;
  box-shadow: 0 5px 18px rgba(39, 35, 32, 0.18);
}

.map-view-toggle {
  position: absolute;
  z-index: 2;
  top: 20px;
  right: 20px;
  min-height: 31px;
  padding: 0 10px;
  border: 1px solid rgba(208, 199, 190, 0.9);
  border-radius: 10px;
  background: rgba(255, 253, 250, 0.94);
  color: var(--ink);
  cursor: pointer;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 8px rgba(45, 39, 35, 0.07);
}

.map-view-toggle:focus-visible {
  outline: 2px solid var(--berry);
  outline-offset: 2px;
}

.map-library-error {
  display: grid;
  height: 100%;
  margin: 0;
  padding: 24px;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.map-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: -3px;
  color: var(--muted);
  font-size: 11px;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.legend-dot.visited {
  background: var(--sage);
}

.legend-dot.planned {
  border: 2px solid var(--berry);
  background: transparent;
}

.map-disclaimer {
  margin: 9px 0 0;
  color: #9a928a;
  font-size: 9px;
  letter-spacing: 0.04em;
  text-align: center;
}

.map-loading {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(248, 245, 241, 0.9);
  color: var(--muted);
  font-family: var(--serif);
  font-size: 15px;
}

.city-index-panel {
  margin-top: 15px;
}

.map-empty-state {
  padding: 30px 22px;
  border: 1px dashed #d9cec4;
  border-radius: 20px;
  text-align: center;
}

.map-empty-state > span {
  display: grid;
  width: 42px;
  height: 42px;
  margin: 0 auto 13px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--sage);
  font-size: 19px;
}

.map-empty-state h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 18px;
}

.map-empty-state p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

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

.selected-city-header h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 25px;
}

.selected-city-header p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.city-index-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 30px 2px 12px;
}

.city-index-heading h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 25px;
}

.city-index-heading > p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.city-index-list {
  overflow: hidden;
  border-block: 1px solid var(--line);
}

.city-index-item + .city-index-item {
  border-top: 1px solid var(--line);
}

.city-index-row {
  display: flex;
  width: 100%;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  appearance: none;
  padding: 13px 2px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.city-index-row > span:first-child {
  min-width: 0;
}

.city-index-row strong,
.city-index-row small {
  display: block;
}

.city-index-row strong {
  font-family: var(--serif);
  font-size: 19px;
}

.city-index-row small {
  overflow: hidden;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.city-index-count {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}

.city-index-count i {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  font-size: 15px;
  font-style: normal;
}

.city-index-item.selected {
  padding-bottom: 14px;
}

.city-index-preview {
  padding: 0 2px 2px;
}

.city-memory-link {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  appearance: none;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--berry-dark);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.map-memory-list {
  display: grid;
  gap: 9px;
}

.map-memory-card {
  display: grid;
  min-height: 76px;
  padding: 11px;
  grid-template-columns: 62px 1fr 20px;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
  cursor: pointer;
}

.map-memory-thumb,
.map-memory-placeholder {
  width: 62px;
  height: 54px;
  border-radius: 11px;
}

.map-memory-thumb {
  object-fit: cover;
}

.map-memory-placeholder {
  display: grid;
  place-items: center;
  background: var(--sage-soft);
  color: var(--sage-dark);
  font-family: var(--serif);
  font-size: 20px;
}

.map-memory-card strong,
.map-memory-card small {
  display: block;
}

.map-memory-card strong {
  overflow: hidden;
  margin-bottom: 5px;
  font-family: var(--serif);
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-memory-card small {
  color: var(--muted);
  font-size: 11px;
}

.map-memory-card .arrow {
  color: var(--muted);
  font-size: 17px;
}

.unmapped-panel {
  margin-top: 36px;
  padding-bottom: 28px;
}

.section-heading.compact {
  margin-bottom: 8px;
}

.section-heading.compact h2 {
  font-size: 22px;
}

.unmapped-copy {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.unmapped-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line);
}

.unmapped-row strong {
  display: block;
  font-family: var(--serif);
  font-size: 16px;
}

.unmapped-row span {
  color: var(--muted);
  font-size: 11px;
}

.settings-intro {
  max-width: 480px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

@keyframes marker-in {
  from {
    opacity: 0;
    transform: scale(0.65);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 24px 0;
}

.stat-card {
  min-height: 120px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
}

.stat-card strong {
  display: block;
  font-family: var(--serif);
  font-size: 35px;
  font-weight: 650;
  letter-spacing: -0.05em;
}

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

.stat-card:first-child {
  grid-column: 1 / -1;
  min-height: 138px;
  background: var(--ink);
  color: var(--white);
}

.stat-card:first-child span {
  color: #c8c0ba;
}

.settings-card {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
}

.settings-card + .settings-card {
  margin-top: 10px;
}

.settings-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.settings-card h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
}

.settings-card p:not(.settings-label) {
  max-width: 320px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.settings-card .danger-button {
  flex: 0 0 auto;
  min-height: 42px;
  background: transparent;
  color: var(--danger);
  border: 1px solid #e5c8cb;
}

.settings-card .sync-button {
  flex: 0 0 auto;
  min-height: 42px;
  border-color: rgba(166, 93, 104, 0.34);
  color: var(--berry-dark);
}

.settings-card .sync-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.settings-note {
  display: flex;
  gap: 11px;
  margin-top: 18px;
  padding: 2px 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.settings-note span {
  color: var(--sage);
  font-size: 19px;
}

.settings-note p {
  margin: 0;
}

.bottom-nav {
  position: fixed;
  z-index: 30;
  bottom: 0;
  left: 50%;
  display: grid;
  width: min(100%, 720px);
  height: calc(70px + var(--safe-bottom));
  padding: 7px 10px var(--safe-bottom);
  transform: translateX(-50%);
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  border-top: 1px solid rgba(231, 223, 215, 0.85);
  background: rgba(252, 250, 247, 0.94);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.nav-button {
  display: flex;
  min-height: 52px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 9.5px;
  white-space: nowrap;
}

.nav-button.active {
  color: var(--ink);
}

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

.add-button {
  position: fixed;
  z-index: 35;
  right: max(16px, calc((100vw - 720px) / 2 + 16px));
  bottom: calc(82px + var(--safe-bottom));
  display: inline-flex;
  width: auto;
  min-width: 76px;
  height: 44px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 15px 0 13px;
  border: 1px solid rgba(166, 93, 104, 0.48);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--berry-dark);
  box-shadow: 0 8px 24px rgba(69, 54, 45, 0.13);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.01em;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.add-button svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.9;
}

.add-button:active {
  transform: translateY(1px);
  border-color: var(--berry);
  box-shadow: 0 5px 16px rgba(69, 54, 45, 0.11);
}

.app-view.settings-page-visible .add-button {
  transform: translateY(8px);
  opacity: 0;
  pointer-events: none;
}

.sheet-backdrop,
.dialog-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  background: rgba(40, 36, 33, 0.34);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.sheet-backdrop {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bottom-sheet {
  position: relative;
  width: min(100%, 620px);
  padding: 12px 20px calc(28px + var(--safe-bottom));
  border-radius: 25px 25px 0 0;
  background: var(--paper);
  box-shadow: 0 -24px 70px rgba(40, 36, 33, 0.16);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  margin: 0 auto 24px;
  border-radius: 99px;
  background: #d8d0c8;
}

.sheet-close {
  position: absolute;
  top: 19px;
  right: 20px;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: var(--white);
  color: var(--muted);
  font-size: 25px;
}

.type-sheet h2 {
  margin: 0 0 24px;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.type-options {
  display: grid;
  gap: 10px;
}

.type-option {
  display: grid;
  min-height: 86px;
  padding: 14px;
  grid-template-columns: 48px 1fr 30px;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
  text-align: left;
}

.type-option .type-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 14px;
}

.movie-option .type-icon {
  background: var(--berry-soft);
  color: var(--berry-dark);
}

.place-option .type-icon {
  background: var(--sage-soft);
  color: var(--sage-dark);
}

.type-icon svg {
  width: 24px;
  height: 24px;
}

.type-option strong,
.type-option small {
  display: block;
}

.type-option strong {
  margin-bottom: 5px;
  font-family: var(--serif);
  font-size: 19px;
}

.type-option small {
  color: var(--muted);
  font-size: 12px;
}

.type-option .arrow {
  color: var(--muted);
  font-size: 20px;
}

.full-sheet-backdrop {
  align-items: stretch;
  background: rgba(40, 36, 33, 0.22);
}

.full-sheet {
  position: relative;
  overflow-y: auto;
  width: min(100%, 720px);
  max-height: 100vh;
  max-height: 100svh;
  margin: 0 auto;
  padding-bottom: calc(32px + var(--safe-bottom));
  background: var(--paper);
  overscroll-behavior: contain;
}

.sheet-header {
  position: sticky;
  z-index: 4;
  top: 0;
  display: grid;
  min-height: calc(67px + var(--safe-top));
  padding: calc(10px + var(--safe-top)) 16px 9px;
  grid-template-columns: 72px 1fr 72px;
  align-items: center;
  border-bottom: 1px solid rgba(231, 223, 215, 0.82);
  background: rgba(252, 250, 247, 0.94);
  text-align: center;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.sheet-header .text-button:first-child {
  justify-self: start;
}

.sheet-header .save-button,
.sheet-header .text-button:last-child {
  justify-self: end;
}

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

.sheet-header .eyebrow {
  margin-bottom: 2px;
  font-size: 8px;
}

.sheet-header .text-button {
  min-width: 44px;
  min-height: 44px;
  color: var(--muted);
}

.memory-form {
  padding: 18px 18px 30px;
}

.image-field {
  position: relative;
  margin-bottom: 16px;
}

.image-picker {
  display: grid;
  width: 100%;
  min-height: 195px;
  overflow: hidden;
  place-items: center;
  border: 1px dashed #d5c9bf;
  border-radius: 20px;
  background: var(--paper-deep);
  color: var(--muted);
}

.image-picker > span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.image-picker svg {
  width: 29px;
  height: 29px;
}

.image-picker img {
  width: 100%;
  height: 100%;
  min-height: 195px;
  max-height: 360px;
  object-fit: cover;
}

.remove-image {
  position: absolute;
  right: 10px;
  bottom: 10px;
  min-height: 37px;
  padding: 0 12px;
  border-radius: 12px;
  background: rgba(40, 36, 33, 0.78);
  color: var(--white);
  font-size: 12px;
}

.form-section {
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
}

.field {
  display: block;
  margin: 0 0 18px;
  border: 0;
  padding: 0;
}

.field:last-child {
  margin-bottom: 0;
}

.field > span,
.field legend {
  display: block;
  margin-bottom: 8px;
  color: #514b46;
  font-size: 13px;
  font-weight: 650;
}

.field b {
  color: var(--berry);
}

.field input[type="text"],
.field input[type="date"],
.field textarea,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 12px 13px;
  border: 1px solid #ded6cf;
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
}

.field textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.65;
}

.field textarea[rows="6"] {
  min-height: 150px;
}

.field small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.choice-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-row span {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.choice-row input:checked + span {
  border-color: var(--berry);
  background: var(--berry-soft);
  color: var(--berry-dark);
}

.detail-sheet {
  background: var(--paper);
}

.detail-header {
  grid-template-columns: 72px 1fr 72px;
}

.detail-cover {
  display: block;
  width: 100%;
  max-height: 64vh;
  object-fit: cover;
  background: var(--paper-deep);
}

.detail-body {
  padding: 26px 21px 44px;
}

.detail-body h1 {
  margin-top: 10px;
  font-size: 34px;
  line-height: 1.25;
}

.detail-body .memory-quote {
  margin-top: 18px;
  font-size: 19px;
  line-height: 1.75;
}

.detail-note {
  margin-top: 30px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.detail-note h2 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 17px;
}

.detail-note p {
  margin: 0;
  color: #4f4944;
  font-size: 15px;
  line-height: 1.85;
  white-space: pre-wrap;
}

.detail-timestamps {
  margin-top: 30px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.detail-actions {
  position: fixed;
  z-index: 5;
  top: calc(61px + var(--safe-top));
  right: max(16px, calc((100vw - 720px) / 2 + 16px));
  overflow: hidden;
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.detail-actions button {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0 15px;
  text-align: left;
}

.detail-actions button + button {
  border-top: 1px solid var(--line);
}

.danger-text {
  color: var(--danger);
}

.dialog-backdrop {
  display: grid;
  place-items: center;
  padding: 24px;
}

.confirm-dialog {
  width: min(100%, 360px);
  padding: 24px;
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 28px 80px rgba(40, 36, 33, 0.22);
}

.confirm-dialog h2 {
  margin: 0;
  font-size: 25px;
}

.confirm-dialog > p:not(.eyebrow) {
  margin: 12px 0 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.toast {
  position: fixed;
  z-index: 120;
  bottom: calc(136px + var(--safe-bottom));
  left: 50%;
  max-width: calc(100vw - 40px);
  padding: 11px 16px;
  transform: translate(-50%, 18px);
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.skeleton {
  position: relative;
  overflow: hidden;
  min-height: 260px;
  border-radius: 22px;
  background: var(--paper-deep);
}

.skeleton::after {
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: rgba(255, 255, 255, 0.65);
  content: "";
  animation: shimmer 1.35s infinite;
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

@media (min-width: 700px) {
  .app-view {
    border-inline: 1px solid var(--line);
  }

  .full-sheet {
    margin-block: 18px;
    max-height: calc(100svh - 36px);
    border-radius: 24px;
    box-shadow: var(--shadow);
  }

  .full-sheet-backdrop {
    align-items: center;
  }

  .sheet-header {
    min-height: 67px;
    padding-top: 10px;
    border-radius: 24px 24px 0 0;
  }
}

@media (max-width: 390px) {
  .random-section,
  .archive-section,
  .settings-page,
  .map-page {
    padding-inline: 16px;
  }

  .home-intro,
  .home-shelf-heading {
    padding-inline: 16px;
  }

  .home-rail {
    padding-inline: 16px;
    scroll-padding-inline: 16px;
  }

  .app-header {
    padding-inline: 16px;
  }

  .section-heading {
    align-items: center;
  }

  .shuffle-button {
    max-width: 82px;
    justify-content: flex-end;
    line-height: 1.3;
    text-align: right;
  }

  .archive-intro {
    align-items: flex-start;
    flex-direction: column;
  }

  .filter-chips {
    align-self: stretch;
  }

  .filter-chip {
    flex: 1;
  }

  .settings-card {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-card .danger-button {
    width: 100%;
  }

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

  .map-filter-chips {
    width: 100%;
  }

  .map-filter-chip {
    flex: 1;
  }

  .year-filter select {
    width: 100%;
  }

  .footprint-map {
    height: 278px;
    min-height: 278px;
  }

  .bottom-nav {
    padding-inline: 6px;
  }

  .nav-button {
    font-size: 9px;
  }

  .memory-feed.timeline::before {
    left: 55px;
  }

  .memory-day-group {
    grid-template-columns: 45px minmax(0, 1fr);
    gap: 22px;
  }

  .memory-day-group::before {
    left: 51px;
  }

  .memory-date strong {
    font-size: 28px;
  }
}

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