:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #eef3f7;
  --text: #172026;
  --muted: #68737d;
  --line: #dce3e8;
  --accent: #24786d;
  --accent-2: #c44536;
  --warn: #a06200;
  --ok: #257a43;
  --shadow: 0 12px 34px rgba(21, 34, 45, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
}

a.button-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  background: #fff;
  text-decoration: none;
}

a.button-link.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button:hover {
  border-color: #b5c5cc;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.danger {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

button.ghost {
  background: transparent;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
}

textarea {
  min-height: 140px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(130deg, rgba(36, 120, 109, 0.18), transparent 42%),
    linear-gradient(320deg, rgba(196, 69, 54, 0.14), transparent 38%),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.login-panel h1,
.topbar h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 38px);
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: start;
  background: #172026;
  color: #f6f7f9;
  padding: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #24786d;
  font-weight: 800;
}

.brand small {
  display: block;
  color: #aab5bd;
  margin-top: 3px;
}

nav {
  display: grid;
  gap: 5px;
  margin-top: 18px;
}

nav button {
  justify-content: flex-start;
  width: 100%;
  color: #d9e0e5;
  background: transparent;
  border-color: transparent;
  text-align: left;
}

nav button.active,
nav button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.content {
  display: grid;
  gap: 18px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.metrics {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.panel,
.metric,
.release-card,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.metric {
  padding: 16px;
}

.metric strong {
  display: block;
  font-size: 30px;
  line-height: 1;
  margin-bottom: 8px;
}

.muted {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 14px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
}

.release-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

.release-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  min-height: 168px;
  overflow: hidden;
}

.poster-wrap {
  position: relative;
  width: 96px;
  min-height: 168px;
  background: var(--panel-2);
}

.poster {
  width: 96px;
  height: 100%;
  min-height: 168px;
  object-fit: cover;
  background:
    linear-gradient(150deg, #d8e7e3, #f4d8d3),
    var(--panel-2);
}

.poster-placeholder {
  display: grid;
  place-items: center;
  color: #47605a;
  font-weight: 800;
  font-size: 26px;
}

.library-badge {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  min-height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  padding: 3px 7px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  background: rgba(28, 40, 48, 0.86);
}

.library-badge.present {
  background: rgba(37, 122, 67, 0.9);
}

.library-badge.missing {
  background: rgba(196, 69, 54, 0.9);
}

.release-body {
  min-width: 0;
  padding: 14px;
  display: grid;
  gap: 9px;
}

.release-body h3 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  color: #33434c;
  background: #f9fbfc;
  font-size: 12px;
}

.chip.ok {
  color: var(--ok);
  border-color: rgba(37, 122, 67, 0.32);
}

.chip.warn {
  color: var(--warn);
  border-color: rgba(160, 98, 0, 0.32);
}

.chip.danger-chip {
  color: var(--accent-2);
  border-color: rgba(196, 69, 54, 0.34);
}

.sources {
  display: grid;
  gap: 6px;
  font-size: 12px;
}

.library-details {
  border-left: 3px solid rgba(36, 120, 109, 0.35);
  padding-left: 9px;
  color: #42515a;
  font-size: 12px;
  line-height: 1.45;
}

.release-actions {
  margin-top: 2px;
}

.library-card {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 12px;
  min-height: 128px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.library-card img,
.library-card .poster-placeholder {
  width: 82px;
  height: 108px;
  object-fit: cover;
  border-radius: 6px;
  background:
    linear-gradient(150deg, #d8e7e3, #f4d8d3),
    var(--panel-2);
}

.library-card h3 {
  margin: 6px 0 6px;
  font-size: 16px;
}

.sources a {
  color: var(--accent);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: #42515a;
  background: #f8fafb;
  font-weight: 700;
}

.split {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  background: #172026;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 10;
}

.error-text {
  min-height: 20px;
  margin: 0;
  color: var(--accent-2);
}

@media (max-width: 920px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
  }

  nav {
    grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  }

  .workspace {
    padding: 18px;
  }

  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    display: grid;
  }

  .release-grid {
    grid-template-columns: 1fr;
  }

  .release-card {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .poster {
    width: 82px;
  }

  .poster-wrap {
    width: 82px;
  }
}

.dashboard-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 16px;
  align-items: start;
}

.between {
  justify-content: space-between;
}

.compact-grid {
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
}

.mini-list {
  display: grid;
  gap: 10px;
}

.source-row,
.checked-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.source-row button,
.checked-link button,
.checked-link a {
  min-height: 32px;
  white-space: nowrap;
}

.checked-link {
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
}

.source-links {
  display: grid;
  gap: 6px;
}

.checked-link a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  text-decoration: none;
  color: var(--text);
  background: #fff;
}

@media (max-width: 1080px) {
  .dashboard-main {
    grid-template-columns: 1fr;
  }
}

/* Refined release layout */
.release-section {
  display: grid;
  gap: 12px;
}

.release-section h2,
.year-overview strong {
  margin: 0;
  letter-spacing: 0;
}

.release-grid {
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 16px;
  align-items: stretch;
}

.release-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  overflow: hidden;
}

.release-card .poster-wrap {
  width: 100%;
  min-height: 0;
  aspect-ratio: 2 / 3;
}

.release-card .poster {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.release-card .poster-placeholder {
  width: 100%;
  height: 100%;
  font-size: 34px;
}

.release-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 13px;
}

.release-title-row h3 {
  margin: 0 0 4px;
  font-size: 16px;
  line-height: 1.25;
}

.release-overview {
  margin: 0;
  color: #42515a;
  font-size: 12px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sources {
  margin-top: auto;
}

.source-row {
  grid-template-columns: 1fr;
  align-items: start;
  gap: 3px;
  padding: 7px 0;
}

.source-row a {
  font-weight: 700;
}

.release-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 0;
}

.release-actions .primary {
  grid-column: 1 / -1;
}

.release-actions button,
.release-actions .button-link {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
}

.checked-link {
  grid-template-columns: auto minmax(72px, auto) minmax(0, 1fr);
}

.checked-link button,
.checked-link a {
  grid-column: 1 / -1;
}

@media (max-width: 560px) {
  .release-card {
    display: flex;
  }

  .release-card .poster-wrap {
    width: 100%;
  }
}

/* Emby-like media cards */
.release-card {
  background: #fff;
  border-color: #dce5ea;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.release-card:hover {
  transform: translateY(-2px);
  border-color: #bdd2da;
  box-shadow: 0 18px 45px rgba(20, 38, 48, 0.16);
}

.release-card .poster-wrap {
  background: #111a20;
  overflow: hidden;
}

.release-card .poster {
  display: block;
  transition: transform 200ms ease;
}

.release-card:hover .poster {
  transform: scale(1.025);
}

.release-card .poster-wrap::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 46%;
  background: linear-gradient(180deg, rgba(12, 20, 26, 0), rgba(12, 20, 26, 0.76));
  pointer-events: none;
  z-index: 1;
}

.release-card .library-badge {
  z-index: 2;
  left: 10px;
  right: 10px;
  bottom: 10px;
  border-radius: 7px;
  min-height: 28px;
  backdrop-filter: blur(6px);
}

.release-card .release-body {
  background: linear-gradient(180deg, #fff, #fbfdfe);
}

.release-card .release-title-row h3 {
  display: -webkit-box;
  min-height: 40px;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.release-card .release-title-row .muted {
  min-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.release-card .chips {
  min-height: 26px;
}

.release-card .sources {
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

.release-card .source-row {
  border-top: 1px solid rgba(214, 225, 231, 0.74);
}

.release-card .release-actions {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.release-card .release-actions .primary {
  background: #24786d;
  border-color: #24786d;
  color: #fff;
  font-weight: 800;
}

.release-card .release-actions .button-link,
.release-card .release-actions button:not(.primary) {
  background: #f7fafb;
}

/* Emby libraries */
.emby-controls {
  display: grid;
  gap: 14px;
}

.compact-filters {
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}

.emby-libraries {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.emby-library-card {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 112px;
  padding: 14px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.emby-library-card.active {
  border-color: #24786d;
  box-shadow: 0 0 0 2px rgba(36, 120, 109, 0.14), var(--shadow);
}

.emby-library-card strong {
  font-size: 18px;
}

.results-heading {
  padding: 0 2px;
}

.emby-item-grid {
  grid-template-columns: repeat(auto-fill, minmax(315px, 1fr));
}

.emby-item-card {
  min-height: 150px;
}

.emby-item-card img,
.emby-item-card .poster-placeholder {
  width: 96px;
  height: 138px;
  min-height: 138px;
  border-radius: 7px;
  object-fit: cover;
}

.emby-item-body {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
}

.emby-item-body h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.episode-title {
  color: #34444d;
  font-size: 13px;
  line-height: 1.25;
}

.library-path {
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}


/* Hoster download controls and compact management */
.hoster-actions {
  display: grid;
  gap: 8px;
  margin: 8px 0 2px;
}

.hoster-actions button {
  width: 100%;
  min-height: 40px;
  font-weight: 800;
}

.management-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.management-shortcuts button {
  min-width: 132px;
}

.missing-cover {
  background:
    linear-gradient(180deg, rgba(17, 26, 32, 0.04), rgba(17, 26, 32, 0.36)),
    linear-gradient(150deg, #d8e7e3, #f4d8d3);
}

.missing-cover span {
  align-self: start;
  justify-self: start;
  padding: 12px;
  color: rgba(23, 32, 38, 0.68);
  font-size: 28px;
  line-height: 1;
}

.compact-admin-form {
  gap: 10px;
}

.release-card .source-links .muted,
.release-card .source-links .error-text {
  font-size: 12px;
  line-height: 1.35;
}

@media (max-width: 560px) {
  .management-shortcuts button {
    flex: 1 1 100%;
  }
}


/* Source variants and seasons */
.source-variants {
  display: grid;
  gap: 9px;
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

.source-variant {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #f9fbfc;
}

.source-variant-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.source-variant-head strong {
  display: block;
  color: var(--accent);
  font-size: 13px;
}

.source-variant p {
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: #24323a;
  font-size: 12px;
  line-height: 1.35;
}

.source-meta {
  font-size: 11px;
  line-height: 1.35;
}

.source-actions {
  display: grid;
  grid-template-columns: 0.9fr 0.9fr 1fr;
  gap: 6px;
}

.source-actions button,
.source-actions .button-link {
  width: 100%;
  min-height: 34px;
  padding: 0 8px;
  font-size: 12px;
}

.season-summary {
  display: grid;
  gap: 7px;
  padding: 9px;
  border: 1px solid rgba(36, 120, 109, 0.18);
  border-radius: 8px;
  background: #f7fbfa;
}

.season-summary strong {
  font-size: 12px;
  color: #34444d;
}

.quality-list {
  min-height: 0 !important;
}

.quality-chip {
  color: #1f675e;
  border-color: rgba(36, 120, 109, 0.28);
}

@media (max-width: 560px) {
  .source-actions {
    grid-template-columns: 1fr;
  }
}


/* Download management workbench */
.download-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: stretch;
}

.download-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(125px, 1fr));
  gap: 10px;
}

.download-kpis .metric {
  min-height: 78px;
  padding: 14px 16px;
}

.download-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.download-toolbar button {
  min-width: 124px;
}

.jd-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  align-items: start;
}

.jd-list-panel {
  display: grid;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.section-strip,
.jd-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.section-strip strong,
.jd-strip strong {
  display: block;
  font-size: 16px;
}

.section-strip .muted,
.jd-strip .muted {
  display: block;
  margin-top: 2px;
  font-size: 12px;
}

.jd-table-wrap {
  width: 100%;
  overflow: auto;
  background: #fff;
}

.jd-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  font-size: 14px;
}

.jd-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
  border-bottom: 1px solid #cbd9df;
  background: #edf4f7;
  color: #3d4d56;
  font-weight: 900;
  text-align: left;
  white-space: nowrap;
}

.jd-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.jd-row:hover td {
  background: #f5fafb;
}

.jd-package-row td {
  background: #dbeaf2;
}

.jd-package-row:hover td {
  background: #d1e3ed;
}

.jd-part-row td {
  background: #fbfdfe;
}

.jd-name-cell {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 330px;
  max-width: 560px;
}

.jd-name-cell > div {
  min-width: 0;
}

.jd-name-cell strong,
.part-file {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #172229;
  font-weight: 850;
}

.jd-name-cell small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #61737e;
  font-size: 12px;
  white-space: nowrap;
}

.jd-expander {
  width: 26px;
  min-width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1;
}

.jd-folder,
.jd-file,
.part-branch {
  color: #1f8175;
  font-weight: 900;
  line-height: 1.7;
}

.part-name {
  padding-left: 48px;
}

.host-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(36, 120, 109, 0.24);
  border-radius: 999px;
  background: #eef8f6;
  color: #1f675e;
  font-size: 12px;
  font-weight: 850;
}

.active-chip {
  color: #1f675e;
  border-color: rgba(36, 120, 109, 0.25);
  background: #eef8f6;
}

.jd-progress-cell {
  display: grid;
  gap: 5px;
  min-width: 265px;
}

.jd-progress-cell .progress-bar {
  height: 11px;
}

.progress-bar {
  width: 100%;
  height: 14px;
  overflow: hidden;
  border: 1px solid #cfdde3;
  border-radius: 999px;
  background: #e7eef2;
}

.progress-bar span {
  display: block;
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #24786d, #42a38f);
}

.jd-progress-cell span {
  color: #53646e;
  font-size: 12px;
}

.jd-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 280px;
}

.jd-actions button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 13px;
}

.jd-actions .danger {
  border-color: rgba(201, 67, 52, 0.34);
  color: #bf3e31;
}

.error-text {
  color: #c94334 !important;
  white-space: normal !important;
}

.jd-side,
.download-side {
  display: grid;
  gap: 12px;
}

.direct-download-form {
  position: sticky;
  top: 12px;
}

.direct-download-form > div:first-child,
.queue-snapshot {
  display: grid;
  gap: 6px;
}

.form-grid-two {
  display: grid;
  grid-template-columns: 1fr 0.72fr;
  gap: 10px;
}

.queue-snapshot {
  gap: 12px;
}

.mini-list {
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.mini-list > div {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbfc;
}

.download-terminal {
  display: grid;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border-color: #18252b;
  background: #0f171b;
  color: #d6e4e8;
}

.download-terminal .section-strip {
  border-bottom-color: rgba(214, 228, 232, 0.12);
  background: #121e24;
  box-shadow: none;
}

.download-terminal .section-strip strong,
.download-terminal .section-strip .muted {
  color: #d6e4e8;
}

.download-terminal button {
  border-color: #32454f;
  background: #18252b;
  color: #e9f3f5;
}

.download-terminal pre {
  max-height: 360px;
  margin: 0;
  overflow: auto;
  padding: 14px;
  background: #0a1013;
  color: #c9e7db;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.hidden {
  display: none !important;
}

@media (max-width: 1500px) {
  .jd-layout {
    grid-template-columns: 1fr;
  }

  .direct-download-form {
    position: static;
  }

  .download-side {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.65fr);
  }
}

@media (max-width: 980px) {
  .download-topbar {
    grid-template-columns: 1fr;
  }

  .download-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .download-side {
    grid-template-columns: 1fr;
  }

  .form-grid-two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .download-kpis {
    grid-template-columns: 1fr;
  }

  .download-toolbar button {
    flex: 1 1 100%;
  }
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f6faf9;
  color: #41525b;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.ok {
  border-color: #b9dbc8;
  background: #edf8f0;
  color: #237047;
}

.badge.warn {
  border-color: #ead1a7;
  background: #fff8e8;
  color: #9a650d;
}

.wide-search {
  grid-template-columns: minmax(320px, 460px) minmax(720px, 1fr);
}

#search-run-panel {
  min-width: 0;
}

#search-run-status .progress-bar {
  height: 16px;
}

@media (max-width: 1100px) {
  .wide-search {
    grid-template-columns: 1fr;
  }
}

.search-site-picker {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafb;
}

.site-picker-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.site-picker-head .muted {
  display: block;
  margin-top: 3px;
  font-size: 12px;
}

.site-picker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  max-height: 270px;
  overflow: auto;
  padding-right: 2px;
}

.check-tile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 9px;
  background: #fff;
  color: var(--text);
}

.check-tile input {
  width: auto;
}

.check-tile strong,
.check-tile small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.check-tile small {
  margin-top: 2px;
  color: var(--muted);
}

.check-tile.has-error {
  background: #fffafa;
}

.site-health {
  font-style: normal;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  white-space: nowrap;
}

.site-health.ok {
  color: var(--ok);
  border-color: rgba(37, 122, 67, 0.28);
  background: rgba(37, 122, 67, 0.06);
}

.site-health.warn {
  color: var(--warn);
  border-color: rgba(160, 98, 0, 0.28);
  background: rgba(160, 98, 0, 0.06);
}

/* Auto-hidden navigation */
@media (min-width: 921px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    z-index: 40;
    width: 270px;
    height: 100vh;
    min-height: 100vh;
    transform: translateX(-252px);
    transition: transform 180ms ease, box-shadow 180ms ease;
    box-shadow: 8px 0 24px rgba(12, 20, 26, 0);
  }

  .sidebar::after {
    content: "";
    position: absolute;
    top: 0;
    right: -14px;
    width: 18px;
    height: 100%;
  }

  .sidebar:hover,
  .sidebar:focus-within {
    transform: translateX(0);
    box-shadow: 12px 0 34px rgba(12, 20, 26, 0.22);
  }

  .workspace {
    padding-left: 34px;
  }
}

/* Google-like search */
.google-search {
  display: grid;
  justify-items: center;
  gap: 18px;
}

.google-search-card {
  width: min(920px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
}

.search-logo {
  text-align: center;
  color: var(--accent);
  font-size: 26px;
  font-weight: 800;
}

.main-search-input {
  gap: 9px;
}

.main-search-input span {
  text-align: center;
  color: var(--muted);
}

.main-search-input input {
  min-height: 58px;
  border-radius: 999px;
  padding: 0 24px;
  font-size: 21px;
  box-shadow: 0 8px 28px rgba(21, 34, 45, 0.08);
}

.search-pills,
.search-bottom-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-pills button {
  border-radius: 999px;
  background: #f8fafb;
}

.search-modules {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 10px;
}

.search-site-menu {
  position: relative;
}

.search-site-menu summary {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 16px;
  background: #fff;
  cursor: pointer;
  list-style: none;
}

.search-site-menu summary::-webkit-details-marker {
  display: none;
}

.search-site-menu summary strong {
  color: var(--accent);
}

.search-site-menu[open] {
  z-index: 20;
}

.search-site-menu .site-picker-actions,
.search-site-menu .checkbox-grid {
  width: min(720px, calc(100vw - 80px));
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
}

.search-site-menu .site-picker-actions {
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}

.search-site-menu .checkbox-grid {
  border-radius: 0 0 8px 8px;
  max-height: 260px;
}

.search-submit {
  min-width: 140px;
  border-radius: 999px;
}

.search-results-panel {
  width: min(1200px, 100%);
}

.release-card {
  position: relative;
}

.mark-downloaded {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;
  min-height: 30px;
  border-radius: 999px;
  border-color: rgba(23, 32, 38, 0.18);
  background: rgba(255, 255, 255, 0.92);
  color: #172026;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(12, 20, 26, 0.18);
}

.mark-downloaded:disabled {
  color: #fff;
  border-color: rgba(37, 122, 67, 0.55);
  background: rgba(37, 122, 67, 0.9);
  cursor: default;
}

.library-badge.downloaded-missing {
  background: linear-gradient(90deg, rgba(196, 69, 54, 0.92) 0 50%, rgba(37, 122, 67, 0.92) 50% 100%);
}


/* Restore fixed left navigation */
@media (min-width: 921px) {
  .app {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .sidebar {
    min-height: 100vh;
    position: sticky;
    top: 0;
    align-self: start;
    width: auto;
    height: auto;
    transform: none;
    transition: none;
    box-shadow: none;
  }

  .sidebar::after {
    display: none;
  }

  .workspace {
    padding-left: 24px;
  }
}

/* Google-style search refinement */
.google-search {
  min-height: calc(100vh - 170px);
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 22px;
  padding-top: clamp(20px, 8vh, 92px);
}

.google-search-card {
  width: min(760px, 100%);
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: 0 12px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.google-logo {
  display: flex;
  justify-content: center;
  gap: 10px;
  font-size: clamp(42px, 8vw, 76px);
  line-height: 1;
  font-weight: 800;
  color: #1b2a32;
}

.google-logo span:first-child {
  color: #24786d;
}

.google-logo span:last-child {
  color: #c44536;
}

.google-search-box {
  width: min(680px, 100%);
}

.google-search-box input {
  min-height: 58px;
  border-radius: 999px;
  padding: 0 26px;
  font-size: 20px;
  border-color: #d7e0e5;
  background: #fff;
  box-shadow: 0 3px 8px rgba(32, 33, 36, 0.08);
}

.google-search-box input:focus {
  outline: none;
  border-color: #cfd9df;
  box-shadow: 0 3px 14px rgba(32, 33, 36, 0.16);
}

.google-actions,
.google-tools {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.google-actions button,
.advanced-search summary,
.search-site-menu summary {
  border-radius: 4px;
  background: #f8f9fa;
  border-color: #f8f9fa;
  color: #2b3338;
}

.google-actions button:hover,
.advanced-search summary:hover,
.search-site-menu summary:hover {
  border-color: #d9e1e5;
  box-shadow: 0 1px 2px rgba(32, 33, 36, 0.12);
}

.google-actions .primary {
  background: #24786d;
  border-color: #24786d;
  color: #fff;
}

.advanced-search,
.search-site-menu {
  position: relative;
}

.advanced-search summary,
.search-site-menu summary {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  cursor: pointer;
  list-style: none;
}

.advanced-search summary::-webkit-details-marker,
.search-site-menu summary::-webkit-details-marker {
  display: none;
}

.search-site-menu summary strong {
  color: #24786d;
}

.advanced-search[open],
.search-site-menu[open] {
  z-index: 50;
}

.advanced-search .search-modules,
.search-site-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 80px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 14px;
}

.advanced-search .search-modules {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.search-site-popover {
  display: grid;
  gap: 10px;
}

.search-site-popover .site-picker-actions,
.search-site-popover .checkbox-grid {
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
}

.search-site-popover .checkbox-grid {
  max-height: 280px;
  overflow: auto;
}

.search-results-panel {
  width: min(1180px, 100%);
}
