/* Shared styles for all course pages */

/* ─── Design tokens ──────────────────────────────────────────── */
:root {
  /* Raw palette — used by flash messages only */
  --color-blue-50:   #eff6ff;
  --color-blue-600:  #1d4ed8;
  --color-blue-200:  #bfdbfe;
  --color-green-50:  #f0fdf4;
  --color-green-700: #15803d;
  --color-green-200: #bbf7d0;
  --color-red-50:    #fef2f2;
  --color-red-700:   #b91c1c;
  --color-red-200:   #fecaca;

  /* Semantic tokens — light mode */
  --color-accent:           #A78BFA; /* decorative only — ++ logo, highlights */
  --color-link:             #6D28D9; /* all hyperlinks */
  --color-heading:          #334155; /* h1–h4 */
  --color-body:             #475569; /* paragraphs, body copy */
  --color-muted:            #94A3B8; /* decorative muted — timestamps, UI chrome */
  --color-muted-functional: #64748B; /* functional muted — hints, status, labels */
  --color-bg:               #F8F9FB; /* page background */
  --color-surface:          #FFFFFF; /* cards, modals, panels */
  --color-border:           #E2E8F0; /* dividers, card borders */

  /* Flash message colors */
  --flash-notice-bg:     var(--color-blue-50);
  --flash-notice-text:   var(--color-blue-600);
  --flash-notice-border: var(--color-blue-200);
  --flash-success-bg:     var(--color-green-50);
  --flash-success-text:   var(--color-green-700);
  --flash-success-border: var(--color-green-200);
  --flash-error-bg:     var(--color-red-50);
  --flash-error-text:   var(--color-red-700);
  --flash-error-border: var(--color-red-200);
  --flash-default-bg:     var(--color-bg);
  --flash-default-text:   var(--color-body);
  --flash-default-border: var(--color-border);

  /* Auth modal */
  --auth-modal-bg:    var(--color-surface);
  --auth-input-border: var(--color-border);
  --auth-input-bg:    var(--color-surface);
  --auth-btn-bg:      #1a1a1a;
  --auth-btn-text:    #ffffff;
  --auth-btn-hover:   #374151;
}

html.dark {
  /* Raw palette — flash messages dark mode */
  --color-blue-50:   #1e3a5f;
  --color-blue-600:  #93c5fd;
  --color-blue-200:  #1e40af;
  --color-green-50:  #14532d;
  --color-green-700: #86efac;
  --color-green-200: #166534;
  --color-red-50:    #450a0a;
  --color-red-700:   #fca5a5;
  --color-red-200:   #7f1d1d;

  /* Semantic tokens — dark mode */
  --color-accent:           #A78BFA;
  --color-link:             #A78BFA;
  --color-heading:          #F1F5F9;
  --color-body:             #CBD5E1;
  --color-muted:            #94A3B8;
  --color-muted-functional: #94A3B8;
  --color-bg:               #1E1E2E;
  --color-surface:          #252537;
  --color-border:           #334155;

  /* Auth modal dark */
  --auth-btn-bg:    #e5e5e5;
  --auth-btn-text:  #1a1a1a;
  --auth-btn-hover: #d1d5db;
}

/* ─── Base ───────────────────────────────────────────────────── */
html {
  background-color: var(--color-bg);
  transition: background-color 0.3s ease;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--color-body);
  background-color: var(--color-bg);
  transition: color 0.3s ease, background-color 0.3s ease;
}

section {
  margin: 25px 0;
}

/* ─── Typography ─────────────────────────────────────────────── */
h1 {
  font-size: 2.25rem;
  line-height: 2.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--color-heading);
}

h2 {
  font-size: 1.5rem;
  line-height: 2rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--color-heading);
}

h3 {
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--color-heading);
}

h4 {
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: var(--color-heading);
}

p {
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}

ul {
  list-style-type: none;
  padding-left: 0;
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}

li {
  padding-left: 1.5rem;
  margin-bottom: 0.25rem;
}

/* Markdown content: restore real list rendering inside .prose — the bare
   ul reset above is for chrome/nav lists, not article bodies. */
.prose ul,
.prose ol {
  padding-left: 1.5rem;
}
.prose ul { list-style-type: disc; }
.prose ol { list-style-type: decimal; }
.prose ul ul { list-style-type: circle; }
.prose li {
  padding-left: 0.25rem;
  margin-bottom: 0.375rem;
}

/* Markdown tables. Redcarpet emits a bare <table>, so everything below is
   the whole visual treatment. Scrolls horizontally rather than overflowing
   on narrow screens. */
.prose table {
  display: block;
  overflow-x: auto;
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.prose th,
.prose td {
  padding: 0.625rem 0.875rem;
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--color-border);
}

.prose th {
  background: var(--color-bg);
  color: var(--color-heading);
  font-weight: 600;
}

.prose td { color: var(--color-body); }

.prose tbody tr:nth-child(even) td { background: var(--color-bg); }

/* ─── Links ──────────────────────────────────────────────────── */
a:not(h1 a):not(h2 a):not(h3 a):not(h4 a):not(h5 a):not(h6 a):not(.text-white):not(.btn) {
  color: var(--color-link);
}

h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
  color: inherit;
}

a:not(.btn):hover {
  color: var(--color-link);
  text-decoration: underline;
}

/* ─── Theme toggle ───────────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

html.dark .theme-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
}

.theme-toggle:hover svg {
  transform: scale(1.1);
}

.sun-icon  { display: block; color: #f59e0b; }
.moon-icon { display: none;  color: #6366f1; }
html.dark .sun-icon  { display: none; }
html.dark .moon-icon { display: block; color: #818cf8; }

/* ─── Logo light/dark toggle ─────────────────────────────────── */
.logo-light-mode { display: block; }
.logo-dark-mode  { display: none; }
html.dark .logo-light-mode { display: none; }
html.dark .logo-dark-mode  { display: block; }

/* ─── Utility ────────────────────────────────────────────────── */
.text-subtle {
  color: var(--color-muted-functional);
}

/* ─── Flash messages ─────────────────────────────────────────── */
.flash-notice  { background-color: var(--flash-notice-bg);  color: var(--flash-notice-text);  border: 1px solid var(--flash-notice-border); }
.flash-success { background-color: var(--flash-success-bg); color: var(--flash-success-text); border: 1px solid var(--flash-success-border); }
.flash-error   { background-color: var(--flash-error-bg);   color: var(--flash-error-text);   border: 1px solid var(--flash-error-border); }
.flash-default { background-color: var(--flash-default-bg); color: var(--flash-default-text); border: 1px solid var(--flash-default-border); }

/* ─── Auth modal ─────────────────────────────────────────────── */
.auth-modal-container {
  background-color: var(--auth-modal-bg);
  color: var(--color-body);
}

.auth-input {
  background-color: var(--auth-input-bg);
  border: 1px solid var(--auth-input-border);
  color: var(--color-body);
  width: 100%;
  border-radius: 0.25rem;
  padding: 0.5rem 0.75rem;
}

.auth-input:focus {
  outline: none;
  border-color: var(--color-link);
}

.auth-btn {
  background-color: var(--auth-btn-bg);
  color: var(--auth-btn-text);
  width: 100%;
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
  border: none;
  cursor: pointer;
  font-weight: 500;
}

.auth-btn:hover    { background-color: var(--auth-btn-hover); }
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-link       { color: var(--color-muted-functional); }
.auth-link:hover { color: var(--color-body); }

.auth-close-btn       { color: var(--color-muted-functional); }
.auth-close-btn:hover { color: var(--color-body); }

/* ─── Pro badge ──────────────────────────────────────────────── */
.pro-badge {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  vertical-align: middle;
  margin-left: 0.35rem;
}

html.dark .pro-badge {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

/* ─── Pro locked content ─────────────────────────────────────── */
.pro-locked-content {
  background-color: #fef3c7;
  border: 2px solid #f59e0b;
  border-radius: 0.5rem;
  padding: 2rem;
  text-align: center;
  margin: 2rem 0;
}

html.dark .pro-locked-content {
  background-color: #292524;
  border-color: #d97706;
}

.pro-locked-message h2 { color: #92400e; margin-top: 0; margin-bottom: 1rem; }
html.dark .pro-locked-message h2 { color: #fbbf24; }

.pro-locked-message p { color: #78350f; margin-bottom: 1.5rem; }
html.dark .pro-locked-message p { color: #fde68a; }

.pro-upgrade-button {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 0.375rem;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pro-upgrade-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
  color: white;
}

/* ─── Lesson cards grid ──────────────────────────────────────── */
.lesson-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (min-width: 768px) {
  .lesson-cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

/* ─── Lesson thumbnail animation ─────────────────────────────── */
.lesson-thumbnail-wrapper {
  display: inline-block;
  position: relative;
  width: 80px;
  height: 45px;
  vertical-align: middle;
  margin-right: 8px;
}

.lesson-thumbnail-wrapper .lesson-thumbnail,
.lesson-thumbnail-wrapper .lesson-thumbnail-animation {
  position: absolute;
  top: 0; left: 0;
  width: 80px; height: 45px;
  object-fit: cover;
  border-radius: 4px;
  transition: opacity 0.2s ease;
}

.lesson-thumbnail-wrapper .lesson-thumbnail           { opacity: 1; }
.lesson-thumbnail-wrapper .lesson-thumbnail-animation { opacity: 0; }

/* Fade the still out only when there is an animation to fade in. A lesson
   without a video has no animation, and hiding its still left an empty box —
   which only became possible once courses served their own thumbnails, since
   before that a still implied a video. */
.lesson-thumbnail-wrapper:has(.lesson-thumbnail-animation):hover .lesson-thumbnail,
.lesson-thumbnail-wrapper:has(.lesson-thumbnail-animation).active .lesson-thumbnail { opacity: 0; }

.lesson-thumbnail-wrapper:hover .lesson-thumbnail-animation,
.lesson-thumbnail-wrapper.active .lesson-thumbnail-animation { opacity: 1; }

/* ─── Lesson cards ───────────────────────────────────────────── */
.lesson-card-thumbnail  { opacity: 1; }
.lesson-card-animation  { opacity: 0; }

/* Same guard as the list above: no animation, no fade-out. */
.lesson-card:has(.lesson-card-animation):hover .lesson-card-thumbnail { opacity: 0; }
.lesson-card:hover .lesson-card-animation { opacity: 1; }
.lesson-card-play-icon  { display: none; }

.lesson-card:hover {
  outline: 3px solid var(--color-accent);
}

/* ─── Breadcrumbs ────────────────────────────────────────────── */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: var(--color-muted);
  margin-bottom: 1.5rem;
}

.breadcrumbs a {
  color: var(--color-muted);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--color-body);
  text-decoration: none;
}

.breadcrumb-separator { opacity: 0.4; }

.breadcrumb-current { color: var(--color-heading); }

/* ─── Shared list item styles (modules + lessons) ────────────── */
.list-item-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-heading);
  text-decoration: none;
  line-height: 1.4;
}

.list-item-blurb {
  font-size: 1rem;
  color: var(--color-muted-functional);
  margin-bottom: 0.5rem;
}

.list-item-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--color-muted);
}

.list-item-index {
  font-size: 0.875rem;
  color: var(--color-muted);
}

.lesson-list-item:hover .list-item-title {
  color: var(--color-link);
}

/* ─── Lesson list ────────────────────────────────────────────── */
.lesson-list {
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.lesson-list-item {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.lesson-list-item:first-child {
  border-top: none;
}

.lesson-list-item:hover {
  background: var(--color-bg);
}

/* ─── Curriculum tree ────────────────────────────────────────── */
.curriculum-module {
  padding: 1.25rem 0;
  border-top: 1px solid var(--color-border);
}

.curriculum-module:last-child {
  border-bottom: 1px solid var(--color-border);
}

.curriculum-chapter {
  margin: 0.75rem 0 0.25rem 1rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--color-border);
}

.curriculum-lesson {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 0 0.2rem 1rem;
}

/* ─── Module show stats ──────────────────────────────────────── */
.module-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--color-muted-functional);
  margin-bottom: 1.5rem;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 600;
  font-size: 15px;
  padding: 11px 22px;
  border-radius: 8px;
  letter-spacing: 0.01em;
  transition: background 150ms ease;
  text-decoration: none;
  cursor: pointer;
  border: none;
}

/* Primary — same in light and dark */
.btn-primary             { background: #6D28D9; color: #FFFFFF; }
.btn-primary:hover       { background: #5B21B6; color: #FFFFFF; text-decoration: none; }

/* Secondary */
.btn-secondary           { background: #EDE9FE; color: #6D28D9; }
.btn-secondary:hover     { background: #DDD6FE; color: #6D28D9; text-decoration: none; }

html.dark .btn-secondary       { background: #2D2B55; color: #C4B5FD; }
html.dark .btn-secondary:hover { background: #3B3870; color: #C4B5FD; }

/* Ghost */
.btn-ghost           { background: transparent; color: var(--color-heading); border: 1.5px solid var(--color-border); }
.btn-ghost:hover     { background: #F1F5F9; color: var(--color-heading); text-decoration: none; }

html.dark .btn-ghost       { background: transparent; color: var(--color-body); border: 1.5px solid var(--color-border); }
html.dark .btn-ghost:hover { background: #1E2A3A; color: var(--color-body); }

/* ─── Inline code ────────────────────────────────────────────── */
:not(pre) > code {
  background-color: #272822;
  color: #f8f8f2;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-size: 0.875em;
}

/* ─── Lesson prev/next navigation ────────────────────────────── */
.lesson-nav {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.lesson-nav-prev,
.lesson-nav-next { flex: 1 1 0; min-width: 0; }
.lesson-nav-next { text-align: right; }

.lesson-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  background: var(--color-surface);
  text-decoration: none;
  height: 100%;
}

.lesson-nav-link:hover { border-color: var(--color-link); }

.lesson-nav-direction {
  font-size: 0.75rem;
  color: var(--color-muted-functional);
}

.lesson-nav-title {
  font-weight: 500;
  color: var(--color-link);
  overflow-wrap: anywhere;
}

.lesson-nav-position {
  align-self: center;
  flex: 0 0 auto;
  font-size: 0.75rem;
  color: var(--color-muted-functional);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .lesson-nav { flex-wrap: wrap; }
  .lesson-nav-prev,
  .lesson-nav-next { flex: 1 1 100%; text-align: left; }
  .lesson-nav-position { order: 3; margin: 0 auto; }
}

/* ─── Obfuscated preview of a locked lesson ──────────────────── */
.lesson-preview {
  position: relative;
  margin-top: 2rem;
  max-height: 32rem;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

/* Fade the tail so it reads as "there is more" rather than "it ends here". */
.lesson-preview::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 12rem;
  background: linear-gradient(to bottom, transparent, var(--color-bg));
  pointer-events: none;
}

.lesson-preview-cta {
  display: flex;
  justify-content: center;
  margin: -2rem 0 2rem;
  position: relative;
  z-index: 1;
}

/* ─── Reduced motion ─────────────────────────────────────────────
   Honour the OS/browser setting. Two reasons, and the second is not
   incidental: motion is a genuine accessibility problem for people with
   vestibular disorders, and it is also what made the auth system tests flaky.
   Capybara asserts a class has landed and interacts immediately, while the
   element is still mid-transition — Chrome then hands back a node that has
   been re-laid-out, and the driver raises "Node with given id does not belong
   to the document". The suite runs Chrome with --force-prefers-reduced-motion,
   so this rule makes those tests deterministic instead of merely retried. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/* ── Avatars + profiles ─────────────────────────────────────────────────
   An avatar is a coloured circle with the name's first letter; the colour is
   set inline from the user's palette choice. */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: #475569;
  color: #fff;
  font-weight: 600;
  line-height: 1;
  user-select: none;
}
.profile-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.profile-name { margin: 0; font-size: 1.25rem; font-weight: 700; color: var(--color-heading); }
h1.profile-name { font-size: 1.75rem; }
.profile-bio { white-space: pre-wrap; overflow-wrap: anywhere; }
.profile-form__row { margin: 0 0 1.25rem; border: 0; padding: 0; }
.profile-form__row > label, .profile-form__row > legend { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.375rem; color: var(--color-heading); }
.profile-form__check { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; color: var(--color-heading); cursor: pointer; }
.profile-form__hint { font-size: 0.8125rem; color: var(--color-muted-functional); margin: 0.375rem 0 0; }
.profile-swatches { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.profile-swatch input { position: absolute; opacity: 0; pointer-events: none; }
.profile-swatch span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 999px;
  color: #fff; font-weight: 600; cursor: pointer;
  outline: 3px solid transparent; outline-offset: 2px;
}
.profile-swatch input:checked + span { outline-color: var(--color-heading); }
.profile-swatch input:focus-visible + span { outline-color: var(--color-link); }

/* ── Comments module ────────────────────────────────────────────────────
   Markup comes from comments/_pane.html.erb and comments_controller.js. */
.cmt-layout { position: relative; }
.cmt-pane { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--color-border); }
.cmt-pane__title { font-size: 1.125rem; font-weight: 700; margin: 0 0 0.25rem; color: var(--color-heading); }
.cmt-pane__hint, .cmt-pane__empty { font-size: 0.8125rem; color: var(--color-muted-functional); margin: 0 0 0.75rem; }
.cmt-pane kbd { font: inherit; padding: 0 0.25rem; border: 1px solid var(--color-border); border-radius: 4px; }
/* The shortcut is meaningless on touch devices. */
@media (hover: none) { .cmt-pane__shortcut { display: none; } }

/* Wide screens: pane beside the post once there is something in it. */
@media (min-width: 1024px) {
  .cmt-layout--open {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 19rem;
    gap: 2.5rem;
    align-items: start;
  }
  .cmt-layout--open .cmt-pane {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
}

mark.cmt-mark {
  background: rgba(250, 204, 21, 0.32);
  color: inherit;
  border-radius: 2px;
  cursor: pointer;
}
mark.cmt-mark--active { background: rgba(250, 204, 21, 0.7); }
mark.cmt-mark--pending { background: rgba(167, 139, 250, 0.4); cursor: default; }
html.dark mark.cmt-mark { background: rgba(250, 204, 21, 0.22); }
html.dark mark.cmt-mark--active { background: rgba(250, 204, 21, 0.45); }

.cmt-thread {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
}
.cmt-thread--active { border-color: var(--color-link); box-shadow: 0 4px 14px rgba(109, 40, 217, 0.12); }
.cmt-quote {
  margin: 0 0 0.625rem;
  padding-left: 0.625rem;
  border-left: 3px solid rgba(250, 204, 21, 0.9);
  font-size: 0.8125rem;
  color: var(--color-muted-functional);
  overflow-wrap: anywhere;
}
.cmt-detached { font-size: 0.75rem; font-style: italic; color: var(--color-muted-functional); margin: 0 0 0.5rem; }
.cmt-comment { display: flex; gap: 0.5rem; margin-bottom: 0.625rem; }
.cmt-avatar { width: 28px; height: 28px; font-size: 0.8125rem; }
.cmt-comment__main { min-width: 0; flex: 1; }
.cmt-comment__head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.375rem; }
.cmt-name { font-size: 0.8125rem; font-weight: 600; color: var(--color-heading); overflow-wrap: anywhere; }
a.cmt-name:hover { text-decoration: underline; }
/* Signed-out readers don't get private commenters' names — a grey bar stands in. */
.cmt-name--hidden { display: inline-block; width: 5rem; height: 0.625rem; border-radius: 999px; background: var(--color-border); }
.cmt-time { font-size: 0.75rem; color: var(--color-muted); }
.cmt-comment__actions { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.25rem; }
.cmt-action { font-size: 0.75rem; color: var(--color-muted-functional); background: none; border: 0; padding: 0; cursor: pointer; }
.cmt-action:hover:not(:disabled) { text-decoration: underline; }
.cmt-action:disabled { cursor: default; }
.cmt-like { font-size: 0.875rem; line-height: 1; }
.cmt-like:hover:not(:disabled) { text-decoration: none; color: #DB2777; }
.cmt-like--on, .cmt-like:disabled { color: #DB2777; }
/* The comment a shared link points at. */
.cmt-comment--target { background: rgba(250, 204, 21, 0.18); border-radius: 8px; box-shadow: 0 0 0 6px rgba(250, 204, 21, 0.18); }

/* "Hide comments" / "Show comments" switch above the post. */
.cmt-toolbar { display: flex; justify-content: flex-end; grid-column: 1 / -1; margin-bottom: 0.5rem; }
.cmt-toggle { font-size: 0.8125rem; color: var(--color-muted-functional); background: none; border: 1px solid var(--color-border); border-radius: 999px; padding: 0.25rem 0.75rem; cursor: pointer; }
.cmt-toggle:hover { color: var(--color-heading); border-color: var(--color-muted); }
/* Post only: as if comments didn't exist. */
.cmt-layout.cmt-layout--hidden { display: block; }
.cmt-layout--hidden .cmt-pane { display: none; }
.cmt-layout--hidden mark.cmt-mark { background: none; cursor: auto; }
.cmt-body { margin: 0.125rem 0 0; font-size: 0.875rem; line-height: 1.5; color: var(--color-body); white-space: pre-wrap; overflow-wrap: anywhere; }

.cmt-input {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-body);
  resize: vertical;
}
.cmt-input:focus { outline: 2px solid var(--color-link); outline-offset: 0; }
.cmt-reply__extras { margin-top: 0.5rem; }
.cmt-reply__extras .cmt-input { margin-bottom: 0.5rem; }
.cmt-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
.cmt-btn { width: auto; padding: 0.375rem 0.875rem; font-size: 0.8125rem; border-radius: 8px; cursor: pointer; }
.cmt-btn--ghost { background: none; border: 0; color: var(--color-muted-functional); }
.cmt-btn--ghost:hover { text-decoration: underline; }
.cmt-error { font-size: 0.8125rem; color: #DC2626; margin: 0 0 0.5rem; }

/* Floating "Comment" button under a selection, and the composer / prompts. */
.cmt-fab {
  position: absolute;
  z-index: 40;
  padding: 0.3125rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  background: #6D28D9;
  border: 0;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}
.cmt-fab:hover { background: #5B21B6; }
.cmt-fab[hidden] { display: none; }
.cmt-popover {
  position: absolute;
  z-index: 41;
  width: 20rem;
  max-width: calc(100vw - 16px);
  padding: 0.875rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.cmt-popover .cmt-input { margin-bottom: 0.5rem; }
.cmt-who { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.cmt-popover__title { font-weight: 700; color: var(--color-heading); margin: 0 0 0.25rem; }
.cmt-popover__text { font-size: 0.875rem; color: var(--color-body); margin: 0 0 0.75rem; }
/* Small screens: a bottom sheet instead of a popover that could land off-screen. */
@media (max-width: 640px) {
  .cmt-popover {
    position: fixed;
    top: auto !important;
    left: 0 !important;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    border-radius: 12px 12px 0 0;
  }
}
