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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #0f1419;
  color: #e0e0e0;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* HEADER */
.header {
  text-align: center;
  padding: 60px 20px 40px;
  border-bottom: 1px solid #2a3f5a;
  margin-bottom: 60px;
}

.header h1 {
  font-size: 3.5rem;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #4a9eff, #ffc107);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
}

.header .subtitle {
  font-size: 1.2rem;
  color: #aaa;
}

/* ERROR BANNER */
.error-banner {
  background: #4a2020;
  border-left: 4px solid #ff6b4a;
  padding: 15px 20px;
  margin: 20px 0;
  border-radius: 4px;
  color: #ffc0cb;
}

.error-banner code {
  background: #2a1010;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: "Monaco", "Courier New", monospace;
  font-size: 0.9rem;
}

/* SECTIONS */
.section {
  margin-bottom: 80px;
  padding: 40px;
  background: #1a2332;
  border: 1px solid #2a3f5a;
  border-radius: 6px;
}

.section h2 {
  font-size: 2rem;
  margin-bottom: 20px;
  color: #4a9eff;
  border-bottom: 2px solid #2a3f5a;
  padding-bottom: 15px;
}

.section h3 {
  font-size: 1.3rem;
  margin-bottom: 10px;
  color: #ffc107;
}

.section h4 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section p {
  margin-bottom: 15px;
  color: #c0c0c0;
}

.section ul {
  margin-left: 20px;
  margin-bottom: 15px;
}

.section li {
  margin-bottom: 8px;
  color: #c0c0c0;
}

/* HERO SECTION */
.hero-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
  align-items: start;
}

.hero-text {
  /* Left column */
}

.hero-diagram {
  /* Right column */
}

.diagram {
  width: 100%;
  height: 200px;
  background: #0f1419;
  border: 1px solid #2a3f5a;
  border-radius: 4px;
  padding: 10px;
}

.diagram-title {
  font-weight: bold;
  fill: #4a9eff;
}

/* COMPARISON TABLE */
.comparison-table {
  margin-top: 40px;
  overflow-x: auto;
}

.comparison-table table {
  width: 100%;
  border-collapse: collapse;
  background: #0f1419;
  border: 1px solid #2a3f5a;
}

.comparison-table thead {
  background: #2a3f5a;
}

.comparison-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: #4a9eff;
  border-bottom: 1px solid #3a5f7a;
}

.comparison-table td {
  padding: 12px;
  border-bottom: 1px solid #2a3f5a;
  color: #c0c0c0;
}

.comparison-table tr:hover {
  background: #1a2f42;
}

/* CELLS SECTION */
.cells-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 30px;
  margin-bottom: 30px;
}

.cell-widget {
  background: #0f1419;
  border: 1px solid #2a3f5a;
  border-radius: 6px;
  padding: 20px;
  transition: border-color 0.3s;
}

.cell-widget:hover {
  border-color: #4a9eff;
}

.cell-widget h3 {
  margin-bottom: 15px;
}

.cell-info {
  background: #1a2f42;
  padding: 12px;
  border-radius: 4px;
  margin-bottom: 15px;
  font-size: 0.95rem;
}

.cell-info p {
  margin-bottom: 6px;
}

.truth-table {
  margin-bottom: 15px;
}

.truth-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.truth-table th,
.truth-table td {
  padding: 8px;
  border: 1px solid #2a3f5a;
  text-align: center;
  background: #0f1419;
}

.truth-table th {
  background: #2a3f5a;
  color: #4a9eff;
  font-weight: 600;
}

.truth-table tr.highlight {
  background: #1a2f42;
}

.symbol-and-code {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 15px;
}

.cell-symbol {
  width: 100%;
  height: 150px;
  background: #0f1419;
  border: 1px solid #2a3f5a;
  border-radius: 4px;
}

.verilog-snippet {
  background: #0f1419;
  border: 1px solid #2a3f5a;
  border-radius: 4px;
  padding: 12px;
  overflow-x: auto;
}

.verilog-snippet pre {
  font-family: "Monaco", "Courier New", monospace;
  font-size: 0.8rem;
  color: #aaa;
  line-height: 1.4;
  margin: 0;
}

.verilog-snippet code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.cell-control {
  background: #1a2f42;
  padding: 12px;
  border-radius: 4px;
  font-size: 0.9rem;
}

.cell-control label {
  display: flex;
  align-items: center;
  cursor: pointer;
  margin-bottom: 10px;
}

.cell-control input[type="checkbox"] {
  margin-right: 8px;
  cursor: pointer;
  width: 18px;
  height: 18px;
}

.bl-output {
  color: #ffc107;
  font-weight: 600;
  margin: 8px 0 0 0;
}

/* EXPLORER SECTION */
.explorer-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 30px;
}

.control-group {
  display: flex;
  flex-direction: column;
}

.control-group label {
  margin-bottom: 8px;
  color: #aaa;
  font-weight: 600;
  font-size: 0.9rem;
}

.control-group select {
  padding: 8px 12px;
  background: #0f1419;
  color: #e0e0e0;
  border: 1px solid #2a3f5a;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
}

.control-group select:focus {
  outline: none;
  border-color: #4a9eff;
  box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.1);
}

.explorer-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 30px;
}

.summary-chip {
  background: #0f1419;
  border: 1px solid #2a3f5a;
  padding: 15px;
  border-radius: 4px;
  text-align: center;
  font-weight: 600;
  color: #4a9eff;
}

.table-wrapper {
  overflow-x: auto;
  margin-bottom: 30px;
}

.cells-table {
  width: 100%;
  border-collapse: collapse;
  background: #0f1419;
  border: 1px solid #2a3f5a;
  font-size: 0.9rem;
}

.cells-table thead {
  background: #2a3f5a;
  position: sticky;
  top: 0;
}

.cells-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: #4a9eff;
  border-bottom: 1px solid #3a5f7a;
  white-space: nowrap;
}

.cells-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #2a3f5a;
  color: #c0c0c0;
}

.cells-table tr:hover {
  background: #1a2f42;
}

.leakage-chart {
  background: #0f1419;
  border: 1px solid #2a3f5a;
  padding: 20px;
  border-radius: 4px;
  margin-top: 30px;
}

.leakage-chart h4 {
  margin-bottom: 20px;
}

#leakageChartSvg {
  width: 100%;
  height: auto;
  max-height: 200px;
}

/* VERILOG BROWSER */
.verilog-controls {
  margin-bottom: 20px;
}

.verilog-controls label {
  margin-right: 10px;
  color: #aaa;
  font-weight: 600;
}

.verilog-controls select {
  padding: 8px 12px;
  background: #0f1419;
  color: #e0e0e0;
  border: 1px solid #2a3f5a;
  border-radius: 4px;
  cursor: pointer;
}

.verilog-browser {
  background: #0f1419;
  border: 1px solid #2a3f5a;
  border-radius: 4px;
  padding: 20px;
  max-height: 600px;
  overflow-y: auto;
}

.module-list {
  font-family: "Monaco", "Courier New", monospace;
  font-size: 0.9rem;
}

.module {
  background: #1a2f42;
  border: 1px solid #2a3f5a;
  margin-bottom: 10px;
  border-radius: 4px;
  overflow: hidden;
}

.module-header {
  background: #2a3f5a;
  padding: 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: #4a9eff;
  user-select: none;
}

.module-header:hover {
  background: #3a5f7a;
}

.module-toggle {
  font-size: 1.2rem;
  transition: transform 0.2s;
}

.module.expanded .module-toggle {
  transform: rotate(90deg);
}

.module-body {
  display: none;
  padding: 12px;
  border-top: 1px solid #2a3f5a;
}

.module.expanded .module-body {
  display: block;
}

.module-body pre {
  margin: 0;
  color: #aaa;
  font-size: 0.85rem;
  line-height: 1.4;
  overflow-x: auto;
}

/* LAYOUT VIEWER */
.layout-controls {
  margin-bottom: 20px;
}

.layout-controls label {
  margin-right: 10px;
  color: #aaa;
  font-weight: 600;
}

.layout-controls select {
  padding: 8px 12px;
  background: #0f1419;
  color: #e0e0e0;
  border: 1px solid #2a3f5a;
  border-radius: 4px;
  cursor: pointer;
}

.layout-viewer {
  background: #0f1419;
  border: 1px solid #2a3f5a;
  border-radius: 4px;
  padding: 20px;
  margin-bottom: 20px;
  min-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#layoutSvg {
  width: 100%;
  height: auto;
  max-width: 100%;
}

.layout-legend {
  display: flex;
  gap: 30px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: #aaa;
}

.legend-color {
  width: 20px;
  height: 20px;
  border-radius: 2px;
  display: block;
}

/* EXAMPLE SECTION */
.example-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 30px;
}

.weight-map {
  background: #0f1419;
  border: 1px solid #2a3f5a;
  padding: 20px;
  border-radius: 4px;
}

.weight-display {
  font-family: "Monaco", "Courier New", monospace;
  font-size: 1.2rem;
  line-height: 1.8;
  color: #aaa;
  margin: 15px 0;
  text-align: center;
  letter-spacing: 2px;
}

.weight-map-info {
  font-size: 0.9rem;
  color: #aaa;
  margin-top: 15px;
}

.example-stats {
  background: #0f1419;
  border: 1px solid #2a3f5a;
  padding: 20px;
  border-radius: 4px;
}

.summary-text {
  font-size: 0.95rem;
  line-height: 1.8;
  color: #c0c0c0;
}

.summary-text div {
  margin-bottom: 12px;
  padding: 10px;
  background: #1a2f42;
  border-left: 3px solid #4a9eff;
  border-radius: 2px;
}

/* FLOW SECTION */
.flow-diagram {
  width: 100%;
  height: auto;
}

/* FOOTER */
.footer {
  text-align: center;
  padding: 40px 20px;
  border-top: 1px solid #2a3f5a;
  color: #666;
  margin-top: 60px;
}

.footer a {
  color: #4a9eff;
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

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

  .header .subtitle {
    font-size: 1rem;
  }

  .section {
    padding: 20px;
    margin-bottom: 40px;
  }

  .section h2 {
    font-size: 1.5rem;
  }

  .hero-content,
  .example-content,
  .symbol-and-code {
    grid-template-columns: 1fr;
    gap: 20px;
  }

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

  .comparison-table table,
  .cells-table {
    font-size: 0.85rem;
  }

  .comparison-table th,
  .comparison-table td,
  .cells-table th,
  .cells-table td {
    padding: 8px;
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #0f1419;
}

::-webkit-scrollbar-thumb {
  background: #2a3f5a;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3a5f7a;
}
