:root {
  --bg-dark: #1c1f22;
  --dark-gray: #2b2e30;
  --panel: #24272a;
  --panel-alt: #202326;
  --primary: #1a7fc8;
  --primary-soft: rgba(26, 127, 200, 0.2);
  --text-high: #f5f5f5;
  --text-med: rgba(245, 245, 245, 0.78);
  --text-muted: rgba(245, 245, 245, 0.55);
  --border-subtle: rgba(245, 245, 245, 0.09);
  --shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  --transition: 240ms ease;
  --font-heading: 'Exo 2', sans-serif;
  --font-body: 'Nunito', sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 20%, rgba(26, 127, 200, 0.08) 0, transparent 55%), var(--bg-dark);
  color: var(--text-high);
  font-family: var(--font-body);
  line-height: 1.6;
  padding: 0;
}

/* Wraps the page content below the sticky nav.
   Radius tokens are scoped here so they don't override the global v3 values
   used by the nav and other shared components. */
.toolkit-page-wrap {
  --radius-lg: 18px;
  --radius-md: 12px;
  padding: clamp(1.5rem, 3vw, 2.5rem) clamp(1rem, 4vw, 3rem) clamp(2.5rem, 6vw, 4rem);
}

a {
  color: inherit;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--text-med);
  text-decoration: none;
  margin-bottom: 1.5rem;
  transition: color var(--transition);
}

.back-link::before {
  content: '←';
  font-weight: 700;
  color: var(--primary);
}

.back-link:hover,
.back-link:focus {
  color: var(--primary);
  outline: none;
}

.page-header {
  background: linear-gradient(135deg, rgba(26, 127, 200, 0.18), rgba(26, 127, 200, 0.05));
  border: 1px solid rgba(26, 127, 200, 0.2);
  border-radius: var(--radius-lg);
  padding: clamp(1.75rem, 3vw, 2.75rem);
  display: grid;
  justify-items: center;
  gap: clamp(1rem, 3vw, 1.75rem);
  box-shadow: var(--shadow);
}

.header-brand {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  align-items: center;
  text-align: center;
}

.header-logo {
  width: clamp(120px, 18vw, 160px);
  height: auto;
}

.heading-group h1 {
  margin: 0.15rem 0 0.65rem;
  font-family: var(--font-heading);
  font-size: clamp(2.1rem, 5vw, 3rem);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

.lede {
  max-width: min(640px, 90vw);
  color: var(--text-med);
  margin: 0;
  font-size: 1.05rem;
}

.page-content {
  margin: 2.5rem auto 0;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
  padding: clamp(1rem, 2.5vw, 1.4rem);
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.control-label {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.control-select,
.search-field input {
  background: var(--panel-alt);
  color: var(--text-high);
  border: 1px solid rgba(245, 245, 245, 0.14);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.85rem;
  font-size: 0.98rem;
  transition: border var(--transition), box-shadow var(--transition);
  min-height: 46px;
}

.control-select:focus,
.search-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  outline: none;
}

.search-group {
  align-self: flex-end;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-field input {
  width: 100%;
  padding-right: 2.5rem;
}

.icon-button {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}

.icon-button:hover,
.icon-button:focus {
  color: var(--text-high);
  background: rgba(255, 255, 255, 0.05);
  outline: none;
}

.selected-app {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem clamp(1rem, 3vw, 2rem);
  border-radius: var(--radius-lg);
  background: rgba(26, 127, 200, 0.08);
  border: 1px solid rgba(26, 127, 200, 0.35);
}

.app-meta h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-heading);
  font-size: clamp(1.3rem, 3vw, 1.65rem);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(26, 127, 200, 0.18);
  border: 1px solid rgba(26, 127, 200, 0.45);
  color: var(--text-high);
}

.link-button {
  appearance: none;
  border: none;
  background: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  padding: 0;
  font-size: 0.95rem;
  transition: opacity var(--transition);
}

.link-button:hover,
.link-button:focus {
  opacity: 0.8;
  outline: none;
}

.alert {
  min-height: 0;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-med);
}

.alert.visible {
  background: rgba(26, 127, 200, 0.08);
  border-color: rgba(26, 127, 200, 0.35);
}

.tone-info {
  background: rgba(26, 127, 200, 0.08);
  border-color: rgba(26, 127, 200, 0.35);
}

.tone-warning {
  background: rgba(255, 188, 87, 0.12);
  border-color: rgba(255, 188, 87, 0.45);
  color: #ffdc9b;
}

.tone-error {
  background: rgba(237, 90, 90, 0.12);
  border-color: rgba(237, 90, 90, 0.45);
  color: #ffabaab;
}

.note-card {
  background: rgba(26, 127, 200, 0.08);
  border: 1px solid rgba(26, 127, 200, 0.35);
  border-radius: var(--radius-lg);
  padding: clamp(1rem, 2.5vw, 1.4rem);
  color: var(--text-med);
  box-shadow: var(--shadow);
}

.note-card strong {
  color: var(--text-high);
}

.modules {
  display: grid;
  gap: 1.2rem;
}

.module-card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
}

.module-card:focus-within,
.module-card:hover {
  border-color: rgba(26, 127, 200, 0.35);
  transform: translateY(-2px);
}

.module-header {
  width: 100%;
  padding: 1.3rem clamp(1.1rem, 2.5vw, 1.8rem);
  background: none;
  border: none;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
}

.module-header:focus {
  outline: none;
}

.module-title-group {
  text-align: left;
}

.module-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: clamp(1.3rem, 3vw, 1.6rem);
}

.module-subtitle {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.module-toggle {
  flex: 0 0 auto;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: rgba(26, 127, 200, 0.15);
  border: 1px solid rgba(26, 127, 200, 0.45);
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  color: var(--primary);
  transform: rotate(0deg);
  transition: transform var(--transition), background var(--transition);
}

.module-card.open .module-toggle {
  transform: rotate(45deg);
  background: rgba(26, 127, 200, 0.28);
}

.module-body {
  padding: 0 clamp(1.1rem, 2.5vw, 1.8rem);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 260ms ease, opacity 220ms ease;
}

.module-card.open .module-body {
  padding-bottom: 1.6rem;
  max-height: 900px;
  opacity: 1;
}

.module-body-inner {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding-top: 0.6rem;
}

.step-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.step-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-md);
  background: var(--panel-alt);
  border: 1px solid rgba(245, 245, 245, 0.08);
  transition: border var(--transition), background var(--transition);
}

.step-item.completed {
  border-color: rgba(26, 127, 200, 0.55);
  background: rgba(26, 127, 200, 0.12);
}

.step-info {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  flex: 1 1 auto;
}

.step-index {
  font-weight: 700;
  color: var(--primary);
  min-width: 1.4rem;
}

.step-text {
  color: var(--text-med);
  line-height: 1.55;
}

.step-checkbox {
  appearance: none;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.2rem;
  border-radius: 4px;
  border: 2px solid rgba(245, 245, 245, 0.35);
  background: transparent;
  transition: border var(--transition), background var(--transition);
  cursor: pointer;
}

.step-checkbox:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.step-checkbox:checked {
  background: var(--primary);
  border-color: var(--primary);
  position: relative;
}

.step-checkbox:checked::after {
  content: '✓';
  display: block;
  color: var(--bg-dark);
  font-weight: 700;
  font-size: 0.75rem;
  text-align: center;
  line-height: 1.05rem;
}

.step-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.step-copy,
.step-copy:focus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(26, 127, 200, 0.6);
  background: rgba(26, 127, 200, 0.15);
  color: var(--text-high);
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition);
}

.step-copy:hover,
.step-copy:focus {
  transform: translateY(-1px);
  background: rgba(26, 127, 200, 0.25);
  outline: none;
}

.step-copy.copied {
  background: rgba(26, 127, 200, 0.4);
}

.module-notes {
  margin: 0;
  padding: 0.9rem 1rem;
  border-left: 3px solid var(--primary);
  background: rgba(26, 127, 200, 0.08);
  border-radius: 0.6rem;
  color: var(--text-med);
}

.fallback-message {
  margin: 0;
  padding: 0.9rem 1rem;
  border-radius: 0.65rem;
  background: rgba(255, 204, 92, 0.12);
  border: 1px solid rgba(255, 204, 92, 0.4);
  color: #ffde8a;
}

.helper-card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: clamp(1.4rem, 4vw, 2.1rem);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.helper-card h2 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 3.5vw, 1.8rem);
}

.helper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
}

.helper-item {
  background: var(--panel-alt);
  padding: 1rem 1.2rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(245, 245, 245, 0.07);
}

.helper-item h3 {
  margin: 0 0 0.6rem;
  font-family: var(--font-heading);
  font-size: 1.05rem;
}

.helper-item ol {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-med);
}

.site-footer {
  margin-top: 2rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.footer-actions {
  display: flex;
  gap: 0.8rem;
}

@media (max-width: 768px) {
  .page-header {
    padding: 1.6rem clamp(1rem, 4vw, 2rem);
    align-items: flex-start;
  }

  .selected-app {
    flex-direction: column;
    align-items: flex-start;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .step-item {
    flex-direction: column;
    align-items: stretch;
  }

  .step-actions {
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
