/* ===== App-specific overrides ===== */
:root {
  --app-header-bg: #1a1d2e;
  --app-header-text: #e8eaf6;
  --app-header-height: 56px;
  --app-body-bg: #f4f6fb;
}

body.dark {
  --app-body-bg: #12141f;
}

.app-viewer-body {
  padding: 0;
}

/* ===== Views ===== */
.view {
  display: none;
  animation: fadeIn 0.3s ease;
}
.view.active {
  display: block;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Hero ===== */
.hero {
  background: linear-gradient(135deg, #2d3561 0%, #1a1d2e 100%);
  color: #fff;
  padding: 3rem 1.5rem 2.5rem;
  text-align: center;
}
.hero h1 {
  font-size: 2.2rem;
  margin: 0 0 0.5rem;
  letter-spacing: -0.5px;
}
.hero p {
  margin: 0 auto;
  max-width: 600px;
  opacity: 0.85;
  font-size: 1rem;
  line-height: 1.5;
}

/* ===== Project Grid ===== */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.project-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e0e4f0;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}
body.dark .project-card {
  background: #1c1f30;
  border-color: #2a2e42;
}
.project-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px rgba(45, 53, 97, 0.18);
}
.card-banner {
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  color: #fff;
}
.card-body {
  padding: 1.1rem 1.25rem 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.card-body h3 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  color: #1a1d2e;
}
body.dark .card-body h3 {
  color: #e8eaf6;
}
.card-difficulty {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 0.6rem;
}
.diff-beginner { background: #e3f6e3; color: #2e7d32; }
.diff-intermediate { background: #fff3d6; color: #b8860b; }
.diff-advanced { background: #fcdede; color: #c62828; }
body.dark .diff-beginner { background: #1e3320; color: #81c784; }
body.dark .diff-intermediate { background: #3d3415; color: #ffcc80; }
body.dark .diff-advanced { background: #3d1e1e; color: #ef9a9a; }

.card-body p {
  font-size: 0.88rem;
  line-height: 1.5;
  color: #555;
  margin: 0 0 0.8rem;
  flex: 1;
}
body.dark .card-body p { color: #aab; }

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.card-tags span {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: #eef0fa;
  color: #2d3561;
}
body.dark .card-tags span {
  background: #2a2e42;
  color: #9fa8da;
}
.card-saved-badge {
  position: absolute;
  margin: 0.5rem;
  background: #ffc107;
  color: #1a1d2e;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}
.project-card { position: relative; }

/* ===== Detail View ===== */
.detail-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}
.section-title {
  font-size: 1.5rem;
  color: #1a1d2e;
  margin: 0 0 1rem;
}
body.dark .section-title { color: #e8eaf6; }

.detail-header {
  margin-bottom: 1.5rem;
}
.detail-header h2 {
  font-size: 1.8rem;
  margin: 0 0 0.5rem;
  color: #1a1d2e;
}
body.dark .detail-header h2 { color: #e8eaf6; }

.detail-header .meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.detail-desc {
  font-size: 0.98rem;
  line-height: 1.6;
  color: #444;
  margin-bottom: 1.5rem;
}
body.dark .detail-desc { color: #bcc; }

.detail-section {
  background: #fff;
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  border: 1px solid #e0e4f0;
}
body.dark .detail-section {
  background: #1c1f30;
  border-color: #2a2e42;
}
.detail-section h3 {
  font-size: 1.1rem;
  margin: 0 0 0.8rem;
  color: #1a1d2e;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
body.dark .detail-section h3 { color: #e8eaf6; }

/* Component list */
.component-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.component-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #eef0fa;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #333;
}
body.dark .component-list li {
  border-color: #2a2e42;
  color: #ccd;
}
.component-list li:last-child { border-bottom: none; }
.component-list .qty {
  font-weight: 700;
  color: #2d3561;
}
body.dark .component-list .qty { color: #9fa8da; }

/* Wiring diagram */
.wiring-diagram {
  background: #fafbff;
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  border: 1px solid #e0e4f0;
}
body.dark .wiring-diagram {
  background: #161827;
  border-color: #2a2e42;
}
.wiring-diagram svg {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

.diagram-caption {
  font-size: 0.82rem;
  color: #777;
  text-align: center;
  margin-top: 0.6rem;
  font-style: italic;
}
body.dark .diagram-caption { color: #889; }

/* Steps */
.steps-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: step;
}
.steps-list li {
  padding: 0.6rem 0 0.6rem 2.5rem;
  position: relative;
  font-size: 0.9rem;
  line-height: 1.55;
  color: #333;
  border-bottom: 1px solid #eef0fa;
}
body.dark .steps-list li {
  border-color: #2a2e42;
  color: #ccd;
}
.steps-list li:last-child { border-bottom: none; }
.steps-list li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.5rem;
  width: 1.8rem;
  height: 1.8rem;
  background: #2d3561;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

/* Code block */
.code-block {
  background: #1a1d2e;
  color: #c5cae9;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}
.code-block .comment { color: #7986cb; }
.code-block .keyword { color: #ffcc80; }
.code-block .string { color: #a5d6a7; }

/* Save button */
.save-btn {
  background: #2d3561;
  color: #fff;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.save-btn:hover { background: #3d4571; }
.save-btn.saved {
  background: #ffc107;
  color: #1a1d2e;
}

/* Action button (theme) */
.action-btn {
  background: transparent;
  border: none;
  color: var(--app-header-text);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background 0.15s ease;
}
.action-btn:hover {
  background: rgba(255,255,255,0.12);
}

/* Saved list */
.saved-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.saved-item {
  background: #fff;
  border: 1px solid #e0e4f0;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}
body.dark .saved-item {
  background: #1c1f30;
  border-color: #2a2e42;
}
.saved-item:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.08); }
.saved-item h4 {
  margin: 0 0 0.2rem;
  font-size: 1rem;
  color: #1a1d2e;
}
body.dark .saved-item h4 { color: #e8eaf6; }
.saved-item p {
  margin: 0;
  font-size: 0.82rem;
  color: #777;
}
body.dark .saved-item p { color: #889; }
.saved-item .remove-btn {
  background: transparent;
  border: 1px solid #ddd;
  color: #c62828;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}
.saved-item .remove-btn:hover { background: #fcdede; }
body.dark .saved-item .remove-btn {
  border-color: #2a2e42;
}
body.dark .saved-item .remove-btn:hover { background: #3d1e1e; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #888;
}
.empty-state .icon { font-size: 3rem; margin-bottom: 0.5rem; }

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1a1d2e;
  color: #fff;
  padding: 0.7rem 1.4rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 2000;
  transition: transform 0.3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 600px) {
  .hero h1 { font-size: 1.6rem; }
  .detail-header h2 { font-size: 1.4rem; }
  .project-grid { padding: 1rem; }
}