* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

:root {
  --font-base: var(--font-custom, "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);
  --bg: #08090b;
  --bg-soft: #11131a;
  --text: #d8dfeb;
  --muted: #9ca9bd;
  --accent: #97d3ff;
  --line: #1d2634;
  --panel: rgba(10, 14, 20, 0.72);
  --error: #d9b2b2;
  --maxw: 900px;
  --radius-card: 14px;
  --radius-thumb: 10px;
  --radius-pill: 999px;
  --radius-panel: 16px;
}

body {
  font-family: var(--font-base);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent);
}

a:hover,
a:focus-visible {
  color: #c2e7ff;
}

img {
  max-width: 100%;
  display: block;
}

.site-wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.2rem;
  position: relative;
  z-index: 1;
}

.site-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 0 1rem;
}

.site-mark {
  color: var(--muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  justify-self: start;
}

.site-nav {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  justify-self: center;
}

.site-nav a {
  text-decoration: none;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

.site-nav a[aria-current="page"] {
  border-color: var(--line);
  background: rgba(151, 211, 255, 0.08);
}

.audio-cluster {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  justify-self: end;
}

#audio-toggle {
  width: 2.5rem;
  min-width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  justify-content: center;
  align-items: center;
  border-radius: 999px;
}

#audio-toggle .audio-icon {
  width: 1.45rem;
  height: 1.45rem;
  display: block;
}

#audio-toggle .audio-icon path {
  fill: none;
  stroke: #b8cce0;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.audio-hint {
  font-size: 0.7rem;
  color: var(--error);
}

.audio-status {
  display: inline-flex;
  align-items: center;
  width: 170px;
  height: 30px;
  justify-content: center;
  position: relative;
  overflow: visible;
}

.audio-wave-canvas {
  position: absolute;
  inset: 50% 0 auto 0;
  transform: translateY(-50%);
  width: 100%;
  height: 48px;
  display: block;
}

.audio-status[data-wave-state="flat"] .audio-wave-canvas {
  opacity: 0.7;
}

.home-audio-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(4, 7, 11, 0.58);
  backdrop-filter: blur(1.5px);
}

.home-reveal-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgb(7, 10, 16);
  overflow: hidden;
  transition: opacity 520ms ease, visibility 0ms linear 520ms;
  opacity: 1;
}

.home-reveal-fx {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  transition: opacity 700ms ease;
}

.home-reveal-fx canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.home-reveal-overlay.is-transitioning {
  background: #000;
}

.home-reveal-overlay.is-transitioning .home-reveal-fx {
  opacity: 1;
}

.home-reveal-overlay.is-transitioning .home-reveal-panel {
  opacity: 0;
  transform: scale(0.97);
}

.home-reveal-overlay.is-leaving {
  opacity: 0;
  visibility: hidden;
}

.home-reveal-panel {
  width: min(720px, calc(100vw - 2rem));
  background: rgba(7, 10, 16, 0.72);
  border: 1px solid #1c2735;
  border-radius: var(--radius-panel);
  padding: clamp(1.2rem, 4vw, 2rem);
  text-align: center;
  display: grid;
  justify-items: center;
  position: relative;
  z-index: 2;
  transition: opacity 620ms ease, transform 620ms ease;
}

.home-audio-panel {
  min-width: min(92vw, 320px);
  text-align: center;
}

.home-audio-title {
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 0.9rem;
}

.home-audio-actions {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
}

main {
  padding: 1.5rem 0 2rem;
}

h1,
h2,
h3 {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  line-height: 1.25;
}

h1 {
  font-size: clamp(1.3rem, 3vw, 2rem);
  margin: 0 0 0.7rem;
}

h2 {
  font-size: 1rem;
  margin: 0 0 0.6rem;
}

p {
  margin: 0 0 0.8rem;
}

.lede {
  color: var(--muted);
  max-width: 62ch;
}

.stack {
  display: grid;
  gap: 1rem;
}

.cards-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.card,
.category-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 1rem;
  backdrop-filter: blur(1px);
}

.card-subtitle {
  color: var(--muted);
}

.card-thumb,
.project-thumb {
  border-radius: var(--radius-thumb);
  border: 1px solid #223044;
  margin-bottom: 0.8rem;
  opacity: 0.9;
}

.tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.tag {
  border: 1px solid #233149;
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  color: #b4c1d6;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.hub-card {
  position: relative;
  min-height: clamp(220px, 36vh, 300px);
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto 1fr;
  align-items: start;
  padding-bottom: 3.2rem;
}

.hub-card h1,
.hub-card > .lede:first-of-type,
.hub-card .card-actions {
  grid-column: 1;
}

.hub-card .card-actions {
  flex-direction: column;
  align-items: flex-start;
}

.hub-card .card-actions .btn {
  width: 9.25rem;
  justify-content: center;
}

.hub-prompt {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  text-align: right;
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  border: 1px solid #264463;
  background: rgba(151, 211, 255, 0.08);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.btn-secondary {
  background: rgba(148, 155, 173, 0.1);
  border-color: #2a3345;
}

.loading,
.note-date {
  color: var(--muted);
  font-size: 0.9rem;
}

.note-meta-row {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.7rem;
}

.note-meta-row .note-date {
  margin: 0;
}

.note-back {
  color: var(--muted);
  text-decoration: none;
  line-height: 1;
  font-size: 1.15rem;
  padding: 0 0.1rem;
}

.note-back:hover,
.note-back:focus-visible {
  color: var(--accent);
}

.notes-list,
.link-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.notes-list li {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 0.8rem;
  border-top: 1px solid var(--line);
  padding: 0.65rem 0;
}

.link-list li {
  border-top: 1px solid var(--line);
  padding: 0.65rem 0;
}

.link-list a {
  font-weight: 600;
  text-decoration: none;
}

.error-state {
  border: 1px solid #3d2d2d;
  background: rgba(43, 26, 26, 0.35);
  border-radius: var(--radius-thumb);
  padding: 1rem;
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
}

.gateway {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.2rem;
}

.gateway-panel {
  width: min(720px, 100%);
  background: rgba(7, 10, 16, 0.72);
  border: 1px solid #1c2735;
  border-radius: var(--radius-panel);
  padding: clamp(1.2rem, 4vw, 2rem);
  text-align: center;
  display: grid;
  justify-items: center;
}

.gateway-title {
  margin-bottom: 0.8rem;
}

.gateway-actions {
  display: flex;
  justify-content: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.gateway-rules-title {
  margin: 0.4rem 0 0.4rem;
  text-align: center;
}

.gateway-rules {
  margin: 0 auto;
  width: min(560px, calc(100% - 1.5rem));
  padding: 0;
  list-style: none;
  color: var(--muted);
  text-align: left;
}

.gateway-rules li {
  margin: 0.15rem 0;
}

.scan-beam {
  margin: 1rem auto;
  width: 100%;
  max-width: 520px;
  height: 8px;
  border: 1px solid #1c2735;
  border-radius: var(--radius-pill);
  position: relative;
  overflow: hidden;
}

.scan-beam::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(151, 211, 255, 0.65), transparent);
  transform: translateX(-100%);
  animation: scanLine 8s linear infinite;
}

@keyframes scanLine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@media (max-width: 640px) {
  .site-header {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.8rem;
  }

  .site-mark,
  .site-nav,
  .audio-cluster {
    justify-self: auto;
  }

  .site-nav {
    width: 100%;
    justify-content: space-between;
  }

  .notes-list li {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .hub-card {
    position: static;
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    padding-bottom: 1rem;
  }

  .hub-prompt {
    position: static;
    grid-column: 1;
    grid-row: auto;
    justify-self: start;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-reveal-overlay {
    transition: none !important;
  }

  .home-reveal-fx {
    display: none !important;
  }

  .home-reveal-panel {
    transition: none !important;
  }
}

body.ui-flat {
  --radius-card: 0;
  --radius-thumb: 0;
  --radius-pill: 0;
  --radius-panel: 0;
}

body.ui-flat .card,
body.ui-flat .category-block,
body.ui-flat .gateway-panel,
body.ui-flat .btn,
body.ui-flat .site-nav a,
body.ui-flat .tag,
body.ui-flat .card-thumb,
body.ui-flat .project-thumb,
body.ui-flat .error-state,
body.ui-flat .scan-beam {
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

body.ui-flat .card,
body.ui-flat .category-block,
body.ui-flat .gateway-panel {
  background: transparent;
  backdrop-filter: none;
}
