:root {
  color-scheme: light;
  --ink: #18211f;
  --muted: #65736f;
  --paper: #f6f8f5;
  --panel: #ffffff;
  --line: #e2e8e3;
  --green: #1f6f5b;
  --green-soft: #e8f3ee;
  --blue: #275f91;
  --amber: #a86116;
  --shadow: 0 18px 50px rgba(31, 50, 44, .10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, #edf5f1 0, var(--paper) 360px),
    var(--paper);
  color: var(--ink);
}

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

.app-header {
  width: min(1180px, calc(100% - 32px));
  min-height: 230px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 26px;
  align-items: center;
  padding: 34px 0 24px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin-bottom: 16px;
  border: 1px solid rgba(31, 111, 91, .14);
  border-radius: 999px;
  padding: 5px 13px 5px 6px;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 10px 26px rgba(31, 50, 44, .08);
  color: var(--ink);
  font-size: .92rem;
  font-weight: 900;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: block;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: .78rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .08em;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.2rem, 6vw, 5rem);
  line-height: .95;
  letter-spacing: 0;
}

.intro {
  max-width: 620px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.55;
}

.team-credit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  margin-bottom: 0;
  border: 1px solid rgba(31, 111, 91, .18);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 255, 255, .7);
  color: var(--muted);
  font-size: .88rem;
  font-weight: 750;
}

.team-credit strong {
  color: var(--green);
}

.hero-visual {
  position: relative;
  width: 190px;
  height: 190px;
  justify-self: end;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.flask {
  position: absolute;
  inset: 58px 58px 44px;
  border: 3px solid var(--green);
  border-top: 0;
  border-radius: 0 0 24px 24px;
  background: linear-gradient(to top, rgba(250, 187, 79, .72) 0 44%, rgba(31, 111, 91, .08) 44%);
  transform: rotate(-6deg);
}

.flask:before {
  content: "";
  position: absolute;
  left: 50%;
  top: -42px;
  width: 36px;
  height: 44px;
  border: 3px solid var(--green);
  border-bottom: 0;
  transform: translateX(-50%);
}

.flask span {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
}

.flask span:nth-child(1) { left: 15px; top: 44px; }
.flask span:nth-child(2) { right: 16px; top: 58px; width: 9px; height: 9px; }
.flask span:nth-child(3) { left: 42px; top: 66px; width: 7px; height: 7px; }

.orbit {
  position: absolute;
  inset: 25px;
  border: 1px solid rgba(31, 111, 91, .18);
  border-radius: 50%;
}

.orbit-two {
  transform: rotate(62deg);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 48px;
}

.site-footer {
  width: min(1180px, calc(100% - 32px));
  min-height: 70px;
  margin: -24px auto 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .9rem;
}

.site-footer span {
  font-weight: 850;
  color: var(--ink);
}

.site-footer strong {
  color: var(--green);
}

.toolbar {
  position: sticky;
  top: 10px;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 14px;
  align-items: end;
  padding: 14px;
  border: 1px solid rgba(226, 232, 227, .92);
  border-radius: 8px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 12px 35px rgba(31, 50, 44, .08);
  backdrop-filter: blur(14px);
}

label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cfdbd5;
  border-radius: 8px;
  padding: 0 14px;
  background: #fbfdfb;
  color: var(--ink);
  font: inherit;
  outline: 0;
}

input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(31, 111, 91, .10);
}

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

.subject-filters {
  grid-column: 1 / -1;
  display: none;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.subject-filters.is-visible {
  display: flex;
}

button,
.video-link {
  min-height: 42px;
  border: 1px solid #cfdbd5;
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

button:hover,
.video-link:hover {
  border-color: var(--green);
  transform: translateY(-1px);
}

.filter.is-active,
.subject-filter.is-active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  box-shadow: 0 8px 20px rgba(31, 111, 91, .18);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 18px 0;
}

.summary-grid article,
.catalog-panel,
.card,
.detail {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.summary-grid article {
  border-radius: 8px;
  padding: 16px 18px;
}

.summary-grid strong {
  display: block;
  font-size: 1.65rem;
  line-height: 1;
}

.summary-grid span {
  color: var(--muted);
  font-size: .88rem;
}

.layout {
  display: block;
}

.catalog-panel {
  border-radius: 8px;
  padding: 18px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: 1.18rem;
}

#resultCount {
  color: var(--muted);
  font-weight: 800;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.empty-state {
  grid-column: 1 / -1;
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px dashed #c9d7d1;
  border-radius: 8px;
  color: var(--muted);
  background: #fbfdfb;
  font-weight: 800;
  text-align: center;
  padding: 24px;
}

.card {
  display: grid;
  gap: 12px;
  border-radius: 8px;
  padding: 16px;
  box-shadow: none;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: rgba(31, 111, 91, .32);
  box-shadow: 0 14px 35px rgba(31, 50, 44, .10);
}

.card h3 {
  margin-bottom: 0;
  font-size: .98rem;
  line-height: 1.38;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--green-soft);
  color: var(--green);
  font-size: .72rem;
  font-weight: 850;
}

.pill.subject {
  background: #edf4fb;
  color: var(--blue);
}

.materials {
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 0;
  font-size: .9rem;
}

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

.card-actions button,
.card-actions .video-link {
  min-height: 38px;
  font-size: .88rem;
  flex: 1 1 110px;
}

dialog {
  width: min(940px, calc(100% - 24px));
  border: 0;
  padding: 0;
  border-radius: 8px;
  background: transparent;
}

dialog::backdrop {
  background: rgba(14, 24, 22, .56);
  backdrop-filter: blur(4px);
}

.detail {
  position: relative;
  max-height: min(88vh, 920px);
  overflow: auto;
  border-radius: 8px;
  padding: 28px;
}

.close-button {
  position: sticky;
  top: 0;
  float: right;
  width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.2rem;
  background: #f7faf8;
}

.detail h2 {
  max-width: 760px;
  padding-right: 46px;
  margin: 8px 0 10px;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.16;
}

.detail > .materials {
  margin-bottom: 12px;
}

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

.note {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background:
    linear-gradient(#fff 31px, #edf1ec 32px),
    #fff;
  background-size: 100% 32px;
}

.note h3 {
  display: inline-block;
  margin-bottom: 10px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: .83rem;
  text-decoration: none;
}

.note p,
.note li {
  color: #46534f;
  line-height: 1.58;
}

.note p:last-child,
.note table:last-child,
.note ol,
.note ul {
  margin-bottom: 0;
}

.note ol,
.note ul {
  padding-left: 20px;
}

.manual-table {
  width: 100%;
  border-collapse: collapse;
  color: #46534f;
  font-size: .9rem;
  background: #fff;
}

.manual-table th,
.manual-table td {
  border: 1px solid var(--line);
  padding: 9px;
  text-align: left;
  vertical-align: top;
}

.manual-table th {
  color: var(--ink);
  background: #f2f7f4;
}

.video-missing {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  border: 1px dashed #c9b18f;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--amber);
  font-size: .88rem;
  font-weight: 800;
  background: #fff8ec;
}

.video-title {
  flex-basis: 100%;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.35;
}

.video-badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  font-size: .72rem;
  font-weight: 850;
}

.video-badge.is-verified {
  color: var(--green);
  background: var(--green-soft);
}

.video-badge.needs-review {
  color: var(--amber);
  background: #fff2df;
}

.diagram-box {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.diagram-icon {
  min-height: 86px;
  border: 1px solid #d7e2dc;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(31, 111, 91, .08), rgba(39, 95, 145, .08)),
    #fff;
  position: relative;
  overflow: hidden;
}

.diagram-icon:before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  height: 2px;
  background: var(--green);
}

.diagram-icon span {
  position: absolute;
  border: 2px solid var(--green);
  background: #fff;
}

.diagram-icon span:nth-child(1) {
  width: 28px;
  height: 40px;
  left: 16px;
  bottom: 20px;
  border-radius: 12px 12px 4px 4px;
}

.diagram-icon span:nth-child(2) {
  width: 16px;
  height: 54px;
  left: 50px;
  bottom: 20px;
  border-radius: 999px;
}

.diagram-icon span:nth-child(3) {
  width: 18px;
  height: 18px;
  right: 16px;
  bottom: 20px;
  border-radius: 50%;
  background: #f8c66a;
}

.wide {
  grid-column: 1 / -1;
}

@media (max-width: 980px) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-header,
  .toolbar,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .hero-visual {
    display: none;
  }

  .toolbar {
    position: static;
  }
}

@media (max-width: 640px) {
  main,
  .app-header,
  .site-footer {
    width: min(100% - 20px, 1180px);
  }

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

  .app-header {
    min-height: 190px;
    padding-top: 26px;
  }

  .toolbar,
  .catalog-panel,
  .detail {
    padding: 14px;
  }

  .site-footer {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
  }

  .diagram-box {
    grid-template-columns: 1fr;
  }

  .diagram-icon {
    min-height: 76px;
  }
}
