:root {
  --mist: #f7f9f4;
  --sand: #edf0e6;
  --sage: #9db59a;
  --moss: #6b8d68;
  --forest: #2f4b3e;
  --bg: #eef2ea;
  --surface: rgba(255, 255, 253, 0.94);
  --surface-strong: rgba(255, 255, 255, 0.98);
  --border: rgba(70, 95, 77, 0.12);
  --text: #21362c;
  --muted: #5b6d62;
  --accent: var(--moss);
  --accent-strong: var(--forest);
  --accent-soft: rgba(107, 141, 104, 0.14);
  --shadow: 0 18px 52px rgba(40, 63, 51, 0.09);
  --radius-xl: 34px;
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body.index-template,
body.sidecar-template {
  min-height: 100vh;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 16% 6%, rgba(255, 255, 255, 0.82), transparent 32%),
    radial-gradient(circle at 90% 14%, rgba(157, 181, 154, 0.12), transparent 34%),
    linear-gradient(138deg, var(--bg) 0%, var(--mist) 50%, var(--sand) 100%);
}

.index-template a,
.sidecar-template a {
  color: var(--accent-strong);
}

.index-template button {
  font: inherit;
}

.index-template .rendered-content,
.sidecar-template .rendered-content {
  color: var(--text);
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", serif;
  font-size: clamp(1.12rem, 1.02rem + 0.3vw, 1.28rem);
  line-height: 1.55;
}

.sidecar-template .rendered-content {
  max-width: 74ch;
}

.index-template .rendered-content > :first-child,
.sidecar-template .rendered-content > :first-child {
  margin-top: 0;
}

.index-template .rendered-content > :last-child,
.sidecar-template .rendered-content > :last-child {
  margin-bottom: 0;
}

.index-template .rendered-content h1,
.index-template .rendered-content h2,
.index-template .rendered-content h3,
.index-template .rendered-content h4,
.sidecar-template .rendered-content h1,
.sidecar-template .rendered-content h2,
.sidecar-template .rendered-content h3,
.sidecar-template .rendered-content h4 {
  font-family: "Manrope", "Segoe UI", sans-serif;
  line-height: 1.16;
  letter-spacing: -0.02em;
  margin: 1.8em 0 0.6em;
}

.index-template .rendered-content h1,
.sidecar-template .rendered-content h1 {
  font-size: clamp(1.8rem, 1.45rem + 1vw, 2.7rem);
}

.index-template .rendered-content h2,
.sidecar-template .rendered-content h2 {
  font-size: clamp(1.4rem, 1.2rem + 0.65vw, 2rem);
}

.index-template .rendered-content h3,
.sidecar-template .rendered-content h3 {
  font-size: clamp(1.15rem, 1.03rem + 0.38vw, 1.45rem);
}

.index-template .rendered-content p,
.index-template .rendered-content ul,
.index-template .rendered-content ol,
.index-template .rendered-content blockquote,
.sidecar-template .rendered-content p,
.sidecar-template .rendered-content ul,
.sidecar-template .rendered-content ol,
.sidecar-template .rendered-content blockquote {
  margin: 0 0 1.35em;
}

.index-template .rendered-content li p,
.sidecar-template .rendered-content li p {
  margin: 0;
}

.index-template .rendered-content ul,
.index-template .rendered-content ol,
.sidecar-template .rendered-content ul,
.sidecar-template .rendered-content ol {
  padding-left: 1.4em;
}

.index-template .rendered-content li + li,
.sidecar-template .rendered-content li + li {
  margin-top: 0.25em;
}

.index-template .rendered-content a,
.sidecar-template .rendered-content a {
  color: var(--accent-strong);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

.index-template .rendered-content blockquote,
.sidecar-template .rendered-content blockquote {
  margin-left: 0;
  padding-left: 1.1em;
  border-left: 3px solid rgba(107, 141, 104, 0.28);
  color: #445248;
}

.index-template .rendered-content table,
.sidecar-template .rendered-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-family: "Manrope", "Segoe UI", sans-serif;
  font-size: 0.95rem;
}

.index-template .rendered-content th,
.index-template .rendered-content td,
.sidecar-template .rendered-content th,
.sidecar-template .rendered-content td {
  padding: 12px 14px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.index-template .rendered-content img,
.sidecar-template .rendered-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.8em 0;
  border-radius: 18px;
}

.index-template .rendered-content code,
.index-template .rendered-content pre,
.sidecar-template .rendered-content code,
.sidecar-template .rendered-content pre {
  font-family: "IBM Plex Mono", monospace;
}

.index-template .rendered-content pre,
.sidecar-template .rendered-content pre {
  overflow: auto;
  padding: 16px;
  border-radius: 16px;
  background: rgba(29, 36, 32, 0.05);
}

.index-template .rendered-content code,
.sidecar-template .rendered-content code {
  font-size: 0.9em;
}

.index-template .rendered-content--empty,
.sidecar-template .rendered-content--empty {
  padding: 22px 24px;
  border: 1px dashed rgba(70, 95, 77, 0.2);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  font-family: "Manrope", "Segoe UI", sans-serif;
}

.index-template .viewer__empty,
.index-template .error-state,
.sidecar-template .viewer__empty,
.sidecar-template .error-state {
  padding: 24px;
  color: var(--muted);
  line-height: 1.6;
}

.index-template .page {
  max-width: 1800px;
  margin: 0 auto;
  padding: 28px;
}

.index-template .hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 34px;
  background:
    radial-gradient(circle at 88% 8%, rgba(157, 181, 154, 0.13), transparent 36%),
    linear-gradient(145deg, rgba(255, 255, 254, 0.98), rgba(245, 247, 241, 0.94));
  box-shadow: var(--shadow);
}

.index-template .hero::after {
  content: "";
  position: absolute;
  inset: auto -100px -100px auto;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(107, 141, 104, 0.14), transparent 72%);
}

.index-template .hero__eyebrow,
.index-template .status {
  font-family: "IBM Plex Mono", monospace;
}

.index-template .hero__eyebrow {
  display: inline-block;
  margin-bottom: 16px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--accent-strong);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.index-template .hero h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1;
}

.index-template .hero__intro {
  max-width: 72ch;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.index-template .hero__links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.index-template .hero__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  text-decoration: none;
}

.index-template .shell {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(0, 3fr);
  gap: 20px;
  align-items: start;
}

.index-template .panel {
  min-height: 70vh;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.index-template .panel__header {
  padding: 22px 22px 14px;
}

.index-template .panel__header--nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.index-template .panel__body {
  padding: 0 22px 22px;
}

.index-template .nav-layout {
  display: flex;
  flex-direction: column;
  min-height: 58vh;
}

.index-template .nav-section {
  flex: 1;
}

.index-template .panel__title {
  margin: 0;
  font-size: 1.1rem;
}

.index-template .panel__subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.5;
}

.index-template .status {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.78rem;
}

.index-template .tree {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.index-template .tree details {
  margin: 0;
  border-left: 1px solid var(--border);
  padding-left: 12px;
}

.index-template .tree details > div {
  margin-top: 2px;
  padding-left: 20px;
}

.index-template .tree ul {
  margin: 0;
  padding: 0 0 0 12px;
}

.index-template .tree details[open] > summary {
  color: var(--accent-strong);
}

.index-template .tree summary {
  cursor: pointer;
  list-style: none;
  padding: 6px 0 6px 10px;
  font-weight: 700;
  line-height: 1.35;
}

.index-template .tree summary::-webkit-details-marker {
  display: none;
}

.index-template .tree summary::marker {
  content: "";
}

.index-template .tree__folder-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 0;
}

.index-template .tree__folder-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  min-width: 1em;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1;
}

.index-template .tree__folder-label {
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.35;
}

.index-template .tree__folder-link {
  width: auto;
  flex: 1;
  display: inline-flex;
  align-items: center;
  min-height: 0;
  margin: 0;
  padding: 4px 8px;
}

.index-template .tree__folder-link .tree__label {
  display: inline;
  font-size: 0.96rem;
  font-weight: 650;
}

.index-template .tree__leaf {
  margin: 0;
  padding: 0;
  list-style: none;
}

.index-template .tree__button {
  width: 100%;
  border: 0;
  margin-top: 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 120ms ease, transform 120ms ease;
}

.index-template .tree__button:hover,
.index-template .tree__button:focus-visible {
  background: rgba(255, 255, 255, 0.84);
  outline: none;
  transform: translateX(2px);
}

.index-template .tree__button.is-active {
  background: linear-gradient(135deg, rgba(107, 141, 104, 0.16), rgba(107, 141, 104, 0.05));
  box-shadow: inset 0 0 0 1px rgba(107, 141, 104, 0.16);
}

.index-template .tree__label {
  display: block;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.35;
}

.index-template .tree__button--resource .tree__label {
  font-weight: 600;
}

.index-template .tree__button--page {
  margin-left: 0;
  padding-left: 16px;
}

.index-template .tree__button--page .tree__label {
  font-size: 0.84rem;
  font-weight: 520;
}

.index-template .tree__button--page.is-active .tree__label {
  font-size: 0.84rem;
  font-weight: 560;
}

.index-template .resource-nav {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 10px;
}

.index-template .resource-nav__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.index-template .resource-nav__title {
  margin: 0;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.index-template .resource-nav__group {
  margin: 0;
  border-left: 1px solid var(--border);
  padding-left: 12px;
}

.index-template .resource-nav__group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  padding: 6px 0;
}

.index-template .resource-nav__summary-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.index-template .resource-nav__summary-label::before {
  content: "▸";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  min-width: 1em;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1;
}

.index-template .resource-nav__group summary::-webkit-details-marker {
  display: none;
}

.index-template .resource-nav__group[open] > summary {
  color: var(--accent-strong);
}

.index-template .resource-nav__group[open] > summary .resource-nav__summary-label::before {
  content: "▾";
}

.index-template .resource-nav__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.8em;
  height: 1.8em;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.74rem;
  line-height: 1;
}

.index-template .resource-nav__list {
  margin: 0;
  padding: 0 0 0 8px;
}

.index-template .resource-nav__empty {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.index-template .viewer {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  min-width: 0;
}

.index-template .viewer__toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 12px;
  padding: 22px;
  border-bottom: 1px solid var(--border);
}

.index-template #viewer-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.index-template #viewer-breadcrumbs .action-link {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.index-template #viewer-breadcrumbs .action-link.is-active {
  background: linear-gradient(135deg, rgba(107, 141, 104, 0.16), rgba(107, 141, 104, 0.05));
  box-shadow: inset 0 0 0 1px rgba(107, 141, 104, 0.16);
}

.index-template #viewer-breadcrumbs .status {
  padding: 0;
  background: transparent;
  font-size: 0.76rem;
}

.index-template .viewer__headline {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.3rem);
}

.index-template .viewer__description {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.index-template .viewer__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.index-template .subnav-fallback {
  padding: 18px;
  text-align: left;
}

.index-template .subnav-fallback__intro {
  margin: 0 0 14px;
}

.index-template .subnav-fallback__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.index-template .subnav-fallback__item {
  margin: 0;
}

.index-template .subnav-fallback__button {
  width: 100%;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  min-height: 56px;
  border-radius: 14px;
  padding: 10px 14px;
  text-align: left;
}

.index-template .subnav-fallback__title {
  display: block;
  font-weight: 650;
  font-size: 0.95rem;
  line-height: 1.25;
}

.index-template .subnav-fallback__path {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
  font-family: "IBM Plex Mono", monospace;
}

.index-template .action-link,
.sidecar-template .button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-strong);
  text-decoration: none;
  color: var(--accent-strong);
  transition: background-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.index-template .action-link:hover,
.index-template .action-link:focus-visible,
.sidecar-template .button-link:hover,
.sidecar-template .button-link:focus-visible {
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(40, 68, 55, 0.08);
  transform: translateY(-1px);
}

.index-template .action-link--primary,
.sidecar-template .button-link--primary {
  border-color: transparent;
  background: var(--accent);
  color: #f9fcf8;
}

.index-template .action-link--primary:hover,
.index-template .action-link--primary:focus-visible,
.sidecar-template .button-link--primary:hover,
.sidecar-template .button-link--primary:focus-visible {
  background: #5e815c;
}

.index-template .viewer__frame {
  min-height: 72vh;
  padding: 28px 32px 36px;
  overflow-x: auto;
}

.index-template .viewer__media {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 16px;
}

.index-template .viewer__embed {
  width: 100%;
  min-height: 64vh;
  border: 0;
  border-radius: 16px;
  background: #fff;
}

.index-template .viewer__navigation {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 22px;
  border-top: 1px solid var(--border);
}

.index-template .action-link[disabled] {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.index-template .readme {
  margin-top: 20px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.sidecar-template img {
  display: block;
  max-width: 100%;
  border-radius: 20px;
}

.sidecar-template .page {
  max-width: 1760px;
  margin: 0 auto;
  padding: 28px;
}

.sidecar-template .hero {
  margin-bottom: 20px;
  padding: 30px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 88% 8%, rgba(157, 181, 154, 0.13), transparent 36%),
    linear-gradient(145deg, rgba(255, 255, 254, 0.98), rgba(245, 247, 241, 0.94));
  box-shadow: var(--shadow);
}

.sidecar-template .eyebrow,
.sidecar-template .meta-label,
.sidecar-template .breadcrumbs,
.sidecar-template code {
  font-family: "IBM Plex Mono", monospace;
}

.sidecar-template .eyebrow {
  display: inline-block;
  margin-bottom: 16px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--accent-strong);
  font-size: 0.76rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidecar-template h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.05;
}

.sidecar-template .intro {
  max-width: 72ch;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.sidecar-template .layout {
  display: grid;
  grid-template-columns: minmax(0, 2.3fr) minmax(320px, 1fr);
  gap: 22px;
  align-items: start;
}

.sidecar-template .panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sidecar-template .panel__header {
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
}

.sidecar-template .panel__title {
  margin: 0;
  font-size: 1.15rem;
}

.sidecar-template .panel__subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.sidecar-template .panel__body {
  padding: 24px;
}

.sidecar-template .breadcrumbs {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.sidecar-template .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.sidecar-template .button-link {
  min-height: 44px;
  padding: 0 16px;
}

.sidecar-template .preview {
  min-height: 70vh;
}

.sidecar-template iframe {
  width: 100%;
  min-height: 72vh;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.sidecar-template .meta-stack {
  display: grid;
  gap: 14px;
}

.sidecar-template .meta-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.84);
}

.sidecar-template .meta-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidecar-template .meta-value {
  margin: 0;
  line-height: 1.6;
  word-break: break-word;
}

.sidecar-template .origin-list {
  margin: 0;
  padding-left: 18px;
}

.sidecar-template .origin-list li + li {
  margin-top: 8px;
}

.sidecar-template .meta-card .actions {
  margin-top: 0;
  display: grid;
  gap: 10px;
}

.sidecar-template .meta-card .button-link {
  width: 100%;
  justify-content: center;
}

.sidecar-template .footer {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 1180px) {
  .index-template .shell {
    grid-template-columns: 1fr;
  }

  .index-template .page {
    padding: 16px;
  }

  .index-template .panel {
    min-height: auto;
  }

  .index-template .viewer__frame {
    min-height: 58vh;
  }

  .index-template .nav-layout {
    min-height: auto;
  }
}

@media (max-width: 1080px) {
  .sidecar-template .layout {
    grid-template-columns: 1fr;
  }

  .sidecar-template .preview {
    min-height: 52vh;
  }

  .sidecar-template .page {
    padding: 16px;
  }

  .sidecar-template .hero {
    padding: 24px;
    border-radius: 24px;
  }

  .sidecar-template .panel__header,
  .sidecar-template .panel__body {
    padding-left: 18px;
    padding-right: 18px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .index-template .hero,
  .index-template .panel,
  .sidecar-template .hero,
  .sidecar-template .panel {
    animation: fade-in 320ms ease;
  }

  @keyframes fade-in {
    from {
      opacity: 0;
      transform: translateY(8px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}
