/* ============ Base ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0e1015;
  --surface: #171a22;
  --ink: #e9e7f2;
  --ink-soft: #b9b4c9;
  --muted: #9a95ad;
  --accent: #8f7bee;
  --accent-strong: #a892f7;
  --accent-soft: #232038;
  --peach: #ffb899;
  --gold: #f5a623;
  --line: rgba(255, 255, 255, .09);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .08);
  --radius: 18px;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, 'Courier New', monospace;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: clip;
  background:
    radial-gradient(900px 480px at 88% -120px, rgba(245, 166, 35, .07) 0%, transparent 60%),
    radial-gradient(720px 420px at -120px 32%, rgba(143, 123, 238, .07) 0%, transparent 55%),
    var(--bg);
}

body.modal-open { overflow: hidden; }

button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: none; border-radius: 999px;
  padding: 10px 18px; font-weight: 800; font-size: .92rem;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent-strong), #a98ef5);
  box-shadow: 0 8px 18px rgba(122, 104, 234, .28);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(122, 104, 234, .34); }

.btn-ghost { background: var(--accent-soft); color: var(--accent-strong); }
.btn-ghost:hover { background: #2b2747; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: var(--accent-soft); color: var(--accent-strong);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: #2b2747; }

.chip-btn {
  border: 1.5px solid var(--line); background: #1b1e27; color: var(--danger);
  border-radius: 999px; padding: 5px 12px; font-size: .8rem; font-weight: 800;
}
.chip-btn:hover { background: var(--danger-soft); border-color: transparent; }

/* ============ Header (mobile-first app bar) ============ */
.site-header { padding: 22px 20px 16px; }

.header-inner {
  position: relative;
  max-width: 1140px; margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px 14px;
}
.header-text { grid-column: 1; grid-row: 1; min-width: 0; }

.more-wrap { position: relative; grid-column: 2; grid-row: 1; display: flex; gap: 8px; }
.more-btn {
  width: 44px; height: 44px; border-radius: 999px;
  border: 1.5px solid var(--line); background: #1d212b;
  color: var(--ink-soft);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.more-btn:hover,
.more-btn.open { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.more-btn.active {
  background: linear-gradient(135deg, #ffd34d, #f5a623);
  color: #241703; border-color: transparent;
  box-shadow: 0 6px 16px rgba(245, 166, 35, .3);
}

.more-menu {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 40;
  min-width: 216px;
  background: #1b1e27;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 16px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .45);
  padding: 6px;
}
.more-menu[hidden] { display: none; }
.menu-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; min-height: 44px; padding: 10px 14px;
  background: none; border: none; border-radius: 10px;
  font: inherit; font-size: .93rem; font-weight: 700; color: var(--ink);
  cursor: pointer; text-align: left;
  transition: background .15s ease, color .15s ease;
}
.menu-item:hover { background: var(--accent-soft); color: var(--accent-strong); }

.menu-account {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.menu-account img, .acc-initial {
  width: 36px; height: 36px; border-radius: 50%; flex: 0 0 auto;
}
.acc-initial {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-strong);
  font-weight: 900; font-size: .95rem;
}
.acc-meta { display: flex; flex-direction: column; min-width: 0; }
.acc-name {
  font-weight: 800; font-size: .88rem; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.acc-mail {
  font-size: .75rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.menu-signin { color: var(--accent-strong); }
.menu-divider { border: none; border-top: 1px solid var(--line); margin: 6px 8px; }

.add-entry-btn {
  grid-column: 1 / -1; grid-row: 2;
  width: 100%; justify-content: center;
  min-height: 48px; font-size: 1rem; gap: 9px;
}

/* desktop: same structure, actions move up beside the title */
@media (min-width: 720px) {
  .site-header { padding: 38px 20px 16px; }
  .header-inner { grid-template-columns: 1fr auto auto; }
  .add-entry-btn { grid-column: 3; grid-row: 1; width: auto; min-height: 44px; }
}
.logo {
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  font-weight: 900; letter-spacing: -.5px;
  color: var(--accent-strong);
  background: linear-gradient(120deg, var(--accent-strong), #b48cf2 55%, var(--peach));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.tagline { color: var(--muted); font-weight: 600; font-size: .9rem; margin-top: 2px; }

/* ============ Category filter chips ============ */
.filter-chips {
  display: flex; flex-wrap: nowrap; gap: 8px;
  overflow-x: auto; scrollbar-width: none;
  padding: 2px 2px 10px;
}
.filter-chips::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  flex: 0 0 auto;
  min-height: 42px; padding: 9px 16px; border-radius: 999px;
  border: 1.5px solid var(--line); background: transparent;
  font: inherit; font-size: .85rem; font-weight: 800;
  color: var(--muted);
  transition: color .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.chip:hover { color: var(--ink-soft); border-color: rgba(245, 166, 35, .5); }
.chip.active {
  color: #241703;
  background: linear-gradient(135deg, #ffd34d, #f5a623);
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(245, 166, 35, .3);
}

/* ============ Timeline ============ */
main { max-width: 1140px; margin: 0 auto; padding: 0 20px 30px; }

.page-layout { display: flex; align-items: flex-start; gap: 24px; }
.timeline-area { flex: 1; min-width: 0; }

/* ---- Date rail (left navigation) ---- */
.date-rail {
  flex: 0 0 195px;
  position: sticky; top: 18px;
  background: #15171e;
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 14px;
  padding: 12px 10px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.rail-year {
  display: flex; gap: 7px; align-items: baseline;
  font-family: var(--mono); font-size: .78rem; font-weight: 700; letter-spacing: .1em;
  color: #45d6b8;
  padding: 12px 12px 6px;
}
.rail-year.current { color: #f5a623; }
.rail-year .rail-bracket { opacity: .55; }

.rail-months { position: relative; }
.rail-months::before {
  content: ''; position: absolute; left: 19px; top: 10px; bottom: 10px;
  width: 2px; border-radius: 2px;
  background: rgba(255, 255, 255, .07);
}

.rail-month {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px 8px 14px;
  background: none; border: none; cursor: pointer;
  font-family: var(--mono); font-size: .8rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: rgba(233, 231, 242, .5);
  border-radius: 8px;
  transition: color .15s ease, background .15s ease;
}
.rail-month:hover { color: rgba(233, 231, 242, .92); background: rgba(255, 255, 255, .04); }
.rail-dot {
  width: 10px; height: 10px; border-radius: 3px;
  background: #3d4250; flex: 0 0 auto;
  transition: background .15s ease, box-shadow .15s ease;
}
.rail-month.active { color: #f5a623; }
.rail-month.active .rail-dot {
  background: #f5a623;
  box-shadow: inset 0 0 0 2px rgba(21, 23, 30, .92), 0 0 10px rgba(245, 166, 35, .35);
}

.timeline { position: relative; }
.timeline::before {
  content: ''; position: absolute; top: 6px; bottom: 6px; left: 50%;
  width: 2px; transform: translateX(-50%);
  border-radius: 2px;
  background: linear-gradient(180deg, transparent, var(--line) 6%, var(--line) 94%, transparent);
}

.tl-item { position: relative; width: 50%; padding: 0 42px 34px 0; animation: fadeUp .5s ease both; scroll-margin-top: 24px; }
.tl-item.right { margin-left: 50%; padding: 0 0 34px 42px; }

.tl-item::before {
  content: ''; position: absolute; top: 26px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--bg); border: 3.5px solid var(--accent);
  box-shadow: 0 0 0 5px rgba(143, 123, 238, .16);
  z-index: 1;
}
.tl-item.left::before { right: -7.5px; }
.tl-item.right::before { left: -7.5px; }

/* ============ Cards (dark design) ============ */
.card {
  position: relative;
  background: #171a22;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: var(--radius);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .4);
  padding: 0;
  overflow: hidden;
  color: #e9e7f2;
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 42px rgba(50, 45, 80, .26);
}

/* gold folded-corner accent */
.card::before {
  content: ''; position: absolute; top: 0; right: 0; z-index: 2;
  width: 46px; height: 46px;
  background: linear-gradient(225deg, #ffd34d 0%, #f59e0b 100%);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.card-media { position: relative; }
.card-img {
  display: block; width: 100%; height: 240px; object-fit: cover;
  background: #1d2029;
}
/* darkening gradient — the lower image melts into the card background */
.card-media::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 110px;
  background: linear-gradient(to bottom, rgba(21, 23, 30, 0) 0%, rgba(21, 23, 30, .55) 55%, #15171e 100%);
  pointer-events: none;
}
/* blurred echo of the image bleeding under the content for a cinematic seam */
.card-img-echo {
  position: absolute; left: -30px; top: 150px;
  width: calc(100% + 60px); height: 260px;
  object-fit: cover; object-position: center top;
  filter: blur(7px) saturate(1.1) brightness(.9);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, .55) 22%, #000 42%, rgba(0, 0, 0, .75) 62%, rgba(0, 0, 0, .35) 82%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, .55) 22%, #000 42%, rgba(0, 0, 0, .75) 62%, rgba(0, 0, 0, .35) 82%, transparent 100%);
  pointer-events: none;
}
.card.img-failed .card-media {
  min-height: 170px;
  background: linear-gradient(135deg, #262b36, #181b24);
}
.card.img-failed .card-img,
.card.img-failed .card-img-echo { display: none; }
.card-img {
  display: block; width: 100%; height: 240px; object-fit: cover;
  background: #1d2029;
}

.card-body { position: relative; z-index: 1; padding: 12px 18px 18px; }

/* category badge — overlaid on the image, or inline when there is no image */
.card-cat {
  position: absolute; top: 12px; left: 12px; z-index: 1;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  background: rgba(12, 14, 18, .88);
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 999px; padding: 6px 12px;
}
.card-cat.static { position: static; margin-top: 14px; margin-bottom: 12px; align-self: flex-start; }
.cat-games { color: #b39cff; }
.cat-event { color: #ff9d6b; }
.cat-personal { color: #4ade80; }

.card-meta-top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 12px;
}
.card-date {
  display: inline-flex; align-items: center; gap: 7px;
  background: linear-gradient(135deg, #ffd34d, #f5a623);
  color: #241703;
  font-size: .76rem; font-weight: 900; letter-spacing: .04em; text-transform: uppercase;
  border-radius: 999px; padding: 7px 13px;
  white-space: nowrap;
}
.card-countdown {
  font-size: .66rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(233, 231, 242, .55);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px; padding: 6px 11px;
  white-space: nowrap;
}

.category-options { display: flex; gap: 8px; flex-wrap: wrap; }
.category-option { position: relative; cursor: pointer; }
.category-option input { position: absolute; opacity: 0; pointer-events: none; }
.category-option span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: #1b1e27;
  font-weight: 800; font-size: .85rem; color: var(--muted);
  transition: border-color .15s ease, color .15s ease, background .15s ease, box-shadow .15s ease;
}
.category-option span:hover { border-color: var(--accent); color: var(--ink-soft); }
.category-option input:checked + span {
  border-color: var(--accent); color: var(--accent-strong); background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.category-option input:focus-visible + span {
  outline: none; box-shadow: 0 0 0 4px var(--accent-soft);
}

.import-modes { flex-direction: column; align-items: stretch; }
.import-modes span { justify-content: center; }

.card-title { font-size: 1.18rem; font-weight: 800; margin-bottom: 6px; color: #fff; }
.card-desc { color: rgba(233, 231, 242, .62); font-size: .95rem; white-space: pre-line; }

.card-footer-meta {
  display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  border-top: 1px solid rgba(255, 255, 255, .08);
  margin-top: 14px; padding-top: 12px;
  font-size: .78rem; color: rgba(233, 231, 242, .5);
}
.card-footer-meta span { display: inline-flex; align-items: center; gap: 6px; }
.card-footer-meta b { color: rgba(233, 231, 242, .92); font-weight: 700; }

.card-actions { display: flex; gap: 10px; margin-top: 14px; }
.card-actions .btn {
  flex: 1; justify-content: center; padding: 10px 8px;
  font-size: .85rem; border-radius: 10px; border: 1px solid transparent;
}
.btn-card-share { background: #262b36; color: #fff; border-color: rgba(255, 255, 255, .05); }
.btn-card-share:hover { background: #2e3442; }
.btn-card-edit { background: rgba(245, 158, 11, .08); color: #fbbf24; border-color: rgba(245, 158, 11, .5); }
.btn-card-edit:hover { background: rgba(245, 158, 11, .16); }
.btn-card-delete { background: rgba(248, 113, 113, .07); color: #f87171; border-color: rgba(248, 113, 113, .45); }
.btn-card-delete:hover { background: rgba(248, 113, 113, .14); }

.tl-item.highlight .card { border-color: #f5a623; animation: glowPulse 2.2s ease; }

/* ============ Compact view ============ */
.timeline.compact {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  grid-auto-rows: 1fr;
  gap: 12px;
}
.timeline.compact::before { display: none; }
.timeline.compact .tl-item,
.timeline.compact .tl-item.right { width: auto; margin-left: 0; padding: 0; }
.timeline.compact .tl-item::before { display: none; }
.timeline.compact .card-media::after { display: none; }
.timeline.compact .card-img-echo { display: none; }
.timeline.compact .card-img { height: 205px; }
.timeline.compact .card { display: flex; flex-direction: column; height: 100%; }
.timeline.compact .card-body {
  padding: 10px 12px 12px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 7px;
}
.timeline.compact .card-meta-top {
  flex-direction: column; align-items: flex-start; gap: 7px; margin-bottom: 0;
}
.timeline.compact .card-date { font-size: .64rem; padding: 5px 10px; gap: 5px; }
.timeline.compact .card-date svg { width: 11px; height: 11px; }
.timeline.compact .card-countdown { display: none; }
.timeline.compact .card-title {
  font-size: .9rem; line-height: 1.35; margin-bottom: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.timeline.compact .card-desc,
.timeline.compact .card-footer-meta,
.timeline.compact .card-actions { display: none; }
.timeline.compact .card::before { width: 32px; height: 32px; }
.timeline.compact .card:hover { transform: translateY(-3px); }
.timeline.compact .card-cat { font-size: .6rem; padding: 4px 9px; top: 8px; left: 8px; }
.timeline.compact .card-cat.static { margin-top: 0; margin-bottom: 0; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes glowPulse {
  0% { box-shadow: 0 0 0 0 rgba(245, 166, 35, .45); }
  100% { box-shadow: 0 0 0 26px rgba(245, 166, 35, 0); }
}

/* ============ Empty state ============ */
.empty { text-align: center; padding: 70px 20px 40px; }
.empty-emoji {
  width: 86px; height: 86px; margin: 0 auto 18px; border-radius: 50%;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem;
}
.empty h2 { font-size: 1.3rem; margin-bottom: 6px; }
.empty p { color: var(--muted); font-weight: 600; margin-bottom: 20px; }

/* ============ Modal ============ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(4, 5, 9, .62);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}
.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
  background: #171a22;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 22px;
  width: 100%; max-width: 530px;
  max-height: calc(100vh - 40px); overflow-y: auto;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  transform: translateY(14px) scale(.98);
  transition: transform .2s ease;
}
.modal-overlay.open .modal { transform: none; }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.modal-head h2 { font-size: 1.25rem; font-weight: 900; }

.field { margin-bottom: 16px; }
.field label, .field-label {
  display: block; font-weight: 800; font-size: .88rem; margin-bottom: 7px;
}
.optional { color: var(--muted); font-weight: 600; }

.field input[type="text"], .field input[type="datetime-local"], .field textarea {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--line); border-radius: 12px;
  font: inherit; color: var(--ink); background: #1b1e27; resize: vertical;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.field-hint {
  margin-top: 7px; font-size: .78rem; font-weight: 600; color: var(--muted);
}

.image-inputs { display: flex; gap: 8px; flex-wrap: wrap; }
.image-inputs input[type="text"] {
  flex: 1; min-width: 180px; padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: 999px;
  font: inherit; color: var(--ink); background: #1b1e27;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.image-inputs input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.image-preview { margin-top: 12px; }
.image-preview img {
  display: block; width: 100%; max-height: 190px; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--line); margin-bottom: 8px;
  background: #1b1e27;
}
.image-preview img.loading { opacity: .35; }
.image-preview img.failed { display: none; }

.field-error {
  margin-top: 0; margin-bottom: 8px;
  font-size: .78rem; font-weight: 700; color: var(--danger);
}

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ============ Toast & footer ============ */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 60;
  transform: translateX(-50%) translateY(10px);
  background: #262b36; color: #fff;
  border: 1px solid rgba(255, 255, 255, .08);
  padding: 11px 20px; border-radius: 999px;
  font-size: .9rem; font-weight: 700;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .45);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  max-width: calc(100vw - 40px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

.site-footer {
  text-align: center; color: var(--muted);
  font-size: .84rem; font-weight: 600;
  padding: 26px 20px 42px;
}

/* ============ Mobile ============ */
@media (max-width: 900px) {
  .page-layout { flex-direction: column; gap: 16px; }
  .date-rail {
    position: static; flex: none;
    display: flex; gap: 4px; align-items: center;
    overflow-x: auto; overflow-y: hidden;
    padding: 8px;
  }
  .rail-year { display: none; }
  .rail-months { display: contents; }
  .rail-months::before { display: none; }
  .rail-month { width: auto; white-space: nowrap; padding: 7px 12px 7px 9px; }
}

@media (max-width: 720px) {
  .timeline::before { left: 11px; }
  .tl-item,
  .tl-item.right { width: 100%; margin-left: 0; padding: 0 0 26px 36px; }
  .tl-item.left::before,
  .tl-item.right::before { left: 3.5px; right: auto; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; justify-content: center; }
}
