/*
 * Design system for Nusa Talenta.
 * Single-file vanilla CSS (no build step) organized with cascade layers so
 * later layers always win over earlier ones, regardless of selector specificity.
 */

@layer reset, base, layout, components, utilities;

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

  html, body, h1, h2, h3, h4, p, figure, blockquote, dl, dd, ul, ol {
    margin: 0;
  }

  ul[class], ol[class] {
    list-style: none;
    padding: 0;
  }

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

  body {
    min-height: 100dvh;
  }

  img, picture, video {
    display: block;
    max-width: 100%;
  }

  input, button, textarea, select {
    font: inherit;
    color: inherit;
  }

  button {
    cursor: pointer;
  }

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

@layer base {
  :root {
    /* Color palette -- OKLCH: perceptually uniform, easy to tune lightness/chroma independently */
    --color-canvas: oklch(100% 0 0);
    --color-surface: oklch(97.5% 0.004 260);
    --color-surface-hover: oklch(95% 0.006 260);
    --color-border: oklch(90% 0.006 260);
    --color-border-strong: oklch(80% 0.008 260);

    --color-ink: oklch(24% 0.012 260);
    --color-ink-light: oklch(46% 0.014 260);
    --color-ink-faint: oklch(62% 0.012 260);
    --color-ink-inverted: oklch(100% 0 0);

    --color-accent: oklch(52% 0.19 258);
    --color-accent-hover: oklch(45% 0.19 258);
    --color-accent-light: oklch(93% 0.03 258);

    --color-positive: oklch(52% 0.13 152);
    --color-positive-light: oklch(94% 0.05 152);
    --color-negative: oklch(52% 0.19 25);
    --color-negative-light: oklch(94% 0.05 25);
    --color-warning: oklch(62% 0.15 75);
    --color-warning-light: oklch(94% 0.07 80);

    /* Spacing */
    --space-2xs: 0.25rem;
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2.5rem;
    --space-2xl: 4rem;

    /* Type */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --text-small: 0.85rem;
    --text-normal: 1rem;
    --text-medium: 1.1rem;
    --text-large: 1.4rem;
    --text-xlarge: 2rem;

    /* Misc */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 999px;
    --shadow-sm: 0 1px 2px oklch(0% 0 0 / 0.06), 0 1px 1px oklch(0% 0 0 / 0.04);
    --shadow-md: 0 8px 24px oklch(0% 0 0 / 0.08);
    --content-width: 72rem;
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

    --focus-ring-color: var(--color-accent);
    --focus-ring: 2px solid var(--focus-ring-color);
  }

  body {
    font-family: var(--font-sans);
    font-size: var(--text-normal);
    line-height: 1.5;
    color: var(--color-ink);
    background: var(--color-surface);
  }

  h1, h2, h3, h4 {
    line-height: 1.25;
    font-weight: 700;
    color: var(--color-ink);
  }

  h1 { font-size: var(--text-xlarge); }
  h2 { font-size: var(--text-large); margin-top: var(--space-xl); margin-bottom: var(--space-sm); }
  h3 { font-size: var(--text-medium); }

  p { color: var(--color-ink-light); }

  a {
    color: var(--color-accent);
  }

  a:hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
  }

  *:focus-visible {
    outline: var(--focus-ring);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
  }
}

@layer layout {
  .container {
    max-width: var(--content-width);
    margin-inline: auto;
    padding-inline: clamp(var(--space-md), 4vw, var(--space-xl));
  }

  .page {
    padding-block: var(--space-xl);
  }

  .page--narrow {
    max-width: 32rem;
    margin-inline: auto;
    padding-inline: var(--space-md);
  }

  .page--narrow-wide {
    max-width: 48rem;
    margin-inline: auto;
  }

  .site-header {
    background: var(--color-canvas);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 30;
  }

  .site-header__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding-block: var(--space-sm);
  }

  .site-logo {
    font-weight: 800;
    font-size: var(--text-medium);
    color: var(--color-ink);
    letter-spacing: -0.01em;
  }

  .site-logo:hover {
    color: var(--color-ink);
    text-decoration: none;
  }

  .site-logo span {
    color: var(--color-accent);
  }

  .site-nav {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
  }

  .site-nav__links {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
  }

  .site-nav a:not(.btn) {
    color: var(--color-ink-light);
    font-size: var(--text-small);
    font-weight: 600;
  }

  .site-nav a:not(.btn):hover {
    color: var(--color-ink);
    text-decoration: none;
  }

  .site-nav__actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
  }

  .nav-toggle-label {
    display: none;
    font-size: 1.5rem;
    line-height: 1;
    padding: var(--space-2xs) var(--space-xs);
    border-radius: var(--radius-sm);
  }

  .nav-toggle-input {
    display: none;
  }

  .site-footer {
    border-top: 1px solid var(--color-border);
    margin-top: var(--space-2xl);
    padding-block: var(--space-xl);
    color: var(--color-ink-faint);
    font-size: var(--text-small);
  }

  .site-footer__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
  }

  .site-footer a {
    color: var(--color-ink-light);
  }

  @media (max-width: 47.99rem) {
    .nav-toggle-label {
      display: inline-flex;
    }

    .site-nav {
      position: absolute;
      inset-inline: 0;
      top: 100%;
      flex-direction: column;
      align-items: stretch;
      background: var(--color-canvas);
      border-bottom: 1px solid var(--color-border);
      box-shadow: var(--shadow-md);
      padding: var(--space-md);
      display: none;
    }

    .site-nav__links {
      flex-direction: column;
      align-items: stretch;
      gap: 0;
    }

    .site-nav__links a {
      padding-block: var(--space-sm);
      border-bottom: 1px solid var(--color-border);
    }

    .site-nav__actions {
      flex-direction: column;
      align-items: stretch;
      margin-top: var(--space-md);
    }

    .nav-toggle-input:checked ~ .site-nav {
      display: flex;
    }
  }
}

@layer components {
  /* Buttons */
  .btn {
    --btn-bg: var(--color-canvas);
    --btn-color: var(--color-ink);
    --btn-border: var(--color-border-strong);

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: 0.6em 1.2em;
    font-size: var(--text-small);
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid var(--btn-border);
    background: var(--btn-bg);
    color: var(--btn-color);
    transition: filter 0.15s var(--ease-out-expo), background-color 0.15s var(--ease-out-expo), transform 0.1s;
    white-space: nowrap;
  }

  .btn:hover {
    text-decoration: none;
    filter: brightness(0.97);
  }

  .btn:active {
    transform: translateY(1px);
  }

  .btn--primary {
    --btn-bg: var(--color-accent);
    --btn-color: var(--color-ink-inverted);
    --btn-border: var(--color-accent);
  }

  .btn--primary:hover {
    filter: brightness(1.08);
  }

  .btn--danger {
    --btn-bg: var(--color-canvas);
    --btn-color: var(--color-negative);
    --btn-border: var(--color-negative-light);
  }

  .btn--danger:hover {
    --btn-bg: var(--color-negative-light);
  }

  .btn--ghost {
    --btn-bg: transparent;
    --btn-border: transparent;
  }

  .btn--ghost:hover {
    --btn-bg: var(--color-surface-hover);
  }

  .btn--ghost-inverted {
    --btn-bg: transparent;
    --btn-color: var(--color-ink-inverted);
    --btn-border: oklch(100% 0 0 / 0.4);
  }

  .btn--ghost-inverted:hover {
    --btn-bg: oklch(100% 0 0 / 0.12);
  }

  .btn--small {
    padding: 0.4em 0.9em;
    font-size: var(--text-small);
  }

  .btn--block {
    width: 100%;
  }

  .btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
  }

  /* Cards */
  .card {
    background: var(--color-canvas);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
  }

  /* Split layout: branded visual panel + auth form, so auth pages don't
     look like a lonely card floating in empty space on wide screens. */
  .auth-split {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: var(--space-xl);
    align-items: stretch;
    min-height: 32rem;
  }

  .auth-visual {
    background: linear-gradient(135deg, var(--color-accent), oklch(38% 0.17 292));
    color: var(--color-ink-inverted);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl) var(--space-xl);
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .auth-visual__logo {
    font-weight: 800;
    font-size: var(--text-medium);
    opacity: 0.85;
    margin-bottom: var(--space-lg);
  }

  .auth-visual h2 {
    color: var(--color-ink-inverted);
    font-size: var(--text-xlarge);
    margin-bottom: var(--space-lg);
  }

  /* Carousel (auth pages' rotating highlights) */
  .carousel {
    margin-top: var(--space-lg);
  }

  .carousel__track {
    position: relative;
    min-height: 5.5rem;
  }

  .carousel__slide {
    position: absolute;
    inset-inline: 0;
    top: 0;
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s var(--ease-out-expo);
  }

  .carousel__slide.is-active {
    position: relative;
    opacity: 1;
    visibility: visible;
  }

  .carousel__icon {
    font-size: 1.8rem;
    line-height: 1;
  }

  .carousel__slide p {
    color: var(--color-ink-inverted);
    opacity: 0.95;
    font-size: var(--text-medium);
    margin: 0;
  }

  .carousel__dots {
    display: flex;
    gap: var(--space-xs);
    margin-top: var(--space-lg);
  }

  .carousel__dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: oklch(100% 0 0 / 0.35);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
  }

  .carousel__dot:hover {
    background: oklch(100% 0 0 / 0.6);
  }

  .carousel__dot.is-active {
    background: oklch(100% 0 0 / 0.95);
    transform: scale(1.2);
  }

  .auth-split .auth-card {
    margin: auto;
  }

  @media (max-width: 55rem) {
    .auth-split {
      grid-template-columns: 1fr;
      min-height: auto;
    }

    .auth-visual {
      display: none;
    }
  }

  /* Auth-style forms centered in a card */
  .auth-card {
    max-width: 26rem;
    margin-inline: auto;
  }

  .auth-card h1 {
    margin-bottom: var(--space-xs);
  }

  .auth-card__hint {
    margin-bottom: var(--space-lg);
    font-size: var(--text-small);
  }

  .auth-card__footer {
    margin-top: var(--space-lg);
    text-align: center;
    font-size: var(--text-small);
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
  }

  /* Forms */
  .field {
    margin-bottom: var(--space-md);
  }

  .field label {
    display: block;
    margin-bottom: var(--space-2xs);
    font-size: var(--text-small);
    font-weight: 600;
    color: var(--color-ink);
  }

  .field input[type="text"],
  .field input[type="email"],
  .field input[type="password"],
  .field input[type="tel"],
  .field input[type="number"],
  .field input[type="search"],
  .field textarea,
  .field select {
    width: 100%;
    padding: 0.65em 0.85em;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: var(--color-canvas);
    font-size: var(--text-normal);
  }

  .field input:focus,
  .field textarea:focus,
  .field select:focus {
    outline: var(--focus-ring);
    outline-offset: 1px;
    border-color: var(--color-accent);
  }

  .field textarea {
    min-height: 6rem;
    resize: vertical;
  }

  .input-prefix {
    position: relative;
  }

  .input-prefix__label {
    position: absolute;
    left: 0.85em;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-ink-light);
    pointer-events: none;
  }

  .field input[type="text"].input-prefix__field {
    padding-left: 2.5em;
  }

  .field input[type="submit"] {
    width: auto;
  }

  .search-form {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
  }

  .search-form input[type="text"] {
    flex: 1;
    padding: 0.6em 0.9em;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
  }

  .error-messages {
    background: var(--color-negative-light);
    border: 1px solid oklch(85% 0.1 25);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    color: var(--color-negative);
  }

  .error-messages h2 {
    font-size: var(--text-small);
    margin-bottom: var(--space-xs);
  }

  .error-messages ul {
    padding-left: var(--space-md);
    list-style: disc;
  }

  .error-messages li {
    font-size: var(--text-small);
  }

  /* Flash */
  .flash {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--text-small);
    font-weight: 600;
    margin-bottom: var(--space-md);
  }

  .flash--notice {
    background: var(--color-positive-light);
    color: var(--color-positive);
  }

  .flash--alert {
    background: var(--color-negative-light);
    color: var(--color-negative);
  }

  /* Badges */
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    padding: 0.25em 0.7em;
    border-radius: var(--radius-full);
    font-size: var(--text-small);
    font-weight: 600;
    background: var(--color-surface);
    color: var(--color-ink-light);
  }

  .badge--accent {
    background: var(--color-accent-light);
    color: var(--color-accent);
  }

  .badge--positive {
    background: var(--color-positive-light);
    color: var(--color-positive);
  }

  .badge--warning {
    background: var(--color-warning-light);
    color: var(--color-warning);
  }

  /* Course catalog */
  .filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
  }

  .filter-bar a {
    padding: 0.4em 1em;
    border-radius: var(--radius-full);
    background: var(--color-canvas);
    border: 1px solid var(--color-border);
    font-size: var(--text-small);
    font-weight: 600;
    color: var(--color-ink-light);
  }

  .filter-bar a:hover {
    text-decoration: none;
    border-color: var(--color-accent);
  }

  .filter-bar a.is-active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-ink-inverted);
  }

  .course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: var(--space-lg);
  }

  .course-card {
    display: flex;
    flex-direction: column;
    background: var(--color-canvas);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s var(--ease-out-expo), box-shadow 0.15s var(--ease-out-expo);
  }

  .course-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }

  .course-card__cover {
    aspect-ratio: 16 / 9;
    background: var(--color-surface);
    overflow: hidden;
  }

  .course-card__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .course-card__cover--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-ink-faint);
    font-size: 2rem;
  }

  .course-card__body {
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    flex: 1;
  }

  .course-card__title {
    font-size: var(--text-medium);
    font-weight: 700;
    color: var(--color-ink);
  }

  .course-card__title:hover {
    text-decoration: none;
    color: var(--color-accent);
  }

  .course-card__meta {
    font-size: var(--text-small);
    color: var(--color-ink-faint);
  }

  .course-card__footer {
    margin-top: auto;
    padding-top: var(--space-xs);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .price {
    font-weight: 700;
    color: var(--color-ink);
  }

  .price--free {
    color: var(--color-positive);
  }

  .rating {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    font-size: var(--text-small);
    color: var(--color-ink-light);
    font-weight: 600;
  }

  /* Course detail */
  .course-hero {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-xl);
    align-items: start;
  }

  .course-hero__cover {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--color-border);
  }

  .course-sidebar {
    position: sticky;
    top: calc(var(--space-xl) + 3.5rem);
  }

  .course-sidebar .price {
    font-size: var(--text-large);
    display: block;
    margin-bottom: var(--space-md);
  }

  @media (max-width: 55rem) {
    .course-hero {
      grid-template-columns: 1fr;
    }

    .course-sidebar {
      position: static;
    }
  }

  .lesson-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
  }

  .lesson-list__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }

  .lesson-list__item a {
    font-weight: 600;
    color: var(--color-ink);
  }

  .lesson-list__item a:hover {
    color: var(--color-accent);
  }

  .lesson-list__item--locked {
    color: var(--color-ink-faint);
  }

  /* Comments / reviews */
  .comment-list, .review-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
  }

  .comment, .review {
    padding: var(--space-md);
    background: var(--color-canvas);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }

  .comment__meta, .review__meta {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--text-small);
    color: var(--color-ink-faint);
    margin-bottom: var(--space-2xs);
  }

  .comment__author {
    font-weight: 700;
    color: var(--color-ink);
  }

  .empty-state {
    padding: var(--space-xl);
    text-align: center;
    color: var(--color-ink-faint);
    background: var(--color-canvas);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-lg);
  }

  .pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    margin-top: var(--space-xl);
    font-size: var(--text-small);
    color: var(--color-ink-light);
  }

  .pagination a {
    font-weight: 600;
  }

  /* Panel header (page title + primary action) */
  .panel-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
  }

  .panel-header h1 {
    margin-bottom: 0;
  }

  .back-link {
    display: inline-block;
    font-size: var(--text-small);
    font-weight: 600;
    margin-bottom: var(--space-md);
  }

  .divider {
    border: none;
    border-top: 1px solid var(--color-border);
    margin-block: var(--space-xl);
  }

  /* Stat cards (admin/mentor dashboards) */
  .stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
  }

  .stat-card {
    background: var(--color-canvas);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    box-shadow: var(--shadow-sm);
  }

  .stat-card__label {
    font-size: var(--text-small);
    color: var(--color-ink-faint);
    font-weight: 600;
  }

  .stat-card__value {
    font-size: var(--text-large);
    font-weight: 800;
    color: var(--color-ink);
  }

  /* Data tables */
  .table-wrap {
    overflow-x: auto;
    background: var(--color-canvas);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }

  .table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-small);
  }

  .table th, .table td {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--color-border);
  }

  .table th {
    color: var(--color-ink-faint);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.03em;
  }

  .table tbody tr:hover {
    background: var(--color-surface-hover);
  }

  .table tbody tr:last-child td {
    border-bottom: none;
  }

  .table td.is-actions {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
  }

  /* Generic content rows (materi list, kategori list, soal list...) */
  .list-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-canvas);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }

  .list-row + .list-row {
    margin-top: var(--space-xs);
  }

  .list-row__main {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-weight: 600;
  }

  .list-row__actions {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
  }

  .list-rows {
    display: flex;
    flex-direction: column;
  }

  /* Checkbox / inline field */
  .field--checkbox {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
  }

  .field--checkbox label {
    margin-bottom: 0;
  }

  .field--checkbox input {
    width: auto;
  }

  .choice-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-xs) var(--space-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-xs);
  }

  .choice-row input[type="text"] {
    flex: 1;
    padding: 0.65em 0.85em;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: var(--color-canvas);
    color: var(--color-ink);
    font-size: var(--text-normal);
  }

  .choice-row label {
    display: flex;
    align-items: center;
    gap: 0.4em;
    font-size: var(--text-small);
    white-space: nowrap;
    margin-bottom: 0;
  }

  .choice-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8em;
    height: 1.8em;
    flex-shrink: 0;
    border-radius: var(--radius-full);
    background: var(--color-surface);
    font-weight: 700;
    font-size: var(--text-small);
    color: var(--color-ink-light);
  }

  .answer-option .choice-label {
    background: var(--color-canvas);
    border: 1px solid var(--color-border-strong);
  }

  .answer-option:has(input:checked) .choice-label {
    background: var(--color-accent);
    color: var(--color-ink-inverted);
    border-color: var(--color-accent);
  }

  .question-image {
    max-width: 22rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    margin-bottom: var(--space-md);
    overflow: hidden;
  }

  .question-image--small {
    max-width: 12rem;
  }

  .essay-answer-box {
    padding: var(--space-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    white-space: pre-wrap;
  }

  /* Quiz attempt answer options */
  .answer-option {
    display: block;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-xs);
    cursor: pointer;
  }

  .answer-option:has(input:checked) {
    border-color: var(--color-accent);
    background: var(--color-accent-light);
  }

  .answer-option label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
  }

  .answer-option--correct {
    border-color: var(--color-positive);
    background: var(--color-positive-light);
  }

  .answer-option--wrong-pick {
    border-color: var(--color-negative);
    background: var(--color-negative-light);
  }

  .question-block {
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    background: var(--color-canvas);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
  }

  .question-block__title {
    font-weight: 700;
    margin-bottom: var(--space-sm);
  }

  .quiz-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    font-size: var(--text-small);
    color: var(--color-ink-light);
  }

  .quiz-result {
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
  }

  .quiz-result--pass {
    background: var(--color-positive-light);
  }

  .quiz-result--fail {
    background: var(--color-negative-light);
  }

  .quiz-result__score {
    font-size: var(--text-xlarge);
    font-weight: 800;
  }

  /* Certificate */
  .certificate {
    max-width: 42rem;
    margin: var(--space-xl) auto;
    padding: var(--space-2xl) var(--space-xl);
    text-align: center;
    background: var(--color-canvas);
    border: 3px double var(--color-accent);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
  }

  .certificate__eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: var(--text-small);
    color: var(--color-ink-faint);
    font-weight: 700;
  }

  .certificate__name {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--color-ink);
    margin-block: var(--space-md);
  }

  .certificate__course {
    font-size: var(--text-large);
    font-weight: 700;
    color: var(--color-accent);
    margin-bottom: var(--space-lg);
  }

  .certificate__footer {
    margin-top: var(--space-xl);
    font-size: var(--text-small);
    color: var(--color-ink-faint);
  }

  /* Landing page */
  .hero {
    padding-block: var(--space-2xl);
    text-align: center;
  }

  .hero__copy {
    max-width: 40rem;
    margin-inline: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
  }

  .hero h1 {
    font-size: 2.4rem;
    letter-spacing: -0.02em;
  }

  .benefit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: var(--space-lg);
  }

  .benefit-card {
    background: var(--color-canvas);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
  }

  .benefit-card__icon {
    font-size: 1.75rem;
    display: block;
    margin-bottom: var(--space-sm);
  }

  .testimonial-card {
    background: var(--color-canvas);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
  }

  .testimonial-card .rating {
    color: var(--color-accent);
    letter-spacing: 0.15em;
  }

  .cta-band {
    background: linear-gradient(135deg, var(--color-accent), oklch(38% 0.17 292));
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
    color: var(--color-ink-inverted);
  }

  .cta-band h2, .cta-band p {
    color: var(--color-ink-inverted);
  }

  /* Breadcrumb */
  .breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2xs);
    font-size: var(--text-small);
    color: var(--color-ink-faint);
  }

  .breadcrumb a {
    color: var(--color-ink-light);
  }

  /* Reviews */
  .review-card {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--color-canvas);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }

  .review-card__meta {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-bottom: var(--space-2xs);
  }

  .avatar-circle {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--color-accent-light);
    color: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
  }

  /* Progress bar */
  .progress-bar {
    height: 0.4rem;
    border-radius: var(--radius-full);
    background: var(--color-surface);
    overflow: hidden;
  }

  .progress-bar__fill {
    height: 100%;
    background: var(--color-accent);
    border-radius: var(--radius-full);
  }

  /* Lesson navigation */
  .lesson-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-canvas);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }

  .lesson-nav__link {
    font-size: var(--text-small);
    font-weight: 600;
  }

  /* Quiz live timer */
  .quiz-timer {
    padding: var(--space-sm) var(--space-md);
    background: var(--color-warning-light);
    border-radius: var(--radius-md);
  }

  .quiz-timer strong {
    color: var(--color-warning);
  }

  /* Bulk action bar (admin tables) */
  .bulk-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-accent-light);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-md);
  }

  @media print {
    .site-header, .site-footer, .flash, .no-print {
      display: none !important;
    }

    .page {
      padding: 0;
    }
  }
}

@layer utilities {
  .stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
  }

  .cluster {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
  }

  .txt-center { text-align: center; }
  .txt-small { font-size: var(--text-small); }
  .txt-large { font-size: var(--text-large); }
  .txt-muted { color: var(--color-ink-faint); }
  .mt-lg { margin-top: var(--space-lg); }
  .mt-xl { margin-top: var(--space-xl); }
  .mb-lg { margin-bottom: var(--space-lg); }
  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* Dark mode -- redefines the same tokens :root sets in @layer base, kept in
   the last layer so it always wins regardless of specificity. */
[data-theme="dark"] {
  --color-canvas: oklch(23% 0.014 260);
  --color-surface: oklch(17% 0.014 260);
  --color-surface-hover: oklch(27% 0.014 260);
  --color-border: oklch(32% 0.014 260);
  --color-border-strong: oklch(42% 0.016 260);

  --color-ink: oklch(93% 0.006 260);
  --color-ink-light: oklch(76% 0.01 260);
  --color-ink-faint: oklch(56% 0.012 260);
  --color-ink-inverted: oklch(15% 0.01 260);

  --color-accent: oklch(68% 0.17 258);
  --color-accent-hover: oklch(74% 0.17 258);
  --color-accent-light: oklch(26% 0.05 258);

  --color-positive: oklch(68% 0.14 152);
  --color-positive-light: oklch(26% 0.06 152);
  --color-negative: oklch(68% 0.19 25);
  --color-negative-light: oklch(28% 0.07 25);
  --color-warning: oklch(74% 0.13 75);
  --color-warning-light: oklch(28% 0.06 80);

  --shadow-sm: 0 1px 2px oklch(0% 0 0 / 0.3), 0 1px 1px oklch(0% 0 0 / 0.2);
  --shadow-md: 0 8px 24px oklch(0% 0 0 / 0.4);
}
