/* YourTimeline — warm editorial look */
:root {
  --paper: #faf6f0;
  --ink: #241f1a;
  --ink-soft: #6b6259;
  --line: #e4dcd1;
  --card: #ffffff;
  --accent: #c4572e;        /* terracotta — "you" lane */
  --accent-soft: #fbe9df;
  --world: #2e6e64;         /* deep teal — world lane */
  --world-soft: #e3efec;
  --gold: #c9a227;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(36, 31, 26, .06), 0 6px 20px rgba(36, 31, 26, .07);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; } /* the hidden attribute always wins over display rules */
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .year-num, .logo { font-family: var(--serif); }
button { font-family: inherit; cursor: pointer; }
.logo { color: var(--accent); }

/* ---------- buttons ---------- */
.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 999px;
  padding: .8rem 1.6rem;
  font-size: 1rem;
  font-weight: 600;
  transition: transform .12s ease, background .12s ease;
}
.btn-primary:hover { background: var(--accent); transform: translateY(-1px); }
.btn-primary.small { padding: .55rem 1.1rem; font-size: .88rem; }
.btn-ghost {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: .55rem 1.1rem;
  font-size: .88rem;
}
.btn-ghost:hover { border-color: var(--ink-soft); color: var(--ink); }

/* ---------- onboarding ---------- */
.onboarding {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at 15% 20%, var(--accent-soft) 0%, transparent 45%),
    radial-gradient(circle at 85% 80%, var(--world-soft) 0%, transparent 45%),
    var(--paper);
}
.ob-card {
  width: min(620px, 100%);
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 2.5rem 2.25rem;
}
.ob-head { text-align: center; margin-bottom: 1.75rem; }
.ob-head .logo { font-size: 1.6rem; }
.ob-head h1 { font-size: 2.3rem; font-weight: 600; letter-spacing: -.02em; }
.tagline { color: var(--ink-soft); margin-top: .35rem; font-size: 1.02rem; }

#ob-form { display: flex; flex-direction: column; gap: 1.1rem; }
.field { display: flex; flex-direction: column; gap: .4rem; flex: 1; }
.field > span { font-size: .82rem; font-weight: 600; letter-spacing: .02em; color: var(--ink-soft); text-transform: uppercase; }
.field em { text-transform: none; font-weight: 400; }
.field input, .field select, .field textarea {
  font: inherit;
  padding: .7rem .85rem;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  transition: border-color .12s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.field-row { display: flex; gap: 1rem; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: .45rem .9rem;
  font-size: .9rem;
  transition: all .12s;
}
.chip:hover { border-color: var(--accent); }
.chip.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.import-line {
  text-align: center;
  margin-top: 1.1rem;
  font-size: .88rem;
  color: var(--ink-soft);
}
.import-link {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.boot-msg {
  text-align: center;
  color: var(--ink-soft);
  padding: 40vh 2rem 0;
  font-size: 1rem;
}

/* ---------- login ---------- */
.login-card { max-width: 440px; margin: 0 auto; }
.login-btn { width: 100%; margin-top: .4rem; }
.login-alt { width: 100%; margin-top: .6rem; }
.login-hint { color: var(--ink-soft); font-size: .95rem; margin-bottom: 1rem; text-align: center; }
.login-error {
  margin-top: 1rem;
  padding: .7rem .9rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 10px;
  font-size: .9rem;
  text-align: center;
}
#stage-email, #stage-code { display: flex; flex-direction: column; gap: 1rem; }

#sync-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  background: #8c2f1b;
  color: #fff;
  font-size: .88rem;
  padding: .7rem 1rem;
  text-align: center;
}
#sync-banner button {
  margin-left: .6rem;
  background: #fff;
  color: #8c2f1b;
  border: none;
  border-radius: 6px;
  padding: .25rem .7rem;
  font-weight: 600;
}

.footer-account { margin-top: .4rem; font-size: .8rem; }
.link-quiet {
  background: none;
  border: none;
  color: var(--ink-soft);
  text-decoration: underline;
  font-size: inherit;
  padding: 0;
}
.link-quiet:hover { color: var(--accent); }

/* ---------- header ---------- */
.tl-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(250, 246, 240, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 1rem 1.5rem .6rem;
}
.tl-header-inner {
  max-width: 1060px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.tl-header h1 { font-size: 1.55rem; font-weight: 600; letter-spacing: -.01em; }
.tl-header .sub { color: var(--ink-soft); font-size: .88rem; }
.header-actions { display: flex; gap: .6rem; align-items: center; }

.decades {
  max-width: 1060px;
  margin: .6rem auto 0;
  display: flex;
  gap: .35rem;
  overflow-x: auto;
  padding-bottom: .4rem;
}
.decades a {
  text-decoration: none;
  color: var(--ink-soft);
  font-size: .82rem;
  font-weight: 600;
  padding: .3rem .75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  white-space: nowrap;
  background: var(--card);
}
.decades a:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- legend ---------- */
.lane-legend {
  max-width: 1060px;
  margin: 1.4rem auto 0;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.legend-item i {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: .4rem;
}
.legend-item.world i { background: var(--world); }
.legend-item.you i { background: var(--accent); }

/* ---------- filter bar ---------- */
.filter-bar {
  max-width: 1060px;
  margin: .8rem auto 0;
  padding: 0 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem;
}
.filter-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-right: .2rem;
}
.chip.small { padding: .3rem .7rem; font-size: .8rem; }
.restore-chip { color: var(--accent); border-color: var(--accent); }
.match-note {
  max-width: 1060px;
  margin: .6rem auto 0;
  padding: 0 1.5rem;
  font-size: .82rem;
  color: var(--ink-soft);
  font-style: italic;
}

/* ---------- timeline ---------- */
.timeline {
  max-width: 1060px;
  margin: 0 auto;
  padding: 1rem 1.5rem 4rem;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(var(--line), var(--line));
  transform: translateX(-50%);
}

.year { position: relative; padding: 1.2rem 0; }
.year.slim { padding: .2rem 0; }
.year.slim .year-marker { opacity: .45; }
.year.slim .year-num { font-size: .8rem; }

.year-marker {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: .9rem;
}
.year-num {
  background: var(--ink);
  color: var(--paper);
  font-size: 1.05rem;
  font-weight: 600;
  padding: .25rem .95rem;
  border-radius: 999px;
}
.year-age {
  margin-top: .3rem;
  font-size: .78rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--paper);
  padding: 0 .5rem;
}

.year-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
}
.year-world { padding-right: .5rem; display: flex; flex-direction: column; gap: .8rem; align-items: flex-end; }
.year-mine  { padding-left: .5rem;  display: flex; flex-direction: column; gap: .8rem; align-items: flex-start; }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  display: flex;
  gap: .8rem;
  width: 100%;
  max-width: 430px;
  border-top: 3px solid transparent;
}
.card h3 { font-size: 1.02rem; font-weight: 600; line-height: 1.3; }
.card p { font-size: .88rem; color: var(--ink-soft); margin-top: .2rem; }
.card-emoji { font-size: 1.5rem; line-height: 1.2; }

.card { position: relative; }
.world-card { border-top-color: var(--world); flex-direction: column; cursor: pointer; }
.world-card:hover { box-shadow: 0 2px 4px rgba(36, 31, 26, .08), 0 10px 28px rgba(36, 31, 26, .12); }
.world-row { display: flex; gap: .8rem; }
.world-photo {
  width: calc(100% + 2.2rem);
  margin: -1rem -1.1rem .7rem;
  border-radius: var(--radius) var(--radius) 0 0;
  height: 160px;
  object-fit: cover;
  object-position: center 25%;
  background: var(--world-soft);
}
.card-date {
  font-size: .72rem !important;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--world) !important;
  margin: 0 0 .1rem !important;
}
.hide-btn {
  position: absolute;
  top: .5rem; right: .6rem;
  z-index: 2;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  width: 26px; height: 26px;
  font-size: .8rem;
  color: var(--ink-soft);
  opacity: 0;
  transition: opacity .12s;
}
.world-card:hover .hide-btn { opacity: 1; }
.hide-btn:hover { color: var(--accent); border-color: var(--accent); }
.card-meta { display: flex; align-items: center; gap: .7rem; }
.read-more {
  margin-top: .5rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--world);
  text-decoration: none;
}
.read-more:hover { text-decoration: underline; }
.world-card.fav {
  border-top-color: var(--gold);
  background: linear-gradient(160deg, #fffdf4, var(--card) 55%);
}
.fav-star { color: var(--gold); }

.tag {
  display: inline-block;
  margin-top: .5rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--world);
  background: var(--world-soft);
  padding: .15rem .55rem;
  border-radius: 999px;
}

.world-card.extra { display: none; }
.year-world.expanded .world-card.extra { display: flex; }
.pre-birth {
  margin-left: .6rem;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: .12rem .5rem;
  border-radius: 999px;
  vertical-align: 1px;
}
.more-toggle {
  background: none;
  border: none;
  color: var(--world);
  font-size: .82rem;
  font-weight: 600;
  padding: .2rem 0;
}
.more-toggle:hover { text-decoration: underline; }
.quiet { font-size: .85rem; color: var(--ink-soft); font-style: italic; }

/* personal lane */
.mem-card {
  border-top-color: var(--accent);
  flex-direction: column;
  gap: .4rem;
  position: relative;
}
.mem-card h3 { color: var(--ink); }
.mem-date { font-size: .75rem !important; font-weight: 600; color: var(--accent) !important; }
.mem-photo {
  width: calc(100% + 2.2rem);
  margin: -1rem -1.1rem .4rem;
  border-radius: var(--radius) var(--radius) 0 0;
  max-height: 240px;
  object-fit: cover;
}
.mem-actions {
  position: absolute;
  top: .5rem; right: .6rem;
  display: flex;
  gap: .3rem;
  opacity: 0;
  transition: opacity .12s;
}
.mem-card:hover .mem-actions { opacity: 1; }
.mem-actions button {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  width: 26px; height: 26px;
  font-size: .8rem;
  color: var(--ink-soft);
}
.mem-actions button:hover { color: var(--accent); border-color: var(--accent); }
.mem-card .mem-photo + .mem-body .mem-actions,
.mem-card:has(.mem-photo) .mem-actions { background: none; }

.birth-card {
  flex-direction: row;
  background: linear-gradient(160deg, var(--accent-soft), var(--card) 70%);
}

.milestone-card {
  flex-direction: row;
  align-items: center;
  gap: .8rem;
  background: transparent;
  border: 1.5px dashed var(--accent);
  border-top-width: 1.5px;
  box-shadow: none;
  padding: .7rem 1rem;
  opacity: .92;
}
.milestone-card h3 { font-size: .95rem; }
.milestone-card .mem-date { margin-top: 0 !important; }

.add-here {
  background: none;
  border: 1.5px dashed var(--line);
  color: var(--ink-soft);
  border-radius: var(--radius);
  padding: .55rem 1rem;
  font-size: .82rem;
  width: 100%;
  max-width: 430px;
  opacity: 0;
  transition: opacity .15s, border-color .15s, color .15s;
}
.year:hover .add-here { opacity: .8; }
.add-here:hover { opacity: 1 !important; border-color: var(--accent); color: var(--accent); }

/* ---------- modal ---------- */
.modal-backdrop[hidden] { display: none; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(36, 31, 26, .45);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 1rem;
}
.modal {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  width: min(520px, 100%);
  padding: 1.8rem;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { font-size: 1.4rem; margin-bottom: 1.1rem; }
#memory-form { display: flex; flex-direction: column; gap: .9rem; }
#photo-preview img { max-width: 100%; border-radius: 10px; max-height: 200px; object-fit: cover; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .4rem; }

/* ---------- detail view ---------- */
.detail-modal { width: min(600px, 100%); padding: 0 0 1.6rem; overflow: hidden; }
.detail-modal > *:not(.detail-img):not(.detail-close) { margin-left: 1.8rem; margin-right: 1.8rem; }
.detail-close {
  position: absolute;
  top: .8rem; right: .9rem;
  z-index: 3;
  background: rgba(250, 246, 240, .9);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 30px; height: 30px;
  font-size: .9rem;
  color: var(--ink);
}
.detail-close:hover { color: var(--accent); border-color: var(--accent); }
.detail-modal { position: relative; }
.detail-img {
  width: 100%;
  max-height: 46vh;
  object-fit: contain;
  background: #171310;
  margin-bottom: 1.2rem;
}
.detail-date {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--world);
  margin-top: .2rem;
}
.detail-modal h2 { font-size: 1.55rem; margin: .25rem 0 .6rem; }
.detail-text { color: var(--ink); }
.detail-extract {
  color: var(--ink-soft);
  font-size: .92rem;
  margin-top: .7rem;
  padding-left: .9rem;
  border-left: 3px solid var(--line);
}
.detail-modal .read-more { display: inline-block; margin-top: .8rem; font-size: .85rem; }
.detail-meanwhile {
  margin-top: 1.3rem;
  padding: 1rem 1.1rem;
  background: var(--accent-soft);
  border-radius: var(--radius);
}
.detail-meanwhile h4 {
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--accent);
  margin-bottom: .6rem;
}
.mw-item {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  background: var(--card);
  border-radius: 10px;
  padding: .6rem .7rem;
  margin-bottom: .5rem;
}
.mw-item img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; }
.mw-item strong { display: block; font-size: .92rem; }
.mw-item span { font-size: .75rem; font-weight: 600; color: var(--accent); }
.mw-item p { font-size: .82rem; color: var(--ink-soft); margin-top: .15rem; }
.detail-meanwhile .btn-ghost { margin-top: .3rem; background: var(--card); }

/* ---------- footer ---------- */
.tl-footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: .85rem;
  padding: 2rem 1rem 3rem;
  border-top: 1px solid var(--line);
}

/* ---------- print ---------- */
@media print {
  body { background: #fff; }
  .header-actions, .decades, .add-here, .mem-actions, .lane-legend, .more-toggle, .modal-backdrop, .filter-bar, .hide-btn { display: none !important; }
  .tl-header {
    position: static;
    background: none;
    backdrop-filter: none;
    border-bottom: 2px solid var(--ink);
  }
  .world-card.extra { display: flex !important; }
  .timeline::before { background: var(--line); }
  .card {
    box-shadow: none;
    border: 1px solid var(--line);
    break-inside: avoid;
  }
  .year-marker { break-after: avoid; }
  .world-photo, .mem-photo { max-height: 110px; }
  .tl-footer { border: none; }
}

/* Sticky header only on wide screens — on phones and portrait tablets the
   tall header would cover too much of the page while scrolling. */
@media (max-width: 1023px) {
  .tl-header { position: static; }
}

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  .timeline::before { left: 14px; }
  .year-marker { align-items: flex-start; padding-left: 40px; }
  .year-cols { grid-template-columns: 1fr; gap: .8rem; padding-left: 40px; }
  .year-world, .year-mine { align-items: stretch; padding: 0; }
  .hidden-events { align-items: stretch; }
  .card, .add-here { max-width: none; }
  .field-row { flex-direction: column; }
  .add-here { opacity: .8; }
  .lane-legend { padding-left: 40px; justify-content: flex-start; gap: 1.2rem; }
}
