/* ═══════════════════════════════════════════════════════════════
   openscience.fun — styles
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #0d1117;
  --bg-surface: #161b22;
  --bg-surface-hover: #1c2129;
  --bg-elevated: #21262d;
  --border: #30363d;
  --border-focus: #58a6ff;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-subtle: #6e7681;
  --accent: #58a6ff;
  --accent-dim: #1f6feb;
  --green: #3fb950;
  --green-dim: #238636;
  --orange: #d29922;
  --red: #f85149;
  --mono: "IBM Plex Mono", monospace;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Header ──────────────────────────────────────────────── */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-family: var(--mono);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logo-accent { color: var(--accent); }

.header-right { display: flex; gap: 16px; align-items: center; }

.header-link {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: lowercase;
}
.header-link:hover { color: var(--text); text-decoration: none; }

/* ─── Main ────────────────────────────────────────────────── */

.main-content {
  flex: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  width: 100%;
}

/* ─── Steps ───────────────────────────────────────────────── */

.step {
  margin-bottom: 40px;
  transition: opacity 0.3s ease;
}

.step.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.step-number {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.step:not(.disabled) .step-number {
  border-color: var(--accent);
  color: var(--accent);
}

.step h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.step-desc {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 16px;
  padding-left: 36px;
}

/* ─── Search ──────────────────────────────────────────────── */

.search-container {
  position: relative;
  margin-bottom: 8px;
}

.search-input {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 0.9rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--border-focus);
}

.search-input::placeholder {
  color: var(--text-subtle);
}

.search-stats {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-subtle);
  margin-top: 4px;
  padding-left: 2px;
  height: 18px;
}

/* ─── Case List ───────────────────────────────────────────── */

.case-list-container {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-surface);
}

.case-list-container:empty,
.case-list:empty + .case-list-container {
  display: none;
}

.case-list {
  display: flex;
  flex-direction: column;
}

.case-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  gap: 12px;
}

.case-item:last-child { border-bottom: none; }

.case-item:hover { background: var(--bg-surface-hover); }

.case-item-id {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
  white-space: nowrap;
  min-width: 72px;
}

.case-item-title {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-item-meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-subtle);
  white-space: nowrap;
}

/* ─── Selected Case ───────────────────────────────────────── */

.selected-case {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--green-dim);
  border-radius: 6px;
}

.selected-case-header {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green);
  margin-bottom: 6px;
}

.selected-case-detail {
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.selected-case-detail .case-item-id {
  font-size: 0.85rem;
}

/* ─── Config Options ──────────────────────────────────────── */

.config-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.config-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.config-option:hover { border-color: var(--text-subtle); }

.config-option input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--accent);
}

.option-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.option-info strong { font-size: 0.9rem; }

.option-detail {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ─── Model Picker ───────────────────────────────────────── */

.hybrid-model-panel {
  padding: 8px 14px 14px;
  margin-top: -4px;
}

.model-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.model-picker-header label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.model-selected-name {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
}

.model-search-input {
  margin-bottom: 6px;
  font-size: 0.82rem !important;
  padding: 7px 10px !important;
}

.model-list-container {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-surface);
}

.model-list {
  display: flex;
  flex-direction: column;
}

.model-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.model-item:last-child { border-bottom: none; }
.model-item:hover { background: var(--bg-surface-hover); }
.model-item.selected { background: var(--bg-elevated); border-left: 2px solid var(--accent); }

.model-item-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
}

.model-item-id {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-subtle);
  margin-top: 1px;
}

.model-item-context {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-subtle);
  white-space: nowrap;
}

.model-list-loading {
  padding: 16px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.model-list-container::-webkit-scrollbar { width: 6px; }
.model-list-container::-webkit-scrollbar-track { background: transparent; }
.model-list-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── Advanced Settings ───────────────────────────────────── */

.config-advanced { margin-bottom: 8px; }

.advanced-panel {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.config-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.config-row label {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 120px;
}

.config-row select {
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  outline: none;
}

.config-row select:focus { border-color: var(--border-focus); }

/* ─── Checklist ───────────────────────────────────────────── */

.checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1.4;
}

.check-item input[type="checkbox"] {
  margin-top: 3px;
  accent-color: var(--green);
}

/* ─── Buttons ─────────────────────────────────────────────── */

.btn {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover { background: var(--bg-elevated); }

.btn-primary {
  background: var(--green-dim);
  border-color: var(--green-dim);
  color: #fff;
  font-size: 1rem;
  padding: 12px 28px;
}

.btn-primary:hover:not(:disabled) {
  background: var(--green);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 4px 0;
  cursor: pointer;
}

.btn-text:hover { color: var(--text); background: none; }

.btn-clear {
  font-size: 0.78rem;
  padding: 4px 10px;
}

.btn-small {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 3px 8px;
}

/* ─── Session Info ────────────────────────────────────────── */

.session-info {
  margin-top: 16px;
  padding: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.session-token-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.session-token-row label {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 100px;
}

.session-token-row code {
  font-family: var(--mono);
  font-size: 0.85rem;
  background: var(--bg-elevated);
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--accent);
  user-select: all;
}

.session-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ─── Secrets Checklist ──────────────────────────────────── */

.secrets-checklist {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.secrets-checklist h3 {
  font-family: var(--mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--orange);
  margin-bottom: 6px;
}

.secrets-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 10px;
}

.secret-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.secret-item code {
  font-family: var(--mono);
  font-size: 0.82rem;
  background: var(--bg-surface);
  padding: 3px 8px;
  border-radius: 4px;
  color: var(--accent);
  white-space: nowrap;
}

.secret-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ─── References ─────────────────────────────────────────── */

.references {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.references a {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--accent);
}

/* ─── Footer ──────────────────────────────────────────────── */

.app-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.app-footer p {
  font-size: 0.75rem;
  color: var(--text-subtle);
  line-height: 1.5;
}

/* ─── Scrollbar ───────────────────────────────────────────── */

.case-list-container::-webkit-scrollbar {
  width: 6px;
}

.case-list-container::-webkit-scrollbar-track {
  background: transparent;
}

.case-list-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ─── Responsive ──────────────────────────────────────────── */

@media (max-width: 600px) {
  .main-content { padding: 20px 16px 48px; }
  .step-desc { padding-left: 0; }
  .config-row { flex-direction: column; align-items: flex-start; gap: 4px; }
  .config-row label { min-width: auto; }
  .session-token-row { flex-wrap: wrap; }
}
