/* ============================================
   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;
}
.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; 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;
  min-width: 0;
}
.feed-meta .time { color: var(--ink-3); margin-left: auto; font-size: 12px; flex-shrink: 0; }

/* Hide src on desktop grid */
@media (min-width: 768px) {
  .feed-meta { font-size: 12px; margin-bottom: 8px; }
  .feed-meta .avatar { width: 20px; height: 20px; }
  .feed-meta .dot, .feed-meta .src { display: none; }
}

.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.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; }
.edit-mode .dt-header .select-btn { display: none; }

/* ============= Confirm Sheet ============= */
.sheet-backdrop {
  position: absolute; 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; }
.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: 2px; }
.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; }
}

/* =========================================================================
   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-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;
  }
}
