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

:root {
  color-scheme: light;
  --c-bg: #f8fafc;
  --c-surface: #ffffff;
  --c-border: #e2e8f0;
  --c-text: #1e293b;
  --c-text-secondary: #526070;
  --c-muted: #f1f5f9;
  --c-text-muted: #5c6b82;
  --c-primary: #6366f1;
  --c-primary-hover: #4f46e5;
  --c-primary-light: #eef2ff;
  --c-success: #15803d;
  --c-success-bg: #f0fdf4;
  --c-warning: #b45309;
  --c-warning-bg: #fffbeb;
  --c-error: #b91c1c;
  --c-error-bg: #fef2f2;
  --c-info: #0369a1;
  --c-info-bg: #f0f9ff;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --max-width: 768px;
  --transition: 200ms ease;
}

/* ---- Dark theme tokens ----
   Applied in two cases, kept identical on purpose:
   1. The OS prefers dark and the user has made no explicit choice
      (`:root` with no `data-theme`) — this is the "default to system" path
      and works even before theme.js runs, so there is no flash.
   2. The user explicitly picked dark via the toggle (`[data-theme="dark"]`),
      which also wins over the OS preference.
   An explicit light choice (`[data-theme="light"]`) falls through to the
   light tokens in `:root` above. Keep both blocks in sync. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --c-bg: #0f172a;
    --c-surface: #1e293b;
    --c-border: #334155;
    --c-text: #e2e8f0;
    --c-text-secondary: #94a3b8;
    --c-muted: #273449;
    --c-text-muted: #94a3b8;
    --c-primary: #818cf8;
    --c-primary-hover: #a5b4fc;
    --c-primary-light: #312e81;
    --c-success: #4ade80;
    --c-success-bg: #14321f;
    --c-warning: #fbbf24;
    --c-warning-bg: #3a2e12;
    --c-error: #f87171;
    --c-error-bg: #3a1d1d;
    --c-info: #38bdf8;
    --c-info-bg: #0c2a3a;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --c-bg: #0f172a;
  --c-surface: #1e293b;
  --c-border: #334155;
  --c-text: #e2e8f0;
  --c-text-secondary: #94a3b8;
  --c-muted: #273449;
  --c-text-muted: #94a3b8;
  --c-primary: #818cf8;
  --c-primary-hover: #a5b4fc;
  --c-primary-light: #312e81;
  --c-success: #4ade80;
  --c-success-bg: #14321f;
  --c-warning: #fbbf24;
  --c-warning-bg: #3a2e12;
  --c-error: #f87171;
  --c-error-bg: #3a1d1d;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* Hide Alpine-controlled elements until Alpine initializes, to avoid a flash
   of the wrong screen/panel before x-show takes effect. */
[x-cloak] {
  display: none !important;
}

/* ---- Login Screen ---- */
#login-section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* Sample preview on login page */
.sample-preview-toggle {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 16px;
  padding: 8px;
  background: none;
  border: 1px dashed var(--c-border);
  border-radius: var(--radius);
  color: var(--c-text-secondary);
  font-size: 0.8125rem;
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
}

.sample-preview-toggle:hover {
  border-color: var(--c-primary);
  color: var(--c-primary);
  background: var(--c-primary-light);
}

.sample-preview {
  margin-top: 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  background: var(--c-bg);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 400ms ease, opacity 300ms ease, margin 300ms ease;
}

.sample-preview.open {
  max-height: 600px;
  opacity: 1;
  overflow-y: auto;
}

.sample-preview-inner {
  padding: 16px;
}

.sample-preview .sample-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--c-text-muted);
  margin-bottom: 4px;
}

.sample-preview .sample-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 8px;
  line-height: 1.4;
}

.sample-preview .sample-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}

.sample-preview .sample-tags .tag {
  font-size: 0.6875rem;
  padding: 2px 8px;
  opacity: 0.85;
}

.sample-preview .sample-desc {
  font-size: 0.8125rem;
  color: var(--c-text-secondary);
  line-height: 1.5;
  margin-bottom: 10px;
}

.sample-preview .sample-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  font-size: 0.75rem;
}

.sample-preview .sample-fields .sf-label {
  color: var(--c-text-muted);
}

.sample-preview .sample-fields .sf-value {
  color: var(--c-text);
  font-weight: 500;
}

.sample-preview .sample-source {
  font-size: 0.6875rem;
  color: var(--c-text-muted);
  font-style: italic;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--c-border);
}

/* Login pricing teaser (pre-signup) */
.login-pricing-teaser {
  font-size: 0.8125rem;
  color: var(--c-text-secondary);
  text-align: center;
  margin-top: 8px;
  line-height: 1.5;
}

.login-plans-preview {
  margin-top: 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  background: var(--c-bg);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 400ms ease, opacity 300ms ease, margin 300ms ease;
}

.login-plans-preview.open {
  max-height: 500px;
  opacity: 1;
  overflow-y: auto;
}

.login-plans-inner {
  padding: 16px;
}

.login-plans-heading {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--c-text);
  margin: 0 0 10px;
}

.login-plans-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-plan-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
}

.login-plan-row .plan-name {
  font-weight: 500;
  color: var(--c-text);
}

.login-plan-row .plan-price {
  font-weight: 600;
  color: var(--c-primary);
}

.login-plan-row .plan-credits {
  font-size: 0.75rem;
  color: var(--c-text-secondary);
}

.login-plans-footnote {
  font-size: 0.6875rem;
  color: var(--c-text-muted);
  margin: 10px 0 0;
  font-style: italic;
}

.login-footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.login-footer-links a {
  color: var(--c-text-secondary);
  text-decoration: none;
  font-size: 0.75rem;
  transition: color var(--transition);
}

.login-footer-links a:hover {
  color: var(--c-primary);
  text-decoration: underline;
}

.login-container {
  width: 100%;
  max-width: 400px;
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 40px 32px;
}

.logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo h1 {
  font-size: 1.5rem;
  margin-top: 12px;
  color: var(--c-text);
}

.tagline {
  color: var(--c-text-secondary);
  font-size: 0.875rem;
  margin-top: 4px;
  line-height: 1.5;
}

.login-benefits {
  list-style: none;
  margin: 20px 0 4px;
  padding: 0;
  text-align: left;
  border-top: 1px solid var(--c-border);
  padding-top: 20px;
}

.login-benefits li {
  font-size: 0.875rem;
  color: var(--c-text-secondary);
  padding: 4px 0 4px 24px;
  position: relative;
}

.login-benefits li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--c-success);
  font-weight: 700;
}

.login-step label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 6px;
  color: var(--c-text);
}

.login-step input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition);
}

.login-step input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-light);
}

.otp-sent-msg {
  font-size: 0.875rem;
  color: var(--c-text-secondary);
  margin-bottom: 16px;
  text-align: center;
}

#otp-input {
  font-size: 1.5rem;
  letter-spacing: 6px;
  text-align: center;
  min-height: 44px;
}

.error-msg {
  background: var(--c-error-bg);
  color: var(--c-error);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  margin-top: 8px;
}

.credit-nudge {
  margin-top: 8px;
  font-size: 0.8125rem;
  color: var(--c-text-secondary);
  text-align: center;
}

/* Inline override: the upgrade link sits within the nudge sentence, not as a
   full-width block like the default .btn-text. */
.credit-nudge .btn-text {
  display: inline;
  width: auto;
  padding: 0;
  margin: 0;
  font-size: inherit;
  color: var(--c-primary);
  font-weight: 600;
  text-decoration: underline;
}

/* ---- Buttons ---- */
.btn-primary {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 20px;
  background: var(--c-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: background var(--transition);
}

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

.btn-secondary {
  min-height: 44px;
  padding: 8px 18px;
  background: var(--c-surface);
  color: var(--c-primary);
  border: 1px solid var(--c-primary);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover {
  background: var(--c-primary-light);
}

.btn-text {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px;
  background: none;
  color: var(--c-text-secondary);
  border: none;
  font-size: 0.8125rem;
  cursor: pointer;
  margin-top: 4px;
  text-align: center;
}

.btn-text:hover {
  color: var(--c-primary);
}

.btn-text-inline {
  display: inline;
  background: none;
  color: var(--c-primary);
  border: none;
  padding: 0;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}

.btn-text-inline:hover {
  color: var(--c-primary-dark, #4f46e5);
}

/* ---- Focus Visible ---- */
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.mode-tab:focus-visible,
.tone-pill:focus-visible,
.btn-icon:focus-visible,
.plan-card:focus-visible,
.history-item:focus-visible,
.btn-text:focus-visible,
.btn-retry:focus-visible,
.btn-text-inline:focus-visible,
.btn-text-danger:focus-visible,
.welcome-dismiss:focus-visible,
.sample-preview-toggle:focus-visible,
.faq-item summary:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}

.btn-retry {
  display: inline;
  background: none;
  border: none;
  color: var(--c-primary);
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  margin-left: 4px;
}

.btn-retry:hover {
  color: var(--c-primary-hover);
}

.btn-icon {
  background: none;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--c-text-secondary);
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--c-primary-light);
  color: var(--c-primary);
}

/* ---- Theme toggle ---- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  padding: 0;
  background: none;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  color: var(--c-text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.theme-toggle:hover {
  background: var(--c-primary-light);
  color: var(--c-primary);
  border-color: var(--c-primary);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* Floating variant for screens without a header (login, marketing pages). */
.theme-toggle-fixed {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 50;
  background: var(--c-surface);
  box-shadow: var(--shadow-sm);
}

/* ---- Dashboard Layout ---- */
#dashboard-section {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.dashboard-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.0625rem;
}

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

.user-email {
  font-size: 0.8125rem;
  color: var(--c-text-secondary);
}

#logout-btn {
  width: auto;
  margin: 0;
  color: var(--c-text-secondary);
  font-weight: 500;
}

.dashboard-main {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dashboard-footer {
  text-align: center;
  padding: 16px;
  color: var(--c-text-secondary);
  font-size: 0.75rem;
  border-top: 1px solid var(--c-border);
}

.footer-links {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--c-text-secondary);
  text-decoration: none;
  font-size: 0.75rem;
  transition: color var(--transition);
}

.footer-links a:hover {
  color: var(--c-primary);
  text-decoration: underline;
}

.footer-sep {
  color: var(--c-border);
}

/* Deployed-version stamp — muted, on its own line below the footer links.
   width:100% forces a line break inside the flex footer navs; injected by
   version-footer.js from /version.json. */
.app-version {
  display: block;
  width: 100%;
  margin-top: 8px;
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--c-text-secondary);
  opacity: 0.55;
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
}

.card-desc {
  font-size: 0.8125rem;
  color: var(--c-text-secondary);
  margin-bottom: 16px;
}

/* ---- Welcome Card (Onboarding) ---- */
.welcome-card {
  position: relative;
  background: linear-gradient(135deg, var(--c-primary-light) 0%, #f5f3ff 100%);
  border: 1px solid var(--c-primary);
  text-align: center;
  padding: 28px 20px 24px;
  animation: welcomeFadeIn 400ms ease;
}

@keyframes welcomeFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.welcome-dismiss {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--c-text-secondary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--transition);
}

.welcome-dismiss:hover {
  color: var(--c-text);
  background: rgba(0, 0, 0, 0.05);
}

.welcome-icon {
  margin-bottom: 12px;
}

.welcome-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 6px;
}

.welcome-subtitle {
  font-size: 0.875rem;
  color: var(--c-text-secondary);
  margin-bottom: 20px;
}

.welcome-subtitle strong {
  color: var(--c-primary);
}

.welcome-steps {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.welcome-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--c-text-secondary);
}

.welcome-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--c-primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

#welcome-cta-btn {
  max-width: 280px;
  margin: 0 auto;
}

/* ---- Quota ---- */
.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 100px;
}

.badge-free {
  background: var(--c-warning-bg);
  color: var(--c-warning);
}
.badge-pro {
  background: var(--c-success-bg);
  color: var(--c-success);
}

.plan-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.plan-free {
  background: var(--c-muted);
  color: var(--c-text-muted);
}
.plan-pro {
  background: var(--c-success-bg);
  color: var(--c-success);
}

.quota-bar-track {
  height: 8px;
  background: var(--c-border);
  border-radius: 4px;
  margin: 8px 0;
  overflow: hidden;
}

.quota-bar-fill {
  height: 100%;
  background: var(--c-primary);
  border-radius: 4px;
  transition: width 500ms ease;
}

.quota-bar-fill.low {
  background: var(--c-error);
}
.quota-bar-fill.warn {
  background: var(--c-warning);
}

.quota-label {
  font-size: 0.8125rem;
  color: var(--c-text-secondary);
}

/* ---- Plans ---- */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.plan-card {
  position: relative;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  /* Button reset: plan cards are <button> elements for keyboard accessibility */
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: var(--c-bg);
  width: 100%;
  display: block;
  min-height: 44px;
}

.plan-card:hover {
  border-color: var(--c-primary);
  box-shadow: var(--shadow-sm);
}

.plan-card.selected {
  border-color: var(--c-primary);
  background: var(--c-primary-light);
}

.plan-card.current {
  border-color: var(--c-success);
}

.plan-card.current.selected {
  box-shadow: 0 0 0 1px var(--c-success);
}

.plan-current-pill {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--c-success-bg);
  color: var(--c-success);
  white-space: nowrap;
}

.plan-save-pill {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--c-primary);
  color: #fff;
  white-space: nowrap;
}

/* Marks the plan a pending scheduled switch (e.g. a deferred downgrade) lands on. */
.plan-scheduled-pill {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--c-primary);
  color: #fff;
  white-space: nowrap;
}

.plan-card .plan-card-name {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
}

.plan-card .plan-credits {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--c-primary);
  margin: 4px 0;
}

.plan-card .plan-price {
  font-size: 0.8125rem;
  color: var(--c-text-secondary);
}

.plan-card .plan-price-note {
  font-size: 0.6875rem;
  color: var(--c-text-secondary);
  margin-top: 2px;
}

.plan-card .plan-perk {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--c-primary);
  margin-top: 6px;
}

.plan-upgrade-note {
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--c-text-secondary);
  text-align: center;
  padding: 4px 2px 0;
}

/* ---- Generate ---- */
#notes-input {
  width: 100%;
  min-height: 44px;
  padding: 12px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-family: inherit;
  line-height: 1.5;
  outline: none;
  resize: vertical;
  transition: border-color var(--transition);
}

#notes-input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-light);
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

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

/* ---- Result ---- */
.result-field {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--c-text);
  white-space: pre-wrap;
}

.result-field.editable {
  cursor: text;
  border-radius: var(--radius);
  padding: 4px 6px;
  margin: -4px -6px;
  transition: background var(--transition), box-shadow var(--transition);
  position: relative;
}

.result-field.editable:hover {
  background: var(--c-muted);
}

.result-field.editable::after {
  content: "✎";
  position: absolute;
  right: 6px;
  top: 4px;
  font-size: 0.7rem;
  color: var(--c-text-muted);
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}

.result-field.editable:hover::after {
  opacity: 1;
}

.result-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.result-tags.editable {
  cursor: text;
  border-radius: var(--radius);
  padding: 4px 6px;
  margin: -4px -6px;
  transition: background var(--transition);
  min-height: 28px;
}

.result-tags.editable:hover {
  background: var(--c-muted);
}

/* Inline edit controls */
.inline-edit-input {
  width: 100%;
  padding: 6px 10px;
  border: 2px solid var(--c-primary);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-family: inherit;
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-surface);
  outline: none;
  box-shadow: 0 0 0 3px var(--c-primary-light);
}

.inline-edit-input-tags {
  width: 100%;
  padding: 6px 10px;
  border: 2px solid var(--c-primary);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-surface);
  outline: none;
  box-shadow: 0 0 0 3px var(--c-primary-light);
}

.inline-edit-textarea {
  width: 100%;
  min-height: 120px;
  padding: 8px 12px;
  border: 2px solid var(--c-primary);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-family: inherit;
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-surface);
  outline: none;
  resize: vertical;
  box-shadow: 0 0 0 3px var(--c-primary-light);
}

.edit-hint {
  display: inline-block;
  font-size: 0.6875rem;
  color: var(--c-text-muted);
  margin-top: 4px;
  font-style: italic;
}

.edited-indicator {
  display: inline-block;
  font-size: 0.6875rem;
  color: var(--c-warning);
  background: var(--c-warning-bg);
  padding: 1px 8px;
  border-radius: 100px;
  font-weight: 600;
  margin-left: 8px;
  vertical-align: middle;
}

.tag {
  background: var(--c-primary-light);
  color: var(--c-primary);
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 500;
}

.tag-invalid {
  background: var(--c-error-bg);
  color: var(--c-error);
}

.tag-suggestion {
  background: var(--c-success-bg);
  color: var(--c-success);
}

/* ---- Validation ---- */
.val-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.val-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.875rem;
}

.val-label {
  font-weight: 600;
  color: var(--c-text-secondary);
  min-width: 60px;
}

.val-badge {
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

.val-ok {
  background: var(--c-success-bg);
  color: var(--c-success);
}

.val-bad {
  background: var(--c-error-bg);
  color: var(--c-error);
}

.val-warning {
  font-size: 0.75rem;
  color: var(--c-warning);
}

/* Resolved note: the system already fixed this (e.g. shortened over-length tags),
   so it reassures rather than alarms — success color, not warning (SG-T2). */
.val-resolved {
  font-size: 0.75rem;
  color: var(--c-success);
}

/* Seller-facing notice that the banned-phrase scrub rewrote a field (SG-1). */
.val-adjusted {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--c-warning-bg, var(--c-error-bg));
}

.val-adjusted .val-warning {
  flex: 1;
  min-width: 0;
}

.val-issues {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.val-arrow {
  color: var(--c-text-secondary);
  font-size: 0.875rem;
}

.val-status {
  margin-top: 4px;
  padding: 4px 12px;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: center;
}

.val-status-ok {
  background: var(--c-success-bg);
  color: var(--c-success);
}

.val-status-warn {
  background: var(--c-warning-bg);
  color: var(--c-warning);
}

.result-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.result-actions .btn-text {
  width: auto;
  margin: 0;
}

/* ---- Export platform chooser ---- */
/* A compact <select> next to each "Download CSV" button so a seller can pick
   the platform-native schema (Etsy or Shopify). The chosen value is sent as
   ?platform=etsy|shopify and the backend emits that platform's importer CSV. */
.export-platform-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--c-text-secondary);
}
.export-platform-label {
  font-weight: 500;
}
.export-platform-select {
  /* Meet WCAG 2.5.8 (44px on touch) via the same input sizing as other fields. */
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 0.875rem;
  cursor: pointer;
}
.export-platform-select:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--c-text);
  color: #fff;
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 300ms ease;
}

.toast.show {
  opacity: 1;
}
.toast.error {
  background: var(--c-error);
}

/* ---- Tag Clickable ---- */
.tag {
  cursor: pointer;
  user-select: none;
}

.tag:active {
  transform: scale(0.95);
}

/* ---- Copy Feedback ---- */
.copy-btn.copied {
  background: var(--c-success-bg);
  border-color: var(--c-success);
  color: var(--c-success);
}

.copy-btn .checkmark {
  display: inline-block;
  margin-right: 2px;
  animation: checkPop 300ms ease;
}

@keyframes checkPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  60% {
    transform: scale(1.3);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ---- Character Badge ---- */
.char-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 100px;
  margin-left: 6px;
  vertical-align: middle;
}

.char-badge.ok {
  background: var(--c-success-bg);
  color: var(--c-success);
}
.char-badge.warn {
  background: var(--c-warning-bg);
  color: var(--c-warning);
}
.char-badge.bad {
  background: var(--c-error-bg);
  color: var(--c-error);
}

/* ---- Mode Toggle ---- */
.mode-toggle {
  display: flex;
  background: var(--c-bg);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 12px;
  gap: 2px;
}

.mode-tab {
  flex: 1;
  min-height: 44px;
  padding: 6px 16px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--c-text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.mode-tab.active {
  background: var(--c-surface);
  color: var(--c-primary);
  box-shadow: var(--shadow-sm);
}

/* ---- Tone Selector ---- */
.tone-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.tone-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--c-text-secondary);
  margin-right: 4px;
}

.tone-pill {
  min-height: 44px;
  padding: 4px 14px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--c-text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.tone-pill:hover {
  border-color: var(--c-primary);
  color: var(--c-primary);
}

.tone-pill.active {
  background: var(--c-primary-light);
  border-color: var(--c-primary);
  color: var(--c-primary);
  font-weight: 600;
}

.tone-pill-sm {
  padding: 3px 10px;
  font-size: 0.75rem;
}

.tone-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: var(--c-primary-light);
  color: var(--c-primary);
  text-transform: capitalize;
}

.tone-description {
  font-size: 0.75rem;
  color: var(--c-text-secondary);
  margin: 4px 0 10px 0;
  min-height: 1.25em;
}

/* ---- Bulk Mode ---- */
#bulk-notes-input {
  width: 100%;
  min-height: 44px;
  padding: 12px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: monospace;
  line-height: 1.5;
  outline: none;
  resize: vertical;
  transition: border-color var(--transition);
}

#bulk-notes-input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-light);
}

.bulk-hint {
  font-size: 0.75rem;
  color: var(--c-text-secondary);
  margin-top: 6px;
}

/* ---- Progress Bar ---- */
.progress-bar-track {
  height: 8px;
  background: var(--c-border);
  border-radius: 4px;
  margin: 10px 0 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--c-primary);
  border-radius: 4px;
  transition: width 300ms ease;
}

.progress-label {
  font-size: 0.8125rem;
  color: var(--c-text-secondary);
  text-align: center;
}

/* ---- Generation Loading Indicator ---- */
.gen-loading {
  padding: 24px 0 8px;
}

.gen-loading-bar {
  height: 4px;
  background: var(--c-border);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.gen-loading-fill {
  height: 100%;
  width: 30%;
  background: var(--c-primary);
  border-radius: 2px;
  animation: genPulse 1.4s ease-in-out infinite;
  position: absolute;
  left: 0;
}

@keyframes genPulse {
  0% {
    left: -30%;
    width: 30%;
  }
  50% {
    left: 50%;
    width: 40%;
  }
  100% {
    left: 100%;
    width: 30%;
  }
}

.gen-loading-label {
  font-size: 0.875rem;
  color: var(--c-text-secondary);
  text-align: center;
  margin-top: 10px;
}

.dots-anim::after {
  content: "";
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0% {
    content: "";
  }
  25% {
    content: ".";
  }
  50% {
    content: "..";
  }
  75% {
    content: "...";
  }
  100% {
    content: "...";
  }
}

/* ---- Bulk Results Table ---- */
.bulk-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
}

.bulk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.bulk-table th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  color: var(--c-text-secondary);
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}

.bulk-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}

.bulk-table tr.row-clickable {
  cursor: pointer;
}
.bulk-table tr.row-clickable:hover {
  background: var(--c-bg-subtle, rgba(99, 102, 241, 0.06));
}
.bulk-table tr.row-clickable .bulk-title {
  color: var(--c-primary);
}

.bulk-table .status-ok {
  color: var(--c-success);
  font-weight: 600;
}
.bulk-table .status-err {
  color: var(--c-error);
  font-weight: 600;
}
.bulk-table .status-pending {
  color: var(--c-warning);
  font-weight: 600;
}
.bulk-table .status-processing {
  color: var(--c-primary);
  font-weight: 600;
}
.bulk-row-error {
  color: var(--c-error);
  font-size: 0.75rem;
}
.bulk-table .status-queued {
  color: var(--c-text-secondary);
  font-weight: 600;
}
.bulk-table .status-cancelled {
  color: var(--c-text-secondary);
  font-weight: 600;
}

/* In-flight rows get a subtle shimmer so progress feels alive. */
.bulk-table tr.row-active td {
  position: relative;
}
.bulk-table tr.row-active .bulk-title::after {
  content: "";
  display: inline-block;
  width: 60px;
  height: 0.7em;
  margin-left: 2px;
  vertical-align: middle;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--c-border) 25%,
    var(--c-bg) 37%,
    var(--c-border) 63%
  );
  background-size: 400% 100%;
  animation: shimmer 1.2s ease infinite;
}
@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

/* ---- Bulk progress + status ---- */
.bulk-progress {
  padding: 14px 0 4px;
}
.progress-bar-fill.is-error {
  background: var(--c-error);
}
.progress-bar-fill.is-partial {
  background: var(--c-warning);
}
.progress-bar-fill.is-done {
  background: var(--c-success);
}

/* Status pill, shared by progress head, results header, and batch history. */
.batch-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--c-border);
  color: var(--c-text-secondary);
  white-space: nowrap;
}
.batch-pill.pill-queued {
  background: var(--c-border);
  color: var(--c-text-secondary);
}
.batch-pill.pill-processing {
  background: var(--c-primary-light);
  color: var(--c-primary-hover);
}
.batch-pill.pill-completed {
  background: var(--c-success-bg);
  color: var(--c-success);
}
.batch-pill.pill-completed_with_errors {
  background: var(--c-warning-bg);
  color: var(--c-warning);
}
.batch-pill.pill-failed {
  background: var(--c-error-bg);
  color: var(--c-error);
}
.batch-pill.pill-cancelled {
  background: var(--c-border);
  color: var(--c-text-secondary);
}

/* Danger text button (Cancel). */
.btn-text-danger {
  background: none;
  border: none;
  color: var(--c-error);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.btn-text-danger:hover {
  background: var(--c-error-bg);
}
.btn-text-danger:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Pacing / deferred banner. */
.bulk-banner {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  line-height: 1.45;
  border: 1px solid transparent;
}
.bulk-banner.banner-info {
  background: var(--c-primary-light);
  border-color: #c7d2fe;
  color: var(--c-primary-hover);
}
.bulk-banner.banner-warn {
  background: var(--c-warning-bg);
  border-color: #fde68a;
  color: var(--c-warning);
}
.bulk-banner a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
}
.bulk-counts {
  font-size: 0.8125rem;
  color: var(--c-text-secondary);
}

/* ---- FAQ ---- */
.faq-item {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}

.faq-item:last-child {
  margin-bottom: 0;
}

.faq-item summary {
  padding: 10px 14px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  background: var(--c-bg);
  list-style: none;
}

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

.faq-item summary::before {
  content: "+ ";
  color: var(--c-primary);
  font-weight: 700;
}

.faq-item[open] summary::before {
  content: "\2212 ";
}

.faq-item summary:hover {
  background: var(--c-primary-light);
}

.faq-item p {
  padding: 10px 14px;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--c-text);
}

/* ---- Specs ---- */
.specs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.spec-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.spec-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--c-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.spec-value {
  font-size: 0.875rem;
  color: var(--c-text);
  word-break: break-word;
}

.result-specs {
  margin-top: 10px;
}

/* ---- Empty States ---- */
.empty-state {
  text-align: center;
  padding: 12px;
  color: var(--c-text-secondary);
  font-size: 0.8125rem;
  font-style: italic;
}

/* ---- Validation Issues ---- */
.validation-issues {
  margin-top: 8px;
}

.validation-issues .val-warning-item {
  font-size: 0.8125rem;
  color: var(--c-warning);
  margin-bottom: 2px;
}

/* ---- Card Header Actions ---- */
.card-header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .login-container {
    padding: 28px 20px;
  }
  .dashboard-main {
    padding: 16px;
    gap: 14px;
  }
  .dashboard-header {
    padding: 0 16px;
  }
  .user-email {
    display: none;
  }
  .plans-grid {
    grid-template-columns: 1fr 1fr;
  }
  .tone-selector {
    gap: 4px;
  }
  .tone-pill {
    padding: 4px 10px;
    font-size: 0.75rem;
    min-height: 44px;
  }
  .specs-grid {
    grid-template-columns: 1fr;
  }
  .bulk-table {
    font-size: 0.75rem;
  }
  .bulk-table th,
  .bulk-table td {
    padding: 6px 8px;
  }
  .result-tags {
    gap: 4px;
  }
  .tag {
    font-size: 0.75rem;
    padding: 2px 8px;
  }
}

/* ---- History ---- */
.history-card {
  position: relative;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 480px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  gap: 12px;
}

.history-item:hover {
  border-color: var(--c-primary);
  background: var(--c-primary-light);
}

.history-item-main {
  flex: 1;
  min-width: 0;
}

.history-item-notes {
  font-size: 0.875rem;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.history-item-tone {
  font-size: 0.75rem;
  color: var(--c-text-secondary);
  text-transform: capitalize;
}

.history-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--c-text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.history-status {
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: capitalize;
}

.history-status-completed {
  background: var(--c-success-bg);
  color: var(--c-success);
}

.history-status-failed {
  background: var(--c-error-bg);
  color: var(--c-error);
}

.history-status-pending {
  background: var(--c-warning-bg);
  color: var(--c-warning);
}

.history-date {
  font-size: 0.75rem;
  color: var(--c-text-secondary);
}

#history-detail-results > .card {
  border-top: none;
  border-radius: 0;
}

#history-detail-results > .card:last-child {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

#history-detail-results > .card:first-child {
  border-top: 1px solid var(--c-border);
}

#history-detail-results > .result-actions {
  padding: 16px 0;
}

/* 404 Error Page */
.error-page-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--c-bg, #f8f9fb);
}

.error-page-card {
  text-align: center;
  max-width: 420px;
  width: 100%;
  background: var(--c-surface, #fff);
  border-radius: var(--radius-lg, 12px);
  padding: 48px 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.04);
}

.error-page-card .logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.error-page-card .logo h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--c-text, #1e293b);
}

.error-page-code {
  font-size: 4rem;
  font-weight: 700;
  color: var(--c-primary, #6366f1);
  line-height: 1;
  margin: 8px 0;
}

.error-page-msg {
  font-size: 1rem;
  font-weight: 500;
  color: var(--c-text, #1e293b);
  margin: 16px 0 8px;
}

.error-page-hint {
  font-size: 0.8125rem;
  color: var(--c-text-secondary, #64748b);
  margin: 0 0 24px;
}

/* ---- Billing Redirect Pages ---- */
.billing-redirect-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--c-bg, #f8f9fb);
}

.billing-redirect-card {
  text-align: center;
  max-width: 420px;
  width: 100%;
  background: var(--c-surface, #fff);
  border-radius: var(--radius-lg, 12px);
  padding: 48px 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.04);
}

.billing-redirect-card .logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.billing-redirect-card .logo h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--c-text, #1e293b);
}

.billing-redirect-icon {
  margin: 16px auto;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.billing-redirect-msg {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--c-text, #1e293b);
  margin: 4px 0 8px;
}

.billing-redirect-hint {
  font-size: 0.875rem;
  color: var(--c-text-secondary, #64748b);
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.billing-redirect-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--c-border, #e2e8f0);
  border-top-color: var(--c-primary, #6366f1);
  border-radius: 50%;
  animation: billing-spin 0.6s linear infinite;
  flex-shrink: 0;
}

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

/* ---- Account / Settings ---- */
.account-info-card {
  padding: 24px;
}

.account-section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--c-text, #1e293b);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--c-border, #e2e8f0);
}

.account-field {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 6px 0;
}

.account-field + .account-field {
  border-top: none;
}

.account-field-label {
  font-size: 0.8125rem;
  color: var(--c-text-secondary, #64748b);
  flex-shrink: 0;
}

.account-field-value {
  font-size: 0.8125rem;
  color: var(--c-text, #1e293b);
  font-weight: 500;
  text-align: right;
  word-break: break-all;
}

.account-action-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--c-border, #e2e8f0);
}

.account-help-text {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--c-text-muted, #64748b);
}

/* Cookie / storage notice — fixed bottom strip, dismissible. */
.cookie-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--c-surface, #ffffff);
  border: 1px solid var(--c-border, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}
.cookie-banner.hidden {
  display: none;
}
.cookie-banner-text {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--c-text-secondary, #475569);
}
.cookie-banner-text a {
  color: var(--c-primary);
}
.cookie-banner-btn {
  flex: 0 0 auto;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: var(--c-primary, #6366f1);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}
.cookie-banner-btn:hover {
  filter: brightness(0.95);
}

.btn-warning {
  color: var(--c-error, #b91c1c);
  font-weight: 500;
}

.btn-warning:hover {
  color: #991b1b;
  text-decoration: underline;
}

.account-balance-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  background: var(--c-primary-light, #eef2ff);
  color: var(--c-primary, #6366f1);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.account-ledger-loading,
.account-ledger-empty {
  text-align: center;
  padding: 24px;
  color: var(--c-text-secondary, #64748b);
  font-size: 0.8125rem;
}

.account-ledger-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.account-ledger-table th {
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--c-text-secondary, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 6px;
  border-bottom: 1px solid var(--c-border, #e2e8f0);
}

.account-ledger-table td {
  padding: 8px 6px;
  font-size: 0.8125rem;
  color: var(--c-text, #1e293b);
  border-bottom: 1px solid var(--c-border, #e2e8f0);
}

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

.account-ledger-credit-positive {
  color: var(--c-success, #15803d);
  font-weight: 500;
}

.account-ledger-credit-negative {
  color: var(--c-error, #b91c1c);
  font-weight: 500;
}

.account-ledger-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--c-border, #e2e8f0);
}

.account-ledger-pagination .btn-text {
  width: auto;
  font-size: 0.8125rem;
}

.account-ledger-pagination .btn-text:disabled {
  color: var(--c-text-muted, #78859c);
  cursor: default;
  opacity: 0.5;
}

.account-ledger-page-info {
  font-size: 0.75rem;
  color: var(--c-text-secondary, #64748b);
}

#account-nav-btn {
  width: auto;
  margin: 0;
  color: var(--c-text-secondary);
  font-weight: 500;
}

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

/* ============================================================
   Unified "Your generations" feed + detail modal
   ============================================================ */

/* Source badge: distinguishes a single listing from a bulk batch in the feed
   and the modal header. */
.feed-source-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.feed-source-badge.src-single {
  background: var(--c-primary-light);
  color: var(--c-primary-hover);
}
.feed-source-badge.src-bulk {
  background: var(--c-info-bg);
  color: var(--c-info);
}

.feed-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.feed-item-head .history-item-notes {
  margin: 0;
}
.feed-item-sub {
  font-size: 0.8125rem;
  color: var(--c-text-secondary);
  margin-top: 4px;
}

/* The rotation angle for the flowing border. Registered so it can be animated
   (a plain custom property can't interpolate). Browsers without @property fall
   back to the static 0deg gradient via the var() fallback below. */
@property --feed-flow-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

/* Active (queued/processing) feed row — lifted out of the static list so the
   "still generating" signal is impossible to miss: a tinted wash, soft glow, and
   a light glint that flows clockwise around the border like water (below). Sits
   above the plain rows (which float to the top in JS). */
.feed-item.is-active {
  position: relative;
  border-color: transparent;
  background: var(--c-primary-light);
  box-shadow: var(--shadow-sm);
}

/* Flowing conic-gradient border. The gradient fills the box and is masked to just
   the border ring; a light glint sweeps clockwise as --feed-flow-angle rotates,
   reading as gentle water-like motion rather than a static outline. */
.feed-item.is-active::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  padding: 2px;
  background: conic-gradient(
    from var(--feed-flow-angle, 0deg),
    var(--c-primary) 0deg,
    var(--c-primary) 150deg,
    rgba(255, 255, 255, 0.9) 190deg,
    var(--c-primary) 230deg,
    var(--c-primary) 360deg
  );
  /* Show only the padding ring: full-box mask minus the content-box. */
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  animation: feed-flow-border 3.5s linear infinite;
  pointer-events: none;
}
@keyframes feed-flow-border {
  to { --feed-flow-angle: 360deg; }
}
/* Keep the row's own content above the border ring. */
.feed-item.is-active > .history-item-main,
.feed-item.is-active > .history-item-meta {
  position: relative;
  z-index: 1;
}

/* Pulsing "live" dot in the meta rail — the at-a-glance cue that work is running. */
.feed-live-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--c-primary);
  flex-shrink: 0;
  box-shadow: 0 0 0 0 var(--c-primary);
  animation: feed-live-pulse 1.4s ease-out infinite;
}
@keyframes feed-live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.55); }
  70% { box-shadow: 0 0 0 6px rgba(99, 102, 241, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

/* Inline mini progress bar on an active feed row. */
.feed-progress {
  position: relative;
  height: 4px;
  border-radius: 999px;
  background: var(--c-muted);
  overflow: hidden;
  margin-top: 8px;
}
.feed-progress-fill {
  position: relative;
  height: 100%;
  background: var(--c-primary);
  border-radius: 999px;
  overflow: hidden;
  transition: width var(--transition);
}
/* A moving sheen over the bar so it reads as "actively working", not stalled. */
.feed-progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.5) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: translateX(-100%);
  animation: feed-progress-sheen 1.4s linear infinite;
}
/* No per-item percentage (a single listing) → animate the fill itself so the bar
   never sits misleadingly empty. */
.feed-progress.is-indeterminate .feed-progress-fill {
  animation: feed-progress-indeterminate 1.5s ease-in-out infinite;
  transform-origin: left center;
}
@keyframes feed-progress-sheen {
  to { transform: translateX(100%); }
}
@keyframes feed-progress-indeterminate {
  0% { transform: scaleX(0.15); opacity: 0.7; }
  50% { transform: scaleX(0.6); opacity: 1; }
  100% { transform: scaleX(0.15); opacity: 0.7; }
}

/* Honour reduced-motion: keep every prominence cue that reads while static
   (border, wash, glow, dot, full bar) but drop the looping animations. */
@media (prefers-reduced-motion: reduce) {
  .feed-live-dot,
  .feed-item.is-active::before,
  .feed-progress-fill::after,
  .feed-progress.is-indeterminate .feed-progress-fill {
    animation: none;
  }
  .feed-progress.is-indeterminate .feed-progress-fill {
    transform: none;
  }
}

/* ---- Detail modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.hidden {
  display: none;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}
.modal-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--max-width);
  /* Fixed height (not just max-height) so the panel doesn't size to the tiny
     "Loading…" placeholder on open and then resize when content renders. The
     body scrolls, so a stable height is fine for both short and tall content. */
  height: 90vh;
  max-height: 90vh;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
}
.modal-head-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.modal-title {
  font-size: 1.0625rem;
  margin: 0;
  margin-right: 4px;
}
.modal-close {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
}
.modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 20px;
}
.modal-body .result-card:first-child {
  margin-top: 0;
}
#gen-modal-progress {
  padding: 12px 20px 0;
}
.modal-item-nav {
  margin-bottom: 12px;
}
.modal-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
}
.modal-foot-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* Full-screen on mobile for prominence. */
@media (max-width: 600px) {
  .modal-overlay {
    padding: 0;
  }
  .modal-panel {
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
  }
}
