@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #64727d;
  --line: #d9e1e5;
  --paper: #f5f7f6;
  --panel: #ffffff;
  --accent: #e66b45;
  --accent-soft: #fff0e9;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  margin: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 220px;
  height: 100vh;
  overflow: hidden;
}

.navigation-dock,
.ads-dock {
  background: #edf2f0;
  height: 100vh;
  overflow-y: auto;
  padding: 32px 20px;
}

.navigation-dock {
  border-right: 1px solid var(--line);
}

.ads-dock {
  border-left: 1px solid var(--line);
}

.dock-heading {
  padding: 0 8px 26px;
}

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

h1,
h2,
h3 {
  font-family: 'Space Grotesk', sans-serif;
}

h1 {
  font-size: 1.45rem;
  margin: 0;
}

.sr-only {
  border: 0;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.search-wrap {
  margin: 0 0 18px;
  padding: 0 8px;
}

.item-search {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font: 500 0.92rem 'DM Sans', sans-serif;
  padding: 10px 12px;
  width: 100%;
}

.item-search:focus {
  border-color: rgba(230, 107, 69, 0.6);
  outline: 2px solid rgba(230, 107, 69, 0.15);
}

.item-navigation {
  display: grid;
  gap: 20px;
}

.navigation-category {
  display: grid;
  gap: 4px;
}

.category-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: #7b8985;
  cursor: pointer;
  display: flex;
  font: 700 0.68rem 'Space Grotesk', sans-serif;
  justify-content: space-between;
  letter-spacing: 0.1em;
  padding: 0 8px 6px;
  text-align: left;
  text-transform: uppercase;
}

.category-chevron {
  color: var(--muted);
  display: inline-block;
  font-size: 0.9rem;
  transition: transform 160ms ease;
}

.category-toggle[aria-expanded='false'] .category-chevron {
  transform: rotate(-90deg);
}

.category-items {
  display: grid;
  gap: 2px;
}

.navigation-row {
  align-items: center;
  display: flex;
}

.category-items[hidden] {
  display: none;
}

.navigation-empty {
  color: var(--muted);
  font: 500 0.92rem 'DM Sans', sans-serif;
  margin: 8px 0 0;
  padding: 0 8px;
}

.item-navigation button {
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font: 600 0.92rem 'DM Sans', sans-serif;
  padding: 12px 14px;
  text-align: left;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.item-navigation button:hover {
  background: #e3eae7;
  color: var(--ink);
  transform: translateX(2px);
}

.item-navigation button[aria-current='true'] {
  background: var(--accent-soft);
  color: #b74727;
}

.navigation-row .item-button {
  flex: 1;
  min-width: 0;
}

.favorite-button {
  background: transparent;
  border: 0;
  color: #a6b1ad;
  cursor: pointer;
  line-height: 1;
  padding: 8px;
  transition: color 160ms ease, transform 160ms ease;
}

.favorite-button:hover,
.favorite-button[aria-pressed='true'] {
  color: var(--accent);
}

.favorite-button:hover {
  transform: scale(1.12);
}

.item-heading {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.item-heading h2 {
  min-width: 0;
}

.card-favorite {
  font-size: 1.8rem;
  padding: 2px 0 0;
}

.content-area {
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 48px clamp(22px, 5vw, 80px);
}

#item-list {
  margin: 0 auto;
  max-width: 920px;
}

.item-card {
  animation: appear 240ms ease-out;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(23, 33, 43, 0.06);
  min-width: 0;
  padding: clamp(22px, 4vw, 42px);
}

.item-card h2 {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  margin: 0 0 8px;
}

.item-card h2 {
  margin-top: 0;
}

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

.item-card > p:first-of-type {
  font-size: 1.05rem;
  margin: 0 0 12px;
}

.item-card a {
  color: var(--accent);
  font-weight: 700;
}

.drawing-area {
  margin-top: 18px;
}

.function-tables {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.function-tables:has(> .function-table:only-child) {
  grid-template-columns: 1fr;
}

.item-canvas {
  display: block;
  width: 100%;
  height: 480px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.ads-placeholder {
  align-items: center;
  border: 1px dashed #bdc9c6;
  color: #899692;
  display: flex;
  font-size: 0.68rem;
  justify-content: center;
  letter-spacing: 0.12em;
  min-height: 250px;
  text-transform: uppercase;
}

.function-table {
  margin-top: 18px;
}

.function-tables .function-table {
  min-width: 0;
}

.function-table h3 {
  margin: 0 0 8px;
  color: #374151;
  font-size: 1rem;
  text-align: center;
}

.table-scroll {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
}

.function-table table {
  border-collapse: collapse;
  color: #1f2937;
  font-size: 0.8rem;
  min-width: 100%;
  white-space: nowrap;
  width: max-content;
}

.function-table th,
.function-table td {
  border: 1px solid #cbd5e1;
  padding: 6px 8px;
  text-align: left;
}

.function-table th {
  background: #e2e8f0;
  font-weight: 600;
}

.function-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

@keyframes appear {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .ads-dock {
    display: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
    height: auto;
    overflow: visible;
  }

  .navigation-dock {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    height: auto;
    padding: 20px;
  }

  .dock-heading {
    padding-bottom: 16px;
  }

  .item-navigation {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .item-navigation button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .content-area {
    height: auto;
    overflow: visible;
    padding: 24px 14px;
  }

  .function-tables {
    grid-template-columns: 1fr;
  }
}