:root {
  --forest: #173D32;
  --dark: #242A25;
  --sage: #87977B;
  --lime: #B9E769;
  --off: #F5F4ED;
  --beige: #D6C8AE;
  --serif: 'Playfair Display', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  display: flex;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1d2a22 0%, #121713 100%);
  color: var(--off);
  font-family: var(--sans);
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }

/* App shell: full screen on phones, centred 9:16 column on desktop */
#app {
  display: flex;
  flex-direction: column;
  width: min(100vw, calc(100dvh * 9 / 16));
  height: 100vh;
  height: 100dvh;
  background: var(--dark);
  overflow: hidden;
}
.viewport { position: relative; flex: 1; min-height: 0; }

/* Feed */
.feed {
  height: 100%;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }

.slide {
  position: relative;
  height: 100%;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: linear-gradient(160deg, var(--forest), var(--dark));
}
.poster, .stage, .stage video { position: absolute; inset: 0; width: 100%; height: 100%; }
.poster { object-fit: cover; }
.stage video { object-fit: cover; opacity: 0; transition: opacity .3s; background: #0d120e; }
.stage video.contain { object-fit: contain; }
.stage video.ready { opacity: 1; }

/* Slide states: loading / preparing / error */
.state {
  position: absolute; inset: 0;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  text-align: center; padding: 24px; pointer-events: none;
}
.state.loading, .state.preparing, .state.error { display: flex; }
.state.error { background: rgba(20, 27, 22, .82); pointer-events: auto; }
.state p { font-size: 15px; max-width: 260px; line-height: 1.4; }
.state .actions { display: flex; gap: 10px; margin-top: 4px; }
.btn {
  padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px;
  background: var(--lime); color: var(--forest);
}
.btn.ghost { background: transparent; color: var(--off); border: 1px solid rgba(245, 244, 237, .35); }

.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid rgba(245, 244, 237, .25); border-top-color: var(--lime);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.splash {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px; text-align: center; color: var(--beige);
}
.splash .btn { margin-top: 6px; }

/* Video information */
.info {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 90px 20px 50px;
  background: linear-gradient(to top, rgba(10, 15, 11, .85), rgba(10, 15, 11, 0));
  pointer-events: none;
}
.info > * { pointer-events: auto; }
.info:empty { display: none; }
.info h2 { font-size: 24px; font-weight: 700; line-height: 1.2; }
.info .location { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 17px; }
.info .location svg { width: 18px; height: 18px; flex: none; }
.info .desc {
  margin-top: 8px; font-size: 15px; line-height: 1.45; color: var(--off);
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.info .desc.open { -webkit-line-clamp: unset; display: block; max-height: 30dvh; overflow-y: auto; }
.info .row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.info .by { font-size: 14px; color: rgba(245, 244, 237, .85); }
.info .by b { color: var(--off); font-weight: 600; }
.info .more {
  padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 500;
  background: rgba(36, 42, 37, .6); border: 1px solid rgba(245, 244, 237, .12);
}
.info .community { font-size: 13px; color: var(--beige); opacity: .9; }

/* Header */
.top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; gap: 14px;
  padding: calc(env(safe-area-inset-top) + 16px) 16px 40px;
  background: linear-gradient(to bottom, rgba(10, 15, 11, .6), rgba(10, 15, 11, 0));
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand { display: flex; flex-direction: column; align-items: flex-start; }
.mark { width: 40px; height: 22px; margin-left: 20px; }
.name { display: flex; flex-direction: column; font-family: var(--serif); font-weight: 600; font-size: 19px; line-height: 1; letter-spacing: .01em; }
.lime { color: var(--lime); }
.tagline {
  flex: 1; padding-left: 14px; border-left: 1px solid rgba(185, 231, 105, .5);
  font-family: var(--serif); font-style: italic; font-size: 13px; line-height: 1.35; color: var(--off);
}
.pill {
  display: none; align-items: center; gap: 8px; padding: 8px 16px 8px 10px; border-radius: 999px;
  background: rgba(36, 42, 37, .65); border: 1px solid rgba(185, 231, 105, .35);
  color: var(--lime); font-weight: 600; font-size: 14px;
}
.pill svg { width: 22px; height: 22px; }
@media (min-width: 380px) { .pill { display: inline-flex; } }

/* Right-hand controls */
.rail {
  position: absolute; right: 16px; top: calc(env(safe-area-inset-top) + 96px); z-index: 3;
  display: flex; flex-direction: column; gap: 14px;
}
.round {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(36, 42, 37, .65); backdrop-filter: blur(6px);
}
.round svg { width: 24px; height: 24px; }

/* Play / pause indicator */
.indicator {
  position: absolute; top: 50%; left: 50%; z-index: 2;
  width: 76px; height: 76px; margin: -38px 0 0 -38px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(36, 42, 37, .7); color: var(--off);
  opacity: 0; pointer-events: none; transform: scale(.9);
}
.indicator svg { width: 34px; height: 34px; }
.indicator.flash { animation: flash .8s ease-out; }
@keyframes flash {
  0% { opacity: 0; transform: scale(.85); }
  20% { opacity: 1; transform: scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.05); }
}

/* Progress */
.progress {
  position: absolute; left: 20px; right: 20px; bottom: 12px; z-index: 3;
  display: flex; align-items: center; gap: 14px;
}
.track { flex: 1; height: 4px; border-radius: 4px; background: rgba(245, 244, 237, .3); position: relative; cursor: pointer; }
.track::before { content: ''; position: absolute; inset: -12px 0; }
.fill { height: 100%; width: 0; border-radius: 4px; background: var(--lime); }
.time { font-size: 13px; font-variant-numeric: tabular-nums; min-width: 78px; text-align: right; }

/* Bottom navigation */
.tabs {
  display: flex; background: var(--dark);
  border-top: 1px solid rgba(245, 244, 237, .08);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 10px 0 12px; color: var(--sage); text-decoration: none; font-size: 15px; font-weight: 500;
}
.tab svg { width: 28px; height: 28px; }
.tab span { padding-bottom: 4px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--lime); }
.tab.active span { border-bottom-color: var(--lime); }

/* About panel */
.sheet {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: flex-end;
  background: rgba(10, 15, 11, .6);
}
.sheet[hidden] { display: none; }
.sheet-body {
  position: relative; width: 100%; max-height: 85%; overflow-y: auto;
  padding: 28px 22px 24px; border-radius: 22px 22px 0 0;
  background: var(--forest); color: var(--off);
  animation: rise .25s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.sheet h2 { font-family: var(--serif); font-size: 24px; margin-right: 40px; }
.sheet .tag { margin: 4px 0 14px; color: var(--lime); font-family: var(--serif); font-style: italic; }
.sheet p { font-size: 15px; line-height: 1.55; margin-bottom: 12px; }
.sheet .small { font-size: 13px; color: var(--beige); }
.sheet h3 { font-size: 14px; margin: 14px 0 4px; color: var(--beige); }
.sheet details { margin-top: 8px; border-top: 1px solid rgba(245, 244, 237, .15); padding-top: 12px; }
.sheet summary { cursor: pointer; font-weight: 600; color: var(--lime); }
.sheet a { color: var(--lime); }
.close { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; font-size: 28px; line-height: 1; border-radius: 50%; }

@media (prefers-reduced-motion: reduce) {
  .indicator.flash, .sheet-body { animation: none; }
  .indicator.flash { opacity: 1; }
  .spinner { animation-duration: 2s; }
}
