:root {
  color-scheme: light;
  --bg: #f7f9f8;
  --surface: #ffffff;
  --surface-2: #eef4f1;
  --text: #172321;
  --muted: #60706d;
  --line: #d8e3df;
  --brand: #0f3d3e;
  --brand-2: #247a62;
  --accent: #d89822;
  --danger: #a64028;
  --shadow: 0 18px 40px rgba(15, 61, 62, 0.12);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101614;
  --surface: #17201d;
  --surface-2: #1f2b27;
  --text: #edf4f1;
  --muted: #a8bbb5;
  --line: #31423d;
  --brand: #6ed1b3;
  --brand-2: #88c7ff;
  --accent: #f1bc57;
  --danger: #ff9278;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Aptos, Inter, Segoe UI, system-ui, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.text-button,
.link-grid a,
.document-card,
.image-card,
.notebook-card {
  border-radius: 8px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "brand nav menu theme";
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding: 12px clamp(16px, 3vw, 40px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(18px);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.topbar.header-hidden {
  transform: translateY(calc(-100% - 8px));
}

.brand {
  grid-area: brand;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid var(--brand);
  color: var(--brand);
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand small {
  display: block;
  white-space: nowrap;
}

.brand small {
  color: var(--muted);
}

.nav-links {
  grid-area: nav;
  justify-self: center;
  display: flex;
  gap: clamp(8px, 2vw, 24px);
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.95rem;
}

.nav-links a {
  text-decoration: none;
}

.nav-links a:hover {
  color: var(--brand);
}

.menu-toggle {
  grid-area: menu;
  display: none;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
}

.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 2px 0;
  background: currentColor;
}

#themeToggle {
  grid-area: theme;
}

.icon-button,
button,
.text-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.text-button:hover {
  border-color: var(--brand);
  color: var(--brand);
}

@media (prefers-reduced-motion: reduce) {
  .topbar {
    transition: none;
  }
}

main {
  display: grid;
  gap: clamp(24px, 4vw, 48px);
}

.overview-band,
.media-band,
.notebook-band,
.about-band,
.ai-contact-grid {
  padding: clamp(28px, 5vw, 56px) clamp(16px, 4vw, 56px);
}

.overview-band {
  min-height: 420px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: end;
  gap: 28px;
  background:
    linear-gradient(110deg, rgba(15, 61, 62, 0.9), rgba(36, 122, 98, 0.72)),
    url("../assets/hero-background.png") center right / min(56vw, 680px) auto no-repeat;
  color: #fff;
}

.overview-copy {
  max-width: 880px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.overview-band .eyebrow {
  color: #ffd783;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 18px;
  max-width: 780px;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(1.35rem, 2vw, 2rem);
  line-height: 1.15;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 6px;
  font-size: 1.05rem;
}

.lead {
  max-width: 760px;
  color: rgba(255, 255, 255, 0.88);
  font-size: clamp(1rem, 1.8vw, 1.22rem);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  max-width: 920px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
}

.summary-strip div {
  padding: 16px;
  border-right: 1px solid rgba(255, 255, 255, 0.22);
}

.summary-strip div:last-child {
  border-right: 0;
}

.summary-strip strong,
.summary-strip span {
  display: block;
}

.summary-strip strong {
  font-size: 1.35rem;
}

.summary-strip span {
  color: rgba(255, 255, 255, 0.78);
}

.workbench {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1680px);
  justify-content: center;
  gap: 24px;
  padding: 0 clamp(16px, 4vw, 56px);
}

.side-panel {
  position: sticky;
  top: 96px;
  align-self: start;
  display: grid;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-block {
  display: grid;
  gap: 8px;
}

.panel-block p {
  color: var(--muted);
  margin-bottom: 0;
}

label {
  color: var(--muted);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 11px 12px;
  border-radius: 6px;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.search-form button {
  min-height: 46px;
}

textarea {
  resize: vertical;
}

.stat-list {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.stat-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  color: var(--muted);
}

.stat-list strong {
  color: var(--text);
}

.content-panel {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.document-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 14px;
}

.document-card,
.image-card,
.notebook-card,
.ai-panel,
.contact-panel {
  border: 1px solid var(--line);
  background: var(--surface);
}

.document-card,
.notebook-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  overflow-wrap: anywhere;
}

.document-card p,
.image-card p,
.notebook-card p {
  color: var(--muted);
  margin-bottom: 0;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.card-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  color: var(--brand);
  text-decoration: none;
  border-radius: 6px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 14px;
}

.image-card {
  overflow: hidden;
  overflow-wrap: anywhere;
}

.image-card button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--surface-2);
}

.image-card figcaption {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.tag {
  display: inline-flex;
  width: fit-content;
  padding: 4px 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  font-size: 0.78rem;
}

.media-band,
.notebook-band,
.about-band {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.notebook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 12px;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 12px;
}

.link-grid a {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.link-grid a:hover {
  border-color: var(--brand);
}

.link-grid span {
  color: var(--muted);
}

.ai-contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 22px;
}

.ai-panel,
.contact-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.key-row,
.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.chat-log {
  min-height: 260px;
  max-height: 420px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.message {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.message.user {
  justify-self: end;
  background: color-mix(in srgb, var(--brand) 16%, var(--surface));
}

.message.assistant {
  justify-self: start;
}

.contact-form {
  display: grid;
  gap: 12px;
}

.about-band {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 24px;
  align-items: start;
}

.compact a {
  min-height: 58px;
  align-items: center;
}

.asset-dialog {
  width: min(1100px, calc(100vw - 32px));
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 16px;
}

.asset-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.dialog-close {
  float: right;
  margin-bottom: 10px;
}

.asset-dialog img {
  display: block;
  width: 100%;
  max-height: 76vh;
  object-fit: contain;
  background: var(--surface-2);
}

#dialogCaption {
  margin: 12px 0 0;
  color: var(--muted);
}

@media (max-width: 960px) {
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand theme"
      "nav nav";
  }

  .nav-links {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .overview-band {
    background:
      linear-gradient(110deg, rgba(15, 61, 62, 0.93), rgba(36, 122, 98, 0.78)),
      url("../assets/hero-background.png") top right / 420px auto no-repeat;
  }

  .workbench,
  .ai-contact-grid,
  .about-band {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "brand menu theme"
      "nav nav nav";
    gap: 10px;
    min-height: 64px;
  }

  .menu-toggle {
    display: grid;
  }

  .nav-links {
    justify-self: stretch;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    font-size: 0.93rem;
    transition: max-height 180ms ease, opacity 180ms ease;
  }

  .nav-links.nav-open {
    max-height: 320px;
    opacity: 1;
    padding-top: 4px;
  }

  .nav-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    border-radius: 6px;
    text-align: center;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 620px) {
  .overview-band {
    background: linear-gradient(145deg, rgba(15, 61, 62, 0.98), rgba(36, 122, 98, 0.9));
  }

  .brand small {
    white-space: normal;
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }

  .summary-strip div {
    border-bottom: 1px solid rgba(255, 255, 255, 0.22);
  }

  .section-head,
  .key-row,
  .chat-form {
    grid-template-columns: 1fr;
    display: grid;
    align-items: start;
  }

  .message {
    max-width: 100%;
  }

  .gallery-grid {
    grid-template-columns: minmax(0, 1fr);
    max-width: 360px;
    margin-inline: auto;
    width: 100%;
  }
}

@media (max-width: 360px) {
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand brand"
      "menu theme"
      "nav nav";
    gap: 10px;
    padding-inline: 12px;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
  }

  .brand strong {
    white-space: normal;
  }

  .nav-links {
    grid-template-columns: 1fr;
    gap: 8px;
    font-size: 0.88rem;
  }

  .menu-toggle,
  .icon-button {
    justify-self: start;
  }

  .overview-band,
  .media-band,
  .notebook-band,
  .about-band,
  .ai-contact-grid,
  .workbench {
    padding-inline: 12px;
  }

  .side-panel,
  .ai-panel,
  .contact-panel {
    padding: 14px;
  }

  .search-form {
    grid-template-columns: 1fr;
  }

  .search-form button {
    width: 100%;
  }

  .section-head {
    gap: 10px;
  }
}
