:root {
  color-scheme: light;
  --bg: #f5f8f9;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-2: rgba(255, 255, 255, 0.96);
  --surface-3: #edf4f5;
  --line: rgba(35, 52, 62, 0.12);
  --line-strong: rgba(35, 52, 62, 0.22);
  --text: #1d2b32;
  --muted: #617178;
  --subtle: #8b9aa2;
  --accent: #4f9c92;
  --accent-2: #4b73df;
  --danger: #d9465f;
  --focus: #2f6fed;
  --radius-sm: 6px;
  --radius-md: 8px;
  --shadow-soft: 0 26px 80px rgba(26, 52, 64, 0.14);
  --shadow-panel: 0 14px 42px rgba(28, 52, 64, 0.1);
  --poster-aspect: 3 / 2;
  --bg-blur: 36px;
  --bg-scale: 1.16;
  --bg-brightness: 0.92;
  --bg-saturation: 1.2;
  --vignette-opacity: 0.22;
  --photo-scale: 1;
  --photo-x: 0%;
  --photo-y: 0%;
  --photo-radius: 18px;
  --photo-shadow: 42px;
  --border-width: 1px;
  --border-color: rgba(255, 255, 255, 0.72);
  --photo-aspect: 2 / 3;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background:
    linear-gradient(115deg, rgba(79, 156, 146, 0.14), transparent 34%),
    linear-gradient(245deg, rgba(75, 115, 223, 0.08), transparent 40%),
    linear-gradient(180deg, #fbfdfe 0%, #f5f8f9 58%, #edf4f5 100%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.44;
  background-image:
    linear-gradient(90deg, rgba(55, 79, 89, 0.07) 1px, transparent 1px),
    linear-gradient(0deg, rgba(55, 79, 89, 0.05) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.48), transparent 76%);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

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

.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 100;
  transform: translateY(-200%);
  border-radius: var(--radius-sm);
  background: var(--focus);
  color: #ffffff;
  padding: 0.65rem 0.85rem;
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  min-height: 100dvh;
  padding: 0.75rem;
}

.topbar {
  position: sticky;
  top: 0.75rem;
  z-index: 30;
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.72)),
    rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-panel);
  padding: 0.8rem clamp(0.9rem, 2vw, 1.4rem);
  backdrop-filter: blur(18px) saturate(1.2);
}

.brand-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.9rem;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-md);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.28), transparent),
    linear-gradient(135deg, #4f9c92, #4b73df);
  color: #ffffff;
  font-family: Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
}

.brand-lockup h1 {
  margin: 0;
  font-size: clamp(1.04rem, 2vw, 1.22rem);
  font-weight: 760;
}

.brand-lockup p {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.save-support {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid rgba(79, 156, 146, 0.22);
  border-radius: 999px;
  background: rgba(79, 156, 146, 0.08);
  color: #315d59;
  padding: 0 0.75rem;
  font-size: 0.8rem;
  white-space: nowrap;
}

.icon-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.9rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(246, 249, 250, 0.86)),
    var(--surface-2);
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(32, 56, 66, 0.08);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    opacity 180ms ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.icon-button:active {
  transform: translateY(0);
}

.icon-button.primary {
  border-color: rgba(69, 132, 125, 0.45);
  background:
    linear-gradient(180deg, #5baaa1, #438d85);
  color: #ffffff;
  font-weight: 760;
  box-shadow: 0 12px 26px rgba(79, 156, 146, 0.22);
}

.icon-button:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.icon-button.is-loading .icon-slot {
  animation: spin 900ms linear infinite;
}

.icon-button.secondary {
  color: var(--muted);
}

.icon-slot,
.upload-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
}

.icon-slot svg,
.upload-icon svg {
  width: 100%;
  height: 100%;
}

.editor-shell {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr) minmax(280px, 330px);
  gap: 0.75rem;
  min-height: calc(100dvh - 100px);
  margin-top: 0.75rem;
}

.side-panel,
.stage-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.76)),
    var(--surface);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(18px) saturate(1.08);
}

.side-panel {
  overflow: auto;
  padding: 1.1rem;
  scrollbar-color: rgba(79, 156, 146, 0.34) transparent;
}

@media (min-width: 1181px) {
  .editor-shell {
    height: calc(100dvh - 100px);
    min-height: 0;
    overflow: hidden;
  }

  .side-panel,
  .stage-panel {
    height: 100%;
  }
}

.panel-section + .panel-section {
  margin-top: 1.35rem;
  border-top: 1px solid var(--line);
  padding-top: 1.35rem;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.section-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 760;
}

.section-heading span {
  color: var(--muted);
  font-size: 0.78rem;
}

.upload-zone {
  display: grid;
  min-height: 158px;
  place-items: center;
  border: 1px dashed rgba(79, 156, 146, 0.34);
  border-radius: var(--radius-md);
  background:
    linear-gradient(145deg, rgba(79, 156, 146, 0.11), rgba(75, 115, 223, 0.055)),
    rgba(255, 255, 255, 0.68);
  padding: 1.2rem;
  text-align: center;
  cursor: pointer;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    transform 180ms ease;
}

.upload-zone:hover,
.upload-zone.is-dragging {
  transform: translateY(-1px);
  border-color: rgba(79, 156, 146, 0.74);
  background:
    linear-gradient(145deg, rgba(79, 156, 146, 0.16), rgba(75, 115, 223, 0.08)),
    rgba(255, 255, 255, 0.82);
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.upload-icon {
  width: 32px;
  height: 32px;
  color: var(--accent);
  filter: drop-shadow(0 8px 18px rgba(79, 156, 146, 0.18));
}

.upload-title {
  display: block;
  margin-top: 0.7rem;
  font-weight: 760;
}

.upload-copy {
  display: block;
  max-width: 13rem;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.template-grid {
  display: grid;
  gap: 0.8rem;
}

.template-card {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr);
  min-height: 70px;
  gap: 0.7rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(247, 250, 251, 0.82)),
    rgba(255, 255, 255, 0.72);
  padding: 0.6rem;
  text-align: left;
  cursor: pointer;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    transform 180ms ease;
}

.template-card:hover {
  transform: translateY(-1px);
  border-color: rgba(79, 156, 146, 0.28);
}

.template-card.is-active {
  border-color: rgba(79, 156, 146, 0.44);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(238, 248, 247, 0.9)),
    rgba(255, 255, 255, 0.86);
  box-shadow:
    0 0 0 1px rgba(79, 156, 146, 0.08) inset,
    0 10px 24px rgba(79, 156, 146, 0.1);
}

.template-index {
  display: inline-grid;
  grid-row: span 2;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border: 1px solid rgba(35, 52, 62, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(237, 244, 245, 0.74);
  color: var(--subtle);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.template-card.is-active .template-index {
  background: var(--accent);
  color: #ffffff;
}

.template-name,
.template-meta {
  min-width: 0;
}

.template-name {
  grid-column: 2;
  align-self: end;
  font-size: 0.9rem;
  font-weight: 740;
}

.template-meta {
  grid-column: 2;
  align-self: start;
  color: var(--muted);
  font-size: 0.77rem;
}

.stage-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  padding: 1rem;
}

.stage-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 1.1rem;
}

.segmented-control {
  display: flex;
  min-height: 44px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(237, 244, 245, 0.9);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.segment {
  min-width: 54px;
  min-height: 44px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 0.85rem;
}

.segment:last-child {
  border-right: 0;
}

.segment:hover {
  color: var(--text);
}

.segment.is-active {
  background: #ffffff;
  color: #2f6fed;
  font-weight: 780;
  box-shadow: 0 6px 18px rgba(32, 56, 66, 0.1);
}

.canvas-readout {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.74);
  padding: 0 0.8rem;
  color: var(--muted);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.preview-workbench {
  display: grid;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(35, 52, 62, 0.09);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.64), rgba(231, 239, 241, 0.58)),
    linear-gradient(45deg, rgba(87, 110, 119, 0.055) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(87, 110, 119, 0.055) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(87, 110, 119, 0.055) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(87, 110, 119, 0.055) 75%);
  background-color: #eef4f5;
  background-position:
    0 0,
    0 0,
    0 12px,
    12px -12px,
    -12px 0;
  background-size:
    auto,
    24px 24px,
    24px 24px,
    24px 24px,
    24px 24px;
  padding: clamp(1rem, 4vw, 2.5rem);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.92) inset,
    0 22px 58px rgba(72, 95, 105, 0.08) inset;
}

.poster {
  position: relative;
  width: min(100%, 980px);
  max-height: min(72dvh, 760px);
  aspect-ratio: var(--poster-aspect);
  overflow: hidden;
  border: 1px solid rgba(35, 52, 62, 0.16);
  border-radius: var(--radius-sm);
  background: #111;
  box-shadow:
    0 32px 80px rgba(37, 57, 66, 0.24),
    0 1px 0 rgba(255, 255, 255, 0.15) inset;
  isolation: isolate;
}

.poster-bg {
  position: absolute;
  inset: -10%;
  z-index: 0;
  width: 120%;
  height: 120%;
  object-fit: cover;
  transform: scale(var(--bg-scale));
  filter:
    blur(var(--bg-blur))
    brightness(var(--bg-brightness))
    saturate(var(--bg-saturation));
}

.poster-vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(circle at 52% 48%, transparent 0 38%, rgba(0, 0, 0, var(--vignette-opacity)) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 18%, rgba(0, 0, 0, 0.12));
  pointer-events: none;
}

.poster-grain {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0.07;
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.5) 1px, transparent 1px),
    linear-gradient(0deg, rgba(0, 0, 0, 0.46) 1px, transparent 1px);
  background-size: 5px 7px;
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.photo-card {
  position: absolute;
  z-index: 5;
  margin: 0;
  overflow: hidden;
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--photo-radius);
  background: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 calc(var(--photo-shadow) * 0.25) var(--photo-shadow) rgba(0, 0, 0, 0.43),
    0 1px 0 rgba(255, 255, 255, 0.2) inset;
  transform: translate(var(--photo-x), var(--photo-y)) scale(var(--photo-scale));
  transform-origin: center;
  transition:
    width 220ms ease,
    inset 220ms ease,
    border-radius 180ms ease,
    transform 180ms ease;
}

.photo-card img {
  width: 100%;
  height: auto;
  aspect-ratio: var(--photo-aspect);
  object-fit: cover;
}

.camera-meta {
  position: absolute;
  z-index: 4;
  display: grid;
  gap: clamp(0.65rem, 1.7vw, 1.35rem);
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    inset 220ms ease;
}

.camera-meta.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.camera-meta-content {
  display: contents;
}

.custom-watermark {
  display: none;
  max-width: min(24rem, 38vw);
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(1rem, 2.8vw, 2.2rem);
  font-weight: 760;
  line-height: 1.28;
  letter-spacing: 0;
  white-space: pre-wrap;
}

.camera-meta.is-custom {
  display: block;
}

.camera-meta.is-custom .camera-meta-content {
  display: none;
}

.camera-meta.is-custom .custom-watermark {
  display: block;
}

.camera-meta strong {
  margin-bottom: clamp(0.2rem, 1vw, 0.7rem);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.4rem, 5vw, 4.1rem);
  line-height: 1;
  letter-spacing: 0;
}

.meta-row {
  display: grid;
  grid-template-columns: clamp(2.3rem, 6vw, 4.5rem) minmax(2rem, auto);
  align-items: center;
  gap: clamp(0.7rem, 3vw, 3rem);
  font-size: clamp(0.8rem, 1.8vw, 1.35rem);
}

.meta-row span {
  display: inline-grid;
  min-height: clamp(1.55rem, 3vw, 2.35rem);
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.72em;
  font-weight: 520;
}

.meta-row b {
  font-weight: 520;
}

.film-perfs {
  position: absolute;
  left: 5%;
  right: 5%;
  z-index: 6;
  display: none;
  height: 4.5%;
  background: repeating-linear-gradient(
    90deg,
    rgba(246, 242, 234, 0.94) 0 1.5%,
    transparent 1.5% 4.2%
  );
  opacity: 0.92;
}

.film-perfs--top {
  top: 4.5%;
}

.film-perfs--bottom {
  bottom: 4.5%;
}

.poster--camera .photo-card {
  top: 8%;
  right: 8%;
  width: 38%;
}

.poster--camera .camera-meta {
  left: 12%;
  top: 22%;
}

.poster--camera .camera-meta.is-custom {
  max-width: 38%;
  top: 24%;
}

.poster--minimal .photo-card {
  left: 50%;
  top: 50%;
  width: 58%;
  border-width: var(--border-width);
  border-color: var(--border-color);
  background: #f8f8f7;
  padding: clamp(8px, 1.7vw, 18px);
  transform: translate(calc(-50% + var(--photo-x)), calc(-50% + var(--photo-y))) scale(var(--photo-scale));
}

.poster--minimal .photo-card img {
  border-radius: calc(max(var(--photo-radius) - 12px, 0px));
}

.poster--minimal .camera-meta {
  left: 50%;
  bottom: 9%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  transform: translateX(-50%);
}

.poster--minimal .camera-meta.is-custom {
  max-width: 70%;
  text-align: center;
}

.poster--minimal .camera-meta.is-custom .custom-watermark {
  max-width: none;
  font-size: clamp(0.92rem, 1.8vw, 1.18rem);
}

.poster--minimal .camera-meta strong {
  margin: 0;
  font-size: clamp(1rem, 2.4vw, 1.6rem);
}

.poster--minimal .meta-row {
  display: flex;
  gap: 0.45rem;
  font-size: clamp(0.78rem, 1.6vw, 1rem);
}

.poster--minimal .meta-row span {
  display: none;
}

.poster--film {
  border-color: rgba(255, 255, 255, 0.26);
  background: #080806;
}

.poster--film .poster-vignette {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.42), transparent 24%, transparent 76%, rgba(0, 0, 0, 0.5)),
    radial-gradient(circle at 50% 50%, transparent 0 42%, rgba(0, 0, 0, var(--vignette-opacity)) 100%);
}

.poster--film .film-perfs {
  display: block;
}

.poster--film .photo-card {
  left: 50%;
  top: 50%;
  width: 62%;
  border-color: rgba(255, 255, 255, 0.28);
  transform: translate(calc(-50% + var(--photo-x)), calc(-50% + var(--photo-y))) scale(var(--photo-scale));
}

.poster--film .camera-meta {
  left: 8%;
  top: 10%;
  display: flex;
  gap: 0.8rem;
  align-items: center;
  z-index: 7;
}

.poster--film .camera-meta.is-custom {
  max-width: 54%;
}

.poster--film .camera-meta.is-custom .custom-watermark,
.poster--gallery .camera-meta.is-custom .custom-watermark {
  max-width: none;
  font-size: clamp(0.92rem, 1.9vw, 1.35rem);
}

.poster--film .camera-meta strong {
  margin: 0;
  font-size: clamp(1rem, 2.2vw, 1.65rem);
}

.poster--film .meta-row {
  display: flex;
  gap: 0.45rem;
  font-size: clamp(0.78rem, 1.4vw, 0.95rem);
}

.poster--film .meta-row span {
  min-height: 1.55rem;
  min-width: 2.15rem;
}

.poster--gallery .photo-card {
  left: 50%;
  top: 50%;
  width: 70%;
  transform: translate(calc(-50% + var(--photo-x)), calc(-50% + var(--photo-y))) scale(var(--photo-scale));
}

.poster--gallery .camera-meta {
  left: 8%;
  top: 8%;
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

.poster--gallery .camera-meta.is-custom {
  max-width: 54%;
}

.poster--gallery .camera-meta strong {
  margin: 0;
  font-size: clamp(1.1rem, 2.5vw, 1.8rem);
}

.poster--gallery .meta-row {
  display: flex;
  gap: 0.45rem;
  font-size: clamp(0.78rem, 1.5vw, 1rem);
}

.poster--gallery .meta-row span {
  min-height: 1.55rem;
  min-width: 2.15rem;
}

.poster.is-portrait.poster--camera .photo-card {
  top: 7%;
  right: 14%;
  width: 72%;
}

.poster.is-portrait.poster--camera .camera-meta {
  left: 10%;
  right: 10%;
  top: auto;
  bottom: 8%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
}

.poster.is-portrait.poster--camera .camera-meta.is-custom {
  max-width: none;
  text-align: left;
}

.poster.is-portrait.poster--camera .camera-meta.is-custom .custom-watermark {
  max-width: 100%;
  font-size: clamp(0.95rem, 4vw, 1.55rem);
}

.poster.is-portrait.poster--camera .camera-meta strong {
  margin: 0;
  font-size: clamp(1.2rem, 6vw, 2.6rem);
}

.poster.is-portrait.poster--camera .meta-row {
  display: flex;
  gap: 0.4rem;
  font-size: clamp(0.74rem, 3vw, 1.05rem);
}

.poster.is-portrait.poster--camera .meta-row span {
  min-width: 2rem;
}

.control-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr) 3.4rem;
  align-items: center;
  gap: 0.7rem;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.84rem;
}

.control-row input[type="range"] {
  width: 100%;
  height: 6px;
  accent-color: var(--accent-2);
  cursor: pointer;
}

.control-row input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(79, 156, 146, 0.24), rgba(75, 115, 223, 0.22));
}

.control-row input[type="range"]::-webkit-slider-thumb {
  margin-top: -6px;
}

.control-row input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(79, 156, 146, 0.24), rgba(75, 115, 223, 0.22));
}

.control-row output {
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.swatch-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.swatch {
  width: 44px;
  height: 44px;
  border: 2px solid rgba(35, 52, 62, 0.12);
  border-radius: var(--radius-sm);
  background: var(--swatch, #fff);
  cursor: pointer;
  box-shadow:
    0 8px 18px rgba(32, 56, 66, 0.1),
    0 1px 0 rgba(255, 255, 255, 0.74) inset;
}

.swatch[data-color="#ffffff"] {
  --swatch: #ffffff;
}

.swatch[data-color="#111827"] {
  --swatch: #111827;
}

.swatch[data-color="#737373"] {
  --swatch: #737373;
}

.swatch[data-color="#c9ced6"] {
  --swatch: #c9ced6;
}

.swatch.is-active {
  border-color: #ffffff;
  outline: 2px solid rgba(79, 156, 146, 0.5);
  outline-offset: 2px;
}

.switch {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-2);
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 44px;
  margin-bottom: 0.85rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(237, 244, 245, 0.9);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.mode-option {
  min-height: 44px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.86rem;
}

.mode-option:last-child {
  border-right: 0;
}

.mode-option:hover {
  color: var(--text);
}

.mode-option.is-active {
  background: #ffffff;
  color: var(--focus);
  font-weight: 760;
  box-shadow: 0 6px 18px rgba(32, 56, 66, 0.1);
}

.watermark-panel.is-hidden,
.custom-watermark-field.is-hidden {
  display: none;
}

.metadata-status {
  min-height: 34px;
  margin: -0.25rem 0 0.85rem;
  border: 1px solid rgba(79, 156, 146, 0.18);
  border-radius: var(--radius-sm);
  background: rgba(79, 156, 146, 0.07);
  color: #46615d;
  padding: 0.45rem 0.65rem;
  font-size: 0.8rem;
}

.text-field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.7rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.text-field input,
.text-field select,
.text-field textarea {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 251, 0.92)),
    rgba(255, 255, 255, 0.88);
  color: var(--text);
  padding: 0 0.75rem;
  outline: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.86) inset;
}

.text-field textarea {
  min-height: 88px;
  padding: 0.7rem 0.75rem;
  line-height: 1.45;
  resize: vertical;
}

.text-field input:focus,
.text-field select:focus,
.text-field textarea:focus,
.segment:focus-visible,
.mode-option:focus-visible,
.icon-button:focus-visible,
.template-card:focus-visible,
.swatch:focus-visible,
.upload-zone:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.export-status {
  min-height: 34px;
  margin: 0.25rem 0 0;
  border: 1px solid rgba(75, 115, 223, 0.16);
  border-radius: var(--radius-sm);
  background: rgba(75, 115, 223, 0.06);
  color: #4d5f82;
  padding: 0.45rem 0.65rem;
  font-size: 0.8rem;
}

.toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 60;
  max-width: min(26rem, calc(100vw - 2rem));
  transform: translateY(1rem);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 252, 0.94)),
    rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 48px rgba(28, 52, 64, 0.18);
  color: var(--text);
  opacity: 0;
  padding: 0.8rem 0.95rem;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.toast[data-tone="success"] {
  border-color: rgba(79, 156, 146, 0.38);
}

.toast[data-tone="error"] {
  border-color: rgba(217, 70, 95, 0.42);
}

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

@media (max-width: 1180px) {
  .editor-shell {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 330px);
  }

  .library-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
    gap: 1rem;
  }

  .library-panel .panel-section + .panel-section {
    margin-top: 0;
    border-top: 0;
    padding-top: 0;
  }

  .template-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .template-card {
    min-height: 78px;
  }
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .topbar-actions .icon-button {
    flex: 1;
  }

  .editor-shell,
  .library-panel {
    grid-template-columns: 1fr;
  }

  .stage-panel {
    order: -1;
  }

  .template-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .preview-workbench {
    min-height: 420px;
  }
}

@media (max-width: 560px) {
  .brand-lockup p {
    display: none;
  }

  .icon-button {
    padding-inline: 0.72rem;
  }

  .save-support {
    justify-content: center;
    width: 100%;
  }

  .stage-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented-control {
    overflow-x: auto;
  }

  .segment {
    flex: 1 0 auto;
  }

  .control-row {
    grid-template-columns: 1fr 3.2rem;
  }

  .control-row input[type="range"] {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .template-grid {
    grid-template-columns: 1fr;
  }

  .preview-workbench {
    min-height: 340px;
    padding: 0.75rem;
  }
}

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