/* Desktop dimensions are taken from MTPDF-prototipo-media.xd (1920 × 1080).
   A shared rem scale preserves their proportions on laptop screens. */
@font-face {
  font-family: "Cairo";
  src: url("assets/fonts/Cairo-Light.ttf") format("truetype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Cairo";
  src: url("assets/fonts/Cairo-Variable.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Cairo";
  src: url("assets/fonts/Cairo-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Cairo";
  src: url("assets/fonts/Cairo-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Cairo";
  src: url("assets/fonts/Cairo-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Sansation";
  src: url("assets/fonts/Sansation-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Sansation";
  src: url("assets/fonts/Sansation-Light.ttf") format("truetype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Sansation";
  src: url("assets/fonts/Sansation-BoldItalic.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Sansation-BoldItalic";
  src: url("assets/fonts/Sansation-BoldItalic.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Sansation-Italic";
  src: url("assets/fonts/Sansation-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #f6eee8;
  --surface: #fff8f6;
  --surface-2: #fcf4f4;
  --surface-3: #ffffff;
  --red: #f14444;
  --red-deep: #ef1e1e;
  --red-soft: #ffb097;
  --green: #16c946;
  --green-line: #0ebe3d;
  --green-ink: #009a29;
  --text: #5a0012;
  --muted: #a48188;
  --line: #deb4b4;
  --line-2: #dfb8b8;
  --line-3: #f6dacf;
  --nav-bg: rgba(255, 255, 255, 0.5);
  --nav-line: rgba(241, 68, 68, 0.15);
  --drop-bg: #fff8f6;
  --drop-line: rgba(0, 165, 66, 0.5);
  --notice-bg: #fcf4f4;
  --notice-line: rgba(241, 68, 68, 0.3);
  --add-bottom: rgba(255, 248, 246, 0.6);
  --modal-bg: #f6eee8;
  --modal-line: #deb4b4;
  --field-bg: #fff8f6;
  --field-line: #dfb8b8;
  --divider: #deb4b4;
  --overlay: rgba(214, 203, 202, 0.77);
  --shadow: 0 1.5rem 5rem rgba(90, 0, 18, 0.12);
  --toast-bg: #373432;
  --page-title: #3b3230;
  --page-subtitle: #19269c;
  --gutter: 8.75rem;
  --modal-pad: 3.875rem;
  --modal-top: clamp(1.5rem, calc(100dvh - 60.9375rem), 6.5625rem);
  font-size: 1rem;
}

html[data-theme="dark"] {
  --bg: #211f1e;
  --surface: #262423;
  --surface-2: #373432;
  --surface-3: #2b2928;
  --red: #f14444;
  --green: #16c946;
  --green-line: #16c946;
  --green-ink: #16c946;
  --text: #fcf4f4;
  --muted: #918883;
  --line: #5a504c;
  --line-2: #5a504c;
  --line-3: #453d39;
  --nav-bg: rgba(24, 23, 23, 0.94);
  --nav-line: rgba(241, 68, 68, 0.16);
  --drop-bg: #211f1e;
  --drop-hover-bg: #262423;
  --drop-line: rgba(22, 201, 70, 0.45);
  --notice-bg: #373432;
  --notice-line: rgba(241, 68, 68, 0.35);
  --add-bottom: transparent;
  --modal-bg: #262423;
  --modal-line: #5a504c;
  --field-bg: #373432;
  --field-line: #5a504c;
  --divider: #5a504c;
  --overlay: rgba(10, 9, 9, 0.74);
  --shadow: 0 1.5rem 5rem rgba(0, 0, 0, 0.5);
  --toast-bg: #fcf4f4;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Cairo", sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
}

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

img,
svg {
  display: block;
}

img {
  max-width: 100%;
}

:focus-visible {
  outline: 0.125rem solid var(--green);
  outline-offset: 0.1875rem;
}

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

.topbar {
  position: relative;
  z-index: 20;
  height: 4.4375rem;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-line);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.topbar-inner {
  display: flex;
  align-items: center;
  height: 4.4375rem;
  max-width: 120rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.brand {
  flex: none;
  width: 15.944125rem;
  height: 3.2479375rem;
  margin-top: -0.0625rem;
  margin-left: -0.153125rem;
}

.brand svg {
  width: 15.944125rem;
  height: 3.2479375rem;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0;
  margin-left: auto;
  font-size: 1.375rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transform: translateY(-0.125rem);
}

.nav a {
  flex: none;
  padding: 0 0.25rem;
  color: var(--red);
  transition: opacity 0.2s ease, color 0.2s ease;
}

.nav a:hover {
  opacity: 0.68;
}

.nav a[aria-current="page"] {
  color: var(--green-ink);
}

.tools {
  display: flex;
  align-items: center;
  gap: 0.53125rem;
  margin-left: 3.1875rem;
  margin-right: 0.46875rem;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.375rem;
  height: 2.375rem;
  border-radius: 50%;
  color: var(--red);
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.icon-btn:hover {
  background: rgba(241, 68, 68, 0.08);
  transform: translateY(-0.0625rem);
}

.icon-btn img {
  width: 1.625rem;
  height: 1.625rem;
}

.theme-icon--sun {
  display: none;
}

html[data-theme="dark"] .theme-icon--moon {
  display: none;
}

html[data-theme="dark"] .theme-icon--sun {
  display: block;
}

.page {
  display: grid;
  grid-template-columns: 23.875rem minmax(0, 1fr);
  gap: 3.75rem;
  max-width: 120rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.stage {
  min-width: 0;
}

.mascot {
  width: 21.9375rem;
  height: 35.0625rem;
  margin: 3.75rem 0 0 0.6875rem;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

.mascot--dark {
  display: none;
}

html[data-theme="dark"] .mascot--light {
  display: none;
}

html[data-theme="dark"] .mascot--dark {
  display: block;
}

/* Animated boy (boy-animation.js + assets/boy.svg). The SVG takes the PNG's
   place and size; the stage stays in view while the file list scrolls. */
.stage {
  position: sticky;
  top: 1rem;
  align-self: start;
}

.stage.has-boy .mascot {
  display: none;
}

.boy-svg {
  display: block;
  width: 21.9375rem;
  height: 35.0625rem;
  margin: 3.75rem 0 0 0.6875rem;
  user-select: none;
  pointer-events: none;
}

/* Merge animation. Narrow layouts (stage column hidden) or the boy scrolled
   away: he performs in a centred overlay, the cards still visible behind. */
.stage.is-overlay {
  position: fixed;
  inset: 0;
  /* align-self also sizes positioned boxes: "start" (set for the sticky
     stage) would shrink the overlay to its content instead of the viewport. */
  align-self: stretch;
  justify-self: stretch;
  z-index: 140;
  display: flex !important;
  align-items: center;
  justify-content: center;
  margin: 0;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(2px);
}

.stage.is-overlay .boy-svg {
  width: auto;
  height: min(35.0625rem, 72dvh);
  max-width: calc(100vw - 32px);
  margin: 0;
}

.stage.is-overlay .btn--generate {
  display: none;
}

/* The sheets flying from the cards to the boy (positioned by GSAP). */
.boy-fly-layer {
  position: fixed;
  inset: 0;
  z-index: 150;
  pointer-events: none;
}

.boy-flyer {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}

.boy-flyer > * {
  position: absolute;
  top: 0;
  left: 0;
  translate: -50% -50%;
}

.boy-flyer-card {
  box-sizing: border-box;
  border: 1px solid var(--line-3);
  border-radius: 0.375rem;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 0.5rem 1.5rem rgba(90, 0, 18, 0.12);
}

.boy-flyer-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.boy-flyer-sheet {
  overflow: visible;
}

/* A card while its sheet is away (the sheet starts exactly over it). */
.file-card.is-sent {
  opacity: 0;
}

.workspace {
  min-width: 0;
  padding-top: 1.6875rem; /* same as the gap below the buttons (.dropzone margin-top) */
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1.875rem;
  height: 3.9375rem;
  white-space: nowrap;
}

.format-group {
  display: flex;
  align-items: center;
  gap: 0.8125rem;
  flex: none;
}

/* Widths here are content-driven, not fixed: the labels change length with the
   UI language, so anything sized to the English string would clip or overflow.
   Where a control needs visual presence on its own, the old prototype width
   stays as a min-width floor instead. */
.format-label {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  flex: none;
  width: auto;
  color: var(--red);
  font-size: 1.375rem;
  font-weight: 400;
  line-height: 1;
}

.select-wrap {
  position: relative;
  display: inline-flex;
  flex: none;
  width: auto;
  height: 3.9375rem;
}

/* The select sizes to its widest option, so changing format never resizes the
   toolbar; min-width keeps the original proportion for short labels. */
.select-wrap select {
  width: auto;
  min-width: 8.25rem;
  height: 100%;
  appearance: none;
  padding: 0 2.125rem 0 1.25rem;
  border: 0.125rem solid var(--red);
  border-radius: 0.375rem;
  background: var(--surface);
  color: var(--red);
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.select-wrap select:hover {
  background: var(--surface-2);
}

.select-chevron {
  position: absolute;
  top: 50%;
  right: 1rem;
  width: 0.8125rem;
  height: 0.5rem;
  color: var(--red);
  pointer-events: none;
  transform: translateY(-50%);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 3.9375rem;
  gap: 1rem;
  /* Side padding, not a fixed width, is what gives every button its breathing
     room, so the set stays consistent whatever language the labels are in. */
  padding: 0 1.125rem;
  border: 0.125rem solid transparent;
  border-radius: 0.375rem;
  font-size: 1.375rem;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.btn:hover {
  transform: translateY(-0.0625rem);
}

.btn img {
  flex: none;
}

.btn--outline {
  border-color: var(--red);
  background: var(--surface);
  color: var(--red);
}

.btn--outline.btn--create:hover {
  border-color: var(--red-deep);
  background: var(--red);
  color: #fff8f6;
}

/* The outline button's red icon turns light on hover, like the solid button's. */
.btn--outline.btn--create:hover img {
  filter: brightness(0) invert(1);
}

.btn--solid {
  border-color: var(--red-deep);
  background: var(--red);
  color: #fff8f6;
}

.btn--solid:hover {
  background: #ef2f2f;
  border-color: #d81717;
}

/* The three toolbar buttons simply fit their labels, so they stay a consistent
   set in every language instead of one of them overflowing. */
.btn--create,
.btn--download,
.btn--share {
  width: auto;
}

.btn--share {
  border-color: var(--green-line);
  background: var(--green);
  color: #fff;
}

.btn--share:hover {
  background: #009a29;
  border-color: #0ebe3d;
}

/* A lone call to action: it keeps its designed size for short labels and only
   grows when a translation needs the room. */
.btn--generate {
  width: auto;
  min-width: 14.875rem;
  margin: 1rem 0 0 4.5rem;
  justify-content: center;
  gap: 0.75rem;
  border-color: var(--red-deep);
  background: var(--red);
  color: #fff;
}

.btn--generate img {
  width: 1.375rem;
}

.btn--download:hover,
.btn--generate:hover {
  background: #009a29;
  border-color: #16c946;
}

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 15.375rem;
  margin-top: 1.6875rem;
  padding: 2.6546875rem 1.625rem 1.875rem 1.5rem;
  border: 1px dashed var(--drop-line);
  border-radius: 0.375rem;
  background: var(--notice-bg);
  text-align: center;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.dropzone:hover,
.dropzone.is-over {
  border-color: var(--green);
  background: var(--drop-hover-bg, #fff);
}

.dropzone:active {
  transform: scale(0.998);
}

.upload-icon {
  width: 3.233875rem;
  height: 4.1578125rem;
  margin-bottom: 1.5rem;
  color: var(--green);
}

.dropzone h1 {
  margin: 0;
  color: var(--green-ink);
  font-family: "Sansation", sans-serif;
  font-size: 1.75rem;
  font-style: italic;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
}

.dropzone p {
  margin: 0.875rem 0 0;
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.3;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  width: calc(100% + 0.125rem);
  min-height: 4.375rem;
  margin-left: -0.125rem;
  margin-top: 1.4375rem;
  padding: 0.75rem 1.5rem;
  border: 1px solid var(--notice-line);
  border-radius: 0.375rem;
  background: var(--notice-bg);
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 300;
  line-height: 1.3;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.notice:hover {
  border-color: var(--red);
}

.notice-icon {
  flex: none;
  width: 1.75rem;
  height: 1.5625rem;
  background: var(--red);
  -webkit-mask: url("assets/icon--star-shine.svg") center / contain no-repeat;
  mask: url("assets/icon--star-shine.svg") center / contain no-repeat;
  transition: background-color 0.2s ease;
}

.notice strong {
  color: var(--red);
  font-weight: 700;
  transition: color 0.2s ease;
}

.notice:hover strong {
  color: var(--green-ink);
}

.notice:hover .notice-icon {
  background: var(--green-ink);
}

.cards {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1.25rem;
  margin-top: 2.125rem;
  padding-bottom: 3.75rem;
}

.file-card {
  position: relative;
  flex: none;
  width: 11.3125rem;
  height: 19.4375rem;
  overflow: hidden;
  border: 1px solid var(--line-3);
  border-radius: 0.375rem;
  background: var(--surface);
  cursor: grab;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.file-card:hover {
  border-color: var(--line);
  box-shadow: 0 0.5rem 1.5rem rgba(90, 0, 18, 0.08);
}

.file-card.is-dragging {
  opacity: 0.45;
}

.file-media {
  width: 100%;
  height: 18.5rem;
  overflow: hidden;
  background: var(--surface-2);
}

.file-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-meta {
  display: flex;
  align-items: flex-start;
  height: 0.8125rem;
  padding: 0 0.3125rem;
  color: var(--red);
  font-family: "Sansation", sans-serif;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 0.8125rem;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.card-tool {
  position: absolute;
  top: 5px;
  width: 24px;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: grab;
}

.card-tool img {
  display: block;
  width: 24px;
  height: 30px;
}

.card-tool--drag {
  left: 5px;
}

.card-tool--delete {
  right: 5px;
  cursor: pointer;
}

/* 7px to the right of the drag handle (5px + 24px + 7px). Created pages/covers only. */
.card-tool--edit {
  left: 36px;
  cursor: pointer;
}

/* The SVG area is 70% red; a solid red base under it makes the hover 100% opaque. */
.card-tool--edit:hover,
.card-tool--drag:hover,
.card-tool--delete:hover {
  border-radius: 3px;
  background: var(--red);
}

.add-card {
  display: flex;
  flex-direction: column;
  flex: none;
  width: 11.3125rem;
  height: 19.4375rem;
  overflow: hidden;
  border: 1px dashed var(--drop-line);
  border-radius: 0.375rem;
  background: var(--add-bottom);
  text-align: center;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.add-card:hover {
  border-color: var(--green);
}

.add-card:hover .add-card-top {
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}

.add-card-top {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  width: 100%;
  background: transparent;
  height: 13.3125rem;
  border-bottom: 1px dashed var(--drop-line);
  color: var(--green-ink);
  font-family: "Sansation", sans-serif;
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.375rem;
  transition: background-color 0.2s ease;
}

.add-card-bottom {
  display: block;
  flex: 1;
  width: 100%;
  height: 6.125rem;
  background: transparent;
}

.developed {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  color: var(--text);
  font-family: "Sansation", sans-serif;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1;
  pointer-events: auto;
  text-decoration: none;
  cursor: pointer;
}

.developed img {
  width: 4.9375rem;
  height: 2.25rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--modal-top) 1.5rem 1.5rem;
  background: var(--overlay);
  animation: fade-in 0.16s ease both;
}

.modal-panel {
  display: flex;
  flex-direction: column;
  width: 64.875rem;
  max-width: calc(100vw - 3rem);
  height: min(56.625rem, calc(100dvh - var(--modal-top) - 1.5rem));
  overflow: hidden;
  border: 1px solid var(--modal-line);
  border-radius: 0.375rem;
  background: var(--modal-bg);
  box-shadow: var(--shadow);
  animation: pop-in 0.18s ease both;
}

.modal-panel:focus {
  outline: none;
}

.modal-panel.is-wide {
  width: 91.875rem;
  --modal-pad: 3.78125rem;
}

.modal-head {
  position: relative;
  display: flex;
  align-items: center;
  flex: none;
  height: 4.875rem;
  padding: 0 var(--modal-pad);
}

.modal-head::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background: var(--divider);
}

.modal-head h2 {
  flex: 0 0 17.0625rem;
  margin: 0;
  color: var(--green-ink);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.layout-mode {
  display: flex;
  align-items: center;
  gap: 0.8125rem;
}

.layout-label {
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
}

.segmented {
  display: flex;
  width: auto;
  min-width: 14.8125rem;
  height: 2.6875rem;
  overflow: hidden;
  border: 0.125rem solid var(--red);
  border-radius: 0.375rem;
  background: var(--surface);
}

/* Equal halves that can still grow past the minimum when a label is longer. */
.seg {
  flex: 1;
  height: 100%;
  padding: 0 0.75rem;
  white-space: nowrap;
  color: var(--red);
  font-size: 1.375rem;
  font-weight: 400;
  line-height: 1;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.seg.is-active {
  background: var(--red);
  color: #fff;
}

/* Cover is unavailable while both a front and a back cover already exist. */
.seg:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Why a cover face is missing: only one front and one back cover are allowed. */
.cover-note {
  margin: -0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.35;
}

.modal-body {
  display: flex;
  flex: 1;
  min-height: 0;
  align-items: flex-start; /* children size to their content so the bottom padding stays below the last field when scrolling */
  gap: 3.9375rem;
  padding: 0 4rem 2rem var(--modal-pad);
  overflow: auto;
}

.modal-panel.is-wide .modal-body {
  padding-right: 3.0625rem;
  gap: 3.65625rem;
}

.creator-fields {
  display: flex;
  flex-direction: column;
  flex: 0 0 25.875rem;
  /* Without this the column's automatic minimum size is its widest content, so
     one long file name or word would widen it and crush the preview beside it.
     Fields that cannot shrink must truncate or wrap on their own. */
  min-width: 0;
  gap: 1.625rem;
  padding-top: 1.375rem;
}

.face-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.6875rem;
}

.face-label {
  flex: none;
  width: auto;
  white-space: nowrap;
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.6875rem;
  padding: 0 0.75rem;
  border: 1px solid transparent;
  border-radius: 0.375rem;
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
}

.pill--face {
  border-color: var(--red);
  background: var(--surface);
  color: var(--red);
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.pill--face.is-active {
  border-color: var(--green-line);
  background: var(--green);
  color: #fff;
}

.pill--ghost {
  padding: 0 0.625rem;
  color: var(--red);
  border-color: transparent;
  background: transparent;
}

.pill--ghost:hover {
  background: color-mix(in srgb, var(--surface) 65%, transparent);
}

.pill-wrap {
  position: relative;
  display: flex;
  height: 2.6875rem;
  border: 1px solid var(--line);
  border-radius: 0.375rem;
  overflow: hidden;
}

.pill-wrap .pill {
  height: 100%;
  padding-right: 2.375rem;
  border: 0;
  border-radius: 0;
}

.pill-x {
  position: absolute;
  top: 0.5625rem;
  right: 0.3125rem;
  display: grid;
  place-items: center;
  width: 1.4375rem;
  height: 1.4375rem;
  border-radius: 0.125rem;
  background: #fff;
  color: var(--red);
  font-size: 1.0625rem;
  font-weight: 400;
  line-height: 1;
}

/* No × when the back cover is the only face left to create. */
.pill-wrap.is-locked .pill {
  padding-right: 0.75rem;
}

.pill-x:hover {
  background: #fff0ef;
}

.fields-block {
  display: flex;
  flex-direction: column;
  gap: 1.375rem;
}

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

.field > label,
.font-row label {
  display: block;
  margin-bottom: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.875rem;
}

.text-input {
  width: 100%;
  height: 2.6875rem;
  padding: 0 0.8125rem;
  border: 1px solid var(--field-line);
  border-radius: 0.375rem;
  outline: 0;
  background: var(--field-bg);
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 400;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.text-input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.text-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 0.125rem rgba(22, 201, 70, 0.12);
}

.back-text {
  height: 20rem;
  min-height: 20rem;
  padding: 0.625rem 0.8125rem;
  line-height: 1.4;
  resize: none;
  overflow: hidden;
}

.back-text-field {
  margin-bottom: 0;
}

.slider-head {
  display: flex;
  align-items: center;
  height: 1.8125rem;
  gap: 0;
}

.slider-head label {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
}

.value-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  min-width: 3.5rem;
  height: 1.875rem;
  margin-left: 0.625rem;
  padding: 0 0.625rem;
  border: 1px solid var(--field-line);
  border-radius: 0.375rem;
  background: var(--field-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.value-badge:hover,
.value-badge:focus-within {
  border-color: var(--red);
}

.value-badge:focus-within {
  box-shadow: 0 0 0 2px rgba(241, 68, 68, 0.18);
}

.value-badge input {
  width: 3ch;
  min-width: 1ch;
  height: 100%;
  border: 0;
  padding: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}

/* Grow with the number so value and unit stay centered as a pair. */
@supports (field-sizing: content) {
  .value-badge input { width: auto; field-sizing: content; }
}

.value-badge input::-webkit-outer-spin-button,
.value-badge input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.value-badge span {
  margin: 0;
  color: var(--muted);
}

.value-badge--opacity {
  min-width: 3rem;
}

.range {
  display: block;
  width: 100%;
  height: 0.5rem;
  margin: 0.8125rem 0 0;
  border: 1px solid var(--field-line);
  border-radius: 0.375rem;
  outline: 0;
  background: linear-gradient(to right, var(--red) 0 var(--pct, 50%), var(--field-bg) var(--pct, 50%) 100%);
  appearance: none;
  cursor: pointer;
}

.range::-webkit-slider-thumb {
  width: 1rem;
  height: 1rem;
  border: 0;
  border-radius: 50%;
  background: var(--red);
  appearance: none;
  cursor: grab;
}

.range::-moz-range-thumb {
  width: 1rem;
  height: 1rem;
  border: 0;
  border-radius: 50%;
  background: var(--red);
  cursor: grab;
}

.range::-moz-range-track {
  height: 0.375rem;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
}

.font-row {
  display: grid;
  grid-template-columns: 19.25rem 5.375rem;
  gap: 1.25rem;
  align-items: end;
}

.font-row label {
  line-height: 2.125rem;
}

.font-select {
  display: block;
  width: 100%;
  height: 2.6875rem;
  padding: 0 2.25rem 0 0.8125rem;
  border: 1px solid var(--field-line);
  border-radius: 0.375rem;
  outline: 0;
  background-color: var(--field-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1.5 1.5 7 7l5.5-5.5' fill='none' stroke='%23f14444' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9375rem center;
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 400;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.font-select:focus {
  border-color: var(--green);
}

.color-input {
  display: block;
  width: 5.375rem;
  height: 2.6875rem;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--field-line);
  border-radius: 0.375rem;
  background: var(--field-bg);
  cursor: pointer;
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input::-webkit-color-swatch {
  border: 0;
}

.color-input::-moz-color-swatch {
  border: 0;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.file-btn {
  flex: none;
  height: 2.6875rem;
  width: auto;
  min-width: 9.625rem;
  white-space: nowrap;
  padding: 0 0.875rem;
  border: 1px solid var(--field-line);
  border-radius: 0.375rem;
  background: var(--field-bg);
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 400;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.file-btn:hover {
  border-color: var(--red);
  background: var(--surface-2);
}

/* Takes the leftover room and truncates: min-width 0 is what lets a flex item
   shrink below its text, so a long file name ellipsises instead of pushing
   the field column wider. */
.file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fill-row {
  display: flex;
  align-items: flex-end;
  gap: 1.4375rem;
  min-height: 3.125rem;
}

.fill-btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: auto;
  min-width: 8.375rem;
  padding: 0 0.875rem;
  white-space: nowrap;
  height: 2.9375rem;
  border: 1px solid var(--red-deep);
  border-radius: 0.375rem;
  background: var(--red);
  color: #fff;
  font-size: 1.125rem;
  font-weight: 400;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.fill-btn:hover,
.fill-btn.is-active {
  background: #ef2f2f;
  border-color: #d81717;
}

.opacity-group {
  flex: 1;
  min-width: 10rem;
  max-width: 16.0625rem;
}

.opacity-group .slider-head {
  height: 1.375rem;
}

.opacity-group .range {
  margin-top: 0.8125rem;
}

.modal-preview {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  padding-top: 1.25rem;
}

.canvas-stack {
  display: flex;
  width: 100%;
  align-items: flex-start;
  gap: 1.25rem;
}

.canvas {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  container-type: inline-size;
  aspect-ratio: 433 / 611;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.canvas:hover {
  border-color: var(--green-line);
}

.canvas.is-selected {
  border-color: var(--line);
  box-shadow: none;
}

.modal-panel.is-wide .canvas.is-selected {
  border-color: var(--green);
  box-shadow: 0 0 0 0.125rem var(--green);
}

.page-preview {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #fff;
}

.page-bg {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0.8;
  transition: opacity 0.15s ease;
}

.page-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(18 * 100cqw / 433);
  width: 100%;
  height: 100%;
  padding: calc(42 * 100cqw / 433);
  text-align: center;
}

.page-title,
.page-subtitle,
.page-text {
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
  line-height: 1.15;
  white-space: pre-wrap;
  font-size: calc(var(--text-size, 32) * 100cqw / 433);
}

.page-title {
  color: var(--page-title);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
}

.page-subtitle {
  color: var(--page-subtitle);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
}

.page-text {
  color: var(--page-title);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
}

.preview-note {
  display: flex;
  align-items: center;
  /* Same space on the left, between icon and text, and on the right. */
  gap: 1rem;
  width: 100%;
  min-height: 3.9375rem;
  margin-top: 1.25rem;
  padding: 0.625rem 1rem;
  border: 1px solid var(--modal-line);
  border-radius: 0.375rem;
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.375rem;
}

.preview-note img {
  flex: none;
  width: 1.8125rem;
  height: 1.625rem;
  margin-top: 1px;
}

/* No single word left alone on the last line (the &nbsp; in the markup covers browsers
   without text-wrap: pretty). */
.preview-note span {
  flex: 1;
  min-width: 0;
  text-wrap: pretty;
}

.modal-panel.is-wide .preview-note,
.modal-panel.is-wide .modal-actions {
  width: calc(50% - 0.625rem);
  margin-left: auto;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1.25rem;
  margin-top: 1.4375rem;
}

/* Cancel and Add read as a pair, so they share a floor and grow with their text. */
.btn--cancel {
  width: auto;
  min-width: 8.73725rem;
  height: 3.9375rem;
  justify-content: center;
  border-color: var(--red);
  background: var(--modal-bg);
  color: var(--red);
  font-size: 1.375rem;
}

.btn--cancel:hover {
  background: var(--surface-2);
}

.btn--add {
  width: auto;
  min-width: 7.542375rem;
  height: 3.9375rem;
  justify-content: center;
  border-color: var(--red-deep);
  background: var(--red);
  color: #fff;
  font-size: 1.375rem;
}

.btn--add:hover {
  background: #ef2f2f;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.875rem;
  z-index: 160; /* above the boy's merge overlay (140) and flying sheets (150) */
  max-width: min(90vw, 32.5rem);
  padding: 0.75rem 1.25rem;
  border-radius: 0.375rem;
  background: var(--toast-bg);
  color: var(--bg);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.3;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 0.875rem);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

html[data-theme="dark"] .toast {
  color: #211f1e;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(0.5rem) scale(0.995); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}


/* Navigation spacing follows the XD components, but as an even gap rather than a
   per-item width: the labels are translated, so each one sizes to its own text. */
.nav { gap: 1.4375rem; }
.nav a { width: auto; }

/* Intrinsic SVG dimensions also follow the artboard scale. */
.format-label img { width: 1.49075rem; height: 1.88825rem; }
.btn--create img { width: 1.3125rem; height: 1.75rem; }
.btn--download img, .btn--generate img { width: 1.375rem; height: 1.75rem; }
.btn--share img { width: 1.4375rem; height: 1.625rem; }
.add-card-top img { width: 1.625rem; height: 1.625rem; }
.fill-btn img { width: 1.375rem; height: 1.0625rem; }

.segmented { padding: 0.125rem; }
.seg { border-radius: 0.125rem; }
.pill--face { min-width: 7.4375rem; }
.pill--ghost { width: 9.875rem; }

@media (min-width: 961px) {
  .file-card, .add-card {
    width: min(11.3125rem, (100% - 6.25rem) / 6);
  }
}

@media (min-width: 1280px) {
  :root { font-size: min(16px, 0.8333333333vw); }
}

@media (max-width: 1279px) {
  :root { --gutter: 32px; --modal-top: 24px; }
  .topbar-inner { gap: 24px; }
  .nav { gap: 22px; font-size: 20px; }
  .nav a { padding: 0; }
  .tools { margin-left: 12px; margin-right: 0; }
  .stage { display: none; }
  .page { display: block; max-width: 1164px; }
  .workspace { padding-top: 40px; }
  .toolbar { height: auto; min-height: 63px; flex-wrap: wrap; gap: 16px; }
  .notice { width: 100%; margin-left: 0; justify-content: center; padding: 12px 24px; }
  .developed { display: none; }
  .modal-panel, .modal-panel.is-wide {
    --modal-pad: 28px;
    width: 1038px;
    max-width: 100%;
    height: min(906px, calc(100dvh - 48px));
  }
  .modal-head { gap: 24px; }
  .modal-head h2 { flex-basis: auto; margin-right: auto; }
  .modal-body, .modal-panel.is-wide .modal-body { gap: 24px; padding: 0 28px 26px; }
  .creator-fields { flex: 0 0 45%; min-width: 0; }
  .font-row { grid-template-columns: minmax(0, 1fr) 76px; gap: 16px; }
  .color-input { width: 100%; }
  .modal-panel.is-wide .preview-note, .modal-panel.is-wide .modal-actions { width: 100%; margin-left: 0; }
  .fill-row { flex-wrap: wrap; gap: 18px; }
  .opacity-group { min-width: 150px; max-width: none; }
}

@media (max-width: 960px) {
  :root { --gutter: 24px; }
  .brand, .brand svg { width: 220px; height: auto; }
  .brand { aspect-ratio: 255.106 / 51.967; }
  .nav { gap: 18px; font-size: 18px; }
  .topbar-inner { gap: 16px; }
  .tools { margin-left: 0; gap: 4px; }
  .workspace { padding-top: 32px; }
  .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .format-group { min-width: 0; }
  .select-wrap { flex: 1; min-width: 0; }
  /* The toolbar is a grid here, so the content-size floors must stand down or
     they would push the controls out of their columns. */
  .select-wrap select { min-width: 0; }
  .btn--create, .btn--download, .btn--share { width: 100%; min-width: 0; justify-content: center; }
  .btn, .format-label { font-size: 20px; }
  .format-label { width: auto; }
  .btn, .select-wrap { height: 56px; }
  .modal-head { min-height: 79px; height: auto; padding: 18px 28px; flex-wrap: wrap; }
  .modal-head h2 { font-size: 26px; }
  .modal-body, .modal-panel.is-wide .modal-body { flex-direction: column; align-items: stretch; gap: 28px; }
  .creator-fields { flex: none; width: 100%; }
  .modal-preview { flex: none; width: 100%; padding-top: 0; }
  .canvas-stack { max-width: 433px; margin: 0 auto; }
  .modal-panel.is-wide .canvas-stack { max-width: 886px; }
  .preview-note { max-width: 433px; margin-left: auto; margin-right: auto; }
  .modal-actions { max-width: 433px; width: 100%; margin-left: auto; margin-right: auto; }
  .modal-panel.is-wide .preview-note, .modal-panel.is-wide .modal-actions { max-width: none; }
  .font-row { grid-template-columns: minmax(0, 1fr) 86px; gap: 20px; }
  .opacity-group { max-width: 257px; }
  .back-text { height: 320px; }
}

/* The nav moves to its own row under the brand, listing only the pages that exist. */
@media (max-width: 760px) {
  .topbar, .topbar-inner { height: auto; }
  .topbar-inner { flex-wrap: wrap; row-gap: 8px; padding-top: 12px; padding-bottom: 10px; }
  .nav { order: 3; width: 100%; gap: 24px; font-size: 18px; transform: none; }
  .nav a[aria-disabled="true"] { display: none; }
  .tools { margin-left: auto; }
}

@media (max-width: 600px) {
  :root { --gutter: 20px; --modal-top: 12px; }
  .topbar-inner { padding-top: 10px; }
  .brand, .brand svg { width: 190px; }
  .icon-btn { width: 34px; height: 34px; }
  .icon-btn img { width: 23px; height: 23px; }
  .workspace { padding-top: 24px; }
  .toolbar { gap: 10px; }
  .format-group, .btn--create { grid-column: 1 / -1; }
  .format-group { gap: 12px; }
  .btn, .select-wrap { height: 52px; }
  .btn { font-size: 17px; gap: 9px; padding: 0 12px; }
  .format-label { font-size: 18px; }
  .dropzone { margin-top: 20px; min-height: 245px; padding: 28px 18px; }
  .upload-icon { width: 44px; height: 56.6px; margin-bottom: 24px; }
  .dropzone h1 { font-size: 22px; }
  .dropzone p { font-size: 15px; line-height: 1.5; }
  .notice { align-items: flex-start; text-align: left; padding: 14px; gap: 12px; font-size: 15px; line-height: 1.5; }
  .notice .notice-icon { margin-top: 3px; }
  .cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 24px; padding-bottom: 40px; }
  .file-card, .add-card { width: 100%; height: auto; aspect-ratio: 182 / 311; }
  .file-card { display: flex; flex-direction: column; }
  .file-media { flex: 1; height: auto; min-height: 0; }
  .file-meta { flex: none; height: 14px; font-size: 12px; line-height: 14px; }
  .add-card-top { height: 68.5%; font-size: 17px; }
  .add-card-bottom { height: auto; }
  .modal-overlay { padding: 12px; }
  .modal-panel, .modal-panel.is-wide { width: 100%; max-width: 100%; height: calc(100dvh - 24px); }
  .modal-head { padding: 16px 18px; gap: 18px; }
  .modal-head h2 { font-size: 24px; }
  .layout-mode { width: 100%; gap: 12px; justify-content: space-between; }
  .layout-label { font-size: 16px; }
  .segmented { flex: 1; max-width: 237px; width: auto; min-width: 0; height: 39px; }
  .seg { font-size: 18px; }
  .modal-body, .modal-panel.is-wide .modal-body { padding: 0 18px 24px; }
  .creator-fields { gap: 24px; padding-top: 20px; }
  .fields-block { gap: 20px; }
  .face-row { flex-wrap: wrap; gap: 10px; }
  .face-label { width: 100%; }
  .pill { height: 40px; font-size: 16px; }
  .pill--face { min-width: 112px; }
  .pill--ghost { width: auto; padding: 0; }
  .font-row { grid-template-columns: minmax(0, 1fr) 64px; gap: 12px; }
  .font-select { font-size: 22px; }
  .file-row { flex-wrap: wrap; gap: 10px; }
  .file-name { max-width: 100%; font-size: 16px; }
  .fill-row { align-items: flex-start; gap: 20px; }
  .opacity-group { flex-basis: 100%; max-width: none; }
  .canvas-stack { gap: 12px; }
  .preview-note { font-size: 13px; line-height: 20px; }
  .modal-actions { gap: 16px; }
  .btn--cancel, .btn--add { flex: 1; width: auto; min-width: 0; }
  .file-btn, .fill-btn { min-width: 0; }
  .toast { bottom: 20px; }
}

@media (max-width: 380px) {
  .btn--download, .btn--share { grid-column: 1 / -1; }
}

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

/* Beta 2 functionality uses the same visual system as the XD prototype. */
.nav a[aria-disabled="true"] { position: relative; cursor: default; color: color-mix(in srgb, var(--red) 55%, transparent); }
.nav a[aria-disabled="true"]:hover { opacity: 1; }

/* "Coming soon" tooltip on the nav items that are not available yet (no animation) */
.nav a[data-tooltip]:hover::after,
.nav a[data-tooltip]:focus-visible::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 50%;
  z-index: 30;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  background: var(--toast-bg);
  color: var(--bg);
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}
html[data-theme="dark"] .nav a[data-tooltip]:hover::after,
html[data-theme="dark"] .nav a[data-tooltip]:focus-visible::after { color: #211f1e; }
.processing { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; background: var(--overlay); font-size: 22px; }
.spinner { width: 44px; height: 44px; border: 3px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.body-input { height: 220px; min-height: 220px; padding: 12px; resize: none; overflow: hidden; }
.char-counter { text-align: right; font-size: 14px; color: var(--muted); }
.page-body { white-space: pre-wrap; overflow-wrap: anywhere; font: calc(14 * 100cqw / 433)/1.5 "Times New Roman", serif; }
.canvas.is-page .page-content { align-items: stretch; justify-content: flex-start; text-align: left; }
.page-body:empty { display: none; }
/* Page mode: body font/color come from the "Body Font" control, headings from "Headings Font". */
.page-body :is(h1, h2, h3, h4, h5, h6) { font-family: var(--heading-font, inherit); color: var(--heading-color, inherit); }
.file-card { display: flex; flex-direction: column; }
.file-media { flex: none; width: 100%; height: 211px; margin: 0; border-radius: 0; }
.file-meta { flex: 1; height: auto; min-height: 0; flex-direction: column; justify-content: space-between; gap: 3px; padding: 6px 8px 8px; border-top: 1px solid var(--line-3); letter-spacing: -0.05em; text-transform: none; }
/* Scoped to the card: a bare .file-name also matches the modal's chosen-file
   label, where `width: 100%` made a long name stretch the whole column. */
.file-meta .file-name { display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: none; font-family: "Sansation", sans-serif; font-size: 18px; line-height: 1.3; letter-spacing: -0.05em; color: var(--red); }
.file-meta > span:last-child { color: var(--muted); font-size: 14px; line-height: 1.2; }
.file-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.file-card { touch-action: pan-y; }
.sortable-ghost { opacity: .35; }
.card-tool--drag { touch-action: none; }
.card-tool--move { top: auto; bottom: 108px; width: 28px; height: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; font-size: 18px; cursor: pointer; }
.card-tool--previous { left: 6px; }
.card-tool--next { right: 6px; }
@media (max-width: 600px) { .file-media { flex: 1; height: auto; } .file-meta { flex: none; min-height: 36px; padding: 5px; justify-content: center; } .file-name { font-size: 12px; } .file-meta > span:last-child { font-size: 11px; } .card-tool--move { bottom: 40px; } }

/* Language select (XD: select--language-hover) */
.lang-select { position: relative; display: inline-flex; }
.lang-menu { position: absolute; top: calc(100% - 4px); left: 50%; z-index: 60; display: flex; align-items: center; justify-content: center; gap: 17px; width: 184px; height: 41px; transform: translateX(-50%); border: 2px solid var(--red); border-radius: 6px; background: var(--drop-bg); box-sizing: border-box; }
.lang-menu[hidden] { display: none; }
.lang-option { padding: 0; border: 0; background: transparent; color: var(--red); font-family: "Sansation", sans-serif; font-size: 14px; font-weight: 700; line-height: 1; cursor: pointer; }
.lang-option:hover { opacity: .68; }
.lang-option[aria-checked="true"] { color: var(--green-ink); }

/* Font picker (previews each font in its own typeface) */
.font-picker { position: relative; }
.font-picker-button { display: flex; align-items: center; gap: 0.75rem; width: 100%; height: 2.6875rem; padding: 0 2.25rem 0 0.8125rem; border: 1px solid var(--field-line); border-radius: 0.375rem; outline: 0; background-color: var(--field-bg); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1.5 1.5 7 7l5.5-5.5' fill='none' stroke='%23f14444' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.9375rem center; color: var(--text); text-align: left; cursor: pointer; transition: border-color 0.2s ease; }
.font-picker-button:hover, .font-picker-button:focus-visible, .font-picker-button[aria-expanded="true"] { border-color: var(--green); }
.font-picker-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.375rem; line-height: 1.3; }
.font-picker-name { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-family: "Cairo", sans-serif; font-size: 0.75rem; }
.font-picker-name:empty { display: none; }
.font-picker-list { position: fixed; z-index: 300; overflow-y: auto; padding: 0.25rem 0; border: 1px solid var(--field-line); border-radius: 0.375rem; background: var(--field-bg); box-shadow: var(--shadow); outline: 0; }
.font-picker-list[hidden] { display: none; }
.font-picker-group { position: sticky; top: 0; padding: 0.375rem 0.8125rem 0.25rem; background: var(--field-bg); color: var(--red); font-family: "Cairo", sans-serif; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.font-picker-option { display: flex; align-items: center; gap: 0.75rem; padding: 0.3125rem 0.8125rem; color: var(--text); cursor: pointer; }
.font-picker-option.is-active { background: rgba(241, 68, 68, 0.08); }
.font-picker-option[aria-selected="true"] .font-picker-preview { color: var(--green-ink); }
@media (max-width: 380px) { .font-picker-preview { font-size: 1.125rem; } }

.file-remove { flex: none; display: grid; place-items: center; width: 1.4375rem; height: 1.4375rem; padding: 0; border: 0; border-radius: 0.125rem; background: #fff; color: var(--red); font-size: 1.0625rem; font-weight: 400; line-height: 1; cursor: pointer; }
.file-remove:hover, .file-remove:focus-visible { background: #fff0ef; outline: 0; }
.file-remove[hidden] { display: none; }

/* Plain / Markdown switch next to long-text labels */
.label-row { display: flex; align-items: center; gap: 0.75rem; }
.label-row > label { margin: 0; }
.mini-switch { display: inline-flex; padding: 2px; border: 1px solid var(--field-line); border-radius: 0.375rem; background: var(--field-bg); }
.mini-switch button { min-width: 3.25rem; height: 1.5rem; padding: 0 0.5rem; border: 0; border-radius: 0.25rem; background: transparent; color: var(--red); font-family: inherit; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; cursor: pointer; transition: background-color 0.2s ease, color 0.2s ease; }
.mini-switch button:hover:not(.is-active) { background: rgba(241, 68, 68, 0.08); }
.mini-switch button.is-active { background: var(--red); color: #fff; }
.mini-switch button:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }

/* Markdown preview (sizes are em-based so they follow the preview scale) */
.page-body.is-md, .page-text.is-md { white-space: normal; text-align: left; }
.is-md > :first-child { margin-top: 0; }
.is-md > :last-child { margin-bottom: 0; }
.is-md p, .is-md ul, .is-md ol, .is-md blockquote, .is-md pre { margin: 0 0 0.6em; }
.is-md h1, .is-md h2, .is-md h3, .is-md h4, .is-md h5, .is-md h6 { margin: 0.25em 0 0.4em; font-weight: 700; line-height: 1.2; }
.is-md h1 { font-size: 2em; }
.is-md h2 { font-size: 1.6em; }
.is-md h3 { font-size: 1.35em; }
.is-md h4 { font-size: 1.15em; }
.is-md h5 { font-size: 1em; }
.is-md h6 { font-size: 0.9em; }
.is-md ul, .is-md ol { padding-left: 1.5em; }
.is-md li { margin: 0 0 0.2em; }
.is-md blockquote { padding-left: 1.2em; border-left: 0.12em solid currentColor; font-style: italic; }
.is-md pre { padding: 0.5em; border-radius: 0.2em; background: rgba(0, 0, 0, 0.07); white-space: pre-wrap; overflow-wrap: anywhere; }
.is-md code { font-family: "Courier New", monospace; font-size: 0.9em; }
.is-md hr { height: 0; margin: 0.4em 0; border: 0; border-top: 0.06em solid currentColor; opacity: 0.6; }
.is-md .md-link { text-decoration: underline; }

/* Visual editor ("Plain" view): the Markdown shown formatted, without its markers.
   It also carries .is-md, so blocks look like the preview. */
.rich-editor { height: auto; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; }
.rich-editor[hidden] { display: none; }
.rich-editor.is-empty > :first-child::before { content: var(--placeholder); float: left; height: 0; color: var(--muted); opacity: 0.7; pointer-events: none; }
.rich-editor h1 { font-size: 1.8em; }
.rich-editor h2 { font-size: 1.5em; }
.rich-editor h3 { font-size: 1.3em; }
.rich-editor blockquote { border-left-color: var(--red); }
.rich-editor pre, .rich-editor code { background: rgba(0, 0, 0, 0.06); }

/* "Markdown" view: the raw source, unstyled, like a code editor */
.text-input.is-source { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Courier New", monospace; font-size: 0.9375rem; line-height: 1.5; }

/* Keep the preview (and Cancel/Add) in view while the form scrolls. On very short windows
   the column is taller than the viewport and becomes fully reachable at the end of the scroll. */
@media (min-width: 761px) {
  .modal-preview { position: sticky; top: 0; align-self: flex-start; }
}
