/* =========================================================
   Curriculum Design Studio — Main CSS
   Lens-aware theming: structured | constructionist | critical | hybrid
   ========================================================= */

/* --- Custom Properties --- */
:root {
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-serif: 'DM Serif Display', Georgia, serif;
  --font-mono: 'Space Mono', monospace;

  /* Structured (blue/slate) */
  --structured-50: #eff6ff;
  --structured-100: #dbeafe;
  --structured-500: #3b82f6;
  --structured-600: #2563eb;
  --structured-700: #1d4ed8;
  --structured-900: #1e3a5f;

  /* Constructionist (amber/warm) */
  --constructionist-50: #fffbeb;
  --constructionist-100: #fef3c7;
  --constructionist-400: #fbbf24;
  --constructionist-500: #f59e0b;
  --constructionist-600: #d97706;
  --constructionist-900: #78350f;

  /* Critical (rose/red) */
  --critical-50: #fff1f2;
  --critical-100: #ffe4e6;
  --critical-400: #fb7185;
  --critical-500: #f43f5e;
  --critical-600: #e11d48;
  --critical-900: #4c0519;

  /* Hybrid (purple) */
  --hybrid-50: #f5f3ff;
  --hybrid-500: #8b5cf6;
  --hybrid-600: #7c3aed;

  /* Neutrals */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.14);
  --shadow-xl: 0 20px 60px rgba(0,0,0,.18);

  --transition: 200ms ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }

/* =========================================================
   NAVBAR
   ========================================================= */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 2rem;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.navbar__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--gray-900);
  white-space: nowrap;
}
.navbar__logo { font-size: 1.4rem; }

.navbar__lens-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  flex-wrap: wrap;
}
.lens-toggle__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
.lens-toggle__options {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.lens-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  border: 2px solid transparent;
  transition: all var(--transition);
  color: var(--gray-600);
  background: var(--gray-100);
}
.lens-btn:hover { background: var(--gray-200); }

.lens-btn--structured.active { background: var(--structured-100); border-color: var(--structured-500); color: var(--structured-700); }
.lens-btn--constructionist.active { background: var(--constructionist-100); border-color: var(--constructionist-500); color: var(--constructionist-900); }
.lens-btn--critical.active { background: var(--critical-100); border-color: var(--critical-500); color: var(--critical-900); }
.lens-btn--hybrid.active { background: var(--hybrid-50); border-color: var(--hybrid-500); color: var(--hybrid-600); }

.navbar__links { display: flex; gap: 0.5rem; }
.navbar__link {
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-600);
  transition: all var(--transition);
}
.navbar__link:hover { background: var(--gray-100); color: var(--gray-900); }
.navbar__link.active { background: var(--gray-100); color: var(--gray-900); font-weight: 600; }

/* =========================================================
   PAGE HEADER
   ========================================================= */
.page-header {
  background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-700) 100%);
  color: white;
  padding: 3rem 2rem;
}
.page-header__inner { max-width: 760px; }
.page-header__title {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}
.page-header__subtitle {
  font-size: 1.05rem;
  color: rgba(255,255,255,0.8);
  line-height: 1.7;
}

/* =========================================================
   MAIN LAYOUT (index page)
   ========================================================= */
.main-content { flex: 1; }

.studio-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  min-height: calc(100vh - 120px);
}

/* =========================================================
   SIDEBAR
   ========================================================= */
.sidebar {
  background: white;
  border-right: 1px solid var(--gray-200);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}
.sidebar__section { margin-bottom: 2rem; }
.sidebar__heading {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-400);
  margin-bottom: 0.6rem;
  padding-left: 0.5rem;
}
.sidebar__list { display: flex; flex-direction: column; gap: 0.2rem; }
.sidebar__filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  transition: all var(--transition);
  text-align: left;
}
.sidebar__filter:hover { background: var(--gray-100); }
.sidebar__filter.active { background: var(--gray-900); color: white; }
.sidebar__filter--blue.active { background: var(--structured-600); }
.sidebar__filter--amber.active { background: var(--constructionist-600); color: white; }
.sidebar__filter--rose.active { background: var(--critical-600); }

/* Lens info cards */
.lens-info {
  display: none;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  line-height: 1.5;
  border: 1px solid var(--gray-200);
}
.lens-info.active { display: block; }
.lens-info strong { display: block; margin-bottom: 0.4rem; }
.lens-info--structured { background: var(--structured-50); border-color: var(--structured-100); }
.lens-info--constructionist { background: var(--constructionist-50); border-color: var(--constructionist-100); }
.lens-info--critical { background: var(--critical-50); border-color: var(--critical-100); }
.lens-info--hybrid { background: var(--hybrid-50); border-color: #ddd6fe; }

/* =========================================================
   TEMPLATE GRID
   ========================================================= */
.template-grid-section { padding: 1.5rem 2rem; }

.template-grid-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.template-grid-header__title { font-size: 1.3rem; font-weight: 700; }
.template-grid-header__count {
  font-size: 0.82rem;
  color: var(--gray-400);
  font-weight: 500;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

/* Template Cards */
.template-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 2px solid var(--gray-200);
  padding: 1.4rem;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.template-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.template-card--structured:hover { border-color: var(--structured-300); }
.template-card--constructionist {
  border-color: var(--constructionist-100);
  background: linear-gradient(135deg, white 80%, var(--constructionist-50));
}
.template-card--constructionist:hover { border-color: var(--constructionist-400); box-shadow: 0 6px 20px rgba(245,158,11,.15); }
.template-card--critical {
  border-color: var(--critical-100);
  background: linear-gradient(135deg, white 80%, var(--critical-50));
}
.template-card--critical:hover { border-color: var(--critical-400); box-shadow: 0 6px 20px rgba(244,63,94,.15); }

.template-card__header { display: flex; align-items: center; justify-content: space-between; }
.template-card__icon { font-size: 1.8rem; }

.template-card__name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.3;
}
.template-card__desc {
  font-size: 0.875rem;
  color: var(--gray-500);
  line-height: 1.5;
  flex: 1;
}
.template-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.template-card__actions { margin-top: auto; }

/* =========================================================
   LENS BADGES
   ========================================================= */
.lens-badge, .lens-badge--structured, .lens-badge--constructionist,
.lens-badge--critical, .lens-badge--hybrid {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.lens-badge--structured { background: var(--structured-100); color: var(--structured-700); }
.lens-badge--constructionist { background: var(--constructionist-100); color: var(--constructionist-900); }
.lens-badge--critical { background: var(--critical-100); color: var(--critical-600); }
.lens-badge--hybrid { background: var(--hybrid-50); color: var(--hybrid-600); }

.tag {
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: 0.7rem;
  padding: 0.1rem 0.5rem;
  border-radius: 20px;
  font-weight: 500;
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  font-family: inherit;
}
.btn--sm { padding: 0.35rem 0.9rem; font-size: 0.82rem; border-radius: var(--radius-sm); }
.btn--lg { padding: 0.75rem 1.75rem; font-size: 1rem; }

.btn--primary { background: var(--gray-900); color: white; }
.btn--primary:hover { background: var(--gray-700); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.btn--structured { background: var(--structured-600); color: white; }
.btn--structured:hover { background: var(--structured-700); }
.btn--constructionist { background: var(--constructionist-500); color: white; }
.btn--constructionist:hover { background: var(--constructionist-600); }
.btn--critical { background: var(--critical-500); color: white; }
.btn--critical:hover { background: var(--critical-600); }

.btn--ghost {
  background: transparent;
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
}
.btn--ghost:hover { background: var(--gray-100); }

/* =========================================================
   STUDIO PAGE
   ========================================================= */
.studio-page { min-height: 100vh; }

.studio-header {
  padding: 2rem;
  border-bottom: 1px solid var(--gray-200);
}
.studio-header--structured { background: linear-gradient(135deg, var(--structured-50) 0%, white 100%); }
.studio-header--constructionist { background: linear-gradient(135deg, var(--constructionist-50) 0%, white 100%); }
.studio-header--critical { background: linear-gradient(135deg, var(--critical-50) 0%, white 100%); }

.studio-header__inner { max-width: 800px; }
.studio-header__back {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-bottom: 0.75rem;
  font-weight: 500;
}
.studio-header__back:hover { color: var(--gray-800); }
.studio-header__meta { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.studio-header__icon { font-size: 2.5rem; }
.studio-header__category { font-size: 0.8rem; color: var(--gray-500); margin-left: 0.5rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.studio-header__title { font-family: var(--font-serif); font-size: 2rem; color: var(--gray-900); margin-bottom: 0.5rem; }
.studio-header__desc { font-size: 0.95rem; color: var(--gray-600); max-width: 640px; }

/* Studio Workspace (2-col) */
.studio-workspace {
  display: grid;
  grid-template-columns: 420px 1fr;
  min-height: calc(100vh - 200px);
}

/* Form Panel */
.studio-form-panel {
  background: white;
  border-right: 1px solid var(--gray-200);
  padding: 2rem;
  overflow-y: auto;
  max-height: calc(100vh - 200px);
  position: sticky;
  top: 60px;
}

.form-section { margin-bottom: 2rem; }
.form-section__title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.form-section__hint { font-size: 0.82rem; color: var(--gray-500); margin-bottom: 0.75rem; }

.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.4rem;
}
.required-star { color: var(--critical-500); }

.form-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--gray-800);
  background: white;
  transition: border-color var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--structured-500); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.form-control--textarea { resize: vertical; line-height: 1.6; }
.form-control--select { appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.85rem center; padding-right: 2.5rem; }
.form-control--large { min-height: 240px; }

.form-section__toggle {
  font-size: 0.8rem;
  color: var(--structured-600);
  cursor: pointer;
  background: none;
  border: none;
  font-weight: 600;
}

/* Modifiers */
.modifiers-grid { display: flex; flex-direction: column; gap: 0.5rem; }
.modifier-toggle {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  cursor: pointer;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  transition: all var(--transition);
}
.modifier-toggle:hover { background: var(--gray-50); border-color: var(--gray-300); }
.modifier-checkbox { display: none; }
.modifier-toggle__box {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all var(--transition);
}
.modifier-toggle__check { font-size: 11px; color: white; display: none; }
.modifier-checkbox:checked ~ .modifier-toggle__box { background: var(--structured-600); border-color: var(--structured-600); }
.modifier-checkbox:checked ~ .modifier-toggle__box .modifier-toggle__check { display: block; }
.modifier-toggle__label { font-size: 0.85rem; color: var(--gray-700); font-weight: 500; }

/* Mode Selector */
.mode-selector { display: flex; flex-direction: column; gap: 0.6rem; }
.mode-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--gray-200);
  cursor: pointer;
  transition: all var(--transition);
}
.mode-option:hover { border-color: var(--gray-300); background: var(--gray-50); }
.mode-option--selected { border-color: var(--structured-500) !important; background: var(--structured-50) !important; }
.mode-option input[type="radio"] { display: none; }
.mode-option__icon { font-size: 1.3rem; flex-shrink: 0; }
.mode-option__text { display: flex; flex-direction: column; }
.mode-option__text strong { font-size: 0.9rem; color: var(--gray-800); }
.mode-option__text small { font-size: 0.78rem; color: var(--gray-500); margin-top: 0.1rem; }

.form-actions { padding-top: 0.5rem; }
.form-actions .btn { width: 100%; }

/* =========================================================
   OUTPUT PANEL
   ========================================================= */
.studio-output-panel { padding: 2rem; overflow-y: auto; background: var(--gray-50); }

.output-placeholder {
  text-align: center;
  padding: 3rem 2rem;
  max-width: 520px;
  margin: 0 auto;
}
.output-placeholder__icon { font-size: 3.5rem; margin-bottom: 1rem; }
.output-placeholder h3 { font-size: 1.2rem; font-weight: 700; color: var(--gray-700); margin-bottom: 0.5rem; }
.output-placeholder p { color: var(--gray-500); font-size: 0.9rem; margin-bottom: 1.5rem; }
.output-placeholder__tips {
  text-align: left;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}
.output-placeholder__tips h4 { font-size: 0.85rem; font-weight: 700; color: var(--gray-700); margin-bottom: 0.5rem; }
.output-placeholder__tips li { font-size: 0.82rem; color: var(--gray-500); padding: 0.2rem 0; padding-left: 1rem; position: relative; }
.output-placeholder__tips li::before { content: '•'; position: absolute; left: 0; color: var(--structured-500); }

.output-content {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.output-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
.output-toolbar__left { display: flex; align-items: center; gap: 0.75rem; }
.output-toolbar__right { display: flex; gap: 0.5rem; }
.output-toolbar__label { font-size: 0.82rem; font-weight: 700; color: var(--gray-600); text-transform: uppercase; letter-spacing: .05em; }

.output-body { padding: 1.5rem 2rem; }

.output-prompt-section { margin-bottom: 1.5rem; }
.output-prompt-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
.output-prompt-header small { color: var(--gray-400); font-size: 0.78rem; }
.output-prompt-text {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre-wrap;
  color: var(--gray-700);
  max-height: 300px;
  overflow-y: auto;
}

.output-result {
  font-size: 0.92rem;
  line-height: 1.8;
  color: var(--gray-800);
}
.output-result h1, .output-result h2 { font-family: var(--font-serif); margin-bottom: 0.5rem; margin-top: 1.5rem; }
.output-result h2 { font-size: 1.25rem; color: var(--gray-900); border-bottom: 2px solid var(--gray-100); padding-bottom: 0.3rem; }
.output-result h3 { font-size: 1.05rem; font-weight: 700; color: var(--gray-800); margin-top: 1.25rem; margin-bottom: 0.4rem; }
.output-result h4 { font-size: 0.95rem; font-weight: 700; margin-top: 1rem; margin-bottom: 0.3rem; }
.output-result p { margin-bottom: 0.85rem; }
.output-result ul, .output-result ol { padding-left: 1.5rem; margin-bottom: 0.85rem; }
.output-result li { margin-bottom: 0.3rem; }
.output-result strong { color: var(--gray-900); }
.output-result em { color: var(--gray-600); }
.output-result code { background: var(--gray-100); padding: 0.1rem 0.4rem; border-radius: 4px; font-family: var(--font-mono); font-size: 0.85em; }
.output-result table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; font-size: 0.85rem; }
.output-result th { background: var(--gray-100); font-weight: 700; padding: 0.6rem 0.85rem; border: 1px solid var(--gray-200); text-align: left; }
.output-result td { padding: 0.5rem 0.85rem; border: 1px solid var(--gray-200); }
.output-result tr:nth-child(even) td { background: var(--gray-50); }
.output-result blockquote { border-left: 4px solid var(--structured-300); padding-left: 1rem; color: var(--gray-600); font-style: italic; margin: 1rem 0; }
.output-result hr { border: none; border-top: 2px solid var(--gray-100); margin: 1.5rem 0; }

.output-error {
  padding: 1rem 1.5rem;
  background: var(--critical-50);
  border-top: 1px solid var(--critical-100);
  color: var(--critical-600);
  font-size: 0.875rem;
}

/* Skeleton / loading */
.skeleton-line {
  height: 1em;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  margin-bottom: 0.75rem;
}
.skeleton-line--short { width: 60%; }
.skeleton-line--medium { width: 85%; }
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* =========================================================
   TRANSFORM PAGE
   ========================================================= */
.transform-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  min-height: calc(100vh - 200px);
}
.transform-input-panel {
  background: white;
  border-right: 1px solid var(--gray-200);
  padding: 2rem;
  overflow-y: auto;
}
.transform-output-panel {
  padding: 2rem;
  background: var(--gray-50);
  overflow-y: auto;
}

.transform-lens-selector { display: flex; flex-direction: column; gap: 0.75rem; }
.transform-lens-option {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--gray-200);
  cursor: pointer;
  transition: all var(--transition);
}
.transform-lens-option:hover { border-color: var(--gray-300); background: var(--gray-50); }
.transform-lens-option input { display: none; }
.transform-lens-option__inner { display: flex; align-items: flex-start; gap: 0.85rem; }
.transform-lens-option__icon { font-size: 1.5rem; }
.transform-lens-option__inner p { font-size: 0.82rem; color: var(--gray-500); margin: 0; margin-top: 0.2rem; }
.transform-lens-option--constructionist:has(input:checked) { border-color: var(--constructionist-500); background: var(--constructionist-50); }
.transform-lens-option--critical:has(input:checked) { border-color: var(--critical-500); background: var(--critical-50); }
.transform-lens-option--hybrid:has(input:checked) { border-color: var(--hybrid-500); background: var(--hybrid-50); }

/* Fallback for browsers without :has() */
.transform-lens-option.selected--constructionist { border-color: var(--constructionist-500); background: var(--constructionist-50); }
.transform-lens-option.selected--critical { border-color: var(--critical-500); background: var(--critical-50); }
.transform-lens-option.selected--hybrid { border-color: var(--hybrid-500); background: var(--hybrid-50); }

.transform-lens-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* Lens preview cards */
.lens-preview-cards { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1.5rem; text-align: left; }
.lens-preview-card {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  font-size: 0.82rem;
}
.lens-preview-card strong { display: block; margin-bottom: 0.25rem; font-size: 0.85rem; }
.lens-preview-card p { margin: 0; color: var(--gray-500); line-height: 1.5; }
.lens-preview-card--constructionist { background: var(--constructionist-50); border-color: var(--constructionist-100); }
.lens-preview-card--critical { background: var(--critical-50); border-color: var(--critical-100); }
.lens-preview-card--hybrid { background: var(--hybrid-50); border-color: #ddd6fe; }

/* =========================================================
   OUTPUT STRUCTURE PICKER
   ========================================================= */
.form-section--output-structure { border-top: 2px dashed var(--gray-200); padding-top: 1.5rem; }

.form-section__badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-400);
  background: var(--gray-100);
  border-radius: 20px;
  padding: 0.1rem 0.5rem;
  margin-left: 0.5rem;
  vertical-align: middle;
}

/* Chip row */
.struct-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.struct-chip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  border: 2px solid var(--gray-200);
  background: white;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.struct-chip:hover {
  border-color: var(--gray-400);
  background: var(--gray-50);
}
.struct-chip--active {
  border-color: var(--structured-500);
  background: var(--structured-50);
  color: var(--structured-700);
  font-weight: 600;
}
.struct-chip__icon { font-size: 1rem; line-height: 1; }
.struct-chip__label { white-space: nowrap; }

/* Lens-aware chip active colours */
html[data-lens="constructionist"] .struct-chip--active {
  border-color: var(--constructionist-500);
  background: var(--constructionist-50);
  color: var(--constructionist-900);
}
html[data-lens="critical"] .struct-chip--active {
  border-color: var(--critical-500);
  background: var(--critical-50);
  color: var(--critical-600);
}

/* Preview / edit pane */
.struct-preview {
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  overflow: hidden;
  animation: fadeSlideIn 180ms ease;
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.struct-preview__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
.struct-preview__title { font-size: 0.85rem; font-weight: 700; color: var(--gray-700); }
.struct-preview__hint { font-size: 0.72rem; color: var(--gray-400); }

.struct-preview textarea.form-control--mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.7;
  border: none;
  border-radius: 0;
  padding: 0.85rem 1rem;
  resize: vertical;
  color: var(--gray-700);
  background: white;
}
.struct-preview textarea.form-control--mono:focus {
  border: none;
  box-shadow: none;
  outline: none;
  background: #fefefe;
}

/* =========================================================
   TONE SELECTOR
   ========================================================= */
.form-section--tone {
  border-top: 2px dashed var(--gray-200);
  padding-top: 1.5rem;
}

.tone-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.tone-chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  border: 2px solid var(--gray-200);
  background: white;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
}
.tone-chip:hover {
  border-color: var(--gray-400);
  background: var(--gray-50);
}
.tone-chip--active {
  border-color: #7c3aed;
  background: #f5f3ff;
  color: #5b21b6;
  font-weight: 600;
}
.tone-chip__icon { font-size: 0.95rem; line-height: 1; }

.tone-description {
  font-size: 0.78rem;
  color: var(--gray-400);
  font-style: italic;
  margin: 0;
  min-height: 1.2em;
}

/* =========================================================
   GENERATE PAGE
   ========================================================= */

/* Tab strip */
.gen-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gray-200);
  background: white;
  padding: 0 1.5rem;
}

.gen-tab {
  padding: 0.75rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.gen-tab:hover {
  color: var(--gray-700);
}

.gen-tab--active {
  color: var(--structured-600);
  border-bottom-color: var(--structured-600);
}

/* Outline table */
.outline-table-container {
  overflow-x: auto;
  padding: 1rem;
}

.outline-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.outline-table th {
  background: var(--gray-100);
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-weight: 600;
  border: 1px solid var(--gray-200);
  white-space: nowrap;
}

.outline-table td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-200);
  vertical-align: top;
  line-height: 1.4;
}

.outline-table__module {
  font-weight: 600;
  background: var(--structured-50);
  color: var(--structured-700);
}

.outline-output-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Range inputs (modules / lessons scope) */
.range-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.range-inputs__sep {
  color: var(--gray-400);
  font-weight: 500;
}

.form-control--number {
  width: 4.5rem;
  text-align: center;
}

/* =========================================================
   FOOTER
   ========================================================= */
.footer {
  padding: 1.25rem 2rem;
  background: white;
  border-top: 1px solid var(--gray-200);
  text-align: center;
  font-size: 0.78rem;
  color: var(--gray-400);
}

/* =========================================================
   ERROR PAGE
   ========================================================= */
.error-page {
  text-align: center;
  padding: 5rem 2rem;
}
.error-page h1 { font-family: var(--font-serif); font-size: 2rem; margin-bottom: 1rem; }
.error-page a { color: var(--structured-600); font-weight: 600; text-decoration: underline; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1024px) {
  .studio-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--gray-200); display: flex; gap: 2rem; overflow-x: auto; }
  .studio-workspace { grid-template-columns: 1fr; }
  .studio-form-panel { position: static; max-height: none; }
  .transform-workspace { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .navbar { padding: 0.75rem 1rem; }
  .navbar__lens-toggle { display: none; }
  .page-header { padding: 2rem 1rem; }
  .page-header__title { font-size: 1.8rem; }
  .template-grid { grid-template-columns: 1fr; }
  .template-grid-section { padding: 1.25rem 1rem; }
  .studio-form-panel, .studio-output-panel { padding: 1.25rem 1rem; }
}

/* =========================================================
   LENS-AWARE ACCENTS (data-lens on <html>)
   ========================================================= */
html[data-lens="constructionist"] .form-control:focus {
  border-color: var(--constructionist-500);
  box-shadow: 0 0 0 3px rgba(245,158,11,.1);
}
html[data-lens="critical"] .form-control:focus {
  border-color: var(--critical-500);
  box-shadow: 0 0 0 3px rgba(244,63,94,.1);
}
html[data-lens="constructionist"] .page-header {
  background: linear-gradient(135deg, var(--constructionist-900) 0%, var(--constructionist-600) 100%);
}
html[data-lens="critical"] .page-header {
  background: linear-gradient(135deg, var(--critical-900) 0%, var(--critical-600) 100%);
}
