/* Bragi — "Warm Archival Editorial" (from the Stitch design system) */
:root {
  --bg: #121316;
  --s1: #18191e;
  --s2: #202229;
  --s3: #292b34;
  --line: #282a32;
  --line-2: #3a3d48;
  --amber: #e5a93c;
  --champagne: #f3c362;
  --bronze: #d49024;
  --amber-tint: rgba(229, 169, 60, 0.12);
  --text: #f4f4f6;
  --text-2: #a6a9b6;
  --text-3: #636775;
  --serif: 'Newsreader', Georgia, serif;
  --sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --r: 4px;
  --r-lg: 8px;
  --side: 248px;
  --row: 190px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 400 14px/22px var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; letter-spacing: -0.01em; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--s1); color: var(--text); font-weight: 600; font-size: 13px;
  letter-spacing: .01em; cursor: pointer; text-decoration: none; white-space: nowrap; transition: border-color .2s, background .2s, box-shadow .2s; }
.btn:hover { border-color: var(--amber); background: var(--s2); }
.btn-primary { background: var(--amber); border-color: var(--amber); color: var(--bg); }
.btn-primary:hover { background: var(--champagne); border-color: var(--champagne); box-shadow: 0 0 16px rgba(229,169,60,.3); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { color: var(--text); background: transparent; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 15px; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: var(--r); border: 1px solid transparent;
  background: transparent; color: var(--text); cursor: pointer; font-size: 18px; }
.icon-btn:hover { border-color: var(--line-2); background: var(--s2); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* Login */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px;
  background: radial-gradient(ellipse at 50% 30%, rgba(229,169,60,.10), transparent 60%), var(--bg); }
.login-card { text-align: center; max-width: 380px; }
.login-card .crest { width: 56px; height: 56px; color: var(--amber); }
.login-card h1 { font-size: 56px; line-height: 64px; margin: 8px 0 12px; }
.lede { font-family: var(--serif); font-style: italic; font-size: 19px; line-height: 30px; color: var(--text-2); margin: 0 0 32px; }
.login-error { color: #ffb4ab; margin-top: 20px; }

/* Shell */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--s1); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 24px 16px; gap: 24px; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--serif); font-size: 28px; padding: 0 8px; }
.brand .crest { width: 30px; height: 30px; color: var(--amber); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-radius: var(--r);
  text-decoration: none; color: var(--text-2); font-weight: 500; }
.nav a:hover:not(.soon) { color: var(--text); background: var(--s2); }
.nav a.active { color: var(--champagne); background: var(--amber-tint); }
.nav a.soon { color: var(--text-3); cursor: default; }
.nav em { font-style: normal; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--text-3); padding: 0 8px; }
.side-foot a { color: var(--text-2); text-decoration: none; }
.side-foot a:hover { color: var(--champagne); }

.main { margin-left: var(--side); min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 4; display: flex; gap: 16px; align-items: center; padding: 16px 40px;
  background: rgba(18,19,22,.88); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.search { flex: 1; max-width: 560px; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 14px;
  background: var(--s1); border: 1px solid var(--line); border-radius: var(--r); color: var(--text-3); }
.search:focus-within { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(229,169,60,.15); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); }
.topbar .btn-primary { margin-left: auto; }
#view { padding: 32px 40px 120px; outline: none; }

/* Library */
.hero { position: relative; display: grid; grid-template-columns: 1.4fr 1fr; min-height: 300px; border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden; background: var(--s1); margin-bottom: 32px; }
.hero-img { position: relative; background: var(--s2); }
.hero-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-body { padding: 36px; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--amber); }
.hero h1 { font-size: 40px; line-height: 48px; }
.hero p { margin: 0; color: var(--text-2); }
.hero .row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden; margin-bottom: 28px; }
.stat { background: var(--s1); padding: 16px 20px; }
.stat b { display: block; font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 38px; }
.stat span { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.chip { height: 32px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent;
  color: var(--text-2); font-weight: 500; font-size: 13px; cursor: pointer; }
.chip:hover { color: var(--text); }
.chip.on { background: var(--amber-tint); border-color: rgba(229,169,60,.35); color: var(--champagne); }

.day { margin-bottom: 36px; }
.day-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.day-head h2 { font-size: 22px; line-height: 30px; }
.day-head .muted { font-size: 13px; }
.day-head .btn { height: 30px; padding: 0 10px; margin-left: auto; font-size: 12px; }

/* Justified grid: each tile grows in proportion to its aspect ratio. */
.grid { display: flex; flex-wrap: wrap; gap: 6px; }
.grid::after { content: ''; flex-grow: 999999; }
.tile { --ar: 1.5; position: relative; flex-grow: calc(var(--ar) * 100); width: calc(var(--ar) * var(--row));
  aspect-ratio: var(--ar); margin: 0; background: var(--s1); border: 1px solid var(--line); border-radius: 2px;
  overflow: hidden; cursor: zoom-in; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease, opacity .3s; opacity: 0; }
.tile img.loaded { opacity: 1; }
.tile:hover { border-color: var(--amber); }
.tile:hover img { transform: scale(1.015); }
.tile .badge { position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; border-radius: var(--r); background: rgba(12,13,15,.75);
  font-size: 11px; font-weight: 600; letter-spacing: .04em; }
.tile .tick, .tile .fav { position: absolute; top: 8px; width: 26px; height: 26px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; font-size: 13px; opacity: 0; transition: opacity .15s; }
.tile .tick { left: 8px; background: rgba(12,13,15,.6); box-shadow: inset 0 0 0 2px rgba(244,244,246,.85); color: transparent; }
.tile .fav { right: 8px; background: rgba(12,13,15,.6); color: var(--text); }
.tile:hover .tick, .tile:hover .fav, .selecting .tile .tick, .tile .fav.on { opacity: 1; }
.tile .fav.on { color: var(--amber); }
.tile.sel { border: 2px solid var(--amber); }
.tile.sel .tick { opacity: 1; background: var(--amber); box-shadow: none; color: var(--bg); }
.selecting .tile { cursor: pointer; }

.empty { text-align: center; padding: 80px 16px; color: var(--text-2); }
.empty h2 { font-size: 32px; line-height: 40px; color: var(--text); margin-bottom: 8px; }
.empty p { margin: 0 0 24px; }

/* Albums */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head h1 { font-size: 40px; line-height: 48px; }
.page-head .grow { flex: 1; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 24px; }
.album-card { text-decoration: none; display: block; }
.album-card .cover { aspect-ratio: 4/3; background: var(--s1); border: 1px solid var(--line); border-radius: 2px; overflow: hidden; position: relative; }
.album-card .cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.album-card:hover .cover { border-color: var(--amber); }
.album-card:hover .cover img { transform: scale(1.02); }
.album-card h3 { font-size: 20px; line-height: 28px; margin-top: 12px; }
.album-card p { margin: 0; color: var(--text-2); font-size: 13px; }
.album-card .play { position: absolute; right: 10px; bottom: 10px; }
.title-edit { background: none; border: 1px solid transparent; border-radius: var(--r); font-family: var(--serif); font-size: 40px;
  line-height: 48px; padding: 0 6px; margin-left: -7px; width: 100%; max-width: 720px; }
.title-edit:hover, .title-edit:focus { border-color: var(--line-2); outline: 0; }

/* Selection bar */
.selbar { position: fixed; left: calc(var(--side) + 50%); transform: translateX(calc(-50% - var(--side) / 2)); bottom: 24px; z-index: 6;
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 18px; background: var(--s3); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); box-shadow: 0 16px 40px -10px rgba(0,0,0,.65), 0 0 1px 1px rgba(243,195,98,.08); }
.selbar strong { margin-right: 8px; font-weight: 600; white-space: nowrap; }

/* Uploader */
.uploader { position: fixed; right: 24px; bottom: 24px; width: min(400px, calc(100vw - 32px)); z-index: 7; background: var(--s2);
  border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: 0 16px 40px -10px rgba(0,0,0,.65); }
.uploader header { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 18px; border-bottom: 1px solid var(--line); }
.drop { margin: 16px; padding: 24px 16px; border: 1px dashed var(--line-2); border-radius: var(--r-lg); text-align: center; color: var(--text-2); }
.drop p { margin: 0 0 14px; }
.drop .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.up-status { padding: 0 18px 18px; }
.up-status p { margin: 8px 0 0; font-size: 13px; }
.bar { height: 4px; background: var(--s1); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--amber); transition: width .3s; }
.dropveil { position: fixed; inset: 0; z-index: 9; display: grid; place-items: center; background: rgba(12,13,15,.85);
  border: 2px dashed var(--amber); font-family: var(--serif); font-size: 32px; pointer-events: none; }

/* Slideshow */
.show { position: fixed; inset: 0; z-index: 20; background: #000; overflow: hidden; cursor: none; }
.show.awake { cursor: default; }
.stage, .slide { position: absolute; inset: 0; }
.slide { opacity: 0; display: grid; place-items: center; overflow: hidden; }
.slide.active { opacity: 1; z-index: 1; }
.show.fx-fade .slide, .show.fx-kenburns .slide { transition: opacity 1.2s ease; }
.slide img, .slide video { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; }
.show.fx-kenburns .slide img.kb { animation: kb var(--kb-dur, 6s) linear forwards; }
@keyframes kb {
  from { transform: scale(var(--kb-s0)) translate(var(--kb-x0), var(--kb-y0)); }
  to   { transform: scale(var(--kb-s1)) translate(var(--kb-x1), var(--kb-y1)); }
}
.show-caption { position: absolute; left: 32px; bottom: 76px; z-index: 2; font-family: var(--serif); font-size: 22px; line-height: 30px;
  text-shadow: 0 1px 12px rgba(0,0,0,.8); transition: opacity .4s; max-width: 70vw; }
.show-caption small { display: block; font: 600 11px/16px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--champagne); }
.show-progress { position: absolute; left: 0; right: 0; top: 0; height: 3px; z-index: 2; }
.show-progress i { display: block; height: 100%; width: 0; background: var(--amber); }
.show-controls { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 2; display: flex; align-items: center; gap: 4px;
  padding: 6px; background: rgba(24,25,30,.9); backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: var(--r-lg);
  transition: opacity .4s; }
.show-controls select { height: 34px; background: var(--s2); border: 1px solid var(--line-2); border-radius: var(--r); padding: 0 6px; }
.show-controls .on { color: var(--amber); }
.show-count { min-width: 64px; text-align: center; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.show:not(.awake) .show-controls, .show:not(.awake) .show-caption { opacity: 0; pointer-events: none; }

/* Modal + toast */
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(12,13,15,.92); backdrop-filter: blur(24px); }
.modal-card { width: min(440px, 100%); max-height: 80vh; overflow: auto; background: var(--s2); border: 1px solid var(--line-2); border-radius: var(--r-lg); padding: 24px; }
.modal-card h2 { font-size: 24px; line-height: 32px; margin-bottom: 16px; }
.modal-card .list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.modal-card .list button { text-align: left; padding: 10px 12px; background: var(--s1); border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; }
.modal-card .list button:hover { border-color: var(--amber); }
.modal-card .list small { color: var(--text-2); margin-left: 8px; }
.field { display: flex; gap: 8px; }
.field input { flex: 1; min-width: 0; height: 38px; padding: 0 12px; background: var(--s1); border: 1px solid var(--line); border-radius: var(--r); }
.field input:focus { border-color: var(--amber); outline: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast { position: fixed; left: 50%; top: 20px; transform: translateX(-50%); z-index: 40; padding: 10px 16px; background: var(--s3);
  border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: 0 16px 40px -10px rgba(0,0,0,.65); }

/* Nav extras */
.nav .count { font-size: 11px; font-weight: 600; min-width: 20px; padding: 0 6px; border-radius: 999px; text-align: center;
  background: var(--amber); color: var(--bg); line-height: 18px; }
.side-foot .ana { color: var(--champagne); }

/* Timeline */
.month { font-size: 32px; line-height: 40px; margin: 40px 0 20px; padding-top: 8px; border-top: 1px solid var(--line); scroll-margin-top: 90px; }
.month:first-of-type { border-top: 0; }
.month .muted { font-family: var(--sans); font-size: 14px; margin-left: 8px; }
.day { scroll-margin-top: 90px; }
.rail { position: fixed; right: 12px; top: 96px; bottom: 24px; z-index: 3; display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
  padding: 8px 6px; font-size: 11px; text-align: right; scrollbar-width: none; }
.rail a { color: var(--text-3); cursor: pointer; padding: 1px 6px; border-radius: var(--r); text-decoration: none; }
.rail a:hover { color: var(--champagne); background: var(--amber-tint); }
.rail .rail-year { color: var(--text-2); font-weight: 600; margin-top: 8px; font-size: 12px; }
@media (min-width: 861px) { body:has(.rail) #view { padding-right: 84px; } }

/* Notes, checkboxes */
.note { padding: 12px 16px; border: 1px solid rgba(229,169,60,.25); background: var(--amber-tint); border-radius: var(--r-lg); color: var(--champagne); margin: 0 0 24px; }
.check { display: flex; gap: 10px; align-items: center; margin-top: 16px; cursor: pointer; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--amber); }
.small { font-size: 12px; line-height: 18px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* Clean-up page */
.tile.rv { cursor: pointer; }
.tile.rv .badge { top: 8px; bottom: auto; }
.tile.rv.keep { border: 2px solid var(--amber); cursor: default; }
.tile.rv.keep .badge { background: var(--amber); color: var(--bg); }
.tile.rv.del { border: 2px solid #ff8a7a; }
.tile.rv.del img { opacity: .45 !important; filter: grayscale(.6); }
.tile.rv.del::after { content: 'Delete'; position: absolute; right: 8px; bottom: 8px; padding: 2px 8px; border-radius: var(--r);
  background: #ff8a7a; color: #2b0000; font-size: 11px; font-weight: 600; letter-spacing: .04em; }

/* Narrow screens */
@media (max-width: 860px) {
  :root { --side: 0px; --row: 110px; }
  .sidebar { position: sticky; top: 0; inset: auto; width: auto; flex-direction: row; align-items: center; padding: 10px 16px; gap: 12px;
    border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand { font-size: 22px; padding: 0; }
  .brand .crest { width: 24px; height: 24px; }
  .nav { flex-direction: row; }
  .nav a { padding: 6px 10px; }
  .nav a.soon, .side-foot #who, .side-foot #driveLink { display: none; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; padding: 0; white-space: nowrap; }
  .main { margin: 0; }
  .topbar { top: 57px; padding: 12px 16px; }
  #view { padding: 20px 16px 120px; }
  .hero { grid-template-columns: 1fr; }
  .hero-img { aspect-ratio: 16/9; }
  .hero-body { padding: 20px; }
  .hero h1, .page-head h1, .title-edit { font-size: 30px; line-height: 36px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .selbar { left: 16px; right: 16px; transform: none; flex-wrap: wrap; }
  .show-controls { left: 8px; right: 8px; transform: none; flex-wrap: wrap; justify-content: center; }
  .show-caption { left: 16px; bottom: 120px; font-size: 18px; }
  .uploader { right: 16px; bottom: 16px; }
  .rail { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .show.fx-kenburns .slide img.kb { animation: none; }
  .tile img, .album-card .cover img { transition: none; }
}
