:root {
  --bg: #0d1117;
  --card: #161b22;
  --border: #30363d;
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --green: #3fb950;
  --orange: #d29922;
  --red: #f85149;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}
h1 { font-size: 2rem; margin-bottom: 0.25rem; }
h1 span { color: var(--accent); }
h2 { font-size: 1.15rem; margin-bottom: 0.75rem; }
.subtitle { color: var(--text-muted); margin-bottom: 2rem; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}
label { display: block; margin-bottom: 0.5rem; font-weight: 600; }
select, input {
  width: 100%;
  padding: 0.6rem;
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 1rem;
}
select:focus, input:focus { outline: none; border-color: var(--accent); }
.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}
.badge-green { background: rgba(63, 185, 80, 0.15); color: var(--green); }
.badge-orange { background: rgba(210, 153, 34, 0.15); color: var(--orange); }
.badge-red { background: rgba(248, 81, 73, 0.15); color: var(--red); }
.command-block {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 2.4rem 1rem 1rem;
  font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
  position: relative;
}
.command-block.small { font-size: 0.8rem; }
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  z-index: 1;
}
.copy-btn:hover {
  background: var(--border);
  color: var(--text);
}
.copy-btn svg {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.stat { text-align: center; }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }
.hidden { display: none; }
hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
a { color: var(--accent); }
code {
  background: rgba(88, 166, 255, 0.1);
  padding: 0.1em 0.3em;
  border-radius: 3px;
  font-size: 0.85em;
}
.loading {
  text-align: center;
  padding: 3rem 0;
  color: var(--text-muted);
}

/* Step list for setup guide */
.steps { counter-reset: step; margin: 0; padding: 0; }
.step {
  list-style: none;
  margin-bottom: 1rem;
  padding-left: 2.2rem;
  position: relative;
}
.step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step-title {
  font-weight: 600;
  margin-bottom: 0.3rem;
}
.step-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.step .command-block {
  margin-top: 0.3rem;
}
.step-note {
  font-size: 0.85rem;
  color: var(--orange);
  margin-top: 0.3rem;
}

/* ── Model selector cards ── */
.model-option {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.6rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.model-option:hover {
  background: #111820;
}
.model-option.selected {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.06);
}
.model-option-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}
.model-option-name {
  font-weight: 700;
  font-size: 0.95rem;
}
.model-option-arch {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--card);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
}
.model-option-details {
  display: flex;
  gap: 0.8rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
  justify-content: space-between;
}
.model-option-stat {
  white-space: nowrap;
}
.model-option-file {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.model-option-quant {
  white-space: nowrap;
  background: rgba(88, 166, 255, 0.12);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0.3rem;
}
.model-option-quant:hover {
  background: rgba(88, 166, 255, 0.25);
}
.model-option-quant-static {
  white-space: nowrap;
  background: rgba(88, 166, 255, 0.08);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.72rem;
  flex-shrink: 0;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0.3rem;
}

/* ── Quant variant dropdown ── */
.quant-menu {
  z-index: 100;
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.3rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  width: max-content;
  min-width: 180px;
}
.quant-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.1s;
}
.quant-menu-item:hover {
  background: rgba(88, 166, 255, 0.1);
}
.quant-menu-item.current {
  background: rgba(88, 166, 255, 0.15);
}
.quant-menu-item.no-fit {
  opacity: 0.5;
}
.quant-menu-quant {
  font-weight: 700;
  min-width: 3.5rem;
}
.quant-menu-file {
  color: var(--text-muted);
  flex: 1;
}

.model-option-ctx {
  margin-left: auto;
  font-weight: 600;
  flex-shrink: 0;
}
.model-option-footer {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8rem;
}
.model-option-vram {
  color: var(--text-muted);
}
.model-option-speed {
  color: var(--text-muted);
  margin-left: auto;
}

/* ── Memory bar ── */
.mem-bar {
  display: flex;
  height: 1.5rem;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
}
.mem-bar-seg {
  transition: flex 0.2s;
}

/* ── Memory table ── */
.mem-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.mem-table td {
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid var(--border);
}
.mem-table-title {
  font-weight: 700;
  font-size: 0.9rem;
  padding-bottom: 0.5rem !important;
  color: var(--text);
}
.mem-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}
.mem-num {
  text-align: right;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  white-space: nowrap;
}
.mem-pct {
  text-align: right;
  color: var(--text-muted);
  width: 3rem;
}
.mem-total td {
  font-weight: 700;
  border-bottom: 2px solid var(--border);
  padding-top: 0.5rem;
}
.mem-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ── Card header with dropdown button ── */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.card-header h2 {
  margin-bottom: 0;
}
.card-header-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background 0.15s;
  flex-shrink: 0;
}
.card-header-btn:hover {
  background: var(--border);
}
.chevron {
  display: inline-block;
  transition: transform 0.2s;
  line-height: 1;
}
.chevron.open {
  transform: rotate(180deg);
}

/* ── Model selector panel (dropdown overlay) ── */
.selector-panel {
  position: relative;
  z-index: 10;
  margin-top: 0.5rem;
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.selector-panel::-webkit-scrollbar {
  width: 6px;
}
.selector-panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ── Responsive tweaks ── */
/* ── Comparison modal ── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open {
  display: flex;
}
.modal-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
}
.modal-close:hover { color: var(--text); }
.modal-frame {
  width: 100%;
  flex: 1;
  border: none;
  min-height: 60vh;
}

@media (max-width: 600px) {
  .modal-overlay { padding: 0; }
  .modal-box {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
  .modal-frame { min-height: 85vh; }
}

/* ── Mobile: < 600px ── */
@media (max-width: 600px) {
  body {
    padding: 1rem 0.6rem;
  }
  h1 { font-size: 1.5rem; }
  .card {
    padding: 1rem 0.8rem;
  }
  .model-option-header {
    flex-wrap: wrap;
    gap: 0.3rem;
  }
  .model-option-name {
    width: 100%;
  }
  .model-option-arch {
    display: none;
  }
  .model-option-quant,
  .model-option-quant-static {
    margin: 0 0 0 0;
  }

  .model-option-details {
    flex-direction: column;
    gap: 0.15rem;
    justify-content: flex-start;
  }
  .model-option-ctx {
    margin-left: 0;
    text-align: center;
    width: 100%;
  }
  .model-option-file {
    width: 100%;
  }

  .model-option-footer {
    flex-wrap: wrap;
  }
  .model-option-speed {
    margin-left: 0;
  }

  .model-option-vram {
    font-size: 0.75rem;
  }
}
