/* ==========================================================================
   Downloads module
   Cascading filter (platform → vendor → version → architecture) + release cards.
   ========================================================================== */

/* ---------- Hero ---------- */
.dl-hero {
  padding: 28px 0 26px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--brand-50), transparent 92%);
}
.dl-hero .crumbs { margin-bottom: 14px; }
.dl-hero-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px 40px;
}
.dl-hero h1 {
  font-size: clamp(26px, 3.2vw, 34px);
  letter-spacing: -.03em;
}
.dl-hero p {
  max-width: 64ch;
  margin-top: 9px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--ink-3);
  text-wrap: pretty;
}
.dl-hero-stats {
  display: flex;
  gap: 30px;
  flex-shrink: 0;
  padding-bottom: 3px;
}
.dl-hero-stats b {
  display: block;
  font-size: 21px;
  letter-spacing: -.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.dl-hero-stats span { font-size: 11.5px; color: var(--ink-4); }

.dl-body { padding: 20px 0 0; }

/* ---------- Filter panel ---------- */
.dl-filter {
  padding: 18px 24px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.dl-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.dl-filter-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.dl-filter-head h2 svg { width: 15px; height: 15px; color: var(--ink-4); }
.dl-reset {
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  color: var(--ink-4);
  cursor: pointer;
}
.dl-reset:hover { color: var(--brand-700); }

.dl-step {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  gap: 24px;
  padding: 18px 0;
  border-top: 1px dashed var(--line);
}
.dl-step:first-of-type { border-top: 0; }
.dl-step.is-disabled { opacity: .55; }
.dl-step-head { display: flex; align-items: flex-start; gap: 10px; }
.dl-step-num {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-4);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.dl-step.is-active .dl-step-num {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
}
.dl-step-head h2 { font-size: 14px; letter-spacing: -.01em; }
.dl-step-head p {
  margin-top: 3px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-4);
}
.dl-step-main { min-width: 0; }
.dl-placeholder { padding: 6px 0; font-size: 12.5px; color: var(--ink-4); }

/* System cards */
.dl-os-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.dl-os {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .16s var(--ease), background-color .16s var(--ease), box-shadow .16s var(--ease);
}
.dl-os:hover { border-color: var(--line-strong); background: var(--surface-2); }
.dl-os.is-active {
  border-color: var(--brand-500);
  background: var(--brand-50);
  box-shadow: inset 0 0 0 1px var(--brand-500);
}
.dl-os-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--ink-3);
}
.dl-os-icon svg { width: 16px; height: 16px; }
.dl-os.is-active .dl-os-icon { background: var(--surface); color: var(--brand-700); }
.dl-os-text { min-width: 0; }
.dl-os b { display: block; font-size: 13px; font-weight: 600; color: var(--ink); }
.dl-os small {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  font-size: 10.5px;
  color: var(--ink-4);
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Architecture chips */
.dl-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dl-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color .16s var(--ease), background-color .16s var(--ease), color .16s var(--ease);
}
.dl-chip small { font-size: 10.5px; color: var(--ink-4); }
.dl-chip:hover { border-color: var(--line-strong); }
.dl-chip.is-active {
  border-color: var(--brand-600);
  background: var(--brand-600);
  color: #fff;
  font-weight: 600;
}
.dl-chip.is-active small { color: rgba(255, 255, 255, .78); }

/* Version tiles */
.dl-vers { display: flex; flex-wrap: wrap; gap: 10px; }
.dl-ver {
  display: grid;
  gap: 2px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .16s var(--ease), background-color .16s var(--ease), box-shadow .16s var(--ease);
}
.dl-ver:hover { border-color: var(--line-strong); background: var(--surface-2); }
.dl-ver b {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.01em;
}
.dl-ver small { font-size: 10.5px; color: var(--ink-4); }
.dl-ver.is-active {
  border-color: var(--brand-500);
  background: var(--brand-50);
  box-shadow: inset 0 0 0 1px var(--brand-500);
}
.dl-ver.is-active b { color: var(--brand-700); }

/* ---------- Result ---------- */
.dl-result {
  margin-top: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.dl-result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(120deg, var(--brand-50), var(--surface) 62%);
}
.dl-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--brand-700);
}
.dl-result-head h2 { margin-top: 5px; font-size: 20px; letter-spacing: -.02em; }
.dl-meta { margin-top: 4px; font-size: 12.5px; color: var(--ink-3); }
.dl-result-side { display: flex; gap: 8px; flex-shrink: 0; padding-top: 2px; }

.dl-table-wrap { overflow-x: auto; }
.dl-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}
.dl-table th {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-4);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.dl-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 12.5px;
  vertical-align: middle;
}
.dl-table tbody tr:last-child td { border-bottom: 0; }
.dl-table tbody tr { transition: background-color .15s var(--ease); }
.dl-table tbody tr:hover { background: color-mix(in srgb, var(--brand-50) 45%, transparent); }

.dl-file { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.dl-file-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--brand-50);
  color: var(--brand-700);
}
.dl-file-icon svg { width: 16px; height: 16px; }
.dl-file b { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.dl-file small {
  display: block;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
}
.dl-td-size { color: var(--ink); font-weight: 550; white-space: nowrap; }
.dl-td-date { white-space: nowrap; }

.dl-md5 { display: flex; align-items: center; gap: 6px; }
.dl-md5 code {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
}
.dl-md5 button {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink-4);
  cursor: pointer;
  transition: border-color .16s var(--ease), color .16s var(--ease);
}
.dl-md5 button:hover { border-color: var(--brand-500); color: var(--brand-700); }
.dl-md5 button.is-done { border-color: var(--brand-500); color: var(--brand-600); }
.dl-md5 button svg { width: 13px; height: 13px; }

.dl-actions { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.dl-actions .btn { height: 32px; padding: 0 12px; border-radius: 8px; font-size: 12.5px; }
.dl-alt {
  font-size: 11.5px;
  color: var(--ink-4);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.dl-alt:hover { color: var(--brand-700); }

.dl-result-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 11.5px;
  color: var(--ink-4);
}
.dl-result-foot code {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
}

.dl-empty { padding: 52px 24px; text-align: center; }
.dl-empty[hidden] { display: none; }
.dl-empty h2 { font-size: 17px; }
.dl-empty p { margin-top: 6px; font-size: 13px; color: var(--ink-3); }

/* ---------- Help ---------- */
.dl-help { padding: 46px 0 84px; }
.dl-help h2 { font-size: 19px; letter-spacing: -.02em; }
.dl-help > p {
  max-width: 70ch;
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-3);
}
.dl-help-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.dl-help-card {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.dl-help-card h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 9px;
  font-size: 13.5px;
}
.dl-help-card h3 svg { width: 14px; height: 14px; color: var(--brand-600); }
.dl-help-card p { font-size: 12.5px; line-height: 1.7; color: var(--ink-3); }
.dl-help-card p + p { margin-top: 7px; }
.dl-help-card code {
  font-family: var(--font-mono);
  font-size: 11.5px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .dl-step { grid-template-columns: 190px minmax(0, 1fr); gap: 18px; }
  .dl-os-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .dl-hero { padding: 22px 0 24px; }
  .dl-hero-row { flex-direction: column; align-items: flex-start; gap: 18px; }
  .dl-filter { padding: 14px 16px 2px; }
  .dl-step { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 16px 0; }
  .dl-step-head p { display: none; }
  .dl-os-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dl-os small { display: none; }
  .dl-result-head { flex-direction: column; gap: 12px; padding: 18px; }
  .dl-result-side { padding-top: 0; }

  /* table → stacked cards */
  .dl-table { min-width: 0; }
  .dl-table thead { display: none; }
  .dl-table,
  .dl-table tbody { display: block; width: 100%; }
  .dl-table tr {
    display: block;
    padding: 16px;
    border-bottom: 1px solid var(--line);
  }
  .dl-table tbody tr:last-child { border-bottom: 0; }
  .dl-table tbody tr:hover { background: transparent; }
  .dl-table td {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 14px 8px 0;
    padding: 0;
    border: 0;
    font-size: 12px;
  }
  .dl-table td:nth-child(1) { display: flex; margin: 0 0 10px; }
  .dl-table td:nth-child(2)::before,
  .dl-table td:nth-child(3)::before,
  .dl-table td:nth-child(4)::before {
    content: attr(data-label);
    font-size: 11px;
    color: var(--ink-4);
  }
  .dl-table td:nth-child(3) { color: var(--ink); font-weight: 600; }
  .dl-table td:nth-child(5) {
    display: flex;
    margin: 2px 0 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
  }
  .dl-table td:nth-child(5)::before {
    content: "MD5";
    flex-shrink: 0;
    font-size: 11px;
    letter-spacing: .04em;
    color: var(--ink-4);
  }
  .dl-table td:nth-child(6) { display: flex; margin: 0; }
  .dl-md5 code {
    white-space: normal;
    word-break: break-all;
    line-height: 1.6;
    font-size: 10.5px;
  }
  .dl-actions { gap: 14px; }

  .dl-help { padding: 34px 0 64px; }
  .dl-help-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 460px) {
  .dl-os-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dl-hero-stats { gap: 22px; }
  .dl-hero-stats b { font-size: 18px; }
}

@media (max-width: 360px) {
  .dl-os-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Dropdown filter + release cards ---------- */
.dl-drop-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 0 12px;
}
.dl-drop-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.dl-drop-field label {
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
}
.dl-drop-field select {
  width: 100%;
  height: 40px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  outline: 0;
  cursor: pointer;
}
.dl-drop-field select:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-50); }
.dl-drop-field select option:disabled { color: var(--ink-4); }
.dl-filter-extra--dropdown { flex-wrap: wrap; padding-top: 14px; }
.dl-filter-extra--dropdown .dl-sort { flex-shrink: 0; }
.dl-filter-extra--dropdown .dl-sort select {
  height: 36px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
}
.dl-release-list { display: grid; gap: 14px; padding: 18px 20px 20px; }
.dl-release-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.dl-release-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px 13px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(120deg, var(--brand-50), transparent 65%);
}
.dl-release-title { min-width: 0; }
.dl-release-title h3 { margin: 0; font-size: 15px; line-height: 1.45; letter-spacing: -.01em; }
.dl-release-title p { margin: 5px 0 0; overflow-wrap: anywhere; color: var(--ink-4); font-size: 12px; }
.dl-release-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; flex-shrink: 0; }
.dl-release-body {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
  gap: 20px;
  padding: 16px 18px 14px;
}
.dl-release-summary { margin: 0 0 10px; color: var(--ink-3); font-size: 12.5px; line-height: 1.65; }
.dl-release-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; margin: 0; }
.dl-release-meta div { min-width: 0; }
.dl-release-meta dt { color: var(--ink-4); font-size: 11px; }
.dl-release-meta dd { margin: 2px 0 0; overflow-wrap: anywhere; color: var(--ink); font-size: 12.5px; }
.dl-release-hashes { display: grid; align-content: start; gap: 7px; min-width: 0; }
.dl-release-hashes .hash-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.dl-release-hashes .hash-row span { flex-shrink: 0; color: var(--ink-4); font-size: 10.5px; font-weight: 600; }
.dl-release-hashes .hash-row code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--ink-3); font-size: 11px; white-space: nowrap; }
.dl-release-hashes .hash-row button { flex-shrink: 0; }
.dl-release-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px dashed var(--line);
}
.dl-release-source-label { display: flex; align-items: center; gap: 6px; color: var(--ink-4); font-size: 11.5px; font-weight: 600; }
.dl-source-buttons { display: flex; flex-wrap: wrap; gap: 7px; }
.dl-source-buttons .btn { white-space: nowrap; }
.dl-release-foot .dl-alt { margin-left: auto; }
@media (max-width: 900px) {
  .dl-drop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dl-release-body { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .dl-drop-grid { grid-template-columns: 1fr; }
  .dl-release-list { padding: 12px; }
  .dl-release-head { flex-direction: column; }
  .dl-release-badges { justify-content: flex-start; }
  .dl-release-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dl-release-foot .dl-alt { margin-left: 0; }
}

.dl-release-hashes .hash-row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-4);
  cursor: pointer;
}
.dl-release-hashes .hash-row button:hover { background: var(--brand-50); color: var(--brand-700); }
.dl-release-hashes .hash-row button svg { width: 14px; height: 14px; }

.dl-drop-field select:disabled {
  background: var(--surface-2);
  color: var(--ink-4);
  cursor: not-allowed;
  opacity: .75;
}

/* ---------- Domestic systems page ---------- */
.domestic-hero .dl-hero-row { align-items: center; }
.domestic-body { padding: 22px 0 56px; }
.domestic-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 22px;
}
.domestic-back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink-3); font-size: 12.5px; text-decoration: none;
}
.domestic-back:hover { color: var(--brand-700); }
.domestic-back svg { width: 14px; height: 14px; }
.domestic-note { color: var(--ink-4); font-size: 12px; }
.domestic-group { margin-bottom: 30px; }
.domestic-group-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; padding-bottom: 11px; margin-bottom: 13px;
  border-bottom: 1px solid var(--line);
}
.domestic-brand {
  display: inline-block; margin-bottom: 5px;
  color: var(--brand-700); font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
}
.domestic-group-head h2 {
  font-size: 18px; font-weight: 650; letter-spacing: -.02em; color: var(--ink);
}
.domestic-group-head h2 em { font-style: normal; color: var(--ink-4); font-weight: 500; }
.domestic-edition {
  flex-shrink: 0; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-3); font-size: 11.5px;
}
.domestic-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
}
.domestic-card {
  display: flex; flex-direction: column; gap: 9px;
  min-width: 0; padding: 15px 16px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface);
}
.domestic-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.domestic-card-head strong {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink); font-size: 14px; font-weight: 650;
}
.domestic-card-head span {
  flex-shrink: 0; color: var(--ink-4); font-size: 11px;
}
.domestic-file {
  min-height: 34px; margin: 0; overflow: hidden;
  color: var(--ink-3); font-size: 11.5px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  word-break: break-all;
}
.domestic-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px 12px;
  color: var(--ink-4); font-size: 11px;
}
.domestic-meta b { color: var(--ink-3); font-weight: 600; }
.domestic-sha { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.domestic-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; padding-top: 3px; }
.domestic-empty {
  padding: 64px 24px; border: 1px dashed var(--line); border-radius: var(--radius-lg);
  text-align: center; color: var(--ink-3);
}
.domestic-empty h2 { margin-bottom: 8px; font-size: 18px; color: var(--ink); }
.domestic-empty p { font-size: 12.5px; }
.dl-domestic-link {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 14px; color: var(--brand-700); font-size: 12.5px; font-weight: 600;
}
.dl-domestic-link svg { width: 13px; height: 13px; }
@media (max-width: 1000px) {
  .domestic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .domestic-grid { grid-template-columns: 1fr; }
  .domestic-toolbar { align-items: flex-start; flex-direction: column; gap: 7px; }
  .domestic-group-head { align-items: flex-start; flex-direction: column; gap: 7px; }
}
