/* ===================================================================
   Prompt Engineering Tutorial (TH) — stylesheet
   Design: indigo primary, warm orange accent, IBM Plex Sans Thai
   =================================================================== */

:root {
  /* color palette */
  --bg: #f6f6fb;
  --bg-elevated: #ffffff;
  --bg-soft: #fafafe;
  --bg-tint: #f1f1fa;
  --bg-deep: #0e0a26;
  --bg-deeper: #08061a;

  --primary: #6366f1;
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --primary-500: #6366f1;
  --primary-600: #4f46e5;
  --primary-700: #4338ca;
  --primary-glow: rgba(99, 102, 241, 0.35);

  --accent: #fb923c;
  --accent-500: #f97316;
  --accent-600: #ea580c;
  --accent-glow: rgba(251, 146, 60, 0.35);

  --success: #10b981;
  --success-50: #ecfdf5;
  --success-700: #047857;
  --error: #ef4444;
  --error-50: #fef2f2;
  --error-700: #b91c1c;
  --warning: #f59e0b;
  --warning-50: #fffbeb;
  --warning-700: #b45309;

  --text: #0f172a;
  --text-strong: #020617;
  --text-muted: #64748b;
  --text-soft: #94a3b8;
  --text-on-dark: #f1f5f9;
  --text-on-dark-muted: #cbd5e1;

  --border: #e5e7eb;
  --border-soft: #eef0f4;
  --border-strong: #d1d5db;

  --code-bg: #0f0c2a;
  --code-bg-soft: #1a1740;
  --code-text: #e0e7ff;
  --code-comment: #818cf8;

  /* spacing */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-2xl: 32px;

  /* shadows */
  --sh-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --sh-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --sh-lg: 0 12px 32px rgba(15, 23, 42, 0.10), 0 4px 8px rgba(15, 23, 42, 0.04);
  --sh-xl: 0 24px 64px rgba(15, 23, 42, 0.16);
  --sh-glow: 0 0 0 4px var(--primary-glow);

  /* type */
  --font-th: "IBM Plex Sans Thai", "Sarabun", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* =============== reset & base =============== */

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-th);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary-600); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }

code, pre, .mono { font-family: var(--font-mono); }

p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.5em; }
li { margin-bottom: 0.35em; }

h1, h2, h3, h4 {
  margin: 0 0 0.5em;
  line-height: 1.25;
  color: var(--text-strong);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* =============== topnav =============== */

.topnav {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 48px;
  color: var(--text-on-dark);
}

.topnav__brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: opacity 0.15s;
}
.topnav__brand:hover { opacity: 0.85; text-decoration: none; }

.topnav__brand-img {
  height: 38px;
  width: auto;
  object-fit: contain;
  border-radius: 6px;
  display: block;
}

.topnav__links {
  display: flex;
  align-items: center;
  gap: 28px;
}

.topnav__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-on-dark-muted);
  font-size: 14.5px;
  text-decoration: none;
  transition: color 0.15s;
}
.topnav__link:hover { color: white; text-decoration: none; }

.topnav__anthropic {
  opacity: 0.7;
  transition: opacity 0.15s;
}
.topnav__link:hover .topnav__anthropic { opacity: 1; }

/* =============== hero =============== */

.hero {
  position: relative;
  min-height: 92vh;
  background: var(--bg-deep);
  color: var(--text-on-dark);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.hero__bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.45;
  filter: saturate(1.1);
}

.hero__overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at top right, rgba(251, 146, 60, 0.15) 0%, transparent 55%),
    radial-gradient(ellipse at bottom left, rgba(99, 102, 241, 0.30) 0%, transparent 60%),
    linear-gradient(180deg, rgba(8, 6, 26, 0.55) 0%, rgba(14, 10, 38, 0.85) 70%, rgba(14, 10, 38, 0.95) 100%);
}

.hero__content {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 64px 32px;
  max-width: 980px;
  margin: 0 auto;
}

.hero__eyebrow {
  display: inline-block;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-on-dark);
  margin-bottom: 28px;
}

.hero__title {
  font-size: clamp(42px, 7vw, 76px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: white;
  margin-bottom: 24px;
}
.hero__title--gradient {
  background: linear-gradient(135deg, #a5b4fc 0%, #fb923c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero__subtitle {
  font-size: clamp(16px, 2vw, 19px);
  color: var(--text-on-dark-muted);
  max-width: 640px;
  margin: 0 auto 40px;
  line-height: 1.7;
}

.hero__cta {
  display: flex;
  gap: 16px;
  margin-bottom: 64px;
  flex-wrap: wrap;
  justify-content: center;
}

.hero__stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
  width: 100%;
  max-width: 640px;
  padding-top: 32px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.stat__num {
  font-size: 28px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.02em;
}
.stat__lbl {
  font-size: 13px;
  color: var(--text-on-dark-muted);
  letter-spacing: 0.02em;
}

.hero__scroll {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-bottom: 24px;
  font-size: 12px;
  color: var(--text-on-dark-muted);
  letter-spacing: 0.05em;
  animation: bounceY 2.4s ease-in-out infinite;
}
@keyframes bounceY {
  0%, 100% { transform: translateY(0); opacity: 0.6; }
  50% { transform: translateY(6px); opacity: 1; }
}

/* =============== buttons =============== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 14.5px;
  font-weight: 500;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: inherit;
}

.btn--primary {
  background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--primary-glow);
}

.btn--accent {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-600) 100%);
  color: white;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn--accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--accent-glow);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.08);
  color: white;
  border-color: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
}
.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn--secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border);
}
.btn--secondary:hover {
  background: var(--bg-tint);
  border-color: var(--border-strong);
}

.btn--lg {
  padding: 14px 26px;
  font-size: 16px;
}

.btn--sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* =============== app layout =============== */

.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 48px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 64px 48px 96px;
}

/* =============== sidebar =============== */

.sidebar {
  position: sticky;
  top: 24px;
  align-self: start;
  height: calc(100vh - 48px);
  overflow: hidden;
}

.sidebar__inner {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 24px 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-sm);
}

.sidebar__header { margin-bottom: 20px; }
.sidebar__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

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

.progress {
  flex: 1;
  height: 6px;
  background: var(--bg-tint);
  border-radius: 999px;
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 999px;
}
.sidebar__progress-text {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.chaplist {
  flex: 1;
  overflow-y: auto;
  margin: 0 -8px;
  padding: 4px 8px;
}
.chaplist::-webkit-scrollbar { width: 6px; }
.chaplist::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.chap-group { margin-bottom: 16px; }
.chap-group__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 6px 10px;
  margin-bottom: 4px;
}

.chap-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.12s;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  margin-bottom: 2px;
}
.chap-item:hover {
  background: var(--bg-soft);
  border-color: var(--border-soft);
}
.chap-item--active {
  background: var(--primary-50);
  border-color: var(--primary-100);
  color: var(--primary-700);
}
.chap-item--active .chap-item__num {
  background: var(--primary);
  color: white;
}

.chap-item__num {
  flex-shrink: 0;
  width: 24px; height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tint);
  color: var(--text-muted);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
  transition: all 0.15s;
}
.chap-item__title {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}
.chap-item__check {
  flex-shrink: 0;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--success);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
  opacity: 0;
  transform: scale(0.6);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chap-item--done .chap-item__check {
  opacity: 1;
  transform: scale(1);
}

.sidebar__reset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding: 8px 12px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  align-self: flex-start;
}
.sidebar__reset:hover {
  color: var(--error-700);
  border-color: var(--error);
  background: var(--error-50);
}

/* =============== content =============== */

.content { min-width: 0; }

.chapter {
  animation: fadeUp 0.4s ease-out;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.chapter__head {
  margin-bottom: 40px;
}

.chapter__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.badge--primary { background: var(--primary-50); color: var(--primary-700); }
.badge--accent { background: #fff7ed; color: var(--accent-600); }
.badge--success { background: var(--success-50); color: var(--success-700); }
.badge--neutral { background: var(--bg-tint); color: var(--text-muted); }

.chapter__number {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.chapter__title {
  font-size: clamp(32px, 4vw, 44px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.chapter__subtitle {
  font-size: 18px;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0;
  margin-bottom: 20px;
}

.chapter__summary {
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--primary-50) 0%, #fff7ed 100%);
  border: 1px solid var(--primary-100);
  border-radius: var(--r-lg);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
}

/* =============== sections =============== */

.section { margin-bottom: 40px; }
.section + .section { padding-top: 4px; }

.section__title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text-strong);
}

.section__icon {
  flex-shrink: 0;
  width: 28px; height: 28px;
  background: var(--primary-50);
  color: var(--primary-700);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.section--concept .section__icon { background: var(--primary-50); color: var(--primary-700); }
.section--example .section__icon { background: var(--success-50); color: var(--success-700); }
.section--comparison .section__icon { background: #f3e8ff; color: #6d28d9; }
.section--tryit .section__icon { background: #fff7ed; color: var(--accent-600); }
.section--exercise .section__icon { background: var(--accent); color: white; }

.section__body {
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
}
.section__body strong { color: var(--text-strong); font-weight: 600; }
.section__body code {
  background: var(--code-bg-soft);
  color: #c7d2fe;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 0.88em;
  font-weight: 500;
}
.section__body pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 16px 20px;
  border-radius: var(--r-md);
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.6;
  margin: 12px 0;
}
.section__body pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.callout {
  display: flex;
  gap: 12px;
  padding: 14px 18px;
  margin: 16px 0;
  background: #fff7ed;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-size: 15px;
  color: var(--text);
}

.section__description {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* =============== example / playground =============== */

.example-card,
.playground-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--sh-sm);
}
.example-card { margin-top: 12px; }

.playground {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border-soft);
}

.pg-pane {
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  min-height: 100px;
}

.pg-pane__head {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-soft);
}
.pg-pane__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pg-pane__label-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-soft);
}
.pg-pane--system .pg-pane__label-dot { background: var(--primary); }
.pg-pane--user .pg-pane__label-dot { background: var(--accent); }
.pg-pane--prefill .pg-pane__label-dot { background: #a855f7; }
.pg-pane--output .pg-pane__label-dot { background: var(--success); }

.pg-textarea {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  background: transparent;
  color: var(--text);
  min-height: 90px;
}
.pg-textarea::placeholder { color: var(--text-soft); }

.pg-actions {
  padding: 12px 16px;
  background: var(--bg-soft);
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pg-prefill-row {
  background: var(--bg-soft);
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
}
.pg-prefill-row .pg-pane__head {
  padding: 8px 16px;
}
.pg-prefill-row .pg-textarea {
  min-height: 50px;
  background: rgba(168, 85, 247, 0.04);
}

.pg-output {
  border-top: 1px solid var(--border-soft);
  background: var(--bg-soft);
}
.pg-output__head {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-soft);
}
.pg-output__body {
  padding: 16px 20px;
  background: white;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 480px;
  overflow-y: auto;
  min-height: 80px;
  border-top: 1px solid var(--border-soft);
}
.pg-output__body--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  font-family: var(--font-th);
  font-size: 14px;
  font-style: italic;
}
.pg-output__body--loading {
  color: var(--text-muted);
  font-family: var(--font-th);
}

/* rendered markdown output (Thai/English narrative) */
.pg-output__body--rich {
  font-family: var(--font-th);
  font-size: 14.5px;
  line-height: 1.75;
  white-space: normal;
  color: var(--text);
}
.pg-output__body--rich > *:first-child { margin-top: 0; }
.pg-output__body--rich > *:last-child { margin-bottom: 0; }
.pg-output__body--rich p {
  margin: 0 0 12px;
}
.pg-output__body--rich strong {
  font-weight: 600;
  color: var(--text-strong);
}
.pg-output__body--rich em { font-style: italic; }
.pg-output__body--rich ul,
.pg-output__body--rich ol {
  margin: 6px 0 14px;
  padding-left: 26px;
}
.pg-output__body--rich li {
  margin-bottom: 4px;
  line-height: 1.65;
}
.pg-output__body--rich ul li::marker { color: var(--accent); }
.pg-output__body--rich ol li::marker { color: var(--primary); font-weight: 600; }
.pg-output__body--rich .li-body {
  margin-top: 4px;
  margin-bottom: 6px;
  font-weight: 400;
  color: var(--text);
  opacity: 0.92;
}
.pg-output__body--rich h3,
.pg-output__body--rich h4,
.pg-output__body--rich h5,
.pg-output__body--rich h6 {
  margin: 18px 0 8px;
  font-weight: 600;
  color: var(--text-strong);
  line-height: 1.3;
}
.pg-output__body--rich h3 { font-size: 17px; }
.pg-output__body--rich h4 { font-size: 15.5px; }
.pg-output__body--rich h5,
.pg-output__body--rich h6 { font-size: 14.5px; }
.pg-output__body--rich code {
  font-family: var(--font-mono);
  background: var(--code-bg-soft);
  color: #c7d2fe;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 0.85em;
  font-weight: 500;
}
.pg-output__body--rich pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 14px 16px;
  border-radius: 8px;
  margin: 10px 0;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}
.pg-output__body--rich pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  font-weight: 400;
}
.pg-output__body--rich .pg-md-json {
  margin: 0;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 14px 16px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.pg-output__body--rich .pg-md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 16px;
  font-size: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.pg-output__body--rich .pg-md-table thead {
  background: linear-gradient(135deg, var(--primary-50) 0%, #fff7ed 100%);
}
.pg-output__body--rich .pg-md-table th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--primary-700);
  border-bottom: 2px solid var(--primary-100);
  font-size: 13.5px;
}
.pg-output__body--rich .pg-md-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
  color: var(--text);
}
.pg-output__body--rich .pg-md-table tbody tr:last-child td { border-bottom: 0; }
.pg-output__body--rich .pg-md-table tbody tr:nth-child(even) {
  background: var(--bg-soft);
}
.pg-output__body--rich .pg-md-table tbody tr:hover {
  background: var(--primary-50);
}

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--primary-100);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* prefill highlight in output */
.pg-prefill-text {
  background: rgba(168, 85, 247, 0.12);
  border-radius: 3px;
  padding: 1px 0;
}

.pg-note {
  padding: 12px 16px;
  background: #faf5ff;
  border-top: 1px solid #f3e8ff;
  font-size: 14px;
  color: #6d28d9;
  display: flex;
  gap: 8px;
}
.pg-note::before {
  content: "i";
  flex-shrink: 0;
  width: 18px; height: 18px;
  background: #a855f7;
  color: white;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  font-style: italic;
  font-family: serif;
}

/* =============== comparison =============== */

.comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 16px;
}
.comparison__col {
  display: flex;
  flex-direction: column;
}
.comparison__col-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px 8px 0 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  align-self: flex-start;
  margin-bottom: -1px;
}
.comparison__col--bad .comparison__col-label {
  background: var(--error-50);
  color: var(--error-700);
}
.comparison__col--good .comparison__col-label {
  background: var(--success-50);
  color: var(--success-700);
}
.comparison__col-label::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
}
.comparison__col--bad .comparison__col-label::before { background: var(--error); }
.comparison__col--good .comparison__col-label::before { background: var(--success); }

.comparison .playground-card {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.comparison .playground { grid-template-columns: 1fr; }

.comparison__explain {
  margin-top: 16px;
  padding: 14px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  font-size: 14.5px;
  color: var(--text);
}

/* =============== exercise =============== */

.exercise {
  margin-top: 56px;
  padding: 32px;
  background: linear-gradient(135deg, #fff7ed 0%, #fffbeb 100%);
  border: 2px solid #fed7aa;
  border-radius: var(--r-2xl);
  position: relative;
  overflow: hidden;
}
.exercise::before {
  content: "";
  position: absolute;
  top: -100px;
  right: -100px;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}

.exercise__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  position: relative;
}

.exercise__label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--accent);
  color: white;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}
.exercise__label svg { width: 14px; height: 14px; }

.exercise__title {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-600);
  margin-bottom: 12px;
}

.exercise__instruction {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 24px;
}
.exercise__instruction code {
  background: white;
  border: 1px solid #fed7aa;
  color: var(--accent-600);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.9em;
}

.exercise__playground { position: relative; z-index: 1; }
.exercise__playground .playground-card {
  border-color: #fed7aa;
}

.exercise__hint-wrap {
  margin-top: 12px;
}
.exercise__hint-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px dashed var(--accent);
  color: var(--accent-600);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.exercise__hint-btn:hover { background: white; }
.exercise__hint {
  display: none;
  margin-top: 12px;
  padding: 14px 18px;
  background: white;
  border: 1px solid #fed7aa;
  border-radius: var(--r-md);
  font-size: 14px;
  color: var(--text);
}
.exercise__hint--shown { display: block; }

.exercise__feedback {
  margin-top: 16px;
  padding: 16px 20px;
  border-radius: var(--r-md);
  font-size: 14.5px;
  display: none;
  border: 1px solid transparent;
}
.exercise__feedback--shown { display: block; animation: fadeUp 0.3s ease-out; }
.exercise__feedback--pass {
  background: var(--success-50);
  border-color: #a7f3d0;
  color: var(--success-700);
}
.exercise__feedback--fail {
  background: var(--warning-50);
  border-color: #fde68a;
  color: var(--warning-700);
}
.exercise__feedback-title {
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.exercise__feedback-details {
  margin-top: 8px;
  font-size: 13px;
  opacity: 0.9;
}

.exercise--passed {
  background: linear-gradient(135deg, var(--success-50) 0%, #f0fdf4 100%);
  border-color: #a7f3d0;
}
.exercise--passed::before {
  background: radial-gradient(circle, rgba(16, 185, 129, 0.2) 0%, transparent 70%);
}
.exercise--passed .exercise__label {
  background: var(--success);
}
.exercise--passed .exercise__title {
  color: var(--success-700);
}

/* =============== chapter footer nav =============== */

.chap-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}
.chap-nav__btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s;
  flex: 1;
  max-width: 320px;
  cursor: pointer;
}
.chap-nav__btn:hover {
  border-color: var(--primary);
  box-shadow: var(--sh-md);
  text-decoration: none;
  transform: translateY(-2px);
}
.chap-nav__btn--next { margin-left: auto; text-align: right; flex-direction: row-reverse; }
.chap-nav__btn-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}
.chap-nav__btn-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-strong);
  line-height: 1.3;
}
.chap-nav__btn:disabled,
.chap-nav__btn[aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
}

.chap-nav__arrow {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tint);
  border-radius: 50%;
  color: var(--primary-600);
  transition: all 0.15s;
}
.chap-nav__btn:hover .chap-nav__arrow {
  background: var(--primary);
  color: white;
}

/* =============== free playground section =============== */

.freeplay {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-tint) 100%);
  padding: 80px 48px;
  border-top: 1px solid var(--border);
}
.freeplay__inner {
  max-width: 1100px;
  margin: 0 auto;
}
.freeplay__header {
  text-align: center;
  margin-bottom: 32px;
}
.freeplay__title {
  font-size: 36px;
  margin: 12px 0 8px;
}
.freeplay__sub {
  font-size: 17px;
  color: var(--text-muted);
}

/* =============== footer =============== */

.footer {
  background: var(--bg-deeper);
  color: var(--text-on-dark-muted);
  padding: 64px 48px 32px;
  position: relative;
}
.footer::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at top right, rgba(251, 146, 60, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at bottom left, rgba(99, 102, 241, 0.10) 0%, transparent 50%);
  pointer-events: none;
}
.footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  font-size: 14px;
  line-height: 1.7;
  position: relative;
}

.footer__top {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 48px;
  padding-bottom: 40px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.footer__brand {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}
.footer__brand-img {
  max-width: 280px;
  width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
}
.footer__brand-tag {
  margin: 0;
  font-size: 14px;
  color: #c7d2fe;
  font-style: italic;
  letter-spacing: 0.02em;
}
.footer__brand-sub {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-soft);
  letter-spacing: 0.01em;
  line-height: 1.6;
}

.footer__col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.footer__col-title {
  font-size: 12px;
  font-weight: 600;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
}
.footer__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-on-dark-muted);
  font-size: 13.5px;
  text-decoration: none;
  transition: color 0.15s;
  line-height: 1.5;
}
.footer__link:hover { color: white; text-decoration: none; }
.footer__link--static {
  color: var(--text-soft);
  cursor: default;
}
.footer__link--anthropic svg { opacity: 0.8; }
.footer__link--anthropic:hover svg { opacity: 1; }

.footer__bottom {
  padding-top: 24px;
  text-align: center;
}
.footer__bottom p {
  margin: 4px 0;
  font-size: 13px;
  color: var(--text-on-dark-muted);
}
.footer__bottom strong {
  color: white;
  font-weight: 600;
}
.footer__sub {
  font-size: 12px !important;
  color: var(--text-soft) !important;
  max-width: 720px;
  margin: 8px auto 0 !important;
  line-height: 1.6;
}
.footer a { color: #a5b4fc; }
.footer a:hover { color: #c7d2fe; }

/* =============== toasts =============== */

.toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg-deep);
  color: white;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--sh-lg);
  animation: slideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 320px;
}
.toast--error { background: var(--error); }
.toast--success { background: var(--success); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* =============== responsive =============== */

@media (max-width: 980px) {
  .topnav { padding: 16px 24px; }
  .topnav__links { display: none; }
  .topnav__brand-img { height: 32px; }
  .hero__content { padding: 48px 24px; }
  .hero__stats { grid-template-columns: repeat(2, 1fr); gap: 24px; }
  .app {
    grid-template-columns: 1fr;
    gap: 32px;
    padding: 32px 24px 64px;
  }
  .sidebar {
    position: relative;
    top: 0;
    height: auto;
    max-height: none;
  }
  .sidebar__inner { max-height: 360px; }
  .playground { grid-template-columns: 1fr; }
  .comparison { grid-template-columns: 1fr; }
  .freeplay { padding: 56px 24px; }
  .exercise { padding: 24px; }
  .chap-nav { flex-direction: column; }
  .chap-nav__btn { max-width: none; }
  .footer { padding: 48px 24px 24px; }
  .footer__top {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

@media (max-width: 540px) {
  .hero__title { font-size: 36px; }
  .hero__subtitle { font-size: 15px; }
  .hero__cta { flex-direction: column; width: 100%; }
  .hero__cta .btn { width: 100%; justify-content: center; }
  .pg-actions { flex-direction: column; align-items: stretch; }
  .pg-actions .btn { width: 100%; justify-content: center; }
  .chapter__title { font-size: 26px; }
  .exercise { padding: 20px; }
  .exercise__head { flex-direction: column; }
}
