:root {
  --bar-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ptr-height: 72px;        /* max visual pull */
  --ptr-threshold: 60px;     /* distance to trigger */
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0b0b0f;
  color: #eaeaf0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans";
  overflow: hidden; /* views are the scrollers */
}

/* Global “no text selection” default */
html, body, * {
  -webkit-user-select: none;   /* iOS Safari / Chrome iOS */
  -webkit-touch-callout: none; /* Hide long-press menu on iOS */
  -khtml-user-select: none;    /* Old Konqueror, harmless elsewhere */
  -moz-user-select: none;      /* Firefox */
  -ms-user-select: none;       /* Old Edge/IE */
  user-select: none;           /* Modern browsers */
}

/* Allow selection where it makes sense */
input, textarea, [contenteditable="true"], .selectable {
  -webkit-user-select: text;
  -webkit-touch-callout: default;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}


#app { position: relative; height: 100%; }

/* Remove bullets and default spacing */
.media-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* One row per item: image left, text right */

.media-item {
  display: grid;
  grid-template-columns: auto 1fr; /* thumb then flexible text */
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 12px;
  transition: background 0.2s ease;
}

/* Optional hover affordance for clickable rows */
.media-item:hover {
  background: rgba(0,0,0,0.04);
}

.media-item.is-active {
  background: rgba(62, 125, 255, 0.16);
}

.media-item:focus-visible {
  outline: 2px solid rgba(120, 160, 255, 0.8);
  outline-offset: 2px;
}

/* Thumbnail sizing; adjust to taste (48/56/64 px are common) */
.thumb {
  width: 160px;
  height: 100px;
  object-fit: cover;
  border-radius: 6px; /* 0 for square, 50% for circle */
  flex-shrink: 0;
}

/* Stack the two lines; control truncation/wrapping here */
.text {
  min-width: 0;  /* allows text to actually shrink/truncate in grid/flex */
  display: grid;
  grid-template-rows: auto auto;
  align-content: center;
}

/* First line: typically bolder */
.title {
  font-weight: 600;
  line-height: 1.2;
  /* Single-line ellipsis */
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Second line: lighter tone, can be single or multi-line clamp */
.groupname {
  color: #8ba280; /* tweak for theme */
  line-height: 1.2;
  margin-top: 2px;

  /* If you want single-line truncation: */
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;

  /* If you prefer up to 2 lines, comment ^ and use a clamp:
     (requires -webkit- prefix; works in modern browsers) */
  /* display: -webkit-box;
     -webkit-line-clamp: 2;
     -webkit-box-orient: vertical;
     white-space: normal; */
}
.releasetype {
  color: #9b9280; /* tweak for theme */
  line-height: 1.2;
  margin-top: 2px;

  /* If you want single-line truncation: */
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;

  /* If you prefer up to 2 lines, comment ^ and use a clamp:
     (requires -webkit- prefix; works in modern browsers) */
  /* display: -webkit-box;
     -webkit-line-clamp: 2;
     -webkit-box-orient: vertical;
     white-space: normal; */
}


.releasedate {
  color: #6b72a0; /* tweak for theme */
  line-height: 1.2;
  margin-top: 2px;

  /* If you want single-line truncation: */
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;

  /* If you prefer up to 2 lines, comment ^ and use a clamp:
     (requires -webkit- prefix; works in modern browsers) */
  /* display: -webkit-box;
     -webkit-line-clamp: 2;
     -webkit-box-orient: vertical;
     white-space: normal; */
}

/* Compact density variant */
.media-item.compact .thumb { width: 48px; height: 48px; }
.media-item.compact .title { font-size: 0.95rem; }
.media-item.compact .subtitle { font-size: 0.85rem; }

/* Touch-friendly spacing variant */
@media (pointer: coarse) {
  .media-item { padding: 10px 0; }
}

.media-item > a.rowlink {
  display: contents; /* preserves the grid; click area = whole row */
  text-decoration: none;
  color: inherit;
}

.detail-region {
  margin: 12px 0 24px;
}

.detail-card {
  background: #161628;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  padding: 16px 18px 20px;
  display: grid;
  gap: 12px;
}

.detail-toolbar {
  display: flex;
  justify-content: flex-end;
}

.detail-close {
  background: none;
  border: none;
  color: #9ca6dc;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease;
}

.detail-close:hover,
.detail-close:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  outline: none;
}

.detail-body {
  display: grid;
  gap: 16px;
}

.detail-status {
  font-size: 0.95rem;
  color: #bac0df;
}

.detail-status.detail-loading::before {
  content: '⏳ ';
}

.detail-status.detail-error {
  color: #ff9e9e;
}

.detail-status.detail-empty {
  color: #a9b0d5;
}

.release-detail {
  display: grid;
  gap: 16px;
}

.release-detail__header {
  display: grid;
  gap: 6px;
}

.release-detail__title {
  margin: 0;
  font-size: 1.35rem;
}

.release-detail__subtitle {
  margin: 0;
  color: #98a2d8;
}

.release-detail__body {
  display: grid;
  gap: 18px;
}

.release-detail__media {
  width: 100%;
}

.release-detail__image {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
}

.release-detail__meta {
  display: grid;
  gap: 6px;
  margin: 0;
}

.release-detail__meta dt {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #7b82af;
}

.release-detail__meta dd {
  margin: 0 0 10px 0;
  font-size: 0.95rem;
  color: #e6e9ff;
}

.release-detail__meta dd a {
  color: #7ea6ff;
  text-decoration: none;
}

.release-detail__meta dd a:hover,
.release-detail__meta dd a:focus-visible {
  text-decoration: underline;
}

.release-detail__description {
  margin: 0;
  color: #cbd1f5;
  line-height: 1.5;
  white-space: pre-line;
}

.release-detail__downloads {
  display: grid;
  gap: 10px;
}

.release-detail__downloads-title {
  margin: 0;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8d94c7;
}

.release-downloads {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.release-downloads__item {
  margin: 0;
}

.release-download {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: stretch;
  gap: 16px;
  border-radius: 16px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(24, 29, 58, 0.88), rgba(18, 24, 46, 0.88));
  color: #f3f5ff;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.release-download:hover,
.release-download:focus-within {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(8, 10, 25, 0.45);
  background: linear-gradient(135deg, rgba(30, 36, 70, 0.95), rgba(20, 25, 48, 0.95));
}

.release-download__icon-button {
  display: grid;
  gap: 8px;
  align-content: start;
  justify-items: center;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  cursor: pointer;
}

.release-download__icon-button:focus-visible {
  outline: 2px solid rgba(126, 166, 255, 0.8);
  outline-offset: 4px;
}

.release-download__icon-button[aria-expanded="true"] .release-download__icon {
  box-shadow: inset 0 0 0 2px rgba(126, 166, 255, 0.5);
}

.release-download__icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(54, 61, 104, 0.55);
  box-shadow: inset 0 0 0 1px rgba(110, 128, 206, 0.3);
}

.release-download__icon img {
  max-width: 40px;
  max-height: 40px;
}

.release-download__type-short {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9aa3d6;
}

.release-download__main {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}

.release-download__name {
  font-size: 1rem;
  font-weight: 600;
  color: #f6f8ff;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.release-download__actions {
  display: grid;
  gap: 10px;
  grid-auto-rows: minmax(40px, auto);
  align-content: start;
}

.release-download--dual .release-download__actions {
  grid-template-rows: repeat(2, minmax(38px, auto));
}

.release-download__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #f3f5ff;
  background: rgba(60, 73, 126, 0.6);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.release-download__action:hover,
.release-download__action:focus-visible {
  background: rgba(92, 110, 189, 0.85);
  box-shadow: 0 8px 18px rgba(10, 12, 28, 0.38);
  outline: none;
}

.release-download__action:active {
  transform: translateY(1px);
}

.release-download__action[disabled],
.release-download__action.is-loading {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.release-download__action--primary {
  background: linear-gradient(135deg, rgba(104, 126, 255, 0.95), rgba(79, 97, 210, 0.9));
  color: #0f1330;
}

.release-download__action--primary:hover,
.release-download__action--primary:focus-visible {
  background: linear-gradient(135deg, rgba(134, 154, 255, 0.98), rgba(95, 117, 230, 0.95));
}

.release-download__status {
  font-size: 0.78rem;
  min-height: 0.95rem;
  color: #7ea6ff;
  font-weight: 500;
}

.release-download__status[data-status="success"] {
  color: #60e6b7;
}

.release-download__status[data-status="error"] {
  color: #ff7c98;
}

.release-download__info {
  position: absolute;
  left: 18px;
  top: calc(100% + 10px);
  min-width: 210px;
  max-width: min(320px, calc(100% - 36px));
  padding: 14px 16px;
  background: rgba(12, 16, 35, 0.95);
  border-radius: 14px;
  border: 1px solid rgba(126, 166, 255, 0.35);
  box-shadow: 0 18px 36px rgba(8, 10, 25, 0.5);
  z-index: 30;
}

.release-download__info::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 20px;
  width: 16px;
  height: 16px;
  background: inherit;
  border-left: 1px solid rgba(126, 166, 255, 0.35);
  border-top: 1px solid rgba(126, 166, 255, 0.35);
  transform: rotate(45deg);
  border-radius: 2px;
  z-index: -1;
}

.release-download__info-list {
  margin: 0;
  display: grid;
  gap: 10px;
}

.release-download__info-list dt {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7c85c9;
}

.release-download__info-list dd {
  margin: 2px 0 0;
  font-size: 0.88rem;
  color: #f0f3ff;
  word-break: break-word;
  font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}


.library-detail {
  display: grid;
  gap: 10px;
}

.library-detail__title {
  margin: 0;
  font-size: 1.2rem;
}

.library-detail__meta {
  margin: 0;
  color: #9ca6dc;
  font-weight: 500;
}

.library-detail__description {
  margin: 0;
  color: #cbd1f5;
  line-height: 1.5;
}




/* Each view scrolls on its own and stays mounted */
.view { 
  position: absolute;
  inset: 0 0 calc(var(--bar-height) + var(--safe-bottom)) 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;   /* ignored by older iOS, fine elsewhere */
  touch-action: pan-y;               /* default: normal vertical scroll */
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  contain: layout paint style;
  transform: translateZ(0);
  background: #0b0b0f;
  padding: 15px;
  padding-bottom: 30px;
}
.view.active { visibility: visible; opacity: 1; pointer-events: auto; }
/* When we're handling iOS pull, lock native scrolling + momentum */
.view.ptr-lock {
  overflow: hidden !important;
  -webkit-overflow-scrolling: auto !important;
}
/* While pulling/refreshing, we fully take over the gesture */
.view.ptr-pulling,
.view.ptr-refreshing { touch-action: none !important; }


/* Bottom nav */
.menu-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 90px;
  background-color: #1e1e1e;
  display: flex;
  justify-content: space-around;
  align-items: center;
  overflow: hidden;  /* No scrolling or scrollbars here */
  border-top: 1px solid #333;
  padding-bottom: 20px;
  z-index: 100;
  transition: opacity 200ms ease;
}

.menu-button {
  background: none;
  border: 0;
  color: #b9bac6;
  font: inherit;
  font-size: 12px;
  padding: 6px 0 8px;
  display: grid;
  place-items: center;
  gap: 4px;
}

.menu-button[aria-selected="true"],
.menu-button:focus-visible {
  color: #ffffff;
}

.menu-button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 10px;
  outline: none;
}

/* Default: black icon (no filter) */
.menu-button .icon {
  width: 24px;
  height: 24px;
  margin-bottom: 4px;
  filter: invert(1) brightness(0.6);
}

/* Selected tab + focus states should highlight icon */
.menu-button[aria-selected="true"] .icon,
.menu-button:focus-visible .icon,
.menu-button:focus .icon {
  filter: invert(1) brightness(1.1);
}

/* Loader for fragment fetch */
.view .loader {
  display: grid; place-items: center; height: 160px; opacity: 0.8; font-size: 14px;
}
.view.loading .loader { display: grid; }

/* Pull-to-refresh UI */
.view-inner {
  will-change: transform;
  transition: transform 180ms ease;
}
.view.ptr-pulling .view-inner { transition: none; }

/* PTR indicator pinned at top (doesn't move) */
.ptr {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: var(--ptr-height);
  display: grid; place-items: center;
  z-index: 1; pointer-events: none;
}
.ptr > .ptr-box {
  width: 36px; height: 36px; border-radius: 999px;
  border: 0px solid #2b2b38; display: grid; place-items: center;
  opacity: 0.85;
}
.ptr .ptr-arrow {
  width: 14px; height: 14px;
  border-left: 2px solid #b9bac6;
  border-bottom: 2px solid #b9bac6;
  transform: rotate(-45deg);
}
.ptr-label { font-size: 12px; color: #b9bac6; margin-top: 6px; text-align: center; }

.view.ptr-refreshing .ptr > .ptr-box {
  border-top-color: #fff;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* HIT STRIP: invisible, only active at scrollTop==0 to capture the start of pull */
.ptr-hit {
  position: sticky;           /* stays at the top of the scroller */
  top: 0; left: 0; right: 0;
  height: 30px;               /* small touch target at the very top */
  margin-top: -30px;          /* lives just above content */
  z-index: 2;
  pointer-events: none;       /* default: off */
}
/* When the view is at top, we toggle this so the hit strip becomes active */
.view.ptr-ready .ptr-hit { pointer-events: auto; }


.search-section {
  margin-top: 24px;
}

.search-section:first-child {
  margin-top: 0;
}

.search-heading {
  margin: 0 0 12px;
  font-size: 1.1rem;
  font-weight: 600;
}

.group-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.group-item {
  background: rgba(22, 22, 40, 0.7);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.group-item:hover {
  background: rgba(62, 125, 255, 0.16);
}

.group-item:focus-visible {
  outline: 2px solid rgba(120, 160, 255, 0.8);
  outline-offset: 2px;
}

.group-item__name {
  font-weight: 600;
  line-height: 1.2;
}

.group-item__label {
  margin-top: 4px;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b72a0;
}

.search-status,
.search-empty {
  padding: 16px 0;
  color: #9ca6dc;
}

.search-empty {
  color: #7f859f;
}

.search-back {
  background: none;
  border: none;
  color: #9ca6dc;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  margin-bottom: 12px;
}

.search-back:hover {
  color: #c3cbff;
}

.search-back:focus-visible {
  outline: 2px solid rgba(120, 160, 255, 0.8);
  outline-offset: 2px;
}

.search-section--group .search-heading {
  margin-top: 0;
}
