/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f4f6f9;
  color: #1a1a2e;
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }

/* ── Site header ──────────────────────────────────────────────────────────── */
.site-header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%);
  color: white;
  padding: 60px 40px 50px;
  text-align: center;
}
.site-header h1 {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}
.site-header p {
  font-size: 1.1rem;
  opacity: 0.75;
}

/* ── Model card grid ──────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 24px 60px;
}

.model-card {
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}
.model-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.14);
}

.card-image {
  height: 160px;
  background-size: cover;
  background-position: center;
  background-color: #cdd8e8;
  position: relative;
}

.card-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: white;
}
.card-badge.classification { background: #0f3460; }
.card-badge.regression     { background: #e94560; }

.card-body {
  padding: 20px;
  flex: 1;
}
.card-emoji { font-size: 1.8rem; margin-bottom: 8px; }
.card-body h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.card-body p  { font-size: 0.88rem; color: #555; line-height: 1.5; }

/* ── Model hero ───────────────────────────────────────────────────────────── */
.model-hero {
  background-size: cover;
  background-position: center;
  background-color: #1a1a2e;
  position: relative;
  min-height: 260px;
  display: flex;
  align-items: flex-end;
}
.model-hero-overlay {
  width: 100%;
  background: linear-gradient(to top, rgba(10,10,30,0.92) 0%, rgba(10,10,30,0.5) 60%, transparent 100%);
  padding: 28px 40px 36px;
}
.back-link {
  display: inline-block;
  color: rgba(255,255,255,0.8);
  font-size: 0.9rem;
  margin-bottom: 20px;
  transition: color 0.15s;
}
.back-link:hover { color: white; }
.model-hero-text .card-badge { position: static; display: inline-block; margin-bottom: 10px; }
.model-hero-text h1 { color: white; font-size: 2rem; font-weight: 700; margin-bottom: 10px; }
.model-hero-text p  { color: rgba(255,255,255,0.8); font-size: 1rem; max-width: 680px; line-height: 1.6; }

/* ── Model main ───────────────────────────────────────────────────────────── */
.model-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ── Predict panel ────────────────────────────────────────────────────────── */
.predict-panel {
  background: white;
  border-radius: 16px;
  padding: 36px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  margin-bottom: 28px;
}
.predict-panel h2 { font-size: 1.4rem; margin-bottom: 8px; }
.panel-hint { color: #666; font-size: 0.92rem; margin-bottom: 28px; }

.inputs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
}
.unit { font-weight: 400; color: #888; }

.input-group input,
.input-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #dde2ea;
  border-radius: 8px;
  font-size: 1rem;
  background: #f8f9fb;
  transition: border-color 0.15s;
  outline: none;
}
.input-group input:focus,
.input-group select:focus { border-color: #0f3460; background: white; }

.predict-btn {
  background: linear-gradient(135deg, #0f3460, #16213e);
  color: white;
  border: none;
  padding: 14px 40px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.predict-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.predict-btn:active { transform: translateY(0); }

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 32px;
  color: #555;
  font-size: 1rem;
}
.spinner-ring {
  width: 44px;
  height: 44px;
  border: 4px solid #e0e4ed;
  border-top-color: #0f3460;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Result box ───────────────────────────────────────────────────────────── */
.result-box {
  margin-top: 24px;
  padding: 24px 28px;
  border-radius: 12px;
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  animation: fadeIn 0.4s ease;
}
.result-box.positive { background: #eafaf1; color: #1a7a44; border: 2px solid #a8e6c4; }
.result-box.negative { background: #fef0f0; color: #c0392b; border: 2px solid #f5b7b1; }
.result-box.neutral  { background: #eef2ff; color: #2c3e7a; border: 2px solid #c5caff; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── Accordions ───────────────────────────────────────────────────────────── */
.accordions { display: flex; flex-direction: column; gap: 12px; }

.accordion {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  overflow: hidden;
}

.accordion summary {
  padding: 18px 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  transition: background 0.15s;
}
.accordion summary:hover { background: #f8f9fb; }
.accordion summary::after {
  content: '›';
  margin-left: auto;
  font-size: 1.4rem;
  color: #999;
  transition: transform 0.2s;
}
.accordion[open] summary::after { transform: rotate(90deg); }

.acc-hint { font-weight: 400; font-size: 0.82rem; color: #888; }

.accordion-body {
  padding: 0 24px 24px;
}

.trunc-note {
  font-size: 0.82rem;
  color: #888;
  margin-bottom: 12px;
  font-style: italic;
}

/* ── Data tables ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid #e5e9f0; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
thead th {
  background: #f0f3f8;
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
  white-space: nowrap;
  border-bottom: 2px solid #dde2ea;
  color: #333;
}
tbody tr:nth-child(even) { background: #f8f9fb; }
tbody td {
  padding: 8px 14px;
  border-bottom: 1px solid #eef1f6;
  white-space: nowrap;
}

/* ── Code block ───────────────────────────────────────────────────────────── */
pre {
  border-radius: 10px;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.65;
  margin: 0;
}
pre code.hljs {
  border-radius: 10px;
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 0.88rem;
  line-height: 1.65;
}

/* ── Table pagination ─────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 14px 0 2px;
}

.page-btn {
  background: #f0f3f8;
  border: 1.5px solid #dde2ea;
  border-radius: 8px;
  padding: 6px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #0f3460;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.page-btn:hover:not(:disabled) {
  background: #e2e8f4;
  border-color: #0f3460;
}
.page-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.page-info {
  font-size: 0.85rem;
  color: #666;
  min-width: 130px;
  text-align: center;
}

/* ── Decision tree visualization ──────────────────────────────────────────── */
.tree-intro {
  font-size: 0.95rem;
  color: #444;
  line-height: 1.6;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: #f0f4ff;
  border-left: 4px solid #0f3460;
  border-radius: 0 8px 8px 0;
}

.tree-zoom-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  background: #f4f6fb;
  border: 1.5px solid #dde2ea;
  border-radius: 10px;
  padding: 8px 14px;
}

.tree-zoom-btn {
  width: 36px;
  height: 36px;
  border: 2px solid #0f3460;
  border-radius: 8px;
  background: #0f3460;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.tree-zoom-btn:hover {
  background: #1a4a8a;
  border-color: #1a4a8a;
}

.tree-zoom-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f3460;
  min-width: 52px;
  text-align: center;
  background: #fff;
  border: 1.5px solid #dde2ea;
  border-radius: 6px;
  padding: 4px 8px;
}

.tree-zoom-reset {
  padding: 7px 16px;
  border: 1.5px solid #0f3460;
  border-radius: 8px;
  background: #fff;
  color: #0f3460;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-left: 4px;
}

.tree-zoom-reset:hover {
  background: #0f3460;
  color: #fff;
}

.tree-scroll-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  border: 1.5px solid #dde2ea;
  border-radius: 12px;
  background: #fff;
  padding: 16px;
  text-align: center;
}

.tree-img {
  width: 100%;
  max-width: none;
  height: auto;
  display: block;
  margin: 0 auto;
  transition: width 0.15s ease;
}

/* ── Regression equation + calculator ────────────────────────────────────── */

.eq-formula {
  font-family: 'Georgia', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: #0f3460;
  background: #eef2ff;
  border: 1.5px solid #c7d2fe;
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 18px;
  letter-spacing: 0.01em;
  line-height: 1.7;
  word-break: break-word;
}

.eq-calc {
  background: #f9fafb;
  border: 1.5px solid #dde2ea;
  border-radius: 12px;
  padding: 20px 24px;
  margin-top: 6px;
}

.eq-calc-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f3460;
  margin: 0 0 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.eq-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.eq-input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.eq-input-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
}

.eq-input-group input,
.eq-input-group select {
  padding: 8px 10px;
  border: 1.5px solid #ccd4e0;
  border-radius: 7px;
  font-size: 0.95rem;
  background: #fff;
  color: #222;
  transition: border-color 0.15s;
}

.eq-input-group input:focus,
.eq-input-group select:focus {
  outline: none;
  border-color: #0f3460;
}

.eq-result-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #0f3460;
  border-radius: 10px;
  padding: 14px 20px;
}

.eq-result-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255,255,255,0.75);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.eq-result {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.01em;
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .site-header { padding: 40px 20px 32px; }
  .site-header h1 { font-size: 1.8rem; }
  .model-hero-overlay { padding: 20px 20px 28px; }
  .predict-panel { padding: 24px 20px; }
  .inputs-grid { grid-template-columns: 1fr; }
}
