/* === Landing (index) === */
/* Cute = default; Light / Dark via html[data-theme] */
:root {
  --lp-text: #4a3f52;
  --lp-muted: #766a82;
  --lp-border: rgba(100, 80, 120, 0.14);
  --lp-accent: #db2777;
  --lp-card: rgba(255, 255, 255, 0.9);
  --lp-shadow: 0 18px 48px rgba(168, 85, 247, 0.14);
  --lp-body-bg: linear-gradient(165deg, #fff5fb 0%, #f0e8ff 45%, #fff5f5 100%);
  --lp-brand-1: #ec4899;
  --lp-brand-2: #a855f7;
  --lp-brand-3: #f472b6;
  --lp-btn-grad: linear-gradient(135deg, #ec4899, #a855f7);
  --lp-btn-grad-shadow: 0 8px 24px rgba(236, 72, 153, 0.3);
  --lp-ghost-bg: rgba(255, 255, 255, 0.72);
  --lp-ghost-hover-bg: #fff;
  --lp-ghost-hover-border: rgba(236, 72, 153, 0.35);
  --lp-menu-bg: #fff;
  --lp-menu-li-hover: rgba(236, 72, 153, 0.1);
  --lp-lang-btn-bg: rgba(255, 255, 255, 0.82);
  --lp-modal-overlay: rgba(45, 35, 55, 0.48);
  --lp-modal-bg: #fff;
  --lp-modal-tab-bg: #fdf2f8;
  --lp-modal-input-bg: #fff;
  --lp-modal-row-btn-bg: #fff;
  --lp-btn-auth-email-bg: #fce7f3;
  --lp-google-bg: #fff;
  --lp-config-banner-bg: #fff8e6;
  --lp-config-banner-border: #f5d08a;
  --lp-config-banner-text: #7a5a00;
}

html[data-theme="light"] {
  --lp-text: #1a2332;
  --lp-muted: #5a6578;
  --lp-border: rgba(26, 35, 50, 0.12);
  --lp-accent: #2563eb;
  --lp-card: #ffffff;
  --lp-shadow: 0 18px 50px rgba(25, 45, 90, 0.12);
  --lp-body-bg: linear-gradient(165deg, #fff7f0 0%, #e8f4ff 45%, #fff0f8 100%);
  --lp-brand-1: #2563eb;
  --lp-brand-2: #7c3aed;
  --lp-brand-3: #db2777;
  --lp-btn-grad: linear-gradient(135deg, #2563eb, #7c3aed);
  --lp-btn-grad-shadow: 0 8px 24px rgba(37, 99, 235, 0.28);
  --lp-ghost-bg: rgba(255, 255, 255, 0.65);
  --lp-ghost-hover-bg: #fff;
  --lp-ghost-hover-border: rgba(37, 99, 235, 0.35);
  --lp-menu-bg: #fff;
  --lp-menu-li-hover: rgba(37, 99, 235, 0.08);
  --lp-lang-btn-bg: rgba(255, 255, 255, 0.75);
  --lp-modal-overlay: rgba(15, 23, 42, 0.45);
  --lp-modal-bg: #fff;
  --lp-modal-tab-bg: #f8fafc;
  --lp-modal-input-bg: #fff;
  --lp-modal-row-btn-bg: #fff;
  --lp-btn-auth-email-bg: #f1f5f9;
  --lp-google-bg: #fff;
  --lp-config-banner-bg: #fff8e6;
  --lp-config-banner-border: #f5d08a;
  --lp-config-banner-text: #7a5a00;
}

html[data-theme="dark"] {
  --lp-text: #e8eef4;
  --lp-muted: #94a3b8;
  --lp-border: rgba(148, 163, 184, 0.22);
  --lp-accent: #60a5fa;
  --lp-card: #1e293b;
  --lp-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  --lp-body-bg: linear-gradient(165deg, #0f172a 0%, #1e293b 48%, #0f172a 100%);
  --lp-brand-1: #60a5fa;
  --lp-brand-2: #a78bfa;
  --lp-brand-3: #f472b6;
  --lp-btn-grad: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --lp-btn-grad-shadow: 0 8px 24px rgba(59, 130, 246, 0.25);
  --lp-ghost-bg: rgba(30, 41, 59, 0.85);
  --lp-ghost-hover-bg: #334155;
  --lp-ghost-hover-border: rgba(96, 165, 250, 0.45);
  --lp-menu-bg: #1e293b;
  --lp-menu-li-hover: rgba(96, 165, 250, 0.14);
  --lp-lang-btn-bg: rgba(30, 41, 59, 0.92);
  --lp-modal-overlay: rgba(2, 6, 23, 0.78);
  --lp-modal-bg: #1e293b;
  --lp-modal-tab-bg: #0f172a;
  --lp-modal-input-bg: #0f172a;
  --lp-modal-row-btn-bg: #334155;
  --lp-btn-auth-email-bg: #334155;
  --lp-google-bg: #1e293b;
  --lp-config-banner-bg: #422006;
  --lp-config-banner-border: #854d0e;
  --lp-config-banner-text: #fcd34d;
}

[hidden] {
  display: none !important;
}

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

body.landing {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--lp-text);
  background: var(--lp-body-bg);
  background-attachment: fixed;
  position: relative;
  z-index: 0;
}

html[data-theme="cute"] body.landing::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 96'%3E%3Ccircle cx='28' cy='26' r='14' fill='%23d4a574'/%3E%3Ccircle cx='68' cy='26' r='14' fill='%23d4a574'/%3E%3Cellipse cx='48' cy='56' rx='32' ry='28' fill='%23e8c4a0'/%3E%3Ccircle cx='40' cy='50' r='4' fill='%235c4033'/%3E%3Ccircle cx='56' cy='50' r='4' fill='%235c4033'/%3E%3Cellipse cx='48' cy='62' rx='8' ry='5' fill='%23c49a6c'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath fill='%23f9a8d4' d='M32 54 C18 42 8 32 8 20 C8 12 14 6 22 6 C28 6 32 10 32 10 C32 10 36 6 42 6 C50 6 56 12 56 20 C56 32 46 42 32 54Z'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%23c4b5fd' d='M24 40 L6 20 C2 14 4 6 12 6 C16 6 20 9 24 14 C28 9 32 6 36 6 C44 6 46 14 42 20 Z'/%3E%3C/svg%3E");
  background-size: 112px 112px, 72px 72px, 56px 56px;
  background-position: 0 0, 48px 36px, 24px 8px;
}

.landing-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px 56px;
}

.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 12px;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(120deg, var(--lp-brand-1), var(--lp-brand-2), var(--lp-brand-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.landing-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-ghost {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--lp-border);
  background: var(--lp-ghost-bg);
  color: var(--lp-text);
  font-size: 0.95rem;
  cursor: pointer;
}

.btn-ghost:hover {
  border-color: var(--lp-ghost-hover-border);
  background: var(--lp-ghost-hover-bg);
}

.btn-primary {
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  background: var(--lp-btn-grad);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--lp-btn-grad-shadow);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.lang-switcher {
  position: relative;
}

.lang-menu-btn,
.theme-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--lp-border);
  background: var(--lp-lang-btn-bg);
  color: var(--lp-text);
  font-size: 0.95rem;
  cursor: pointer;
}

.lang-menu-list,
.theme-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  border-radius: 12px;
  border: 1px solid var(--lp-border);
  background: var(--lp-menu-bg);
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.18);
  z-index: 200;
}

.lang-menu-list li,
.theme-menu-list li {
  padding: 8px 14px;
  font-size: 0.9rem;
  cursor: pointer;
}

.lang-menu-list li:hover,
.theme-menu-list li:hover {
  background: var(--lp-menu-li-hover);
}

.theme-switcher {
  position: relative;
}

.landing-hero {
  padding: 32px 0 24px;
}

.landing-hero-kicker {
  margin: 0 0 8px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--lp-muted);
}

.landing-hero-title {
  margin: 0 0 16px;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.landing-hero-lead {
  margin: 0 0 28px;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--lp-muted);
  max-width: 56ch;
}

.landing-hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn-lg {
  padding: 12px 22px;
  font-size: 1rem;
}

.landing-features {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-top: 40px;
}

.landing-feature-card {
  background: var(--lp-card);
  border: 1px solid var(--lp-border);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: var(--lp-shadow);
}

.landing-feature-card h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.landing-feature-card p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--lp-muted);
}

.config-banner {
  margin: 28px 0 0;
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--lp-config-banner-bg);
  border: 1px solid var(--lp-config-banner-border);
  color: var(--lp-config-banner-text);
  font-size: 0.9rem;
  line-height: 1.45;
}

/* Auth modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--lp-modal-overlay);
  backdrop-filter: blur(4px);
}

.modal {
  width: min(420px, 100%);
  max-height: min(90vh, 640px);
  overflow-y: auto;
  background: var(--lp-modal-bg);
  color: var(--lp-text);
  border-radius: 16px;
  padding: 22px 24px 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

.modal h2 {
  margin: 0 0 16px;
  font-size: 1.25rem;
}

.modal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.modal-tabs button {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--lp-border);
  background: var(--lp-modal-tab-bg);
  color: var(--lp-text);
  cursor: pointer;
  font-size: 0.95rem;
}

.modal-tabs button.active {
  background: var(--lp-btn-grad);
  color: #fff;
  border-color: transparent;
}

.modal label {
  display: block;
  margin: 12px 0 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--lp-muted);
}

.modal input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--lp-border);
  background: var(--lp-modal-input-bg);
  color: var(--lp-text);
  font-size: 1rem;
}

.modal .row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.modal .row-actions button {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--lp-border);
  background: var(--lp-modal-row-btn-bg);
  color: var(--lp-text);
  cursor: pointer;
}

.modal .row-actions button.primary {
  background: var(--lp-btn-grad);
  color: #fff;
  border: none;
  font-weight: 600;
}

.auth-method-step {
  margin-top: 4px;
}

.auth-method-prompt {
  margin: 0 0 12px;
  font-size: 0.95rem;
  color: var(--lp-muted);
}

.auth-method-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-auth-email {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--lp-border);
  background: var(--lp-btn-auth-email-bg);
  color: var(--lp-text);
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
}

.google-signin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--lp-border);
  background: var(--lp-google-bg);
  color: var(--lp-text);
  cursor: pointer;
  font-size: 0.95rem;
}

.google-signin svg {
  width: 22px;
  height: 22px;
}

.auth-back {
  margin-bottom: 12px;
  padding: 6px 0;
  border: none;
  background: none;
  color: var(--lp-accent);
  cursor: pointer;
  font-size: 0.9rem;
}

.auth-status {
  margin-top: 12px;
  min-height: 1.2em;
  font-size: 0.88rem;
  color: #b91c1c;
}

/* === App (generator) === */
/* —— Themes: cute (default), light, dark —— */
:root {
  --bg: #fdf4ff;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-2: rgba(255, 250, 252, 0.98);
  --border: rgba(192, 168, 210, 0.65);
  --text: #3d3550;
  --muted: #7c6b8a;
  --accent: #ec4899;
  --accent-dim: #db2777;
  --accent-glow: rgba(236, 72, 153, 0.2);
  --accent-soft: rgba(236, 72, 153, 0.12);
  --brand-end: #a855f7;
  --input-bg: rgba(255, 255, 255, 0.96);
  --btn-bg: rgba(255, 255, 255, 0.88);
  --btn-bg-hover: rgba(255, 245, 250, 0.98);
  --panel-bg: linear-gradient(145deg, rgba(255, 252, 254, 0.98), rgba(250, 245, 255, 0.96));
  --panel-shadow: 0 8px 32px rgba(168, 85, 247, 0.1);
  --topbar-bg: rgba(255, 248, 252, 0.94);
  --settings-more-bg: rgba(255, 255, 255, 0.72);
  --settings-more-border: rgba(236, 72, 153, 0.2);
  --preview-chrome-bg: #fce7f3;
  --preview-pager-bg: rgba(255, 255, 255, 0.82);
  --body-bg-extra: radial-gradient(1000px 800px at 8% -5%, rgba(251, 207, 232, 0.55), transparent),
    radial-gradient(900px 700px at 92% 15%, rgba(196, 181, 253, 0.45), transparent),
    radial-gradient(800px 600px at 45% 95%, rgba(167, 243, 208, 0.35), transparent);
}

html[data-theme="dark"] {
  --bg: #0a0e12;
  --surface: #141a22;
  --surface-2: #1a222d;
  --border: #2a3545;
  --text: #e8eef4;
  --muted: #8b9cb0;
  --accent: #5eb8ff;
  --accent-dim: #3d8cc9;
  --accent-glow: rgba(94, 184, 255, 0.15);
  --accent-soft: rgba(94, 184, 255, 0.12);
  --brand-end: #a78bfa;
  --input-bg: #0d1118;
  --btn-bg: #222b36;
  --btn-bg-hover: #2a3544;
  --panel-bg: linear-gradient(145deg, rgba(30, 38, 48, 0.95), rgba(20, 26, 34, 0.98));
  --panel-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  --topbar-bg: rgba(15, 20, 25, 0.92);
  --settings-more-bg: rgba(13, 17, 24, 0.6);
  --settings-more-border: rgba(94, 184, 255, 0.12);
  --preview-chrome-bg: #0a0d12;
  --preview-pager-bg: rgba(13, 17, 24, 0.75);
  --body-bg-extra: radial-gradient(1200px 800px at 10% -10%, rgba(94, 184, 255, 0.08), transparent),
    radial-gradient(900px 600px at 100% 20%, rgba(167, 139, 250, 0.06), transparent);
}

html[data-theme="light"] {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-dim: #1d4ed8;
  --accent-glow: rgba(37, 99, 235, 0.15);
  --accent-soft: rgba(37, 99, 235, 0.1);
  --brand-end: #7c3aed;
  --input-bg: #ffffff;
  --btn-bg: #e2e8f0;
  --btn-bg-hover: #cbd5e1;
  --panel-bg: linear-gradient(145deg, #ffffff, #f8fafc);
  --panel-shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
  --topbar-bg: rgba(255, 255, 255, 0.94);
  --settings-more-bg: rgba(255, 255, 255, 0.88);
  --settings-more-border: rgba(37, 99, 235, 0.15);
  --preview-chrome-bg: #e2e8f0;
  --preview-pager-bg: rgba(255, 255, 255, 0.9);
  --body-bg-extra: radial-gradient(1000px 700px at 0% 0%, rgba(37, 99, 235, 0.06), transparent),
    radial-gradient(900px 600px at 100% 10%, rgba(124, 58, 237, 0.05), transparent);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

html.cuteqr-auth-pending body {
  visibility: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--body-bg-extra), var(--bg);
  color: var(--text);
  line-height: 1.5;
  position: relative;
  z-index: 0;
}

/* Cute mode: soft toys & hearts in the background (screen only; print unchanged) */
html[data-theme="cute"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.42;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 96'%3E%3Ccircle cx='28' cy='26' r='14' fill='%23d4a574'/%3E%3Ccircle cx='68' cy='26' r='14' fill='%23d4a574'/%3E%3Cellipse cx='48' cy='56' rx='32' ry='28' fill='%23e8c4a0'/%3E%3Ccircle cx='40' cy='50' r='4' fill='%235c4033'/%3E%3Ccircle cx='56' cy='50' r='4' fill='%235c4033'/%3E%3Cellipse cx='48' cy='62' rx='8' ry='5' fill='%23c49a6c'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath fill='%23f9a8d4' d='M32 54 C18 42 8 32 8 20 C8 12 14 6 22 6 C28 6 32 10 32 10 C32 10 36 6 42 6 C50 6 56 12 56 20 C56 32 46 42 32 54Z'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%23c4b5fd' d='M24 40 L6 20 C2 14 4 6 12 6 C16 6 20 9 24 14 C28 9 32 6 36 6 C44 6 46 14 42 20 Z'/%3E%3C/svg%3E");
  background-size: 112px 112px, 72px 72px, 56px 56px;
  background-position: 0 0, 48px 36px, 24px 8px;
}

@media print {
  html[data-theme="cute"] body::before {
    display: none;
  }
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.app-topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.app-brand {
  margin-right: auto;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--accent), var(--brand-end));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-decoration: none;
}

.app-brand:hover {
  filter: brightness(1.1);
}

.app-user {
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-topbar .lang-switcher {
  position: relative;
}

.app-topbar .lang-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  cursor: pointer;
}

.app-topbar .lang-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 160px;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  z-index: 100;
}

.app-topbar .lang-menu-list li {
  padding: 8px 12px;
  font-size: 0.88rem;
  cursor: pointer;
}

.app-topbar .lang-menu-list li:hover,
.app-topbar .theme-menu-list li:hover {
  background: var(--accent-soft);
}

.app-topbar .theme-switcher {
  position: relative;
}

.app-topbar .theme-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  cursor: pointer;
}

.app-topbar .theme-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 168px;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  z-index: 100;
}

.app-topbar .theme-menu-list li {
  padding: 8px 12px;
  font-size: 0.88rem;
  cursor: pointer;
}

.app-topbar-logout {
  padding: 0.45rem 0.9rem;
  font-size: 0.88rem;
}

.app {
  max-width: 1320px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
}

.app--studio {
  padding-bottom: 1.5rem;
}

.header--compact h1 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.header--compact .tagline {
  font-size: 0.82rem;
  line-height: 1.45;
  max-width: 62ch;
}

.header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 52ch;
}

.layout {
  display: grid;
  gap: 1.5rem;
  margin-top: 1.75rem;
}

.layout--studio {
  margin-top: 0.75rem;
  gap: 1rem;
}

@media (min-width: 1100px) {
  .layout--studio {
    grid-template-columns: minmax(300px, 40%) 1fr;
    align-items: stretch;
    min-height: calc(100vh - 120px);
  }
}

@media (min-width: 960px) {
  .layout:not(.layout--studio) {
    grid-template-columns: minmax(320px, 420px) 1fr;
    align-items: start;
  }
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem 1.2rem;
  box-shadow: var(--panel-shadow);
}

.panel--compact {
  padding: 1rem 1.15rem;
}

.panel-input textarea {
  width: 100%;
  min-height: 120px;
  max-height: 320px;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.82rem;
  resize: vertical;
}

.field--flush {
  margin-bottom: 0.65rem;
}

.primary-tools {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field-row--tight {
  gap: 0.65rem;
}

.field-row--tight .field {
  flex: 1 1 min(160px, 100%);
  margin-bottom: 0;
}

.actions--primary {
  margin-top: 0;
  justify-content: stretch;
}

.actions--primary .btn {
  flex: 1 1 auto;
  min-height: 44px;
  font-weight: 600;
  border-radius: 10px;
}

.actions--primary .btn.primary {
  box-shadow: 0 4px 20px var(--accent-glow);
}

.panel-input textarea:focus {
  outline: 2px solid var(--accent-dim);
  outline-offset: 1px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.field-row .field {
  flex: 1 1 140px;
  margin-bottom: 0.75rem;
}

.label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

select,
input[type="number"] {
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.95rem;
}

.custom-size {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.custom-size label {
  font-size: 0.85rem;
  color: var(--muted);
}

.custom-size input {
  width: 5rem;
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.grid-hint {
  margin: -0.25rem 0 1rem;
}

.progress {
  color: var(--accent);
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
}

.settings-more {
  margin-top: 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--settings-more-border);
  background: var(--settings-more-bg);
  overflow: hidden;
}

.settings-more__summary {
  list-style: none;
  cursor: pointer;
  padding: 0.65rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.settings-more__summary::-webkit-details-marker {
  display: none;
}

.settings-more__summary::after {
  content: "▸";
  font-size: 0.7rem;
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.settings-more[open] .settings-more__summary::after {
  transform: rotate(90deg);
}

.settings-more__body {
  padding: 0.75rem 0.85rem 0.9rem;
  border-top: 1px solid var(--border);
}

.settings-more__body .field {
  margin-bottom: 0.65rem;
}

.settings-more__body .field-row .field {
  margin-bottom: 0.5rem;
}

.footer--inline {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0 0;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  line-height: 1.45;
  max-width: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.btn {
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
}

.btn:hover {
  background: var(--btn-bg-hover);
}

.btn.primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

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

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.btn--icon {
  min-width: 2.75rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
}

.panel--preview {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.preview-head {
  margin-bottom: 0.5rem;
}

.preview-print-bar {
  margin: 0 0 0.65rem;
  display: flex;
  justify-content: stretch;
}

.btn.btn-print {
  width: 100%;
  min-height: 44px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid #15803d;
  background: linear-gradient(180deg, #22c55e, #16a34a);
  color: #fff;
  box-shadow: 0 3px 14px rgba(22, 163, 74, 0.35);
}

.btn.btn-print:hover {
  background: linear-gradient(180deg, #4ade80, #22c55e);
  border-color: #166534;
  color: #fff;
  filter: none;
}

.btn.btn-print:active {
  background: linear-gradient(180deg, #16a34a, #15803d);
}

.preview-export-block {
  margin: 0 0 0.65rem;
}

.preview-export-block__title {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.preview-export-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.btn.btn-export {
  flex: 1 1 140px;
  min-height: 40px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
}

.btn.btn-export:hover {
  background: var(--btn-bg-hover);
}

.export-status {
  margin: 0.45rem 0 0;
  text-align: center;
}

.preview-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.preview-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
  padding: 0.45rem 0.5rem;
  border-radius: 12px;
  background: var(--preview-pager-bg);
  border: 1px solid var(--border);
}

.preview-pager__label {
  font-size: 0.88rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 0 0.5rem;
  min-width: 6.5rem;
  text-align: center;
  color: var(--text);
}

.preview-viewport {
  flex: 1;
  min-height: 200px;
  max-height: min(62vh, 720px);
  overflow: auto;
  border-radius: 12px;
  background: var(--preview-chrome-bg);
  border: 1px solid var(--border);
  padding: 0.75rem;
  scrollbar-color: var(--border) transparent;
}

.preview-root {
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-page-scale.preview-slide-hidden {
  display: none !important;
}

.empty-hint {
  margin: 0.6rem 0 0;
  text-align: center;
}

.footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 70ch;
}

/* —— Print layout (screen preview uses same mm as print) —— */
.preview-page-scale {
  margin-left: auto;
  margin-right: auto;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

.preview-root .print-page {
  background: #fff;
  color: #111;
}

.preview-page-scale:last-child {
  margin-bottom: 0 !important;
}

.print-page-inner {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  display: grid;
  gap: var(--cell-gap, 2mm);
  padding: var(--page-pad, 10mm);
}

.cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  border: 1px dashed #ddd;
  padding: 1mm;
  overflow: hidden;
}

.cell-export {
  position: absolute;
  top: 1mm;
  right: 1mm;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: flex-end;
  max-width: calc(100% - 2mm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

@media (hover: none) {
  .cell-export {
    opacity: 0.88;
    pointer-events: auto;
  }
}

.cell:hover .cell-export,
.cell:focus-within .cell-export {
  opacity: 1;
  pointer-events: auto;
}

.cell-export-btn {
  padding: 0.2rem 0.4rem;
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.94);
  color: #1a1a1a;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.cell-export-btn:hover {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.22);
}

.cell-export-btn:active {
  transform: translateY(1px);
}

.cell-caption {
  font-size: var(--cap-size, 8pt);
  line-height: 1.2;
  text-align: center;
  word-break: break-word;
  max-width: 100%;
  color: #222;
  font-family: system-ui, sans-serif;
}

.cell-canvas-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.cell-canvas-wrap canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
}

@media print {
  body {
    background: #fff;
    color: #000;
  }

  .app-topbar {
    display: none !important;
  }

  .header,
  .panel-input,
  .footer,
  .preview-title,
  .preview-head,
  .preview-print-bar,
  .preview-export-block,
  .export-status,
  .cell-export,
  .preview-pager,
  .empty-hint,
  .tagline,
  .settings-more {
    display: none !important;
  }

  .layout,
  .layout--studio {
    display: block;
    margin: 0;
    min-height: 0;
  }

  .panel-preview {
    border: none;
    padding: 0;
    background: transparent;
  }

  .preview-viewport {
    max-height: none !important;
    overflow: visible !important;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
  }

  .preview-page-scale {
    box-shadow: none;
  }

  .preview-page-scale.preview-slide-hidden {
    display: block !important;
  }

  .preview-root .print-page {
    margin: 0;
  }

  @page {
    margin: 0;
  }
}
