:root {
  --bg-dark: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: #0f3460;
  --accent: #00d4ff;
  --accent-dim: #0098b8;
  --text: #e0e0e0;
  --error: #ff4d4d;
  --warn: #ffd700;
  --success: #00ff99;
}

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

body {
  background: var(--bg-dark);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
}

/* Navbar */
nav {
  background: #0d0d1a;
  border-bottom: 2px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.5px;
  text-decoration: none;
}

.logo span { color: white; }

.nav-links {
  display: flex;
  gap: 0.5rem;
  list-style: none;
}

.nav-links a {
  color: var(--text);
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.875rem;
  transition: background 0.2s, color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  background: var(--accent);
  color: #0d0d1a;
  font-weight: 600;
}

/* Layout */
.page-wrapper {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 768px) {
  .page-wrapper { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .nav-links a { font-size: 0.75rem; padding: 0.3rem 0.5rem; }
}

/* Calculator sections */
.calc-section {
  scroll-margin-top: 80px;
  background: var(--bg-card);
  border: 1px solid #2a2a4a;
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2rem;
}

.calc-section h2 {
  color: var(--accent);
  font-size: 1.4rem;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.calc-section .desc {
  color: #9090b0;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

/* Form elements */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: #aaaacc;
  margin-bottom: 0.3rem;
}

.input-row {
  display: flex;
  gap: 0.5rem;
}

.input-row input,
.input-row select,
.form-group input,
.form-group select {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid #3a3a6a;
  border-radius: 8px;
  color: white;
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.input-row input:focus,
.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
}

.input-row select,
.form-group select {
  flex: 0 0 auto;
  width: auto;
  cursor: pointer;
}

/* Calc button */
.btn-calc {
  width: 100%;
  padding: 0.8rem;
  background: var(--accent);
  color: #0d0d1a;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-top: 0.5rem;
}

.btn-calc:hover { background: #00b8d9; }
.btn-calc:active { transform: scale(0.98); }

/* Results */
.result-box {
  margin-top: 1.5rem;
  background: #0d1a2e;
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 1.2rem 1.5rem;
  display: none;
}

.result-box.visible { display: block; }

.result-main {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.result-sub {
  font-size: 0.95rem;
  color: #9090b0;
  margin-bottom: 0.3rem;
}

.result-explain {
  margin-top: 0.8rem;
  padding: 0.7rem;
  background: #162030;
  border-radius: 6px;
  font-size: 0.875rem;
  color: #b0c0d0;
  line-height: 1.6;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.result-item {
  background: #162030;
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
}

.result-item .ri-label { font-size: 0.75rem; color: #7080a0; }
.result-item .ri-val { font-size: 1.1rem; color: white; font-weight: 600; }

/* Error / Warning */
.error-msg {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  display: none;
}

.warn-msg {
  background: #3a2a00;
  border: 1px solid var(--warn);
  color: var(--warn);
  border-radius: 6px;
  padding: 0.5rem 0.8rem;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  display: none;
}

/* SVG diagram */
.circuit-diagram {
  margin-top: 1.5rem;
  text-align: center;
  background: #0d0d1a;
  border-radius: 8px;
  padding: 1rem;
}

.circuit-diagram img, .circuit-diagram svg {
  max-width: 100%;
  height: auto;
}

/* Ohm: calc what selector */
.calc-what {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.calc-what-btn {
  padding: 0.4rem 0.9rem;
  border: 1px solid #3a3a6a;
  border-radius: 20px;
  background: transparent;
  color: #9090b0;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.calc-what-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #0d0d1a;
  font-weight: 600;
}

/* E24 highlight */
.e24-val {
  color: var(--success);
  font-weight: 700;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 80px;
}

.adsense-placeholder {
  background: #0d1a2e;
  border: 2px dashed #2a3a5a;
  border-radius: 10px;
  padding: 2rem 1rem;
  text-align: center;
  color: #4a5a7a;
  font-size: 0.8rem;
  margin-bottom: 1rem;
}

/* Footer */
footer {
  background: #0d0d1a;
  border-top: 1px solid #2a2a4a;
  text-align: center;
  padding: 1.5rem;
  color: #5a5a7a;
  font-size: 0.9rem;
}

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

/* Bottom AdSense area */
.bottom-ad {
  background: #0d1a2e;
  border: 2px dashed #2a3a5a;
  border-radius: 10px;
  padding: 2rem 1rem;
  text-align: center;
  color: #4a5a7a;
  font-size: 0.8rem;
  margin: 1rem 0;
}

/* LED color presets */
.led-presets {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.led-preset-btn {
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
  border: 1px solid #3a3a6a;
  background: transparent;
  color: #9090b0;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.led-preset-btn:hover { border-color: var(--accent); color: var(--accent); }
