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

:root {
  --bg: #2a2a2a;
  --bg-alt: #232323;
  --text: #f0f0f0;
  --text-muted: #9a9a9a;
  --accent: #f0f0f0;
  --accent-hover: #cccccc;
  --card-bg: #2a2a2a;
  --border: #3d3d3d;
  --green: #4ade80;
  --yellow: #fbbf24;
  --blue: #60a5fa;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* Navigation */
nav {
  position: fixed;
  top: 0;
  width: 100%;
  background: rgba(42, 42, 42, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.1rem 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  gap: 2.5rem;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 400;
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
}

/* ==================== */
/*  Landing Page        */
/* ==================== */

.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8rem 2rem 4rem;
  text-align: center;
}

.landing h1 {
  font-size: 3.8rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin-bottom: 0.75rem;
  line-height: 1.1;
}

.landing-sub {
  font-size: 1.15rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-bottom: 5rem;
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  width: 100%;
  max-width: 1100px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.landing-card {
  background: var(--bg);
  padding: 3rem 2.5rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  transition: background 0.3s;
  position: relative;
}

.landing-card:hover {
  background: var(--bg-alt);
}

.landing-icon {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.landing-card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}

.landing-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  flex: 1;
}

.landing-arrow {
  display: inline-block;
  margin-top: 1.5rem;
  font-size: 1.25rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.landing-card:hover .landing-arrow {
  transform: translateX(4px);
}

/* ==================== */
/*  Hero (subpages)     */
/* ==================== */

.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.hero-short {
  min-height: auto;
  padding: 10rem 2rem 4rem;
}

.hero-content {
  max-width: 700px;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
  line-height: 1.15;
}

.highlight {
  color: var(--text);
}

/* "Workshop" in handwritten font */
.workshop {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: 1.15em;
  letter-spacing: 0.01em;
}

.logo-workshop {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: 1.15em;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-weight: 400;
}

.description {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 2rem;
  line-height: 1.7;
}

.btn {
  display: inline-block;
  padding: 0.8rem 2rem;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.9rem;
  transition: background 0.2s;
  border: none;
  cursor: pointer;
}

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

/* Sections */
.section {
  padding: 5rem 2rem;
}

.section-alt {
  background: var(--bg-alt);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
}

.section h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

.section p {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 600px;
  line-height: 1.7;
}

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.card-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.card-soon {
  opacity: 0.45;
}

.card-soon:hover {
  box-shadow: none;
}

.card-tag {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.card p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Bio / About page */
.bio-hero {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
  margin-bottom: 3rem;
}

.bio-photo {
  width: 200px;
  height: 200px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
}

.bio-intro p {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.8;
  margin-bottom: 1rem;
  max-width: none;
}

.bio-section {
  margin-bottom: 2.5rem;
}

.bio-section h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0;
}

.bio-entry {
  margin-bottom: 1.5rem;
}

.bio-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.bio-entry-header span {
  color: var(--text-muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.bio-entry p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  max-width: none;
}

.bio-list {
  list-style: none;
  padding: 0;
}

.bio-list li {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  padding-left: 1.25rem;
  position: relative;
  margin-bottom: 0.5rem;
}

.bio-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border);
}

/* Social */
.social-links {
  margin-top: 1rem;
  display: flex;
  gap: 1.5rem;
}

.social-links a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.2s;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
}

.social-links a:hover {
  color: var(--text-muted);
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 2.5rem 2rem;
  text-align: center;
}

footer p {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 1rem;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--text);
}

/* ==================== */
/*  Calculator Styles   */
/* ==================== */

.calc-theory {
  margin-bottom: 3rem;
}

.calc-theory p {
  max-width: 800px;
}

.circuit-diagram {
  margin-top: 1.5rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  overflow-x: auto;
}

.circuit-diagram pre {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.calc-section {
  margin-bottom: 3rem;
}

.calc-section h2 {
  margin-bottom: 1.5rem;
}

.calc-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 2rem 0 1rem;
  color: var(--text-muted);
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

.input-with-unit {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.input-with-unit:focus-within {
  border-color: var(--text);
}

.input-with-unit input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.95rem;
  padding: 0.7rem 0.9rem;
  font-family: inherit;
  outline: none;
  min-width: 0;
}

.input-with-unit .unit {
  padding: 0.7rem 0.9rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  background: var(--bg-alt);
  border-left: 1px solid var(--border);
  white-space: nowrap;
}

.input-group small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.calc-btn {
  margin-top: 2rem;
  font-size: 0.9rem;
  padding: 0.8rem 2.5rem;
}

/* Results */
.result-block {
  margin-bottom: 2.5rem;
  padding: 2rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.result-block h2 {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

.result-desc {
  margin-bottom: 1.5rem !important;
  font-size: 0.9rem !important;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.result-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.result-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.result-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.highlight-card {
  border-color: var(--blue);
}

.highlight-card .result-value {
  color: var(--blue);
}

.warn-card {
  border-color: var(--yellow);
}

.warn-card .result-value {
  color: var(--yellow);
}

.good-card {
  border-color: var(--green);
}

.good-card .result-value {
  color: var(--green);
}

.formula-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-top: 1rem;
}

.formula-block p {
  font-size: 0.9rem !important;
  color: var(--text) !important;
  margin-bottom: 0.5rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  max-width: none;
}

/* ==================== */
/*  Article Layout      */
/* ==================== */

.article-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  max-width: 1100px;
  margin: 0 auto;
  padding-top: 5rem;
  gap: 3rem;
}

.article-sidebar {
  position: relative;
}

.toc {
  position: sticky;
  top: 5.5rem;
  padding: 1.5rem 0;
}

.toc-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: toc;
}

.toc-list li {
  counter-increment: toc;
  margin-bottom: 0.1rem;
}

.toc-link {
  display: block;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  line-height: 1.4;
}

.toc-link:hover {
  color: var(--text);
}

.toc-link.active {
  color: var(--text);
  border-left-color: var(--text);
}

/* Article content */
.article-content {
  max-width: 720px;
  padding: 2rem 0 4rem;
}

.article-header {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.article-tag {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.article-header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

.article-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Chapter sections */
.chapter {
  margin-bottom: 3.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.chapter:last-of-type {
  border-bottom: none;
}

.chapter h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
  line-height: 1.3;
}

.ch-num {
  display: inline-block;
  width: 1.8rem;
  color: var(--text-muted);
  font-weight: 400;
  font-size: 1rem;
  margin-right: 0.25rem;
}

.chapter h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  color: var(--text);
}

.chapter p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.8;
  margin-bottom: 1rem;
  max-width: none;
}

.chapter ul,
.chapter ol {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.8;
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.chapter li {
  margin-bottom: 0.4rem;
}

.chapter blockquote {
  border-left: 3px solid var(--border);
  padding: 0.75rem 1.25rem;
  margin: 1.25rem 0;
  color: var(--text);
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.7;
  background: var(--bg-alt);
  border-radius: 0 8px 8px 0;
}

/* Key result boxes */
.key-result {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: 0 8px 8px 0;
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
}

.key-result p {
  color: var(--text) !important;
  margin-bottom: 0.5rem;
  font-size: 0.92rem !important;
}

.key-result p:last-child {
  margin-bottom: 0;
}

.key-result ul {
  color: var(--text);
  margin-bottom: 0;
}

.key-result-warn {
  border-left-color: var(--yellow);
}

/* Data tables */
.result-table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  padding: 0.65rem 0.75rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 0.6rem 0.75rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: var(--bg-alt);
}

.row-disagree {
  background: rgba(251, 191, 36, 0.08);
}

.row-disagree td {
  color: var(--yellow);
}

.verdict-ok {
  color: var(--green) !important;
  font-weight: 600;
}

.verdict-bad {
  color: var(--yellow) !important;
  font-weight: 600;
}

/* Article figures */
.article-fig {
  margin: 1.75rem 0;
}

.article-fig img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #1a1a1a;
}

.article-fig figcaption {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.article-fig figcaption strong {
  color: var(--text);
}

/* Article back link */
.article-back {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.article-back a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.article-back a:hover {
  color: var(--text);
}

/* Responsive */
@media (max-width: 840px) {
  .landing-grid {
    grid-template-columns: 1fr;
    max-width: 480px;
  }

  .landing h1 {
    font-size: 2.5rem;
  }

  .article-layout {
    grid-template-columns: 1fr;
    padding: 4.5rem 1.5rem 0;
    gap: 0;
  }

  .article-sidebar {
    position: relative;
  }

  .toc {
    position: relative;
    top: 0;
    padding: 1.5rem 0 0.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
  }

  .article-header h1 {
    font-size: 1.6rem;
  }
}

@media (max-width: 640px) {
  .hero h1 {
    font-size: 2rem;
  }

  .nav-links {
    gap: 1.25rem;
  }

  .nav-links a {
    font-size: 0.8rem;
  }

  .section {
    padding: 3rem 1.5rem;
  }

  .calc-grid {
    grid-template-columns: 1fr;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .bio-hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .bio-photo {
    width: 160px;
    height: 160px;
  }

  .bio-entry-header {
    flex-direction: column;
    gap: 0.15rem;
  }
}
