*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #ffffff;
  --fg:      #111111;
  --muted:   #666666;
  --border:  #e0e0e0;
  --accent:  #0066ff;
  --green:   #16a34a;
  --red:     #dc2626;
  --gold:    #b45309;
  --code-bg: #f5f5f5;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: 3px;
}

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 52px;
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}

nav ul {
  display: flex;
  gap: 2rem;
  list-style: none;
}

nav ul a {
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
}

nav ul a:hover,
nav ul a.active { color: var(--fg); }

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.hero { padding: 3rem 2rem 2rem; max-width: 860px; margin: 0 auto; }
.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 1rem;
}
.hero p { color: var(--muted); max-width: 480px; margin-bottom: 1.5rem; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.card {
  display: block;
  padding: 1.5rem;
  background: var(--bg);
  text-decoration: none;
  color: var(--fg);
  transition: background 0.15s;
}
.card:hover { background: #fafafa; text-decoration: none; }
.card + .card { border-left: 1px solid var(--border); }

.card-num { font-size: 12px; color: var(--muted); margin-bottom: 0.75rem; }
.card h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; }
.card p { font-size: 13px; color: var(--muted); margin-bottom: 1rem; line-height: 1.5; }
.card-tags { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.card-tags li { font-size: 11px; color: var(--muted); font-family: 'JetBrains Mono', monospace; }

/* PAGE HEADER */
.page-header { padding: 3rem 2rem 1.5rem; max-width: 860px; margin: 0 auto; border-bottom: 1px solid var(--border); }
.page-header small { font-size: 12px; color: var(--muted); }
.page-header h1 { font-size: 1.8rem; font-weight: 700; margin: 0.25rem 0 0.5rem; }
.page-header p { color: var(--muted); font-size: 14px; max-width: 640px; }

/* SECTIONS */
.section { padding: 2rem; max-width: 860px; margin: 0 auto; border-bottom: 1px solid var(--border); }
.section:last-of-type { border-bottom: none; }
.section h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 1.25rem; }

/* FORM CONTROLS */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

input[type="text"],
input[type="number"],
select {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  color: var(--fg);
  outline: none;
  width: 100%;
}
input:focus, select:focus { border-color: var(--accent); }

.field { margin-bottom: 1rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }

/* BUTTONS */
button {
  font-family: inherit;
  font-size: 13px;
  padding: 7px 16px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  transition: background 0.15s;
}
button:hover { background: #f5f5f5; }

button.primary {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
button.primary:hover { opacity: 0.85; }

.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }

/* OUTPUT / INFO BOX */
.output {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  padding: 0.75rem 1rem;
  background: var(--code-bg);
  border-radius: 5px;
  color: var(--fg);
  min-height: 2.5rem;
  margin-top: 1rem;
  border-left: 3px solid var(--accent);
}
.output.gold-border { border-left-color: var(--gold); }

.alert {
  font-size: 13px;
  padding: 0.75rem 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 5px;
  color: var(--red);
}

/* STATS ROW */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 2rem;
}
.stat {
  padding: 1rem 1.25rem;
  background: var(--bg);
}
.stat + .stat { border-left: 1px solid var(--border); }
.stat-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.stat-value { font-size: 1.3rem; font-weight: 700; }
.stat-value.up   { color: var(--green); }
.stat-value.down { color: var(--red); }
.stat-value.gold { color: var(--gold); }

/* NDARRAY GRID */
.nd-grid { display: inline-grid; gap: 3px; margin-bottom: 1rem; }
.nd-cell {
  width: 42px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--muted);
}
.nd-cell.active { background: #eff6ff; border-color: #bfdbfe; color: var(--accent); }
.nd-cell.sliced { background: #fefce8; border-color: #fde68a; color: var(--gold); }

/* MATRIX GRID */
.mat-grid { display: inline-grid; gap: 3px; }
.mat-cell {
  width: 52px; height: 36px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
  outline: none;
}
.mat-cell:focus { border-color: var(--accent); }
.mat-cell.result { background: #f0fdf4; border-color: #bbf7d0; color: var(--green); }

/* CHART */
.chart-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}
canvas { display: block; width: 100%; height: auto; }

/* CODE BLOCK */
pre {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: var(--code-bg);
  border-radius: 6px;
  padding: 1.25rem;
  overflow-x: auto;
  line-height: 1.7;
  color: var(--muted);
}
pre .kw  { color: var(--accent); }
pre .fn  { color: #7c3aed; }
pre .cm  { color: #aaaaaa; }
pre .str { color: var(--green); }

/* LOADER */
.loader { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 13px; padding: 1rem 0; }
.loader-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: blink 1s ease-in-out infinite; }
.loader-dot:nth-child(2) { animation-delay: 0.2s; }
.loader-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100% { opacity: 0.2; } 40% { opacity: 1; } }

/* FOOTER */
footer {
  text-align: center;
  padding: 2rem;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  margin-top: 2rem;
}

/* UTILS */
.mt { margin-top: 1rem; }
.muted { color: var(--muted); font-size: 13px; }

/* RESPONSIVE */
@media (max-width: 600px) {
  .cards { grid-template-columns: 1fr; }
  .card + .card { border-left: none; border-top: 1px solid var(--border); }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .stat + .stat { border-left: none; }
}