:root {
  /* Page shell — harmonized with the Cinematic Editorial Hub (Light) */
  --rp-bg: #fcf9f2;
  --rp-surface: #f6f3ec;
  --rp-surface-2: #f1eee7;
  --rp-surface-3: #e9e2d2;
  --rp-text: #1c1c18;
  --rp-text-secondary: #55504a;
  --rp-outline: #c4c7c7;
  --rp-outline-variant: #d8d3c8;
  --rp-accent: #b34700;
  --rp-accent-strong: #ff6b00;
  --rp-focus-tint: rgba(28, 28, 24, 0.04);

  /* RPCard's own Protagonist Editorial download button — unchanged, not part of the Hub shell */
  --rp-action-bg: #000000;
  --rp-action-text: #ffffff;

  /* Card-specific (Classic Editorial) — RPCard's approved identity, untouched by the Hub redesign */
  --rp-card-text: #faf7ef;
  --rp-card-text-secondary: #d8d2c2;
  --rp-card-accent: #a69062;
  --rp-card-scrim: linear-gradient(
    to top,
    rgba(10, 9, 6, 0.93) 0%,
    rgba(10, 9, 6, 0.55) 45%,
    rgba(10, 9, 6, 0) 80%
  );
  --rp-card-photo-filter: grayscale(85%) contrast(1.08) brightness(0.98);
}

body.theme-dark {
  /* Page shell — harmonized with the Cinematic Editorial Hub (Dark) */
  --rp-bg: #121414;
  --rp-surface: #1a1c1c;
  --rp-surface-2: #1e2020;
  --rp-surface-3: #282a2b;
  --rp-text: #e2e2e2;
  --rp-text-secondary: #b7a89f;
  --rp-outline: #33302e;
  --rp-outline-variant: #262626;
  --rp-accent: #ffb693;
  --rp-accent-strong: #ff6b00;
  --rp-focus-tint: rgba(255, 107, 0, 0.08);

  /* RPCard's own Protagonist Editorial download button — unchanged, not part of the Hub shell */
  --rp-action-bg: #f0f0f0;
  --rp-action-text: #0a0a0a;

  /* Card-specific (Dark Urban) — RPCard's approved identity, untouched by the Hub redesign */
  --rp-card-text: #f5f5f3;
  --rp-card-text-secondary: #b8b8b6;
  --rp-card-accent: #c9c9c6;
  --rp-card-scrim: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.95) 0%,
    rgba(0, 0, 0, 0.6) 45%,
    rgba(0, 0, 0, 0) 80%
  );
  --rp-card-photo-filter: contrast(1.05) saturate(0.92) brightness(0.96);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--rp-bg);
  color: var(--rp-text);
  transition: background-color 0.2s ease, color 0.2s ease;
}

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

/* Header */
.site-header {
  border-bottom: 1px solid var(--rp-outline-variant);
}

.site-header-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 64px;
}

.back-to-hub {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--rp-text-secondary);
  text-decoration: none;
}

.back-to-hub[hidden] {
  display: none;
}

.back-to-hub:hover {
  color: var(--rp-accent);
}

.wordmark {
  display: block;
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.01em;
  color: var(--rp-text);
  text-decoration: none;
}

.tagline {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--rp-text-secondary);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.theme-toggle-icons {
  display: inline-flex;
  border: 1px solid var(--rp-outline);
  padding: 2px;
}

.theme-icon-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--rp-text-secondary);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.theme-icon-btn[aria-pressed="true"] {
  background: var(--rp-surface-3);
  color: var(--rp-accent-strong);
}

.lang-select-wrap select {
  border: 1px solid var(--rp-outline);
  border-radius: 0;
  background: transparent;
  color: var(--rp-text);
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 6px 8px;
  cursor: pointer;
}

/* Layout */
.app-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 64px;
  align-items: start;
}

/* Editor */
.editor-title {
  margin: 0 0 24px;
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 48px;
  line-height: 1.2;
}

#card-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.field-row {
  display: flex;
  gap: 24px;
}

.field-row .field {
  flex: 1;
  min-width: 0;
}

label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--rp-text-secondary);
}

.field input[type="text"],
.field input[type="number"] {
  padding: 10px 4px;
  border: none;
  border-bottom: 2px solid var(--rp-outline);
  border-radius: 0;
  background: transparent;
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 16px;
  color: var(--rp-text);
  width: 100%;
  min-width: 0;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.field input[type="text"]:focus,
.field input[type="number"]:focus {
  outline: none;
  border-bottom-color: var(--rp-accent-strong);
  background-color: var(--rp-focus-tint);
}

/* Preview */
.preview-stage {
  display: flex;
  justify-content: center;
}

.preview-card-wrap {
  container-type: inline-size;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (min-width: 901px) {
  .preview-stage {
    position: sticky;
    top: 48px;
    align-self: start;
  }
}

.rpcard {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 0;
  overflow: hidden;
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.18);
  font-family: "Manrope", system-ui, sans-serif;
}

.rpcard-remove-photo {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 0;
  background: rgba(0, 0, 0, 0.35);
  color: var(--rp-card-text);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.rpcard-remove-photo:hover,
.rpcard-remove-photo:focus-visible {
  background: rgba(0, 0, 0, 0.5);
  border-color: rgba(255, 255, 255, 0.6);
}

.rpcard-photo {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-image: url("assets/default-character.svg");
  filter: var(--rp-card-photo-filter);
}

.rpcard-photo-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.rpcard-photo-placeholder:focus-visible {
  outline: 2px solid var(--rp-card-accent);
  outline-offset: -6px;
}

.rpcard-photo-placeholder span {
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.35);
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rp-card-text);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.rpcard-photo-placeholder:hover span,
.rpcard-photo-placeholder:focus-visible span {
  background: rgba(0, 0, 0, 0.5);
  border-color: rgba(255, 255, 255, 0.6);
}

.rpcard-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: var(--rp-card-scrim);
}

.rpcard-content {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6cqi 6cqi 7cqi;
  z-index: 2;
  color: var(--rp-card-text);
}

.rpcard-metaline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 5px 10px;
  border: 1px solid var(--rp-card-accent);
  background: rgba(0, 0, 0, 0.28);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--rp-card-text);
}

.rpcard-meta-sep {
  opacity: 0.6;
}

.rpcard-content h3 {
  margin: 0 0 8px;
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: clamp(1.6rem, 6.6cqi, 2.75rem);
  line-height: 1.15;
  color: var(--rp-card-text);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rpcard-role {
  margin: 0 0 20px;
  font-size: 15px;
  font-weight: 700;
  color: var(--rp-card-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rpcard-quote-wrap {
  border-left: 3px solid var(--rp-card-accent);
  background: rgba(0, 0, 0, 0.26);
  padding: 12px 16px;
}

#rpcard-quote {
  margin: 0;
  font-style: italic;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.5;
  color: var(--rp-card-text-secondary);
}

/* Bottom signature strip — renders a discreet brand/domain stamp below the
   content, mirroring the footer drawn into the exported PNG. Kept small so it
   reads as a credit, not a distraction. */
.rpcard-credit {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2.4cqi;
  z-index: 2;
  margin: 0;
  padding: 0 4cqi;
  text-align: center;
  font-family: "Manrope", system-ui, "Segoe UI", sans-serif;
  font-size: 1.5cqi;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--rp-card-accent);
  opacity: 0.85;
}

/* Download button */
.btn-download {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 0;
  background: var(--rp-action-bg);
  color: var(--rp-action-text);
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
}

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

/* FAQ */
.faq-section {
  border-top: 1px solid var(--rp-outline-variant);
}

.faq-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 64px;
}

.faq-title {
  margin: 0 0 24px;
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 28px;
}

.faq-item {
  padding: 16px 0;
  border-top: 1px solid var(--rp-outline-variant);
}

.faq-item h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
}

.faq-item p {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--rp-text-secondary);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--rp-outline-variant);
}

.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 64px;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-links a {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--rp-text-secondary);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--rp-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Institutional pages */
.page-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 64px;
}

.page-main h1 {
  margin: 0 0 24px;
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 40px;
  line-height: 1.2;
}

.page-main h2 {
  margin: 32px 0 8px;
  font-size: 18px;
  font-weight: 700;
}

.page-main p {
  margin: 0 0 16px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--rp-text-secondary);
}

.page-main p:last-child {
  margin-bottom: 0;
}

.page-updated {
  margin: -12px 0 24px;
  font-size: 13px;
  color: var(--rp-text-secondary);
}

@media (max-width: 900px) {
  .site-header-inner {
    padding: 16px;
  }

  .app-main {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 24px 16px;
  }

  .editor-title {
    font-size: 32px;
  }

  .preview-card-wrap {
    max-width: 420px;
    margin: 0 auto;
  }

  .faq-inner,
  .site-footer-inner,
  .page-main {
    padding: 32px 16px;
  }

  .page-main h1 {
    font-size: 30px;
  }
}

@media (max-width: 480px) {
  .field-row {
    flex-direction: column;
    gap: 24px;
  }
}
