:root {
  --ink: #07133d;
  --muted: #5e6d86;
  --line: #d6e2ee;
  --panel: rgba(255, 255, 255, .92);
  --teal: #007f72;
  --cyan: #13d9e6;
  --yellow: #ffe84a;
  --shadow: 0 22px 55px rgba(7, 19, 61, .11);
  --soft-shadow: 0 14px 30px rgba(7, 19, 61, .08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", "Trebuchet MS", Arial, sans-serif;
  font-weight: 700;
  background:
    linear-gradient(90deg, rgba(8, 127, 114, .055) 1px, transparent 1px),
    linear-gradient(0deg, rgba(37, 99, 235, .06) 1px, transparent 1px),
    radial-gradient(circle at 18% 18%, rgba(19, 217, 230, .18), transparent 28%),
    radial-gradient(circle at 82% 10%, rgba(255, 232, 74, .16), transparent 24%),
    #f6f9fc;
  background-size: 48px 48px, 48px 48px, auto, auto, auto;
}

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

button,
input {
  font: inherit;
}

.studio-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 14px;
  min-height: 100vh;
  padding: 16px;
}

.sidebar,
.top-card,
.content-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(14px);
}

.sidebar {
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
  overflow: auto;
  border-radius: 10px;
  padding: 18px;
}

.brand-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.back-link,
.integral-mark {
  display: grid;
  place-items: center;
}

.back-link {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #1f55ad;
  background: #f8fbff;
}

.back-link svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-copy .eyebrow,
.top-eyebrow,
.section-kicker {
  color: var(--teal);
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: 900;
}

.brand-copy h1 {
  margin: 3px 0 0;
  font-size: 1.28rem;
  line-height: 1.05;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0 16px;
}

.stat {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #fff, #f3f8fd);
}

.stat strong {
  display: block;
  font-size: 1.28rem;
  line-height: 1;
}

.stat span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: .82rem;
}

.nav-title {
  margin: 16px 0 8px;
  color: var(--teal);
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: 900;
}

.chapter-list {
  display: grid;
  gap: 8px;
}

.chapter-button {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 10px 10px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, .88);
  cursor: pointer;
  text-align: left;
  transition: transform .16s, border-color .16s, background .16s, box-shadow .16s;
}

.chapter-button:hover,
.chapter-button.active {
  border-color: rgba(0, 127, 114, .45);
  background: rgba(229, 248, 246, .9);
  box-shadow: 0 8px 18px rgba(0, 127, 114, .08);
  transform: translateY(-1px);
}

.chapter-button.disabled {
  opacity: .48;
  cursor: default;
  transform: none;
}

.chapter-button .label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .9rem;
}

.count-pill,
.mini-pill {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  min-height: 28px;
  padding: 2px 9px;
  border: 1px solid #b9ebe5;
  border-radius: 999px;
  color: #0b4c46;
  background: #e8f8f6;
  font-size: .82rem;
  font-weight: 900;
}

.main-column {
  min-width: 0;
  display: grid;
  gap: 12px;
  align-content: start;
}

.top-card {
  display: grid;
  grid-template-columns: minmax(220px, .72fr) minmax(320px, 1fr);
  gap: 16px;
  align-items: center;
  min-height: 0;
  border-radius: 10px;
  padding: 14px 16px;
}

.title-line {
  display: flex;
  align-items: center;
  gap: 12px;
}

.integral-mark {
  width: 42px;
  height: 42px;
  border: 1px solid #c6eee8;
  border-radius: 8px;
  color: var(--teal);
  background: linear-gradient(135deg, #e9fbf8, #fff8cc);
}

.integral-mark svg {
  width: 22px;
  height: 29px;
}

.top-eyebrow {
  font-size: .74rem;
}

.top-card h2 {
  margin: 0;
  font-size: clamp(1.95rem, 3vw, 3rem);
  line-height: .95;
  letter-spacing: 0;
}

.top-card p {
  display: none;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.search-card {
  position: relative;
}

.search-card svg {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 19px;
  height: 19px;
  color: var(--teal);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cbd9e8;
  border-radius: 8px;
  padding: 0 16px 0 48px;
  color: var(--ink);
  background: #fff;
  outline: none;
  font-size: .95rem;
}

.search-input:focus {
  border-color: rgba(0, 127, 114, .62);
  box-shadow: 0 0 0 4px rgba(0, 127, 114, .12);
}

.reset-button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  color: #33415c;
  background: #fff;
  cursor: pointer;
  font-weight: 900;
}

.content-card {
  overflow: visible;
  border: 0;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
}

.section-list {
  display: grid;
  gap: 14px;
  padding: 0;
}

.chapter-section {
  overflow: hidden;
  border: 1px solid #dbe7f0;
  border-radius: 10px;
  background: rgba(255, 255, 255, .78);
  box-shadow: var(--soft-shadow);
}

.chapter-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #dbe7f0;
  background: linear-gradient(90deg, rgba(232, 248, 246, .82), rgba(255, 255, 255, .75));
}

.chapter-heading h4 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.08;
}

.applet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(188px, 1fr));
  gap: 10px;
  padding: 10px;
}

.applet-card {
  display: grid;
  grid-template-rows: 104px minmax(0, 1fr);
  min-height: 232px;
  overflow: hidden;
  border: 1px solid #cfdeeb;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 18px rgba(7, 19, 61, .052);
  transition: transform .16s, box-shadow .16s, border-color .16s;
}

.applet-card:hover,
.applet-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(0, 127, 114, .46);
  box-shadow: var(--shadow);
  outline: none;
}

.thumb-wrap {
  position: relative;
  overflow: hidden;
  border-bottom: 4px solid var(--teal);
  background: #075544;
}

.thumb-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.05) contrast(1.03);
}

.card-copy {
  display: grid;
  gap: 7px;
  align-content: start;
  padding: 10px;
}

.card-copy h5 {
  min-height: 2.2em;
  margin: 0;
  font-size: .96rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.card-copy p {
  display: -webkit-box;
  min-height: 2.45em;
  margin: 0;
  overflow: hidden;
  color: #36445d;
  font-size: .76rem;
  line-height: 1.28;
  font-weight: 800;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: auto;
}

.tag {
  max-width: 100%;
  overflow: hidden;
  border-radius: 999px;
  padding: 3px 6px;
  color: #43536d;
  background: #edf3f8;
  font-size: .64rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  padding: 22px;
  border: 1px dashed #bfd1e2;
  border-radius: 10px;
  color: var(--muted);
  background: #f9fcff;
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 1.1rem;
}

@media (max-width: 1320px) {
  .studio-shell {
    grid-template-columns: 272px minmax(0, 1fr);
  }
}

@media (max-width: 940px) {
  .studio-shell {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .sidebar {
    position: static;
    height: auto;
    max-height: none;
  }

  .chapter-list {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  }

  .top-card {
    grid-template-columns: 1fr;
    min-height: 0;
  }

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

@media (max-width: 620px) {
  .studio-shell {
    padding: 7px;
  }

  .top-card,
  .content-card,
  .sidebar {
    border-radius: 8px;
  }

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

  .result-toolbar,
  .search-row {
    grid-template-columns: 1fr;
  }

  .reset-button {
    width: 100%;
  }

  .top-card h2 {
    font-size: 2rem;
  }
}
