/* ============================================================================
   RewriteAI - Component System (spec sec35)
   Reusable, theme-aware components built on css/tokens.css.
   Tailwind is used for layout utilities in markup; everything that carries
   color, shape or state lives here so the UI stays consistent.
   ========================================================================== */

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

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

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--primary-soft);
  color: var(--foreground);
}

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

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

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -3rem;
  z-index: 100;
  background: var(--primary);
  color: var(--primary-foreground);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-weight: var(--weight-medium);
  transition: top var(--transition);
}

.skip-link:focus {
  top: var(--space-4);
}

/* --------------------------- Layout helpers ------------------------------ */
.container-page {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

@media (min-width: 640px) {
  .container-page {
    padding-inline: var(--space-6);
  }
}

.section {
  padding-block: var(--space-16);
}

@media (min-width: 768px) {
  .section {
    padding-block: var(--space-16);
  }
}

.section--alt {
  background: var(--background-elevated);
  border-block: 1px solid var(--border);
}

.section-head {
  max-width: 44rem;
  margin-bottom: var(--space-10);
}

.section-head--center {
  margin-inline: auto;
  text-align: center;
}

.eyebrow {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: var(--space-3);
}

.headline {
  font-size: var(--text-3xl);
  line-height: var(--leading-tight);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-4);
}

@media (min-width: 768px) {
  .headline {
    font-size: var(--text-4xl);
  }
}

.headline--sm {
  font-size: var(--text-2xl);
}

.lede {
  font-size: var(--text-lg);
  color: var(--muted-foreground);
  margin: 0;
}

.text-gradient {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.muted {
  color: var(--muted-foreground);
}

/* Semantic text utilities missing from the tw.css subset. Token-based, so
   they adapt to the active light/dark theme. */
.text-warning {
  color: var(--warning);
}

.text-info {
  color: var(--info);
}

.grid-cards {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .grid-cards--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  .grid-cards--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .grid-cards--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .grid-cards--4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ------------------------------ Buttons ---------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0.625rem 1.125rem;
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1.2;
  cursor: pointer;
  text-align: center;
  transition: background var(--transition), border-color var(--transition),
    color var(--transition), transform var(--transition-fast);
}

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

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--primary-hover);
  color: var(--primary-foreground);
}

.btn--primary:hover:not(:disabled) {
  background: var(--primary-strong);
}

.btn--secondary {
  background: var(--card);
  border-color: var(--border-strong);
  color: var(--foreground);
}

.btn--secondary:hover:not(:disabled) {
  background: var(--card-hover);
  border-color: var(--primary);
}

.btn--ghost {
  background: transparent;
  color: var(--muted-foreground);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--muted);
  color: var(--foreground);
}

.btn--danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn--danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

.btn--sm {
  padding: 0.375rem 0.75rem;
  font-size: var(--text-sm);
}

.btn--lg {
  padding: 0.8125rem 1.5rem;
  font-size: var(--text-md);
  border-radius: var(--radius-lg);
}

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

.btn__spinner {
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--radius-full);
  animation: rw-spin 0.7s linear infinite;
}

/* ------------------------------- Cards ----------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.card--flush {
  padding: 0;
  overflow: hidden;
}

.card--hover {
  transition: border-color var(--transition), background var(--transition),
    transform var(--transition);
}

.card--hover:hover {
  border-color: var(--border-strong);
  background: var(--card-hover);
  transform: translateY(-2px);
}

.card__icon {
  width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 1.25rem;
  margin-bottom: var(--space-4);
}

.card__icon--accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.card__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin: 0 0 var(--space-2);
  letter-spacing: -0.01em;
}

.card__text {
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  margin: 0;
}

.card__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-4);
  color: var(--primary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.card__link:hover {
  text-decoration: underline;
}

/* ------------------------------- Badge ----------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge--neutral {
  background: var(--muted);
  color: var(--muted-foreground);
  border-color: var(--border);
}

.badge--primary {
  background: var(--primary-soft);
  color: var(--primary-on-soft);
}

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

.badge--success {
  background: var(--success-soft);
  color: var(--success-on-soft);
}

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

.badge--danger {
  background: var(--danger-soft);
  color: var(--danger-on-soft);
}

.badge--outline {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--muted-foreground);
}

/* ------------------------------- Forms ----------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--foreground);
}

.field__hint {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

.input,
.textarea,
.select {
  width: 100%;
  background: var(--background-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--foreground);
  font-family: inherit;
  font-size: var(--text-base);
  padding: 0.5625rem 0.75rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted-foreground);
  opacity: 0.75;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.input[readonly] {
  color: var(--muted-foreground);
  background: var(--muted);
}

.textarea {
  resize: vertical;
  min-height: 8rem;
  line-height: var(--leading-normal);
}

.select {
  appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  cursor: pointer;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  cursor: pointer;
  user-select: none;
}

.checkbox-row input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
  cursor: pointer;
}

/* -------------------------------- Tabs ----------------------------------- */
.tabs {
  display: inline-flex;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.tab:hover {
  color: var(--foreground);
}

.tab[aria-selected="true"],
.tab.is-active {
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-sm);
}

.tabpanel[hidden] {
  display: none;
}

/* ------------------------------ Progress --------------------------------- */
.progress {
  width: 100%;
  height: 0.5rem;
  background: var(--muted);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.progress__bar--warning {
  background: var(--warning);
}

.progress__bar--danger {
  background: var(--danger);
}

.progress--indeterminate .progress__bar {
  width: 35%;
  animation: rw-indeterminate 1.4s ease-in-out infinite;
}

@keyframes rw-indeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(320%);
  }
}

/* ------------------------- Loading / state blocks ------------------------ */
.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: rw-spin 0.7s linear infinite;
}

.spinner--lg {
  width: 2rem;
  height: 2rem;
  border-width: 3px;
}

@keyframes rw-spin {
  to {
    transform: rotate(360deg);
  }
}

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-3);
  padding: var(--space-10) var(--space-6);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--background-elevated);
}

.state--plain {
  border: 0;
  background: transparent;
}

.state__icon {
  width: 3rem;
  height: 3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 1.5rem;
}

.state__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin: 0;
}

.state__text {
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  max-width: 32rem;
  margin: 0;
}

.state__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
  margin-top: var(--space-2);
}

.state--error .state__icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.state--loading .state__icon {
  background: transparent;
}

/* ------------------------------- Notices --------------------------------- */
.note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: var(--text-sm);
}

.note--info {
  background: var(--info-soft);
  border-color: transparent;
  color: var(--foreground);
}

.note--warning {
  background: var(--warning-soft);
  border-color: transparent;
  color: var(--foreground);
}

.note i,
.note .ph {
  flex-shrink: 0;
  margin-top: 0.1em;
}

/* ------------------------------ Toasts ----------------------------------- */
.toast-wrap {
  position: fixed;
  bottom: var(--space-4);
  right: var(--space-4);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  max-width: min(24rem, calc(100vw - 2rem));
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--foreground);
  animation: rw-toast-in var(--transition-slow) ease both;
}

.toast--success {
  border-left-color: var(--success);
}

.toast--error {
  border-left-color: var(--danger);
}

.toast i {
  flex-shrink: 0;
}

.toast.is-leaving {
  animation: rw-toast-out var(--transition) ease both;
}

@keyframes rw-toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes rw-toast-out {
  to {
    opacity: 0;
    transform: translateX(12px);
  }
}

/* ------------------------------ Modal ------------------------------------ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: rw-fade var(--transition) ease both;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 28rem;
  max-height: calc(100vh - 2 * var(--space-8));
  overflow-y: auto;
  padding: var(--space-6);
}

.modal__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin: 0 0 var(--space-2);
}

.modal__body {
  color: var(--muted-foreground);
  font-size: var(--text-sm);
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

@keyframes rw-fade {
  from {
    opacity: 0;
  }
}

/* ----------------------------- Dropdown ---------------------------------- */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 60;
  min-width: 11rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-1);
  display: flex;
  flex-direction: column;
}

.dropdown-menu[hidden] {
  display: none;
}

.dropdown-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--foreground);
  font-family: inherit;
  font-size: var(--text-sm);
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.dropdown-item:hover {
  background: var(--muted);
}

.dropdown-item--danger {
  color: var(--danger);
}

.dropdown-sep {
  height: 1px;
  background: var(--border);
  margin: var(--space-1) 0;
}

/* ------------------------------ Navbar ----------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--background) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--container-wide);
  margin-inline: auto;
  padding-inline: var(--space-4);
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

@media (min-width: 640px) {
  .header-inner {
    padding-inline: var(--space-6);
  }
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  color: var(--foreground);
  flex-shrink: 0;
}

.brand img {
  width: 1.75rem;
  height: 1.75rem;
  object-fit: contain;
}

.nav-links {
  display: none;
  align-items: center;
  gap: var(--space-1);
}

@media (min-width: 1024px) {
  .nav-links {
    display: flex;
  }
}

.nav-link {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--muted-foreground);
  transition: color var(--transition), background var(--transition);
}

.nav-link:hover {
  color: var(--foreground);
  background: var(--muted);
}

.nav-link.is-active {
  color: var(--foreground);
}

/* --------------------------- Products dropdown (ZeroGPT-style nav) -------- */
.nav-menu {
  position: relative;
}

.nav-menu__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

/* Chevron drawn in CSS - the icon subset has no caret glyph. */
.nav-menu__chev {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.7;
  transition: transform var(--transition);
}

.nav-menu.is-open .nav-menu__chev {
  transform: rotate(180deg);
}

.nav-menu__panel {
  position: absolute;
  top: calc(100% + 0.6rem);
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 2rem));
  padding: var(--space-3);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  background: var(--background-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  z-index: 60;
}

/* Hover bridge: fills the 0.6rem gap between the trigger and the panel so
   moving the pointer down toward an item never crosses "dead" space, which
   fired mouseleave on the wrap and closed the menu before a click landed. */
.nav-menu__panel::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -0.65rem;
  height: 0.65rem;
}

.nav-menu__panel[hidden] {
  display: none;
}

.nav-product {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-md);
  color: var(--foreground);
  text-decoration: none;
  background: var(--muted);
  border: 1px solid transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.nav-product:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.nav-product.is-current {
  background: var(--primary-soft);
  border-color: var(--primary);
}

/* Flagship tools (Humanizer + AI Detector) are highlighted at rest so the
   main choices stand out from the secondary tools in the panel. */
.nav-product.is-featured {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.nav-product.is-soon {
  opacity: 0.72;
  cursor: default;
}

.nav-product__icon {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--background-elevated);
  border: 1px solid var(--border);
  color: var(--primary-on-soft);
  font-size: 1.05rem;
}

.nav-product.is-featured .nav-product__icon {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.nav-product__body {
  min-width: 0;
}

.nav-product__name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1.3;
}

.nav-product__desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--muted-foreground);
}

.nav-product__badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--muted);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
}

.header-actions {
  display: none;
  align-items: center;
  gap: var(--space-3);
}

@media (min-width: 1024px) {
  .header-actions {
    display: flex;
  }
}

.header-actions .btn {
  padding: 0.5rem 1rem;
  font-size: var(--text-sm);
}

.header-auth-link {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--muted-foreground);
}

.header-auth-link:hover {
  color: var(--foreground);
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--foreground);
  font-size: 1.25rem;
  cursor: pointer;
}

@media (min-width: 1024px) {
  .menu-toggle {
    display: none;
  }
}

.mobile-panel {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--background);
  padding: var(--space-4);
  max-height: calc(100vh - var(--header-height));
  overflow-y: auto;
}

.mobile-panel.is-open {
  display: block;
}

.mobile-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem var(--space-2);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--foreground);
}

.mobile-link:hover,
.mobile-link.is-active {
  background: var(--muted);
}

/* Flagship tools (Humanizer + AI Detector) stay highlighted in the mobile
   menu too, mirroring the desktop dropdown. */
.mobile-link.is-featured {
  background: var(--primary-soft);
}

.mobile-link.is-featured i {
  color: var(--primary);
}

/* Products group inside the mobile panel (mirrors the desktop dropdown). */
.mobile-group-label {
  display: block;
  padding: 0.9rem var(--space-2) 0.3rem;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
}

.mobile-link i {
  margin-right: 8px;
}

.mobile-link.is-soon {
  opacity: 0.72;
  cursor: default;
}

/* ---------------------- Quick tool strip (homepage icon grid) ------------- */
.quick-tools {
  padding-block: var(--space-2) var(--space-6);
}

/* Balanced grid: 12 tools divide evenly into 6 / 4 / 3 columns, so every
   breakpoint renders complete rows. The old flex-wrap row fit 10 tiles on
   the first line and orphaned the last 2, which read as unbalanced. */
.quick-tools__row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4) var(--space-3);
  max-width: 30rem;
  margin-inline: auto;
  list-style: none;
  padding: 0;
}

@media (min-width: 640px) {
  .quick-tools__row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-width: 40rem;
  }
}

@media (min-width: 1024px) {
  .quick-tools__row {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    max-width: 52rem;
  }
}

.quick-tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.25rem;
  text-decoration: none;
  color: var(--muted-foreground);
  border-radius: var(--radius-lg);
  transition: color var(--transition);
}

.quick-tool__disc {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--radius-xl);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  color: var(--primary);
  font-size: 1.6rem;
  transition: transform var(--transition), box-shadow var(--transition),
    background var(--transition), border-color var(--transition),
    color var(--transition);
}

.quick-tool__disc--all {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-on-soft);
}

.quick-tool:hover {
  color: var(--foreground);
}

.quick-tool:hover .quick-tool__disc {
  transform: translateY(-3px);
  background: var(--primary-soft);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  color: var(--primary-on-soft);
}

.quick-tool__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-align: center;
  line-height: 1.25;
  /* Reserve two lines so every disc stays on one baseline even when a label
     wraps ("Paragraph Rewriter") and its neighbors do not ("Humanizer"). */
  min-height: 2.5em;
}

/* --------------------------- Student / Teacher picker (signup) ------------ */
.role-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.role-option {
  position: relative;
  cursor: pointer;
}

.role-option input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

.role-option__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0.9rem 0.6rem;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition), background var(--transition),
    box-shadow var(--transition);
}

.role-option__card .ph {
  font-size: 1.5rem;
  color: var(--primary-on-soft);
}

.role-option__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--foreground);
}

.role-option__desc {
  font-size: var(--text-xs);
  line-height: 1.3;
  color: var(--muted-foreground);
}

.role-option:hover .role-option__card {
  border-color: var(--border-strong);
  background: var(--card-hover);
}

.role-option input:checked + .role-option__card {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.role-option input:focus-visible + .role-option__card {
  box-shadow: var(--focus-ring);
}

/* -------------------- First-login onboarding wizard (dashboard) ----------- */
.onboard {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--space-4);
}

.onboard[hidden] {
  display: none;
}

.onboard__backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
}

.onboard__panel {
  position: relative;
  width: min(560px, 100%);
  max-height: min(90vh, 720px);
  overflow-y: auto;
  padding: var(--space-6);
  background: var(--background-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.onboard__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.onboard__brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: var(--weight-bold);
  color: var(--foreground);
}

.onboard__brand img {
  border-radius: 6px;
}

.onboard__step {
  flex-shrink: 0;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--muted-foreground);
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 3px 10px;
}

.onboard__progress {
  height: 4px;
  background: var(--muted);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-5);
}

.onboard__progress span {
  display: block;
  height: 100%;
  width: 25%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width var(--transition);
}

.onboard__title {
  margin: 0 0 4px;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
  color: var(--foreground);
}

.onboard__sub {
  margin: 0 0 var(--space-5);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--muted-foreground);
}

.onboard__options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.onboard__opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 0.85rem 0.9rem;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition),
    box-shadow var(--transition);
}

.onboard__opt .ph {
  font-size: 1.25rem;
  color: var(--primary-on-soft);
}

.onboard__opt-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--foreground);
}

.onboard__opt-desc {
  font-size: var(--text-xs);
  line-height: 1.35;
  color: var(--muted-foreground);
}

.onboard__opt:hover {
  border-color: var(--border-strong);
  background: var(--card-hover);
}

.onboard__opt.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.onboard__opt:focus-visible {
  box-shadow: var(--focus-ring);
}

.onboard__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

@media (max-width: 480px) {
  .onboard__options {
    grid-template-columns: 1fr;
  }
  .onboard__foot {
    flex-direction: column-reverse;
  }
  .onboard__foot .btn {
    width: 100%;
  }
}

.mobile-panel .btn {
  width: 100%;
  margin-top: var(--space-2);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--foreground);
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border-radius: var(--radius-full);
  background: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer;
}

.avatar {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}

/* ------------------------------ Footer ----------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--background-elevated);
  padding-block: var(--space-12) var(--space-6);
  margin-top: auto;
}

.footer-grid {
  display: grid;
  gap: var(--space-8);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: var(--container-wide);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

@media (min-width: 640px) {
  .footer-grid {
    padding-inline: var(--space-6);
  }
}

@media (min-width: 768px) {
  .footer-grid {
    grid-template-columns: 2fr repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .footer-grid {
    grid-template-columns: 2fr repeat(6, minmax(0, 1fr));
  }
}

.footer-brand {
  grid-column: 1 / -1;
}

@media (min-width: 768px) {
  .footer-brand {
    grid-column: auto;
  }
}

/* Social column needs ~2 columns so all icon buttons fit one row. */
.footer-col--social {
  grid-column: 1 / -1;
}

@media (min-width: 768px) {
  .footer-col--social {
    grid-column: span 2;
  }
}

.footer-brand p {
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  margin: var(--space-3) 0 0;
  max-width: 18rem;
}

.footer-col h3 {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-foreground);
  margin: 0 0 var(--space-4);
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.footer-link {
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  transition: color var(--transition);
}

.footer-link:hover {
  color: var(--foreground);
}

/* Social icons inside footer links (Phosphor). */
.footer-link .ph {
  margin-right: var(--space-1);
  vertical-align: -2px;
}

/* Inline-SVG brand icons (e.g. WhatsApp - not in Phosphor). */
.footer-link .footer-svg {
  margin-right: var(--space-1);
  vertical-align: -2px;
}

/* Social column: compact horizontal row of icon-only round buttons. */
.footer-col ul.footer-socials {
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.footer-social {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted-foreground);
  background: transparent;
  transition: color var(--transition), border-color var(--transition),
    background-color var(--transition), transform var(--transition);
}

.footer-social:hover {
  color: var(--foreground);
  border-color: var(--muted-foreground);
  background: var(--card-hover);
  transform: translateY(-2px);
}

.footer-social:focus-visible {
  outline: 2px solid var(--foreground);
  outline-offset: 2px;
}

.footer-social .ph,
.footer-social .footer-svg {
  font-size: 18px;
  width: 18px;
  height: 18px;
  line-height: 1;
  margin-right: 0;
  vertical-align: baseline;
}

/* Traveling highlight wave across the social buttons (runs only while the
   footer is in the viewport -- toggled by ui.js via IntersectionObserver). */
@keyframes footer-social-glow {
  0%,
  35%,
  100% {
    border-color: var(--border);
    color: var(--muted-foreground);
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
    transform: translateY(0);
  }
  10% {
    border-color: var(--primary);
    color: var(--primary-on-soft);
    box-shadow: 0 0 0 6px var(--primary-soft), 0 0 18px 0 var(--primary-soft);
    transform: translateY(-2px);
  }
}

.footer-socials--live .footer-social {
  animation: footer-social-glow 3.5s ease-in-out infinite;
}

.footer-socials--live li:nth-child(2) .footer-social { animation-delay: 0.5s; }
.footer-socials--live li:nth-child(3) .footer-social { animation-delay: 1s; }
.footer-socials--live li:nth-child(4) .footer-social { animation-delay: 1.5s; }
.footer-socials--live li:nth-child(5) .footer-social { animation-delay: 2s; }
.footer-socials--live li:nth-child(6) .footer-social { animation-delay: 2.5s; }
.footer-socials--live li:nth-child(7) .footer-social { animation-delay: 3s; }

@media (prefers-reduced-motion: reduce) {
  .footer-socials--live .footer-social {
    animation: none;
  }
}

.footer-bottom {
  max-width: var(--container-wide);
  margin: var(--space-10) auto 0;
  padding: var(--space-6) var(--space-4) 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

@media (min-width: 640px) {
  .footer-bottom {
    padding-inline: var(--space-6);
  }
}

/* ------------------------------ Tables ----------------------------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  min-width: 34rem;
}

.table th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--background-elevated);
  white-space: nowrap;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--foreground);
  vertical-align: middle;
}

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

.table tbody tr:hover td {
  background: var(--card-hover);
}

.table__empty td {
  padding: var(--space-10);
  text-align: center;
  color: var(--muted-foreground);
}

.table__actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}

/* --------------------------- Editor / tools ------------------------------ */
.editor-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: 1fr;
}

@media (min-width: 1024px) {
  .editor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.editor-pane {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 20rem;
}

.editor-pane__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--background-elevated);
}

.editor-pane__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  margin: 0;
}

.editor-pane__meta {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

.editor-textarea {
  flex: 1;
  width: 100%;
  border: 0;
  resize: none;
  background: transparent;
  color: var(--foreground);
  font-family: inherit;
  font-size: var(--text-base);
  line-height: 1.65;
  padding: var(--space-4);
  min-height: 15rem;
}

.editor-textarea:focus {
  outline: none;
}

.editor-textarea::placeholder {
  color: var(--muted-foreground);
  opacity: 0.7;
}

.editor-pane__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--background-elevated);
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

.editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  text-align: center;
  padding: var(--space-8) var(--space-4);
}

.editor-empty__title {
  font-weight: var(--weight-semibold);
  margin: 0;
  font-size: var(--text-base);
}

.editor-empty__text {
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  max-width: 24rem;
  margin: 0;
}

.editor-empty__actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: center;
}

.editor-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  text-align: center;
  padding: var(--space-6);
  border-radius: var(--radius-lg);
}

.editor-overlay[hidden] {
  display: none;
}

.editor-shell {
  position: relative;
}

.editor-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.editor-controls .field {
  min-width: 9rem;
  flex: 1 1 9rem;
}

.editor-controls__spacer {
  flex: 1 1 auto;
}

/* --------------------------- Report / stats ------------------------------ */
.report-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .report-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .report-grid--4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.stat-card__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
}

.stat-card__value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  line-height: 1;
}

.stat-card__hint {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

.probability-gauge {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.gauge-ring {
  --value: 0;
  width: 8.5rem;
  height: 8.5rem;
  border-radius: var(--radius-full);
  background: conic-gradient(
    var(--muted) 0deg,
    var(--muted) 360deg
  );
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.gauge-ring::before {
  content: "";
  position: absolute;
  inset: 0.65rem;
  border-radius: var(--radius-full);
  background: var(--card);
}

.gauge-ring__inner {
  position: relative;
  z-index: 1;
  text-align: center;
}

.gauge-ring__value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.03em;
  display: block;
  line-height: 1.1;
}

.gauge-ring__label {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sentence-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 22rem;
  overflow-y: auto;
  padding-right: var(--space-2);
}

.sentence-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--background-elevated);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.sentence-item__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-full);
  background: var(--muted-foreground);
  flex-shrink: 0;
  margin-top: 0.5em;
}

.sentence-item--ai .sentence-item__dot {
  background: var(--warning);
}

.sentence-item--human .sentence-item__dot {
  background: var(--success);
}

.sentence-item__tag {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  white-space: nowrap;
}

.metric-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
}

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  font-size: var(--text-sm);
  padding-bottom: var(--space-3);
  border-bottom: 1px dashed var(--border);
}

.metric-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.metric-row dt {
  color: var(--muted-foreground);
  margin: 0;
}

.metric-row dd {
  margin: 0;
  font-weight: var(--weight-medium);
  text-align: right;
}

/* --------------------------- Pricing cards ------------------------------- */
.pricing-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  gap: var(--space-5);
  height: 100%;
}

.pricing-card.is-featured {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow-md);
}

.pricing-card__badge {
  position: absolute;
  top: -0.7rem;
  left: 50%;
  transform: translateX(-50%);
}

.pricing-card__name {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin: 0;
}

.pricing-card__desc {
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  margin: var(--space-1) 0 0;
}

.price {
  display: flex;
  align-items: baseline;
  gap: var(--space-1);
}

.price__amount {
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.03em;
  line-height: 1;
}

.price__period {
  font-size: var(--text-sm);
  color: var(--muted-foreground);
}

.plan-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  font-size: var(--text-sm);
  flex: 1;
}

.plan-features li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  color: var(--muted-foreground);
}

.plan-features li i,
.plan-features li .ph {
  color: var(--success);
  flex-shrink: 0;
  margin-top: 0.15em;
}

.plan-features li.is-off {
  color: var(--text-disabled);
}

.plan-features li.is-off i,
.plan-features li.is-off .ph {
  color: var(--text-disabled);
}

/* ------------------------------ Sidebar ---------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  display: none;
  flex-direction: column;
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--background-elevated);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

@media (min-width: 768px) {
  .sidebar {
    display: flex;
  }
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-5) var(--space-4);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
}

.sidebar__brand img {
  width: 1.5rem;
  height: 1.5rem;
}

.sidebar__nav {
  flex: 1;
  padding: 0 var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.side-label {
  font-size: 0.6875rem;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-foreground);
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.side-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.5625rem var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--muted-foreground);
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition), color var(--transition);
}

.side-link:hover {
  background: var(--muted);
  color: var(--foreground);
}

.side-link.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

.side-link i,
.side-link .ph {
  font-size: 1.05rem;
  flex-shrink: 0;
}

.side-link__badge {
  margin-left: auto;
}

.side-link.is-soon {
  opacity: 0.6;
  cursor: default;
}

.side-link.is-soon:hover {
  background: transparent;
  color: var(--muted-foreground);
}

.sidebar__foot {
  border-top: 1px solid var(--border);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-user__meta {
  min-width: 0;
  flex: 1;
}

.sidebar-user__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user__email {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile sidebar drawer */
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--foreground);
  font-size: 1.25rem;
  cursor: pointer;
}

@media (min-width: 768px) {
  .sidebar-toggle {
    display: none;
  }
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 60;
}

.sidebar-backdrop[hidden] {
  display: none;
}

@media (min-width: 768px) {
  .sidebar-backdrop {
    display: none !important;
  }
}

.sidebar.is-open {
  display: flex;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 70;
  width: min(18rem, 85vw);
  box-shadow: var(--shadow-lg);
}

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--background-elevated);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin: 0;
}

.main-content {
  padding: var(--space-6) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  max-width: var(--container-max);
  width: 100%;
}

/* --------------------------- Tool / FAQ cards ---------------------------- */
.tool-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  height: 100%;
  transition: border-color var(--transition), transform var(--transition);
}

.tool-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.tool-card.is-soon {
  border-style: dashed;
}

.tool-card.is-soon .tool-card__title {
  color: var(--muted-foreground);
}

.tool-card.is-soon:hover {
  transform: none;
}

.tool-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.tool-card__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  margin: 0;
}

.tool-card__text {
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  margin: 0;
  flex: 1;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 48rem;
  margin-inline: auto;
}

.faq-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.faq-item summary {
  list-style: none;
  cursor: pointer;
  padding: var(--space-4) var(--space-5);
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  font-size: var(--text-lg);
  color: var(--muted-foreground);
  flex-shrink: 0;
  transition: transform var(--transition);
}

.faq-item[open] summary::after {
  transform: rotate(45deg);
}

.faq-item__body {
  padding: 0 var(--space-5) var(--space-5);
  color: var(--muted-foreground);
  font-size: var(--text-sm);
}

.faq-item__body p {
  margin: 0;
}

/* ------------------------------ Steps ------------------------------------ */
.step {
  position: relative;
  padding-top: var(--space-2);
}

.step__num {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--primary);
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: var(--space-3);
}

.step__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin: 0 0 var(--space-2);
}

.step__text {
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  margin: 0;
}

/* --------------------------- Code snippets ------------------------------- */
.code-block {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.code-block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

.code-block pre {
  margin: 0;
  padding: var(--space-4);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.code-block code {
  font-family: inherit;
}

/* --------------------------- Responsive tables --------------------------- */
@media (max-width: 640px) {
  /* Stacked cards must fit the viewport: drop the desktop .table min-width
     (34rem), which would otherwise keep rows wider than the screen and push
     the value/action columns out of view behind a horizontal scrollbar. */
  .table--cards {
    min-width: 0;
  }

  .table--cards thead {
    display: none;
  }

  .table--cards,
  .table--cards tbody,
  .table--cards tr,
  .table--cards td {
    display: block;
    width: 100%;
  }

  .table--cards tr {
    border-bottom: 1px solid var(--border);
    padding: var(--space-3) 0;
  }

  .table--cards tr:last-child {
    border-bottom: 0;
  }

  .table--cards td {
    border: 0;
    padding: var(--space-1) var(--space-4);
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    text-align: right;
  }

  .table--cards td::before {
    content: attr(data-label);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted-foreground);
    text-align: left;
  }

  .table--cards td.table__empty {
    display: block;
    text-align: center;
  }

  .table--cards td.table__empty::before {
    display: none;
  }

  .table__actions {
    justify-content: flex-end;
  }
}

/* --------------------------- Misc utilities ------------------------------ */
.divider {
  height: 1px;
  background: var(--border);
  border: 0;
  margin: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stack--sm {
  gap: var(--space-2);
}

.stack--lg {
  gap: var(--space-6);
}

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

.row--between {
  justify-content: space-between;
}

.row--end {
  justify-content: flex-end;
}

.chip-note {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  background: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-full);
  padding: 0.25rem 0.75rem;
}

/* ---------------------------------------------------------------------------
   Dialog - native <dialog> modal (dashboard API keys: create + show-once).
   showModal() supplies the focus trap, ESC handling and ::backdrop.
   ---------------------------------------------------------------------------- */
.dialog {
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  width: min(34rem, calc(100vw - 2rem));
  max-width: 34rem;
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.dialog .field {
  margin-top: var(--space-2);
}

/* Show-once raw secret: monospace, selectable, wraps on narrow screens. */
.secret-reveal {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  background: var(--muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}

.secret-reveal__value {
  flex: 1 1 16rem;
  min-width: 0;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: var(--text-sm);
  word-break: break-all;
  user-select: all;
}

/* ---------------------------------------------------------------------------
   API key rows (dashboard API tab, sec23): masked prefix, dates, revoke.
   ---------------------------------------------------------------------------- */
.key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
}

.key-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.key-row:first-child {
  padding-top: 0;
}

.key-row__meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.key-row__name {
  font-weight: var(--weight-semibold);
  overflow-wrap: anywhere;
}

.key-row__prefix {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  user-select: all;
}

.key-row__dates {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

.key-row__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}

/* ------------------------------ API banner (ZeroGPT-style) --------------- */
.api-banner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-5);
  padding: var(--space-8);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.api-banner .headline {
  margin: var(--space-2) 0 var(--space-3);
}

@media (min-width: 768px) {
  .api-banner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* ------------------------------ Blog cards (homepage strip) -------------- */
.blog-card {
  display: flex;
  flex-direction: column;
}

.blog-card__img {
  width: 100%;
  aspect-ratio: 1200 / 630;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  background: var(--muted);
}

.blog-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  margin-bottom: var(--space-2);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
