/* ============================================
   Media Downloader — Real App
   ============================================ */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f4f3ef;
  --ink: #141414;
  --ink-2: #3d3d3e;
  --ink-3: #75757a;
  --ink-4: #a4a4a9;
  --line: #e8e7e2;
  --line-2: #dcdbd5;
  --accent: #0a84ff;
  --accent-soft: #e7f0ff;
  --warn: #ff3b30;
  --ok: #32c759;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 1px rgba(0,0,0,.03);
  --shadow-md: 0 8px 24px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --shadow-lg: 0 20px 48px rgba(0,0,0,.14), 0 6px 16px rgba(0,0,0,.06);
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --bp: 768px;
  --pwa-nav-pad: 24px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: calc(var(--vh) * 100); overscroll-behavior: none; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02","cv03","cv04","cv11";
  overflow: hidden;
}

#root { height: 100%; }

/* ============= App Shell ============= */
.app-shell {
  display: flex;
  height: calc(var(--vh) * 100);
  background: var(--bg);
  overflow: hidden;
}

/* ============= Desktop Rail ============= */
.rail {
  display: none;
  flex-shrink: 0;
  width: 72px;
  padding: 14px 0 18px;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border-right: 1px solid var(--line);
  background: var(--surface-2);
  height: calc(var(--vh) * 100);
}
@media (min-width: 768px) { .rail { display: flex; } }

.rail-btn {
  width: 48px;
  height: 52px;
  border: none;
  background: transparent;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-3);
  cursor: pointer;
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.rail-btn svg { width: 22px; height: 22px; stroke-width: 1.7; padding: 7px; box-sizing: content-box; border-radius: 10px; transition: background .15s, color .15s; }
.rail-btn:hover svg { background: rgba(0,0,0,.04); }
.rail-btn:hover { color: var(--ink-2); }
.rail-btn.active { color: var(--accent); font-weight: 600; }
.rail-btn.active svg { background: var(--accent-soft); color: var(--accent); }
.rail-fab {
  margin-top: auto;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(10,132,255,.35);
}
.rail-fab svg { width: 20px; height: 20px; }

/* ============= App Main ============= */
.app-main {
  flex: 1;
  min-width: 0;
  position: relative;
  height: calc(var(--vh) * 100);
  overflow: hidden;
}

/* Desktop: flex column so dt-header + scroll stack vertically */
@media (min-width: 768px) {
  .app-main {
    display: flex;
    flex-direction: column;
  }
}

/* ============= Scroll Area ============= */
/* Mobile: fills entire app-main absolutely */
.app-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.app-scroll::-webkit-scrollbar { display: none; }

/* Desktop: flex child that fills remaining height */
@media (min-width: 768px) {
  .app-scroll {
    position: static;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }
}

/* ============= Mobile Sticky Header ============= */
.lib-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  background: rgba(251, 250, 247, 0.88);
  backdrop-filter: saturate(1.5) blur(20px);
  -webkit-backdrop-filter: saturate(1.5) blur(20px);
  transition: transform .22s cubic-bezier(.22,1,.36,1), opacity .22s, border-bottom-color .18s;
  border-bottom: 1px solid transparent;
}
.lib-header.scrolled { border-bottom-color: rgba(0,0,0,.08); }
.lib-header.hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}
.edit-mode .lib-header,
.edit-mode .lib-header.hidden {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}
.lib-header-inner { padding: calc(16px + env(safe-area-inset-top, 0px)) 20px 14px; }
.lib-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.lib-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.lib-subtitle {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-top: 2px;
}
.select-btn {
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
  background: transparent;
  border: none;
  padding: 6px 0;
  cursor: pointer;
  flex-shrink: 0;
  align-self: flex-start;
}

/* Hide mobile header on desktop */
@media (min-width: 768px) { .lib-header { display: none !important; } }

/* ============= Desktop Sticky Header ============= */
.dt-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid transparent;
  transition: background .18s, border-bottom-color .18s;
}
.dt-header.scrolled {
  background: rgba(255,255,255,0.88);
  backdrop-filter: saturate(1.5) blur(20px);
  -webkit-backdrop-filter: saturate(1.5) blur(20px);
  border-bottom-color: var(--line);
}
@media (min-width: 768px) { .dt-header { display: block; } }
.dt-header-inner {
  padding: 24px 36px 16px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.dt-header .lib-title { font-size: 32px; }

/* ============= Mobile spacer under lib-header ============= */
.lib-spacer { height: calc(72px + env(safe-area-inset-top, 0px)); }
@media (min-width: 768px) { .lib-spacer { display: none; } }

/* ============= Date Separators ============= */
.date-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .14em;
  padding: 20px 20px 10px;
}
.date-sep .rule { flex: 1; height: 1px; background: var(--line); }
@media (min-width: 768px) { .date-sep { padding: 20px 36px 10px; } }

/* ============= Feed Items ============= */
.feed-section { padding: 0 20px; }
@media (min-width: 768px) { .feed-section { padding: 0 36px; } }

.feed-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
@media (min-width: 768px) {
  .feed-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }
}

.feed-bottom-pad { height: 120px; }
@media (min-width: 768px) { .feed-bottom-pad { height: 60px; } }

.feed-item {
  position: relative;
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
}
.feed-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
  min-width: 0;
}
.feed-meta .avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e9e5dc, #cfccc0);
  flex-shrink: 0;
  overflow: hidden;
}
.feed-meta .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.feed-meta .uploader { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; max-width: 30%; min-width: 0; }
.feed-meta .dot { color: var(--ink-4); font-size: 10px; flex-shrink: 0; }
.feed-meta .src {
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 11px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex: 1 1 0;
  min-width: 0;
  text-decoration: none;
}
.feed-meta .src:hover { text-decoration: underline; }
.feed-meta .time { color: var(--ink-3); font-size: 12px; flex-shrink: 0; }

@media (min-width: 768px) {
  .feed-meta { font-size: 12px; margin-bottom: 8px; }
  .feed-meta .avatar { width: 20px; height: 20px; }
}

.thumb {
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  background: var(--surface-2);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.thumb-zoom img { transition: transform .2s ease; }
.thumb.thumb-zoom:hover img,
.thumb.thumb-zoom:active img { transform: scale(1.03); }
.thumb.tall { aspect-ratio: 4/5; }
/* Square on desktop */
@media (min-width: 768px) {
  .thumb.tall { aspect-ratio: 1; border-radius: 12px; }
}

.chip-group {
  position: absolute;
  top: 10px; left: 10px;
  display: flex; gap: 6px; align-items: center; z-index: 2;
}
.chip {
  background: rgba(0,0,0,.55);
  color: #fff;
  font-family: var(--mono);
  font-size: 10px; font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: .06em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: 4px;
}
.chip svg { width: 10px; height: 10px; }
.dur {
  position: absolute; right: 10px; bottom: 10px; z-index: 2;
  background: rgba(0,0,0,.62);
  color: #fff; font-family: var(--mono); font-size: 11px;
  padding: 3px 7px; border-radius: 5px; backdrop-filter: blur(8px);
}
.play-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 1; pointer-events: none;
}
.play-overlay .pc {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(255,255,255,.92);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
}
.play-overlay .pc svg { width: 22px; height: 22px; margin-left: 2px; color: #000; }
@media (min-width: 768px) {
  .play-overlay .pc { width: 44px; height: 44px; }
  .play-overlay .pc svg { width: 17px; height: 17px; margin-left: 1px; }
}

.dots {
  position: absolute; left: 50%; bottom: 10px;
  transform: translateX(-50%);
  display: flex; gap: 4px; z-index: 2;
}
.dots span { width: 5px; height: 5px; border-radius: 50%; background: rgba(255,255,255,.5); }
.dots span.on { background: rgba(255,255,255,.95); }

/* Selection indicator */
.sel {
  position: absolute; top: 16px; right: 16px; z-index: 5;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(255,255,255,.8);
  border: 1.5px solid rgba(255,255,255,.98);
  backdrop-filter: blur(10px);
  display: none; align-items: center; justify-content: center;
  box-shadow: 0 0 0 1px rgba(0,0,0,.1), 0 2px 6px rgba(0,0,0,.18);
  transition: transform .12s, background .12s;
}
.sel svg { width: 14px; height: 14px; color: #fff; opacity: 0; transition: opacity .1s; }
.edit-mode .sel { display: flex; }
@media (min-width: 768px) {
  .sel { top: 10px; right: 10px; width: 22px; height: 22px; }
}
.feed-item.selected .sel { background: var(--accent); border-color: #fff; transform: scale(1.05); }
.feed-item.selected .sel svg { opacity: 1; }
.feed-item.selected .thumb { box-shadow: 0 0 0 3px var(--accent), 0 0 0 5px rgba(10,132,255,.2); }

/* ============= Mobile Bottom Nav ============= */
.nav {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  background: rgba(251, 250, 247, 0.88);
  backdrop-filter: saturate(1.5) blur(20px);
  -webkit-backdrop-filter: saturate(1.5) blur(20px);
  border-top: 1px solid rgba(0,0,0,.08);
  padding: 6px;
  transition: transform .24s cubic-bezier(.22,1,.36,1);
}
.nav.hidden { transform: translateY(100%); }
.edit-mode .nav { display: none; }
@media (min-width: 768px) { .nav { display: none !important; } }
@media (display-mode: standalone) { .nav { padding-bottom: var(--pwa-nav-pad); } }

.nav-btn {
  flex: 1; padding: 8px 0 6px;
  border: none; background: transparent;
  color: var(--ink-3);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-family: inherit; font-size: 10px; font-weight: 500;
  cursor: pointer; border-radius: 10px;
}
.nav-btn svg { width: 24px; height: 24px; stroke-width: 1.8; }
.nav-btn.active { color: var(--accent); }

/* ============= FAB ============= */
.fab {
  position: absolute; right: 18px; bottom: 80px; z-index: 30;
  width: 56px; height: 56px; border-radius: 50%;
  border: none; background: var(--accent); color: #fff;
  box-shadow: 0 6px 16px rgba(10,132,255,.4), 0 2px 4px rgba(0,0,0,.1);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: bottom .24s cubic-bezier(.22,1,.36,1), transform .15s;
}
.fab:active { transform: scale(.94); }
.fab.nav-hidden { bottom: 18px; }
.fab svg { width: 24px; height: 24px; stroke-width: 2; }
.edit-mode .fab { display: none; }
@media (min-width: 768px) { .fab { display: none; } }
@media (display-mode: standalone) { .fab { bottom: calc(80px + var(--pwa-nav-pad)); } }

/* ============= Mobile Edit Bar ============= */
.edit-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 25;
  background: rgba(251, 250, 247, 0.92);
  backdrop-filter: saturate(1.5) blur(20px);
  -webkit-backdrop-filter: saturate(1.5) blur(20px);
  border-top: 1px solid rgba(0,0,0,.08);
  padding: 12px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  display: none; align-items: center; gap: 14px;
}
.edit-mode .edit-bar { display: flex; }
@media (min-width: 768px) { .edit-bar { display: none !important; } }

.edit-bar .count-label { font-size: 15px; color: var(--ink); font-weight: 600; }
.edit-bar .spacer { flex: 1; }
.edit-bar .delete {
  font-family: inherit; font-size: 15px; font-weight: 500;
  color: var(--warn); background: transparent; border: none;
  cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.edit-bar .delete svg { width: 16px; height: 16px; }
.edit-bar .delete:disabled { color: var(--ink-4); cursor: not-allowed; }

/* ============= Desktop Edit Bar (inside dt-header) ============= */
.dt-edit-bar {
  display: none;
  align-items: center; gap: 10px;
  padding: 10px 36px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--line);
}
.edit-mode .dt-edit-bar { display: flex; }
.dt-edit-bar .count-label { font-size: 15px; color: var(--ink); font-weight: 600; }
.dt-edit-bar .spacer { flex: 1; }
.dt-edit-bar button {
  font-family: inherit; font-size: 13px; font-weight: 500;
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  display: inline-flex; align-items: center; gap: 6px;
}
.dt-edit-bar button:hover { background: var(--surface-2); }
.dt-edit-bar button.danger { background: var(--warn); border-color: var(--warn); color: #fff; }
.dt-edit-bar button.danger:hover { background: #e5342a; }
.dt-edit-bar button.danger:disabled { background: var(--line); color: var(--ink-4); border-color: var(--line); cursor: not-allowed; }
.dt-edit-bar button svg { width: 14px; height: 14px; }

/* ============= Confirm Sheet ============= */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.3);
  display: none; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .2s;
}
.sheet-backdrop.open { display: flex; opacity: 1; }
@media (min-width: 768px) {
  .sheet-backdrop { align-items: center; }
}
.sheet {
  width: 100%;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 12px 18px 26px;
  box-shadow: 0 -12px 40px rgba(0,0,0,.15);
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.22,1,.36,1);
}
.sheet-backdrop.open .sheet { transform: translateY(0); }
@media (min-width: 768px) {
  .sheet {
    max-width: 380px; border-radius: 16px; padding: 22px 24px;
    transform: scale(.96); transition: transform .2s;
  }
  .sheet-backdrop.open .sheet { transform: scale(1); }
}
.sheet .grip {
  width: 36px; height: 4px; background: var(--line-2); border-radius: 2px; margin: 0 auto 14px;
}
@media (min-width: 768px) { .sheet .grip { display: none; } }
.sheet h4 { margin: 6px 0 8px; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.sheet p { margin: 0 0 18px; font-size: 14px; color: var(--ink-3); line-height: 1.5; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; }
@media (min-width: 768px) { .sheet-actions { flex-direction: row-reverse; } }
@media (min-width: 768px) { .sheet-actions button { flex: 1; } }
.sheet-btn {
  padding: 13px 14px; border-radius: 12px; font-family: inherit;
  font-size: 15px; font-weight: 500; border: none;
  background: var(--surface-2); color: var(--ink); cursor: pointer;
}
.sheet-btn.destructive { background: var(--warn); color: #fff; }
@media (min-width: 768px) { .sheet-btn { padding: 10px 14px; font-size: 14px; } }

/* ============= Dark Mode ============= */
body.dark {
  --bg: #0a0a0b;
  --surface: #141416;
  --surface-2: #1e1e21;
  --ink: #f5f5f7;
  --ink-2: #c7c7cc;
  --ink-3: #8e8e93;
  --ink-4: #636366;
  --line: #2a2a2e;
  --line-2: #3a3a3f;
}
body.dark .lib-header { background: rgba(10,10,11,.88); }
body.dark .dt-header.scrolled { background: rgba(20,20,22,.88); border-bottom-color: var(--line); }
body.dark .nav { background: rgba(10,10,11,.88); border-top-color: rgba(255,255,255,.06); }
body.dark .edit-bar { background: rgba(10,10,11,.92); border-top-color: rgba(255,255,255,.06); }
body.dark .sel { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.4); }
body.dark .dt-edit-bar { background: rgba(10,132,255,.15); border-bottom-color: var(--line); }
body.dark .rail { background: #0a0a0b; border-right-color: var(--line); }

/* ============= Tweaks Panel ============= */
#tweaks {
  position: fixed; right: 20px; bottom: 20px;
  width: 260px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--line);
  padding: 14px;
  z-index: 1000;
  font-size: 13px;
}
#tweaks h5 {
  margin: 0 0 10px;
  font-size: 11px; font-family: var(--mono);
  text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3);
}
.tw-row { margin-bottom: 12px; }
.tw-row:last-child { margin-bottom: 0; }
.tw-row-label { font-size: 12px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500; }
.tw-seg { display: flex; background: var(--surface-2); border-radius: 8px; padding: 2px; gap: 2px; }
.tw-seg button {
  flex: 1; padding: 6px 8px; border: none; background: transparent;
  font-family: inherit; font-size: 12px; border-radius: 6px; cursor: pointer; color: var(--ink-3);
}
.tw-seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.tw-swatches { display: flex; gap: 8px; }
.tw-swatches button { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.tw-swatches button.on { border-color: var(--ink); }
body.dark #tweaks { background: var(--surface); border-color: var(--line); }
body.dark .tw-seg { background: var(--surface-2); }
body.dark .tw-seg button.on { background: var(--surface); }

/* =========================================================================
   Downloads Screen
   ========================================================================= */
.dl-section-label {
  padding: 14px 20px 8px;
  font-size: 12px; font-weight: 600; letter-spacing: .06em;
  color: var(--ink-3); text-transform: uppercase;
  display: flex; align-items: baseline; gap: 8px;
}
.dl-section-label .count { font-weight: 500; color: var(--ink-4); letter-spacing: 0; text-transform: none; font-size: 12px; }
@media (min-width: 768px) { .dl-section-label { padding: 18px 36px 10px; font-size: 11px; } }

.dl-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px; align-items: center;
  padding: 14px 20px; position: relative;
}
.dl-row + .dl-row::before {
  content: ''; position: absolute; left: 90px; right: 20px; top: 0; height: 1px; background: var(--line);
}
@media (min-width: 768px) {
  .dl-row { padding: 14px 36px; grid-template-columns: 64px 1fr auto; gap: 18px; }
  .dl-row + .dl-row::before { left: 118px; right: 36px; }
  .dl-row:hover { background: rgba(0,0,0,.02); }
}

.dl-thumb {
  position: relative; width: 56px; height: 56px;
  border-radius: 10px; overflow: hidden; background: var(--surface-2); flex-shrink: 0;
}
.dl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dl-thumb .thumb-chip {
  position: absolute; bottom: 4px; left: 4px;
  background: rgba(0,0,0,.7); color: #fff;
  font-size: 9.5px; font-weight: 600; padding: 2px 5px; border-radius: 4px;
  line-height: 1; letter-spacing: .02em; display: inline-flex; align-items: center;
}
.dl-thumb .thumb-play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 22px; height: 22px; background: rgba(255,255,255,.92); color: #000;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.dl-thumb .thumb-play svg { width: 10px; height: 10px; }
.dl-thumb.inspect {
  background: var(--surface-2); display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace; font-size: 9.5px; color: var(--ink-3);
  letter-spacing: .04em; overflow: hidden;
}
.dl-thumb.inspect::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(10,132,255,.15) 50%, transparent 100%);
  animation: dl-shimmer 1.6s linear infinite;
}
@keyframes dl-shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.dl-thumb.fail { background: #fdecea; display: flex; align-items: center; justify-content: center; color: var(--warn); }
.dl-thumb.fail svg { width: 22px; height: 22px; }
body.dark .dl-thumb.fail { background: rgba(255,69,58,.16); }
@media (min-width: 768px) { .dl-thumb { width: 64px; height: 64px; border-radius: 11px; } }

.dl-main { min-width: 0; }
.dl-name { font-size: 15px; font-weight: 600; color: var(--ink); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-name.muted { color: var(--ink-3); font-weight: 500; }
.dl-sub { margin-top: 2px; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: 'JetBrains Mono', monospace; letter-spacing: -.01em; text-decoration: none; display: block; }
.dl-sub:hover { text-decoration: underline; }
.dl-status {
  margin-top: 6px; font-size: 12px; font-weight: 500;
  display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums;
}
.dl-status.saved { color: var(--ok); }
.dl-status.failed { color: var(--warn); }
.dl-status.queued { color: var(--ink-3); }
.dl-status.active { color: var(--accent); }
.dl-status .sep { color: var(--ink-4); }
.dl-status .retry-link { color: var(--warn); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font-weight: 600; }
.dl-bar {
  margin-top: 8px; height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; position: relative;
}
.dl-bar .fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width .4s cubic-bezier(.22,1,.36,1); position: relative;
}
.dl-bar .fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.4), transparent);
  animation: dl-fill-shine 1.8s linear infinite; transform: translateX(-100%);
}
@keyframes dl-fill-shine { 0% { transform: translateX(-100%); } 100% { transform: translateX(200%); } }
.dl-bar.indeterminate .fill { width: 40% !important; animation: dl-indeterminate 1.2s ease-in-out infinite; }
@keyframes dl-indeterminate { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
body.dark .dl-bar { background: rgba(255,255,255,.08); }

.dl-actions { display: flex; align-items: center; gap: 6px; }
.dl-iconbtn {
  width: 34px; height: 34px; border-radius: 8px; border: 0;
  background: transparent; color: var(--ink-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background .12s;
}
.dl-iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.dl-iconbtn svg { width: 18px; height: 18px; stroke-width: 1.8; }
.dl-iconbtn.warn { color: var(--warn); }
.dl-textbtn {
  font-family: inherit; font-size: 13px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  padding: 6px 12px; border-radius: 7px; cursor: pointer; transition: background .12s;
}
.dl-textbtn:hover { background: var(--surface-2); }
.dl-textbtn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.dl-textbtn.warn { color: var(--warn); border-color: rgba(255,69,58,.25); }

/* Mobile/desktop visibility helpers for dl-actions */
.dl-actions .dt-only { display: none; }
.dl-actions .mb-only { display: flex; }
@media (min-width: 768px) {
  .dl-actions .dt-only { display: inline-flex; }
  .dl-actions .mb-only { display: none; }
}

/* Three-dot dropdown menu */
.dl-more-wrap { position: relative; }
.dl-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 100;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  min-width: 130px;
  animation: menu-in .1s ease;
}
body.dark .dl-menu { box-shadow: 0 4px 20px rgba(0,0,0,.4); }
@keyframes menu-in {
  from { opacity: 0; transform: scale(.95) translateY(-4px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}
.dl-menu-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 10px; border: 0; border-radius: 7px;
  background: transparent; font-family: inherit; font-size: 14px;
  font-weight: 500; color: var(--ink); cursor: pointer; text-align: left;
  transition: background .1s;
}
.dl-menu-item:hover { background: var(--surface-2); }
.dl-menu-item.danger { color: var(--warn); }
.dl-menu-item svg { flex-shrink: 0; stroke-width: 2; }

/* =========================================================================
   Settings Screen
   ========================================================================= */
.st-section-label {
  padding: 20px 20px 8px;
  font-size: 12px; font-weight: 600; letter-spacing: .06em; color: var(--ink-3); text-transform: uppercase;
}
@media (min-width: 768px) { .st-section-label { padding: 22px 0 10px; font-size: 11px; } }

.st-group { margin: 0 16px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
@media (min-width: 768px) { .st-group { margin: 0 0 10px; } }

.st-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; position: relative; min-height: 56px; }
.st-row + .st-row::before { content: ''; position: absolute; left: 56px; right: 0; top: 0; height: 1px; background: var(--line); }
.st-row .ico { width: 28px; height: 28px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.st-row .ico svg { width: 16px; height: 16px; stroke-width: 1.8; }
.st-row .ico.neutral { background: var(--surface-2); color: var(--ink-2); }
body.dark .st-row .ico.neutral { background: rgba(255,255,255,.08); }
.st-row .txt { flex: 1; min-width: 0; }
.st-row .ttl { font-size: 15px; font-weight: 500; color: var(--ink); line-height: 1.25; }
.st-row .val { margin-top: 2px; font-size: 12.5px; color: var(--ink-3); font-family: 'JetBrains Mono', monospace; letter-spacing: -.01em; }
.st-row .chev { width: 16px; height: 16px; color: var(--ink-4); flex-shrink: 0; stroke-width: 2; }
.st-row .badge { padding: 2px 8px; font-size: 11px; font-weight: 600; border-radius: 999px; letter-spacing: .02em; flex-shrink: 0; }
.st-row .badge.ok { background: #dff6e4; color: #2b7a3a; }
body.dark .st-row .badge.ok { background: rgba(48,161,78,.18); color: #7ce088; }
.st-row.tappable { cursor: pointer; transition: background .12s; }
.st-row.tappable:active { background: var(--surface-2); }
/* Desktop: show action buttons, hide chevrons */
.st-row .chev { display: block; }
.st-row .st-btn { display: none; }
@media (min-width: 768px) {
  .st-row .chev { display: none; }
  .st-row .st-btn { display: block; }
}
.st-row .st-btn {
  font-family: inherit; font-size: 13px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  padding: 6px 12px; border-radius: 7px; cursor: pointer; transition: background .12s; flex-shrink: 0;
}
.st-row .st-btn:hover { background: var(--surface-2); }
.st-row .st-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.st-row .st-btn.danger { background: var(--warn); color: #fff; border-color: var(--warn); }

.st-main {
  padding: 0 0 60px;
}
@media (min-width: 768px) {
  .st-main {
    max-width: 620px;
    margin: 0 auto;
    width: 100%;
    padding: 8px 36px 60px;
    box-sizing: border-box;
  }
}

/* =========================================================================
   Spotlight — dims everything except the highlighted library item
   ========================================================================= */
.spotlight-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, .55);
  animation: spotlight-in .18s ease;
  cursor: pointer;
  pointer-events: none;
}
body.dark .spotlight-backdrop { background: rgba(0, 0, 0, .7); }
@keyframes spotlight-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
/* Lift only the thumbnail above the backdrop; meta row stays dimmed */
.feed-item.spotlight-item {
  position: relative;
  border-radius: var(--radius);
}
.feed-item.spotlight-item .thumb {
  position: relative;
  z-index: 41;
}

/* =========================================================================
   Toast notification
   ========================================================================= */
.toast-wrap {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  pointer-events: none;
}
@media (min-width: 768px) {
  .toast-wrap { bottom: 24px; }
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--ink);
  color: var(--bg);
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,.22);
  pointer-events: auto;
  white-space: nowrap;
  animation: toast-in .2s cubic-bezier(.22,1,.36,1);
}
body.dark .toast { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.toast-msg { flex: 1; }
.toast-action {
  background: transparent; border: none; cursor: pointer;
  color: var(--accent); font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 0; flex-shrink: 0;
}
body.dark .toast-action { color: var(--accent); }
.toast-close {
  background: transparent; border: none; cursor: pointer;
  color: inherit; opacity: .5; padding: 0; display: flex; align-items: center;
  flex-shrink: 0;
}
.toast-close:hover { opacity: 1; }
/* ============================================================
   Sign-in page — all states
   Uses the same CSS variables as index.css
   ============================================================ */

/* ── Page shell ── */
.si-page {
  height: calc(var(--vh, 1vh) * 100);
  background: var(--bg);
  overflow: hidden;
}

/* Mobile layout visible by default; desktop hidden */
.si-mobile-wrap { display: flex; height: 100%; }
.si-desktop-wrap { display: none; }

@media (min-width: 768px) {
  .si-mobile-wrap { display: none; }
  .si-desktop-wrap {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    height: 100%;
  }
  /* Right column gets the white background — covers the full grid cell */
  .si-desktop-wrap > :last-child {
    background: var(--surface);
  }
}

/* ── Mobile container ── */
.si-mobile {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 74px 28px 40px;
  overflow-y: auto;
}

/* ── Brand / logo ── */
.si-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 24px;
}

.si-logo {
  width: 72px; height: 72px;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--accent), color-mix(in oklab, var(--accent) 70%, #8a5cf6 30%));
  display: grid; place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 34px;
  letter-spacing: -.04em;
  box-shadow: 0 10px 28px rgba(10,132,255,.28), 0 2px 6px rgba(0,0,0,.08);
  user-select: none;
}

/* ── Hero copy ── */
.si-hero {
  margin-top: 28px;
  text-align: center;
}
.si-hero h1 {
  margin: 0 0 8px;
  font-size: 32px;
  line-height: 1.08;
  letter-spacing: -0.025em;
  font-weight: 700;
}
.si-hero p {
  margin: 0 auto;
  font-size: 15px;
  color: var(--ink-3);
  line-height: 1.45;
  max-width: 280px;
}

.si-spacer { flex: 1; }

/* ── Action buttons ── */
.si-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.si-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: var(--surface);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: background .12s, transform .08s;
}
.si-btn:active { transform: scale(.985); }

.si-btn.google {
  background: #fff;
  border-color: #dadce0;
  color: #1f1f1f;
  box-shadow: 0 1px 2px rgba(60,64,67,.08), 0 1px 3px rgba(60,64,67,.06);
}
body.dark .si-btn.google {
  background: #131314;
  color: #e3e3e3;
  border-color: #3c4043;
}
.si-btn.google:hover { background: #f8f9fa; }
body.dark .si-btn.google:hover { background: #1a1a1c; }

.si-btn.ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--line);
}
.si-btn.ghost:hover { background: var(--surface-2); }

.si-btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.si-btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.si-btn.primary:disabled {
  background: var(--line);
  color: var(--ink-4);
  cursor: not-allowed;
}
.si-btn.primary svg { width: 16px; height: 16px; }

/* ── Google "G" logo ── */
.g-logo { width: 18px; height: 18px; flex-shrink: 0; }

/* ── Divider ── */
.si-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-4);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.si-divider::before, .si-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ── Legal text ── */
.si-legal {
  text-align: center;
  margin-top: 14px;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.5;
}
.si-legal a {
  color: var(--ink-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Back button (mobile) ── */
.si-back {
  position: absolute;
  top: 56px;
  left: 16px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-2);
  display: grid; place-items: center;
  cursor: pointer;
  z-index: 5;
}
.si-back:hover { background: var(--surface-2); }
.si-back svg { width: 20px; height: 20px; }

/* ── Email form ── */
.si-email-form {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.si-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.si-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .1em;
}
.si-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  box-sizing: border-box;
}
.si-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}
.si-input::placeholder { color: var(--ink-4); }

.si-error {
  font-size: 12.5px;
  color: var(--warn);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.si-error svg { width: 14px; height: 14px; flex-shrink: 0; }

.si-help {
  font-size: 13px;
  color: var(--ink-3);
  text-align: center;
  margin-top: 8px;
  line-height: 1.5;
}

/* ── Email tag (inline pill) ── */
.si-email-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink);
  background: var(--surface-2);
  padding: 4px 10px;
  border-radius: 999px;
  margin: 0 2px;
}

/* ── OTP cells — real <input> elements ── */
.otp-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 8px 0 4px;
}
.otp-cell {
  width: 46px;
  height: 56px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
  text-align: center;
  padding: 0;
  outline: none;
  caret-color: transparent;
}
.otp-cell.filled { border-color: var(--ink-3); }
.otp-cell.active,
.otp-cell:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}
.otp-cell.active:not(.filled)::after {
  content: '';
  width: 2px;
  height: 26px;
  background: var(--accent);
  animation: si-blink 1s steps(2) infinite;
}
@keyframes si-blink { 50% { opacity: 0; } }

/* ── Resend row ── */
.si-resend-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--ink-3);
  margin-top: 16px;
}
.si-resend-row button {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}
.si-resend-row button:disabled { color: var(--ink-4); cursor: not-allowed; }

/* ── Success state ── */
.si-success {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 40px;
  text-align: center;
}
.si-success .ring {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--ok), #28a047);
  display: grid; place-items: center;
  color: #fff;
  box-shadow: 0 10px 30px rgba(50,199,89,.3);
  animation: si-pop .45s cubic-bezier(.22,1.4,.36,1);
}
.si-success .ring svg { width: 38px; height: 38px; stroke-width: 3; }
@keyframes si-pop { from { transform: scale(.4); opacity: 0; } }
.si-success h3 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.si-success p {
  margin: 0;
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1.5;
  max-width: 260px;
}
.si-success-email {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-2);
  background: var(--surface-2);
  padding: 5px 10px;
  border-radius: 8px;
}

/* ── Google account chooser sheet (mobile overlay) ── */
.gchoose {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.32);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.gchoose-sheet {
  width: 100%;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 8px 0 28px;
  box-shadow: 0 -12px 40px rgba(0,0,0,.2);
  max-height: 85%;
  overflow: hidden;
}
.gchoose-sheet .grip {
  width: 36px; height: 4px;
  background: var(--line-2);
  border-radius: 2px;
  margin: 8px auto 16px;
}
.gchoose-sheet .ghead {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 16px;
  border-bottom: 1px solid var(--line);
}
.gchoose-sheet .ghead h4 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.gchoose-sheet .ghead .app {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
}
.gchoose-list { padding: 6px 0; }

/* ── Account row (shared mobile + desktop) ── */
.gchoose-acct {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background .1s;
}
.gchoose-acct:hover { background: var(--surface-2); }
.gchoose-acct .av {
  width: 36px; height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-2);
}
.gchoose-acct .av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gchoose-acct .av.letter {
  display: grid; place-items: center;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}
.gchoose-acct .name { flex: 1; min-width: 0; }
.gchoose-acct .name .n { font-size: 14px; font-weight: 500; color: var(--ink); line-height: 1.2; }
.gchoose-acct .name .e { font-size: 12.5px; color: var(--ink-3); font-family: var(--mono); }
.gchoose-acct .chev { color: var(--ink-4); width: 14px; height: 14px; }

.gchoose-add {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px 4px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
}
.gchoose-add:hover { background: var(--surface-2); }
.gchoose-add .plus {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--ink-3);
}

/* ── Desktop left panel ── */
.si-left {
  position: relative;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  padding: 56px 52px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.si-left .si-logo {
  width: 54px; height: 54px;
  border-radius: 14px;
  font-size: 26px;
  box-shadow: 0 6px 18px rgba(10,132,255,.3);
}
.si-left-copy { position: relative; z-index: 2; }
.si-left-copy h2 {
  margin: 0 0 14px;
  font-size: 44px;
  line-height: 1.02;
  letter-spacing: -0.03em;
  font-weight: 700;
  max-width: 420px;
  color: var(--ink);
}
.si-left-copy h2 em {
  font-style: normal;
  color: var(--accent);
}
.si-left-copy p {
  margin: 0 0 22px;
  max-width: 380px;
  font-size: 15px;
  color: var(--ink-3);
  line-height: 1.5;
}
.si-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 380px;
}
.si-feat {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.4;
}
.si-feat .dot {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.si-feat .dot svg { width: 15px; height: 15px; stroke-width: 2; }
.si-feat b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 1px; font-size: 14px; }

/* ── Desktop right panel ── */
/* Outer scroll container — fills the grid cell */
.si-right-col {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
}

/* Inner centering wrapper — centers the fixed-height state block */
.si-right {
  padding: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  position: relative; /* anchor for the absolutely-positioned back link */
}

/* Each state block has a fixed min-height so the centered position is stable
   even when content height varies between states. */
.si-right-state {
  display: flex;
  flex-direction: column;
  min-height: 460px;
  justify-content: flex-start;
}

/* Success is an exception — it centers its own content within the block */
.si-right-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
  min-height: 460px;
}

.si-right h3 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.si-right .sub-text {
  margin: 0 0 24px;
  font-size: 14px;
  color: var(--ink-3);
  line-height: 1.5;
}
.si-right .si-actions { gap: 10px; }
.si-right .si-btn { padding: 12px 16px; }

/* Desktop chooser list (inline, not a sheet) */
.si-chooser-list {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 4px;
}
.si-chooser-list .gchoose-acct { padding: 14px 16px; }
.si-chooser-list .gchoose-acct + .gchoose-acct { border-top: 1px solid var(--line); }
.si-chooser-list .gchoose-add { padding: 14px 16px; }

/* ── Desktop back link — sits in flow just above the heading ── */
.si-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 6px 10px 6px 6px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  transition: color .12s, background .12s;
  align-self: flex-start;
  margin-bottom: 28px;
  margin-left: -6px;
  transform: translateY(-8px);
}
.si-back-link:hover { color: var(--ink); background: var(--surface-2); }
.si-back-link svg { width: 14px; height: 14px; stroke-width: 2; }
/* =========================================================================
   Search Page
   ========================================================================= */

/* Desktop layout: filter rail + content column sit side by side */
.sr-app-main {
  display: flex;
  flex-direction: column;
}
@media (min-width: 768px) {
  .sr-app-main {
    flex-direction: row;
    overflow: hidden;
  }
}

/* ── Content column (wraps dt-header + app-scroll) ── */
.sr-content-col {
  flex: 1;
  min-width: 0;
  position: relative;
  height: calc(var(--vh) * 100);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
@media (min-width: 768px) {
  .sr-content-col {
    display: flex;
    flex-direction: column;
  }
  .sr-content-col .app-scroll {
    position: static;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }
}

/* =========================================================================
   Search bar
   ========================================================================= */
.sr-search-wrap {
  padding: 10px 0 2px;
}

.sr-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 9px 12px;
  cursor: text;
}
.sr-bar--desktop {
  max-width: 560px;
}

.sr-bar-ic {
  width: 16px;
  height: 16px;
  color: var(--ink-3);
  flex-shrink: 0;
}
.sr-bar-q {
  flex: 1;
  font-size: 15px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sr-bar-mode {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 7px;
  border-radius: 6px;
  letter-spacing: .04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.sr-bar-kbd {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 6px;
  flex-shrink: 0;
}

/* =========================================================================
   Mobile filter pills bar
   ========================================================================= */
.sr-filter-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 0 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.sr-filter-pills::-webkit-scrollbar { display: none; }

.sr-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--line-2);
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
.sr-filter-btn svg { width: 14px; height: 14px; }
.sr-filter-count {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 5px;
  line-height: 1.4;
}

/* =========================================================================
   Pills (shared mobile + desktop)
   ========================================================================= */
.sr-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
  flex-shrink: 0;
}
.sr-pill--sim {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}
.sr-pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.sr-pill-x {
  color: var(--ink-3);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  margin-left: 1px;
}
.sr-pill--sim .sr-pill-x { color: var(--accent); opacity: .7; }
.sr-pill-x:hover { opacity: 1; }

/* =========================================================================
   Desktop sticky header (inside sr-content-col)
   ========================================================================= */
.sr-dt-header {
  display: none;
  padding: 20px 36px 0;
  flex-direction: column;
}
@media (min-width: 768px) {
  .sr-dt-header { display: flex; }
}
.sr-dt-top { padding-bottom: 12px; }
.sr-dt-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 0 14px;
  flex-wrap: wrap;
}

/* =========================================================================
   Mobile spacer under lib-header
   ========================================================================= */
.sr-mb-spacer {
  /* safe-area + 16px top + title ~40px + search ~44px + pills ~40px + 14px bottom */
  height: calc(154px + env(safe-area-inset-top, 0px));
}
@media (min-width: 768px) { .sr-mb-spacer { display: none; } }

/* =========================================================================
   Meta line
   ========================================================================= */
.sr-meta {
  padding: 10px 20px 6px;
  font-size: 13px;
  color: var(--ink-3);
}
@media (min-width: 768px) { .sr-meta { padding: 14px 36px 8px; } }
.sr-meta-accent { color: var(--accent); font-weight: 600; }

/* =========================================================================
   Flat results list
   ========================================================================= */
.sr-flat-list--mobile  { display: flex; flex-direction: column; }
.sr-flat-list--desktop { display: none; }

@media (min-width: 768px) {
  .sr-flat-list--mobile  { display: none; }
  .sr-flat-list--desktop {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    padding: 0 36px;
  }
}

/* Mobile row */
.sr-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 20px;
  position: relative;
  cursor: pointer;
}
.sr-row + .sr-row::before {
  content: '';
  position: absolute;
  left: 104px; right: 20px; top: 0;
  height: 1px;
  background: var(--line);
}
.sr-row:active { background: var(--surface-2); }

.sr-row-thumb {
  position: relative;
  width: 72px; height: 72px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  flex-shrink: 0;
}
.sr-row-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.sr-row-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.sr-row-head { display: flex; align-items: center; gap: 7px; }

.sr-row-avatar {
  width: 20px; height: 20px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-2);
}
.sr-row-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.sr-row-uploader {
  font-size: 13px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sr-row-src-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sr-row-src {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.sr-row-time { font-size: 12px; color: var(--ink-3); flex-shrink: 0; }

/* Desktop card */
.sr-card { display: flex; flex-direction: column; gap: 6px; cursor: pointer; min-width: 0; }
.sr-card:hover .sr-card-thumb img { transform: scale(1.03); }

.sr-card-thumb {
  position: relative; width: 100%; aspect-ratio: 1;
  border-radius: 12px; overflow: hidden; background: var(--surface-2);
}
.sr-card-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .2s ease;
}
.sr-card-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sr-card-row .sr-row-uploader { font-size: 12px; flex: 1; }
.sr-card-row .sr-row-time { font-size: 11px; }
.sr-card-src {
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* =========================================================================
   Desktop filter rail
   ========================================================================= */
.sr-filter-rail {
  display: none;
}
@media (min-width: 768px) {
  .sr-filter-rail {
    display: block;
    width: 220px;
    flex-shrink: 0;
    border-right: 1px solid var(--line);
    height: calc(var(--vh) * 100);
    overflow-y: auto;
    scrollbar-width: none;
  }
  .sr-filter-rail::-webkit-scrollbar { display: none; }
}

.sr-filter-rail-inner {
  padding: 20px 16px 40px;
}
.sr-filter-rail-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 14px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.sr-filter-rail-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
}

/* =========================================================================
   Filter panel (shared between sheet + rail)
   ========================================================================= */
.sr-filter-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Group */
.sr-fgrp {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.sr-fgrp:first-child { border-top: none; padding-top: 0; }

.sr-fgrp-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.sr-fgrp-aux {
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-3);
  text-transform: none;
  letter-spacing: 0;
}

/* Checkbox row */
.sr-check {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 0;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  width: 100%;
  text-align: left;
}
.sr-check.on { color: var(--ink); }
.sr-check-box {
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--line-2);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .12s, border-color .12s;
}
.sr-check-box svg { width: 11px; height: 11px; color: #fff; opacity: 0; transition: opacity .1s; }
.sr-check.on .sr-check-box {
  background: var(--accent);
  border-color: var(--accent);
}
.sr-check.on .sr-check-box svg { opacity: 1; }
.sr-check-n { margin-left: auto; font-size: 12px; color: var(--ink-4); }

/* Tag chips */
.sr-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sr-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--line-2);
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.sr-chip.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.sr-chip--add {
  border-style: dashed;
  color: var(--ink-4);
}
.sr-chip-x { font-size: 13px; line-height: 1; opacity: .7; }

/* ── Similarity slider ── */
.sr-sim {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
}
.sr-sim-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.sr-sim-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
}
.sr-sim-title svg { width: 15px; height: 15px; }
.sr-sim.on .sr-sim-title { color: var(--ink); }

.sr-sim-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-3);
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: 5px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.sr-sim.on .sr-sim-badge {
  color: var(--accent);
  background: var(--accent-soft);
}

.sr-sim-sub {
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.45;
  margin-bottom: 12px;
}

.sr-sim-slider {
  position: relative;
  height: 28px;
  display: flex;
  align-items: center;
  margin: 0 6px;
}
.sr-sim-track {
  position: absolute;
  left: 0; right: 0;
  height: 4px;
  border-radius: 2px;
  background: var(--line-2);
}
.sr-sim-fill {
  position: absolute;
  left: 0;
  height: 4px;
  border-radius: 2px;
  background: var(--line-2);
  transition: width .15s;
}
.sr-sim.on .sr-sim-fill { background: var(--accent); }

.sr-sim-stop {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--line-2);
  background: var(--surface);
  transform: translateX(-50%);
  cursor: pointer;
  transition: border-color .12s, background .12s;
  padding: 0;
}
.sr-sim-stop.off-stop { background: var(--surface-2); border-color: var(--line-2); }
.sr-sim-stop.lit { background: var(--accent); border-color: var(--accent); }

.sr-sim-thumb {
  position: absolute;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--line-2);
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  transform: translateX(-50%);
  pointer-events: none;
  transition: left .15s;
}
.sr-sim.on .sr-sim-thumb { border-color: var(--accent); }

.sr-sim-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
  letter-spacing: .04em;
}
.sr-sim-labels .active { color: var(--accent); font-weight: 600; }

/* ── Date jump ── */
.sr-datejump.disabled { opacity: .45; pointer-events: none; }

.sr-date-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  position: relative;
}
.sr-date-input.has-value { border-color: var(--accent); background: var(--accent-soft); }
.sr-date-cal { width: 15px; height: 15px; color: var(--ink-3); flex-shrink: 0; }
.sr-date-input.has-value .sr-date-cal { color: var(--accent); }
.sr-date-display { font-size: 13px; color: var(--ink-2); flex: 1; }
.sr-date-input.has-value .sr-date-display { color: var(--accent); font-weight: 500; }
.sr-date-input input[type="date"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%;
}
.sr-date-clear {
  background: none; border: none; cursor: pointer;
  font-size: 15px; color: var(--accent); padding: 0; line-height: 1;
}
.sr-date-hint {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--ink-3);
}

/* ── Text inputs ── */
.sr-text-input {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
.sr-text-prefix {
  padding: 0 0 0 10px;
  font-size: 14px;
  color: var(--ink-3);
  flex-shrink: 0;
}
.sr-text-input input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 10px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  outline: none;
}
.sr-text-input input::placeholder { color: var(--ink-4); }

/* ── Reset button ── */
.sr-reset-btn {
  margin-top: 16px;
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1.5px solid var(--line-2);
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.sr-reset-btn:hover { background: var(--surface-2); color: var(--ink-2); }

/* =========================================================================
   Mobile filter sheet
   ========================================================================= */
.sr-sheet-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,.3);
  opacity: 0;
  transition: opacity .22s;
}
.sr-sheet-scrim.open {
  display: block;
  opacity: 1;
}
@media (min-width: 768px) { .sr-sheet-scrim { display: none !important; } }

.sr-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 51;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 40px rgba(0,0,0,.15);
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.22,1,.36,1);
  display: flex;
  flex-direction: column;
  max-height: 90dvh;
}
.sr-sheet.open { transform: translateY(0); }
@media (min-width: 768px) { .sr-sheet { display: none !important; } }

.sr-sheet-grip {
  padding: 10px 0 4px;
  display: flex;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.sr-sheet-bar {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--line-2);
}

.sr-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 12px;
  flex-shrink: 0;
}
.sr-sheet-head h4 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.sr-sheet-done {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 0;
}

.sr-sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 8px;
  scrollbar-width: none;
}
.sr-sheet-body::-webkit-scrollbar { display: none; }

.sr-sheet-footer {
  display: flex;
  gap: 10px;
  padding: 12px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.sr-sheet-clear {
  padding: 12px 18px;
  border-radius: 12px;
  border: 1.5px solid var(--line-2);
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
}
.sr-sheet-apply {
  flex: 1;
  padding: 12px 18px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.sr-sheet-apply-count {
  background: rgba(255,255,255,.25);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 13px;
}

/* =========================================================================
   Dark mode
   ========================================================================= */
body.dark .sr-bar           { background: var(--surface-2); }
body.dark .sr-filter-btn    { background: var(--surface); border-color: var(--line); }
body.dark .sr-pill          { background: var(--surface-2); border-color: var(--line); }
body.dark .sr-filter-rail   { border-right-color: var(--line); }
body.dark .sr-sheet         { background: var(--surface); }
body.dark .sr-check-box     { background: var(--surface-2); border-color: var(--line-2); }
body.dark .sr-chip          { background: var(--surface-2); border-color: var(--line); color: var(--ink-3); }
body.dark .sr-date-input    { background: var(--surface-2); border-color: var(--line); }
body.dark .sr-text-input    { background: var(--surface-2); border-color: var(--line); }
body.dark .sr-sim-stop      { background: var(--surface-2); }
body.dark .sr-sim-thumb     { background: var(--surface); }
