/* ==========================================================================
   ComposeForge CE — styles.css (cleaned + deduplicated)
   Structure:
   1) Base
   2) Components
   3) Pages
   ========================================================================== */

/* ==========================================================================
   1) BASE
   ========================================================================== */

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

html { font-size: 16px; }

body {
  margin: 0;
  padding: 2rem 1.5rem 3rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1f2933;
  background-color: #f5f7fa;
  line-height: 1.5;
}

@media (min-width: 960px) {
  body { padding: 3rem 4rem 4rem; }
}

h1 {
  margin: 0 0 0.75rem;
  font-size: 1.8rem;
  font-weight: 600;
  color: #101827;
}

h4 {
  margin: 1.25rem 0 0.4rem;
  font-size: 1rem;
  font-weight: 600;
}

/* --- Links --------------------------------------------------------------- */
a,
.cf-nav-link,
.cf-footer-link,
.cf-link-inline {
  color: #2563eb;
}

a:hover,
.cf-nav-link:hover,
.cf-footer-link:hover,
.cf-link-inline:hover {
  color: #1d4ed8;
}

/* --- Utilities ----------------------------------------------------------- */
.note {
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
  color: #5f6c80;
}

.hidden { display: none !important; }


/* ==========================================================================
   2) COMPONENTS
   ========================================================================== */

/* --------------------------------------------------------------------------
   Layout wrappers (legacy + current)
   -------------------------------------------------------------------------- */
.cf-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.cf-body {
  max-width: 1120px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}

@media (min-width: 960px) {
  .cf-body { padding: 3rem 0 4rem; }
}

.cf-main { margin-top: 2rem; }

/* --------------------------------------------------------------------------
   Header & navigation
   -------------------------------------------------------------------------- */
.cf-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  background-color: inherit; /* fill sticky area */
}

.cf-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0 1rem;
}

.cf-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cf-logo-block {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cf-logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.9rem;
  font-size: 1.2rem;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.06);
}

.cf-logo-text {
  display: flex;
  flex-direction: column;
}

.cf-logo-title {
  font-weight: 650;
  letter-spacing: 0.03em;
}

.cf-logo-subtitle {
  font-size: 0.78rem;
  opacity: 0.75;
}

/* Desktop nav */
.cf-nav {
  display: flex;
  gap: 0.75rem;
  font-size: 0.9rem;
}

@media (min-width: 769px) {
  .cf-header-right { gap: 0.75rem; }
  .cf-nav { margin-right: 0.25rem; }
}

.cf-nav-link {
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  opacity: 0.8;
}

.cf-nav-link:hover {
  opacity: 1;
  background: rgba(15, 23, 42, 0.05);
}

.cf-nav-link-active {
  font-weight: 600;
  background: rgba(15, 23, 42, 0.08);
  opacity: 1;
}

/* Theme toggle button: static bg, same in both dark/light */
.cf-theme-toggle {
  border: 1px solid rgba(148, 163, 184, 0.6);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.9rem;
  background: rgb(29, 79, 216);
  cursor: pointer;
  line-height: 1;
}

.cf-theme-toggle:hover { background: rgb(29, 79, 216); }

/* Mobile nav toggle (hamburger) */
.cf-nav-toggle {
  display: none; /* shown only on small screens */
  border: 1px solid rgba(148, 163, 184, 0.6);
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  font-size: 1rem;
  background: transparent;
  cursor: pointer;
  line-height: 1;
  color: #0f172a; /* force visibility in light mode */
}

/* Mobile layout: collapse nav into dropdown */
@media (max-width: 768px) {
  .cf-nav {
    display: none;
    position: absolute;
    right: 1.25rem;
    top: 100%;
    margin-top: 0.5rem;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.5rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.5);
    background: #ffffff;
  }

  .cf-header-nav-open .cf-nav { display: flex; }

  .cf-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */
.cf-hero { padding: 2rem 0 1.5rem; }

/* Legacy hero helper (kept for older pages) */
.cf-hero-text h1 { margin-bottom: 0.5rem; }
.cf-hero-subtitle { margin-bottom: 1rem; max-width: 40rem; }

.cf-hero-inner {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.cf-hero-copy h1 {
  font-size: 1.9rem;
  margin: 0 0 0.75rem;
}

@media (min-width: 768px) {
  .cf-hero-copy h1 { font-size: 2.2rem; }
}

.cf-hero-lead {
  margin: 0 0 1.25rem;
  font-size: 1rem;
  max-width: 40rem;
}

.cf-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.cf-hero-note {
  font-size: 0.9rem;
  opacity: 0.85;
}

/* --------------------------------------------------------------------------
   Sections & grids
   -------------------------------------------------------------------------- */
.cf-section {
  margin-top: 2.5rem; /* legacy spacing */
  padding: 1.75rem 0 1.5rem;
  border-top: 1px solid rgba(148, 163, 184, 0.28);
}

.cf-section-header { margin-bottom: 1.25rem; }
.cf-section-header h2 { margin: 0 0 0.3rem; font-size: 1.25rem; }
.cf-section-subtitle {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.9;
  max-width: 36rem;
  color: #777; /* matches older subtitle tone */
}
.cf-section-footer { margin-top: 1rem; }

.cf-link-inline { font-size: 0.95rem; }

.cf-grid { display: grid; gap: 1rem; }
.cf-grid-2 { grid-template-columns: 1fr; }
.cf-grid-3 { grid-template-columns: 1fr; }

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

/* --------------------------------------------------------------------------
   Cards (general)
   -------------------------------------------------------------------------- */
.cf-card {
  border-radius: 1rem;
  padding: 1.1rem 1.1rem 1rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.cf-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.cf-card h3 { margin: 0; font-size: 1.05rem; }
.cf-card p { margin: 0; font-size: 0.95rem; }

.cf-card-list {
  margin: 0.25rem 0 0.8rem;
  padding-left: 1.1rem;
  font-size: 0.9rem;
}

.cf-card-list li { margin-bottom: 0.15rem; }

/* Edition card accents */
.cf-card-ce { border-left: 4px solid #22c55e; }
.cf-card-pro { border-left: 4px solid #f97316; }

/* Mini cards */
.cf-mini-card {
  border-radius: 0.9rem;
  padding: 0.9rem 0.95rem;
  border: 1px dashed rgba(148, 163, 184, 0.6);
  background: rgba(248, 250, 252, 0.9);
}

.cf-mini-card h3 { margin: 0 0 0.25rem; font-size: 0.95rem; }
.cf-mini-card p { margin: 0; font-size: 0.9rem; }

/* --------------------------------------------------------------------------
   Stack grids & cards (new + legacy)
   -------------------------------------------------------------------------- */

/* Legacy CF stack grid (for any older pages) */
.cf-stacks-grid {
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

/* Legacy CF stack card (re-skinned to feel like new cards) */
.cf-stack-card {
  border-radius: 10px;
  border: 1px solid #d0d7e2;
  background-color: #f9fafb;
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  box-shadow: 0 3px 6px rgba(15, 23, 42, 0.06);
  font-size: 0.9rem;
}

.cf-stack-card h3 { margin: 0 0 0.25rem; font-size: 0.95rem; }

.cf-stack-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.cf-stack-name { margin: 0; font-size: 1.1rem; }

.cf-stack-category {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
}

.cf-stack-description { margin: 0.25rem 0 0.75rem; }

.cf-stack-tags {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.cf-tag-pill {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid #555;
}

.cf-stack-footer { margin-top: auto; }

/* Stack category accent borders (builder + homepage helpers) */
.cf-stack-web     { border-left: 4px solid #0ea5e9; }  /* web */
.cf-stack-dev     { border-left: 4px solid #a855f7; }  /* dev */
.cf-stack-utility { border-left: 4px solid #eab308; }  /* utility */
.cf-stack-fun     { border-left: 4px solid #22c55e; }  /* fun */

/* Additional legacy category borders used elsewhere */
.cf-stack-core { border-left: 4px solid #a855f7; }
.cf-stack-data { border-left: 4px solid #0ea5e9; }
.cf-stack-apps { border-left: 4px solid #22c55e; }
.cf-stack-monitoring { border-left: 4px solid #f97316; }
.cf-stack-devtools { border-left: 4px solid #eab308; }

/* New stack grids/cards for ce_home.html + builder.html */
.stack-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* 1 column by default */
  gap: 1.1rem;
  margin-top: 0.9rem;
}

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

.stack-card {
  border-radius: 10px;
  border: 1px solid #d0d7e2;
  background-color: #f9fafb;
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  box-shadow: 0 3px 6px rgba(15, 23, 42, 0.06);
}

.stack-card-title {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
}

.stack-card-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.stack-card-toggle input[type="checkbox"] { margin: 0; }

.stack-card-description {
  margin: 0.25rem 0 0.4rem;
  font-size: 0.9rem;
  color: #4b5563;
}

.stack-card-meta {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  color: #6b7280;
}

.stack-card-body { margin-top: 0.4rem; }
.stack-card-body label { margin-top: 0.35rem; }

/* Gentle variety for stacked cards (optional visual interest) */
.stack-grid .stack-card:nth-child(1) { border-color: #bfdbfe; background-color: #eff6ff; }
.stack-grid .stack-card:nth-child(2) { border-color: #c7d2fe; background-color: #eef2ff; }
.stack-grid .stack-card:nth-child(3) { border-color: #a7f3d0; background-color: #ecfdf5; }
.stack-grid .stack-card:nth-child(4) { border-color: #fcd34d; background-color: #fffbeb; }

/* Category-based card colors
   Requires: <div class="stack-card stack-card--core"> etc. 
.stack-card--core    { border-color: #4f46e5; background-color: #eef2ff; }
.stack-card--data    { border-color: #059669; background-color: #ecfdf5; }
.stack-card--web     { border-color: #2563eb; background-color: #eff6ff; }
.stack-card--dev     { border-color: #d97706; background-color: #fffbeb; }
.stack-card--utility { border-color: #6b7280; background-color: #f9fafb; }
.stack-card--fun     { border-color: #7c3aed; background-color: #f5f3ff; }

.stack-card--core:hover    { box-shadow: 0 4px 10px rgba(79, 70, 229, 0.18); }
.stack-card--data:hover    { box-shadow: 0 4px 10px rgba(5, 150, 105, 0.18); }
.stack-card--web:hover     { box-shadow: 0 4px 10px rgba(37, 99, 235, 0.18); }
.stack-card--dev:hover     { box-shadow: 0 4px 10px rgba(217, 119, 6, 0.18); }
.stack-card--utility:hover { box-shadow: 0 4px 10px rgba(107, 114, 128, 0.18); }
.stack-card--fun:hover     { box-shadow: 0 4px 10px rgba(124, 58, 237, 0.18); }
*/

/* Accent borders (match builder categories) */
.stack-card--core    { border-left: 4px solid #a855f7; }
.stack-card--web     { border-left: 4px solid #0ea5e9; }
.stack-card--dev     { border-left: 4px solid #22c55e; }
.stack-card--utility { border-left: 4px solid #f97316; }
.stack-card--fun     { border-left: 4px solid #eab308; }

/* --------------------------------------------------------------------------
   Forms & fieldsets
   -------------------------------------------------------------------------- */
form {
  max-width: 960px;
  margin: 0 auto;
}

fieldset {
  border: 1px solid #d0d7e2;
  border-radius: 10px;
  padding: 1.2rem 1.2rem 1.4rem;
  margin: 0 0 1.5rem;
  background-color: #ffffff;
}

legend {
  padding: 0 0.4rem;
  font-weight: 600;
  font-size: 1rem;
  color: #101827;
}

/* All labels: name above input */
label {
  display: block;
  font-size: 0.95rem;
  color: #777;
}

/* Inline labels like checkboxes/radios */
label > input[type="checkbox"],
label > input[type="radio"] { margin-right: 0.35rem; }

/* Top-level labels directly under a fieldset (for simple checklists) */
fieldset > label { margin-top: 0.3rem; }

/* Row/grid layout */
.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.9rem 1.25rem;
  margin-top: 0.75rem;
}

.row > label { min-width: 0; }

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

/* Inputs & controls */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"] {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.6rem;
  border-radius: 7px;
  border: 1px solid #c4ccd9;
  background-color: #f9fbff;
  font: inherit;
  color: #101827;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

input::placeholder { color: #9aa5b5; }

input:focus {
  border-color: #2563eb;
  background-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Password containers */
[data-password-container] {
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

[data-password-container] input[type="password"],
[data-password-container] input[type="text"] {
  flex: 1 1 auto;
  margin-top: 0;
}

/* --------------------------------------------------------------------------
   Buttons (native buttons) + status feedback
   -------------------------------------------------------------------------- */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid #2563eb;
  background-color: #2563eb;
  color: #ffffff;
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

button:hover {
  background-color: #1d4fd8;
  border-color: #1d4fd8;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.25);
}

button:active {
  transform: translateY(1px);
  box-shadow: 0 3px 8px rgba(37, 99, 235, 0.2);
}

button:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: none;
}

/* Secondary buttons (for regenerate/copy in legacy password containers) */
button.btn-secondary,
[data-password-container] button {
  border-color: #c4ccd9;
  background-color: #ffffff;
  color: #273341;
  box-shadow: none;
}

button.btn-secondary:hover,
[data-password-container] button:hover {
  border-color: #9aa5b5;
  background-color: #f3f5f9;
  box-shadow: 0 2px 6px rgba(148, 163, 184, 0.35);
}

/* Visual feedback for "copied" state */
[data-action="copy-password"][data-copied="true"]::after {
  content: "Copied!";
  margin-left: 0.4rem;
  font-size: 0.8rem;
  color: #059669;
}

/* Submit button spacing */
form > button[type="submit"] { margin-top: 0.75rem; }

/* Status text */
#status {
  display: inline-block;
  margin-left: 0.75rem;
  font-size: 0.9rem;
  color: #4b5563;
}

/* Inline status (used near copy/regenerate buttons) */
.cf-inline-status {
  margin-left: 0.35rem;
  font-size: 0.78rem;
  color: #10b981;
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* --------------------------------------------------------------------------
   Buttons (CF-style: anchors + small variants)
   -------------------------------------------------------------------------- */
.cf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.5rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
}

.cf-btn-primary { background: #2563eb; color: #f9fafb; }
.cf-btn-primary:hover { background: #1d4ed8; }

.cf-btn-secondary {
  background: transparent;
  border-color: rgba(15, 23, 42, 0.18);
}
.cf-btn-secondary:hover { border-color: rgba(15, 23, 42, 0.35); }

.cf-btn-ghost {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.5);
}
.cf-btn-ghost:hover { border-color: rgba(148, 163, 184, 0.9); }

.cf-btn-block { width: 100%; justify-content: center; }

/* Legacy cf-button helpers (kept for older pages) */
.cf-button {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid #555;
  text-decoration: none;
  font-size: 0.9rem;
}
.cf-button-primary { background: #fff; }
.cf-button-secondary { background: transparent; }

/* --------------------------------------------------------------------------
   Ephemeral notice
   -------------------------------------------------------------------------- */
[data-role="ephemeral-notice"] {
  max-width: 960px;
  margin: 0 auto 1.25rem;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  border: 1px solid #facc15;
  background-color: #fef9c3;
  color: #854d0e;
}
[data-role="ephemeral-notice"] strong { font-weight: 600; }

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */
.cf-badge {
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.cf-badge-ce {
  border-color: rgba(34, 197, 94, 0.5);
  background: rgba(22, 163, 74, 0.07);
}

.cf-badge-pro {
  border-color: rgba(249, 115, 22, 0.5);
  background: rgba(248, 153, 60, 0.07);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.cf-footer {
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  margin-top: 2rem;
  padding-top: 1rem;
  font-size: 0.85rem;
}

.cf-footer-inner {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

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

.cf-footer-left {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.cf-license-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.9);
}

.cf-license-label { opacity: 0.85; }
.cf-license-tag { font-weight: 600; }

.cf-footer-right { display: flex; gap: 0.75rem; }
.cf-footer-link { text-decoration: none; }

/* --------------------------------------------------------------------------
   Dark mode (system) + explicit theme overrides
   -------------------------------------------------------------------------- */

/* System dark mode default (unless theme-light is set) */
@media (prefers-color-scheme: dark) {
  body:not(.theme-light),
  html:not(.theme-light) body {
    background-color: #020617;
    color: #e5e7eb;
  }

  html:not(.theme-light) .cf-logo-mark {
    background: rgba(148, 163, 184, 0.16);
  }

  html:not(.theme-light) .cf-nav-link:hover,
  html:not(.theme-light) .cf-nav-link.cf-nav-link-active {
    background: rgba(15, 23, 42, 0.9);
  }

  html:not(.theme-light) .cf-card,
  html:not(.theme-light) .cf-mini-card,
  html:not(.theme-light) .cf-stack-card {
    background: #020617;
    border-color: rgba(51, 65, 85, 0.9);
  }

  html:not(.theme-light) .cf-section {
    border-top-color: rgba(30, 64, 175, 0.7);
  }

  html:not(.theme-light) .cf-btn-secondary,
  html:not(.theme-light) .cf-btn-ghost {
    border-color: rgba(148, 163, 184, 0.8);
  }

  html:not(.theme-light) .cf-footer {
    border-top-color: rgba(31, 41, 55, 0.9);
  }

  html:not(.theme-light) .cf-license-badge {
    border-color: rgba(148, 163, 184, 0.9);
  }

  /* Links in dark mode */
  html:not(.theme-light) a,
  html:not(.theme-light) .cf-nav-link,
  html:not(.theme-light) .cf-footer-link,
  html:not(.theme-light) .cf-link-inline {
    color: #60a5fa;
  }

  html:not(.theme-light) a:hover,
  html:not(.theme-light) .cf-nav-link:hover,
  html:not(.theme-light) .cf-footer-link:hover,
  html:not(.theme-light) .cf-link-inline:hover {
    color: #93c5fd;
  }

  /* Hero heading contrast in dark */
  html:not(.theme-light) .cf-hero-copy h1 { color: #e5e7eb; }

  /* Mobile nav background in dark */
  @media (max-width: 768px) {
    html:not(.theme-light) .cf-nav {
      background: #020617;
      border-color: rgba(51, 65, 85, 0.9);
    }
  }

  /* Inline status in dark */
  html:not(.theme-light) .cf-inline-status { color: #4ade80; }
}

/* Explicit theme overrides from the toggle */
html.theme-dark body { background-color: #020617; color: #e5e7eb; }
html.theme-dark .cf-logo-mark { background: rgba(148, 163, 184, 0.16); }

html.theme-dark .cf-nav-link:hover,
html.theme-dark .cf-nav-link.cf-nav-link-active {
  background: rgba(15, 23, 42, 0.9);
}

html.theme-dark .cf-nav-toggle { color: #e5e7eb; }

html.theme-dark .cf-card,
html.theme-dark .cf-mini-card,
html.theme-dark .cf-stack-card {
  background: #020617;
  border-color: rgba(51, 65, 85, 0.9);
}

html.theme-dark .cf-section { border-top-color: rgba(30, 64, 175, 0.7); }

html.theme-dark .cf-btn-secondary,
html.theme-dark .cf-btn-ghost {
  border-color: rgba(148, 163, 184, 0.8);
}

html.theme-dark .cf-footer { border-top-color: rgba(31, 41, 55, 0.9); }

html.theme-dark .cf-license-badge { border-color: rgba(148, 163, 184, 0.9); }

html.theme-dark a,
html.theme-dark .cf-nav-link,
html.theme-dark .cf-footer-link,
html.theme-dark .cf-link-inline {
  color: #60a5fa;
}

html.theme-dark a:hover,
html.theme-dark .cf-nav-link:hover,
html.theme-dark .cf-footer-link:hover,
html.theme-dark .cf-link-inline:hover {
  color: #93c5fd;
}

html.theme-dark .cf-hero-copy h1 { color: #e5e7eb; }
html.theme-dark .cf-inline-status { color: #4ade80; }

/* Force light theme when explicitly chosen */
html.theme-light body {
  background-color: #f5f7fa;
  color: #1f2933;
}

/* Preserve accent border colors in dark mode */
html.theme-dark .cf-card-ce { border-left-color: #22c55e; }
html.theme-dark .cf-card-pro { border-left-color: #f97316; }

html.theme-dark .cf-stack-web     { border-left-color: #0ea5e9; }
html.theme-dark .cf-stack-dev     { border-left-color: #a855f7; }
html.theme-dark .cf-stack-utility { border-left-color: #eab308; }
html.theme-dark .cf-stack-fun     { border-left-color: #22c55e; }

@media (prefers-color-scheme: dark) {
  html:not(.theme-light) .cf-card-ce { border-left-color: #22c55e; }
  html:not(.theme-light) .cf-card-pro { border-left-color: #f97316; }

  html:not(.theme-light) .cf-stack-web     { border-left-color: #0ea5e9; }
  html:not(.theme-light) .cf-stack-dev     { border-left-color: #a855f7; }
  html:not(.theme-light) .cf-stack-utility { border-left-color: #eab308; }
  html:not(.theme-light) .cf-stack-fun     { border-left-color: #22c55e; }
}

/* ==========================================================================
   3) PAGES
   ========================================================================== */

/* --------------------------------------------------------------------------
   Builder page layout tweaks
   -------------------------------------------------------------------------- */
.cf-hero--compact { padding: 1.25rem 0 0.75rem; }
.cf-section--tight { padding: 1.25rem 0 1.1rem; }

.cf-form { margin-top: 0.5rem; }
.cf-form-card { gap: 0.9rem; }
.cf-form-grid { gap: 0.9rem; }

.cf-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.cf-input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.55);
  background: transparent;
  color: inherit;
}

.cf-input:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.85);
}

.cf-check {
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
  font-size: 0.92rem;
}

.cf-callout {
  border-radius: 0.9rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(148, 163, 184, 0.08);
}

.cf-callout-warning { border-left: 4px solid #f97316; }

/* Builder stack cards: "card" feel (kept as-is) */
.cf-stack-grid { gap: 1rem; }

.cf-stack-card {
  border-radius: 1rem;
  padding: 1rem;
  /*border: 1px solid rgba(148, 163, 184, 0.4);*/
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

/* Title row with checkbox */
.cf-stack-toggle {
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.cf-stack-title { font-weight: 650; }

.cf-stack-desc {
  margin: 0;
  font-size: 0.92rem;
  opacity: 0.95;
}

.cf-stack-meta {
  margin: 0;
  font-size: 0.86rem;
  opacity: 0.9;
}

.cf-stack-body {
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Password row + small buttons */
.cf-password-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.cf-btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; }

.cf-note { font-size: 0.9rem; opacity: 0.9; }

/* Build footer */
.cf-build-footer { border-top: none; padding-top: 0.5rem; }

.cf-build-actions {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Center hero content on builder page */
.cf-builder .cf-hero { text-align: center; }
.cf-builder .cf-hero-inner { align-items: center; }
.cf-builder .cf-hero-copy { max-width: 42rem; }
.cf-builder .cf-hero-copy h1 { margin-left: auto; margin-right: auto; }
.cf-builder .cf-hero-lead { margin-left: auto; margin-right: auto; }

/* Builder cards + inputs in dark mode */
@media (prefers-color-scheme: dark) {
  html:not(.theme-light) .cf-stack-card,
  html:not(.theme-light) .cf-form-card {
    background: #020617;
   /* border-color: rgba(51, 65, 85, 0.9); */
  }

  html:not(.theme-light) .cf-input {
    border-color: rgba(51, 65, 85, 0.9);
  }
}

html.theme-dark .cf-stack-card,
html.theme-dark .cf-form-card {
  background: #020617;
  /* border-color: rgba(51, 65, 85, 0.9); */
}

html.theme-dark .cf-input { border-color: rgba(51, 65, 85, 0.9); }

/* Builder category accent borders (force wins even if border shorthand exists) */
.cf-stack-card.stack-card--web { border-left: 4px solid #0ea5e9 !important; }
.cf-stack-card.stack-card--dev { border-left: 4px solid #a855f7 !important; }
.cf-stack-card.stack-card--utility { border-left: 4px solid #eab308 !important; }
.cf-stack-card.stack-card--fun { border-left: 4px solid #22c55e !important; }

@media (prefers-color-scheme: dark) {
  html:not(.theme-light) .cf-stack-card.stack-card--web { border-left-color: #0ea5e9 !important; }
  html:not(.theme-light) .cf-stack-card.stack-card--dev { border-left-color: #a855f7 !important; }
  html:not(.theme-light) .cf-stack-card.stack-card--utility { border-left-color: #eab308 !important; }
  html:not(.theme-light) .cf-stack-card.stack-card--fun { border-left-color: #22c55e !important; }
}

html.theme-dark .cf-stack-card.stack-card--web { border-left-color: #0ea5e9 !important; }
html.theme-dark .cf-stack-card.stack-card--dev { border-left-color: #a855f7 !important; }
html.theme-dark .cf-stack-card.stack-card--utility { border-left-color: #eab308 !important; }
html.theme-dark .cf-stack-card.stack-card--fun { border-left-color: #22c55e !important; }

/* Dark mode input toning (builder page) */
@media (prefers-color-scheme: dark) {
  html:not(.theme-light) .cf-builder .cf-input {
    background-color: rgba(15, 23, 42, 0.6);
    color: #e5e7eb;
    border-color: rgba(51, 65, 85, 0.9);
  }

  html:not(.theme-light) .cf-builder .cf-input::placeholder {
    color: rgba(148, 163, 184, 0.7);
  }

  html:not(.theme-light) .cf-builder .cf-input:focus {
    background-color: rgba(15, 23, 42, 0.85);
    border-color: #60a5fa;
  }
}

html.theme-dark .cf-builder .cf-input {
  background-color: rgba(15, 23, 42, 0.6);
  color: #e5e7eb;
  border-color: rgba(51, 65, 85, 0.9);
}

html.theme-dark .cf-builder .cf-input::placeholder {
  color: rgba(148, 163, 184, 0.7);
}

html.theme-dark .cf-builder .cf-input:focus {
  background-color: rgba(15, 23, 42, 0.85);
  border-color: #60a5fa;
}

/* Password action buttons (Copy / Regenerate) */
.cf-password-row .cf-btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  line-height: 1;
  border-radius: 0.6rem;
  background-color: rgba(148, 163, 184, 0.15);
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: inherit;
  white-space: nowrap;
}

.cf-password-row .cf-btn:hover {
  background-color: rgba(148, 163, 184, 0.25);
  border-color: rgba(148, 163, 184, 0.6);
}

.cf-password-row .cf-btn:active {
  background-color: rgba(148, 163, 184, 0.35);
}

@media (prefers-color-scheme: dark) {
  html:not(.theme-light) .cf-password-row .cf-btn {
    background-color: rgba(51, 65, 85, 0.6);
    border-color: rgba(71, 85, 105, 0.8);
    color: #e5e7eb;
  }

  html:not(.theme-light) .cf-password-row .cf-btn:hover {
    background-color: rgba(71, 85, 105, 0.8);
  }
}

html.theme-dark .cf-password-row .cf-btn {
  background-color: rgba(51, 65, 85, 0.6);
  border-color: rgba(71, 85, 105, 0.8);
  color: #e5e7eb;
}

html.theme-dark .cf-password-row .cf-btn:hover {
  background-color: rgba(71, 85, 105, 0.8);
}

/* --------------------------------------------------------------------------
   Small-screen tweaks
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  body { padding: 1.5rem 1rem 3rem; }
  h1 { font-size: 1.6rem; }
  fieldset { padding: 1rem 0.9rem 1.1rem; }
  .row { gap: 0.6rem; }
}
