* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, Arial;
  background: radial-gradient(circle at top, #151515, #0a0a0a 60%);
  color: #eaeaea;
  line-height: 1.6;
}

body.project-detail {
  line-height: 1.7;
}

a {
  color: inherit;
  text-decoration: none;
}

.wrap {
  max-width: 1120px;
  margin: auto;
  padding: 0 20px;
}

.project-detail .wrap {
  max-width: 950px;
  width: 100%;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0;
}

.project-detail header {
  border-bottom: 1px solid #1a1a1a;
}

nav a {
  margin-left: 18px;
  color: #9a9a9a;
  font-size: 14px;
}

nav a:hover,
nav a.active {
  color: #fff;
}

.hero {
  padding: 64px 0 36px;
}

.project-detail .hero {
  padding: 22px 0 20px;
}

.badge,
.tag {
  display: inline-block;
  padding: 6px 10px;
  border: 1px solid #2a2a2a;
  border-radius: 999px;
  font-size: 12px;
  color: #aaa;
  background: rgba(255,255,255,0.02);
}

.badge {
  margin-bottom: 18px;
  backdrop-filter: blur(6px);
}

.tag {
  margin-bottom: 14px;
}

h1 {
  font-size: 46px;
  line-height: 1.16;
  margin: 0;
  letter-spacing: 0;
  max-width: 760px;
}

.project-detail h1 {
  font-size: 42px;
  line-height: 1.12;
  max-width: none;
}

.wave {
  display: inline-block;
  font-size: 0.82em;
  vertical-align: 0.04em;
}

.sub {
  color: #9a9a9a;
  max-width: 760px;
  margin-top: 14px;
}

.actions {
  margin-top: 26px;
  display: flex;
  gap: 12px;
}

.btn {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid #2a2a2a;
  font-size: 14px;
  transition: 0.2s;
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(8px);
}

.btn.primary {
  background: #fff;
  color: #000;
  border: none;
}

.btn:hover {
  transform: translateY(-1px);
}

.section {
  padding: 34px 0;
}

.project-detail section {
  margin-top: 36px;
}

.project-detail section:first-of-type {
  margin-top: 0;
}

h2 {
  font-size: 20px;
  color: #cfcfcf;
  margin-bottom: 18px;
  letter-spacing: 0.5px;
}

.project-detail h2 {
  font-size: 18px;
  color: #d0d0d0;
  margin: 0 0 10px;
  letter-spacing: 0;
}

h3 {
  color: #aaa;
  font-size: 14px;
  font-weight: 600;
  margin: 22px 0 8px;
}

p {
  color: #b0b0b0;
  margin: 0 0 16px;
}

p:last-child {
  margin-bottom: 0;
}

.home .grid,
.projects-index .grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.projects-index .grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.home .card,
.projects-index .card {
  display: block;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid #222;
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(10px);
  transition: 0.2s;
}

.home .card:hover,
.projects-index .card:hover {
  border-color: #333;
  transform: translateY(-2px);
}

.thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  border: 1px solid #222;
  background: #1f1f1f;
  object-fit: contain;
  display: block;
  margin-bottom: 14px;
  padding: 10px;
}

.title {
  font-weight: 600;
  margin-bottom: 6px;
}

.desc {
  color: #9a9a9a;
  font-size: 14px;
}

.projects-index .meta {
  color: #777;
  font-size: 13px;
  margin-top: 10px;
}

.tags,
.chips {
  display: flex;
  flex-wrap: wrap;
}

.tags {
  gap: 6px;
  margin-top: 12px;
}

.tags .tag {
  border-color: #292929;
  font-size: 12px;
  padding: 3px 8px;
  margin-bottom: 0;
}

.project-detail .meta {
  color: #888;
  font-size: 13px;
  margin-top: 6px;
  max-width: 760px;
}

.project-detail .card,
.media-block,
.document-block {
  background: rgba(255,255,255,0.03);
  border: 1px solid #222;
  border-radius: 12px;
  padding: 14px;
  margin-top: 14px;
}

.project-detail .card {
  margin-top: 10px;
}

.project-detail .card strong,
.media-block h3,
.document-block h3,
.project-photo h3 {
  margin-top: 0;
}

.chips {
  gap: 8px;
  margin-top: 10px;
}

.chip {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #2a2a2a;
  color: #aaa;
  background: rgba(255,255,255,0.02);
}

.media-block.primary,
.project-photo {
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

.project-photo {
  border: 1px solid #222;
  border-radius: 12px;
  background: rgba(255,255,255,0.018);
  padding: 14px;
  margin-top: 16px;
  max-width: 620px;
}

.project-photo img,
.media-block img {
  display: block;
  width: 100%;
  height: auto;
}

.media-block img {
  border-radius: 10px;
  border: 1px solid #222;
  background: #111;
}

.business-card-page .media-block img {
  background: #222;
}

.schematic-frame {
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.schematic-frame img {
  max-height: 280px;
  object-fit: contain;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.pdf-viewer {
  border-radius: 12px;
  border: 1px solid #222;
  background: #111;
  overflow: hidden;
}

.document-block .pdf-viewer {
  margin-top: 0;
}

.business-card-page .pdf-viewer,
.pdf-viewer.landscape {
  aspect-ratio: 624.24 / 447.84;
}

.pdf-viewer.board {
  aspect-ratio: 200.17 / 273.25;
  width: 100%;
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

.esp32-config-page .media-block.primary {
  max-width: 360px;
  background: #161616;
}

.esp32-config-page .media-block img {
  background: #161616 !important;
  border: 0 !important;
}

.esp32-config-page .pdf-viewer.board {
  max-width: 460px;
}

.pdf-viewer iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.document-link {
  display: inline-block;
  color: #aaa;
  font-size: 13px;
  margin-top: 10px;
}

.document-link:hover {
  color: #eaeaea;
}

.project-detail .grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 0;
}

.box {
  height: 200px;
  border-radius: 12px;
  border: 1px solid #222;
  background: linear-gradient(135deg, #1c1c1c, #0f0f0f);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 13px;
}

pre {
  background: #0f0f0f;
  border: 1px solid #222;
  padding: 14px;
  border-radius: 12px;
  overflow-x: auto;
  font-size: 12px;
  color: #dcdcdc;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 22px;
}

pre:last-child {
  margin-bottom: 0;
}

pre code.hljs {
  background: transparent;
  padding: 0;
}

footer {
  padding: 40px 0;
  display: flex;
  justify-content: space-between;
  color: #666;
  border-top: 1px solid #1a1a1a;
  margin-top: 40px;
  font-size: 13px;
}

.project-detail footer {
  border-top: 1px solid #1f1f1f;
  color: #777;
  gap: 16px;
  margin-top: 34px;
  padding: 24px 0 34px;
}

.project-detail footer a {
  color: #aaa;
}

.project-detail footer a:hover {
  color: #eaeaea;
}

@media (max-width: 780px) {
  header {
    align-items: flex-start;
    gap: 18px;
  }

  h1 {
    font-size: 38px;
  }

  .project-detail .wrap {
    padding: 0 18px;
  }

  .project-detail .hero {
    padding: 20px 0 18px;
  }

  .project-detail h1 {
    font-size: 34px;
  }

  .project-detail section {
    margin-top: 28px;
  }

  .project-photo,
  .project-detail .card,
  .media-block,
  .document-block {
    padding: 12px;
  }

  .pdf-viewer.board {
    max-width: 520px;
  }

  .project-detail footer {
    flex-direction: column;
    gap: 6px;
  }
}

@media (max-width: 560px) {
  .wrap {
    padding: 0 16px;
  }

  .project-detail {
    line-height: 1.6;
  }

  .project-detail .wrap {
    padding: 0 14px;
  }

  header {
    flex-direction: column;
  }

  nav a {
    margin-left: 0;
    margin-right: 16px;
  }

  .hero {
    padding: 44px 0 28px;
  }

  .project-detail .hero {
    padding: 18px 0 14px;
  }

  h1 {
    font-size: 32px;
  }

  .project-detail h1 {
    font-size: 29px;
  }

  .project-detail h2 {
    font-size: 17px;
  }

  .project-detail .meta {
    font-size: 12px;
    line-height: 1.5;
  }

  .actions {
    flex-wrap: wrap;
  }

  .chip {
    font-size: 11px;
    padding: 5px 8px;
  }

  .project-photo,
  .project-detail .card,
  .media-block,
  .document-block {
    border-radius: 10px;
    padding: 10px;
  }

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

  .schematic-frame {
    min-height: 0;
  }

  .pdf-viewer {
    border-radius: 10px;
  }

  .pdf-viewer.landscape,
  .business-card-page .pdf-viewer {
    aspect-ratio: 4 / 3;
    min-height: 260px;
  }

  .pdf-viewer.board {
    max-width: 360px;
  }

  .document-link {
    font-size: 12px;
  }

  pre {
    font-size: 11px;
    line-height: 1.55;
    padding: 12px;
  }

  footer {
    flex-direction: column;
    gap: 6px;
  }
}

@media (max-width: 380px) {
  .project-detail h1 {
    font-size: 26px;
  }

  .project-detail .tag {
    font-size: 11px;
  }

  pre {
    font-size: 10px;
  }
}
