:root {
  --bg: #000000;
  --surface: #121214;
  --surface-2: #1c1c1f;
  --border: rgba(255, 255, 255, 0.09);
  --fg: #ffffff;
  --muted: #8e8e93;
  --accent: #fe2c55;
  --cyan: #25f4ee;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  overscroll-behavior: none;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* Crisp Emil-style tactile press feedback (no bouncy overshoot) */
.press {
  transition: transform 140ms var(--ease-out), opacity 140ms var(--ease-out), background-color 140ms ease;
}
.press:active {
  transform: scale(0.95);
  opacity: 0.85;
}

/* Gates (Install & Pair) — pure native iOS dark, zero AI blur cards */
.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(28px + var(--safe-top)) 24px calc(28px + var(--safe-bottom));
  background: var(--bg);
}

.gate-content {
  width: min(100%, 312px);
  text-align: center;
}

.saratok-logo {
  display: inline-grid;
  place-items: center;
  margin-bottom: 14px;
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.subtitle {
  margin: 0 0 24px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--muted);
}

.subtitle strong {
  color: var(--fg);
  font-weight: 600;
}

#pair-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#pair-input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  outline: none;
  transition: border-color 160ms ease, background-color 160ms ease;
}
#pair-input:focus {
  border-color: rgba(255, 255, 255, 0.32);
  background: var(--surface-2);
}
#pair-input::placeholder {
  color: rgba(255, 255, 255, 0.24);
}

.btn-primary,
.btn-secondary {
  width: 100%;
  height: 50px;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}
.btn-primary:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--fg);
  border: 1px solid var(--border);
}

.error-text {
  margin: 4px 0 0;
  font-size: 13px;
  color: #ff6b81;
}

/* Main Feed Shell */
.app-shell {
  position: fixed;
  inset: 0;
  background: var(--bg);
}

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.52) 0%, transparent 100%);
  pointer-events: none;
}
.top-bar > * {
  pointer-events: auto;
}

.brand-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 4px;
  border: 0;
  background: none;
  color: var(--fg);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.65);
  cursor: pointer;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
  color: var(--fg);
  filter: drop-shadow(0 1px 6px rgba(0, 0, 0, 0.65));
  cursor: pointer;
}
.icon-btn:active {
  background: rgba(255, 255, 255, 0.12);
}

/* Vertical Snap Feed */
.feed {
  width: 100%;
  height: 100dvh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar {
  display: none;
}

.feed-item {
  position: relative;
  width: 100%;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
  background: var(--bg);
  user-select: none;
  -webkit-user-select: none;
}

.media-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
}

.feed-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--bg);
}

/* Slideshow */
.slideshow-track {
  position: absolute;
  inset: 0;
  display: flex;
  overflow-x: scroll;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.slideshow-track::-webkit-scrollbar {
  display: none;
}

.slide-frame {
  position: relative;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #000000;
}

.slide-bg {
  position: absolute;
  inset: -16px;
  width: calc(100% + 32px);
  height: calc(100% + 32px);
  object-fit: cover;
  filter: blur(24px) brightness(0.32);
  transform: scale(1.06);
  pointer-events: none;
}

.slide-img {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.slide-dots {
  position: absolute;
  bottom: calc(14px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 5px;
}
.slide-dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  transition: width 200ms var(--ease-out), background-color 160ms ease;
}
.slide-dot.active {
  width: 16px;
  background: #ffffff;
}

/* Subtle Bottom Gradient Scrim & Meta */
.scrim {
  position: absolute;
  inset: auto 0 0 0;
  height: 34%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.24) 55%, transparent 100%);
  pointer-events: none;
  z-index: 10;
}

.item-meta {
  position: absolute;
  left: 14px;
  right: 74px;
  bottom: calc(22px + var(--safe-bottom));
  z-index: 14;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.note-pill {
  align-self: flex-start;
  max-width: 100%;
  padding: 7px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1.3;
  background: rgba(18, 18, 20, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--fg);
  pointer-events: auto;
}

.author-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}

.new-tag {
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #ffffff;
  background: var(--accent);
}

.caption {
  margin: 0;
  font-size: 14px;
  line-height: 1.36;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  pointer-events: auto;
  cursor: pointer;
}
.caption.expanded {
  -webkit-line-clamp: 8;
}

/* Native TikTok / Smolish Right Action Rail (clean bare icons, zero glass bubbles) */
.action-rail {
  position: absolute;
  right: 10px;
  bottom: calc(28px + var(--safe-bottom));
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.rail-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.rail-count {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.rail-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  background: transparent;
  color: #ffffff;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.65));
}

.rail-btn.liked {
  color: var(--accent);
}

.rail-stat {
  width: 40px;
  height: 36px;
  display: grid;
  place-items: center;
  color: #ffffff;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.65));
}

/* Razor-thin Progress Line (native TikTok style) */
.progress-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--safe-bottom);
  height: 2px;
  background: rgba(255, 255, 255, 0.18);
  z-index: 15;
  pointer-events: none;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: rgba(255, 255, 255, 0.92);
  transition: width 120ms linear;
}

/* Center Tap Feedback (crisp minimal indicator, no heavy blur circle) */
.center-feedback {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.88);
  z-index: 20;
  width: 68px;
  height: 68px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  color: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 220ms var(--ease-out);
}
.center-feedback.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.feedback-heart {
  color: var(--accent);
  display: grid;
  place-items: center;
}

/* Empty State */
.empty-state {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 10;
  background: var(--bg);
}

/* Native iOS History Bottom Sheet */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.62);
}

.drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  max-height: 82dvh;
  display: flex;
  flex-direction: column;
  border-radius: 22px 22px 0 0;
  padding: 10px 14px calc(16px + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  animation: sheetUp 240ms var(--ease-out);
}

@keyframes sheetUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.drawer-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  margin: 0 auto 12px;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 2px;
}

.drawer-sub {
  margin: 2px 0 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.sheet-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--fg);
  cursor: pointer;
}

.history-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  border-radius: 12px;
  overflow-x: hidden;
  padding-bottom: 12px;
}

.history-tile {
  position: relative;
  aspect-ratio: 9 / 14;
  border-radius: 6px;
  overflow: hidden;
  border: 0;
  background: var(--surface-2);
  padding: 0;
  cursor: pointer;
}
.history-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.history-tile.active-tile {
  outline: 2px solid var(--fg);
  outline-offset: -2px;
}

.tile-badges {
  position: absolute;
  top: 5px;
  left: 5px;
  right: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.tile-pill {
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.72);
  color: #ffffff;
}
.tile-pill.new {
  background: var(--accent);
}

.tile-heart {
  position: absolute;
  right: 6px;
  bottom: 5px;
  font-size: 13px;
  color: var(--accent);
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.85));
}

.drawer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.drawer-brand {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--muted);
}

.text-btn {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 4px;
  cursor: pointer;
}

/* Crisp Minimal Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 80;
  padding: 9px 15px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--fg);
  white-space: nowrap;
}
