:root {
  --bg: #f4f1ea;
  --panel: #ffffff;
  --ink: #1f1f1f;
  --muted: #6b6b6b;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-warm: #f59e0b;
  --border: #e7e0d7;
  --shadow: 0 18px 40px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fff6e8 0%, #f4f1ea 55%, #e8f1f0 100%);
}

body.menu-open {
  overflow: hidden;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 72px 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.25);
}

.brand-name {
  font-family: "Fraunces", serif;
  font-size: 20px;
  font-weight: 700;
}

.brand-tag {
  font-size: 13px;
  color: var(--muted);
}

.tool-switch {
  display: flex;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.tool-select {
  display: none;
  width: 100%;
}

.tool-select select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  font-weight: 600;
  background: #fff;
}

.nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.nav-links {
  display: flex;
  gap: 16px;
  align-items: center;
}

.nav-select {
  display: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  font-weight: 600;
  background: #fff;
}

.nav a {
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 999px;
  transition: all 0.2s ease;
}

.nav a:hover {
  background: #eff6ff;
}

.nav a.active-link {
  background: #eef2ff;
  color: var(--accent-strong);
}

.menu-toggle {
  display: none;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.menu-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.12);
}

.mobile-menu-bar {
  display: none;
}

.mobile-menu-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 50;
}

.mobile-menu {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: min(88vw, 360px);
  height: 100%;
  background: linear-gradient(180deg, #ffffff 0%, #f7f8fc 100%);
  border-right: 1px solid var(--border);
  box-shadow: 12px 0 30px rgba(15, 23, 42, 0.18);
  transform: translateX(-100%);
  pointer-events: none;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  z-index: 60;
  padding: 22px 18px;
  gap: 18px;
}

.mobile-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.mobile-menu-title {
  font-weight: 700;
  font-size: 16px;
}

.menu-close {
  border: 1px solid var(--border);
  background: #fff;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}

.mobile-menu-section {
  display: grid;
  gap: 10px;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.mobile-menu-section + .mobile-menu-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.mobile-menu-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.mobile-link {
  display: block;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.mobile-link:hover {
  background: #eff6ff;
  transform: translateY(-1px);
}

body.menu-open .mobile-menu {
  transform: translateX(0);
  pointer-events: auto;
}

body.menu-open .mobile-menu-backdrop {
  opacity: 1;
  pointer-events: auto;
}

body.menu-open .mobile-menu-section {
  opacity: 1;
  transform: translateX(0);
}

body.menu-open .mobile-menu-section:nth-of-type(2) {
  transition-delay: 0.06s;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 18px;
  padding: 20px 24px 28px;
}

.tool-btn {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.tool-btn:hover {
  background: #eff6ff;
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
}

.tool-btn.active {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: var(--accent-strong);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.18);
}

.stage {
  display: grid;
  gap: 18px;
}

.stage-card {
  border: 2px dashed #d7cfc3;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.7);
  padding: 28px;
  text-align: center;
  position: relative;
}

.stage-card.dragging {
  border-color: var(--accent);
  background: #eff6ff;
}

#fileInput {
  display: none;
}

.drop-title {
  font-size: 20px;
  font-weight: 600;
}

.drop-sub {
  color: var(--muted);
  margin: 6px 0 16px;
}

.drop-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}

.security-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.stage-canvas {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  gap: 12px;
}

.canvas-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.canvas-title {
  font-weight: 600;
}

.canvas-meta {
  font-size: 13px;
  color: var(--muted);
}

.canvas-body {
  background: #f9f7f3;
  border-radius: 16px;
  min-height: 320px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  padding: 12px;
}

#preview {
  max-width: 100%;
  max-height: 380px;
  border-radius: 12px;
  display: none;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.15);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  position: absolute;
}

.empty-title {
  font-weight: 600;
}

.canvas-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status {
  font-size: 13px;
  color: var(--muted);
}

.inspector {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  align-content: start;
}

.panel {
  display: none;
  gap: 12px;
}

.panel.active {
  display: grid;
}

.panel-title {
  font-size: 18px;
  font-weight: 600;
}

.field {
  display: grid;
  gap: 6px;
}

.field.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field.inline {
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
  gap: 8px;
}

label {
  font-size: 13px;
  color: var(--muted);
}

input[type="number"],
input[type="text"],
input[type="color"],
select,
input[type="range"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}

input[type="color"] {
  padding: 6px;
  height: 42px;
}

.range-value {
  font-size: 13px;
  color: var(--muted);
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px) scale(1.02);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.25);
}

.btn.primary:hover {
  background: var(--accent-strong);
}

.btn.ghost {
  background: #fff;
  border: 1px solid var(--border);
}

.btn.outline {
  background: transparent;
  border: 1px solid var(--border);
}

.btn.subtle {
  background: #f4f1ea;
  border: 1px solid transparent;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.btn:disabled:hover,
.btn:disabled:active {
  transform: none;
}

.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: grid;
  gap: 10px;
  z-index: 30;
}

.toast {
  background: #1f2937;
  color: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.3);
}

.toast.error {
  background: #b91c1c;
}

.loading {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.25);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  z-index: 40;
}

.loading.active {
  display: flex;
}

.spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid #fff;
  border-top: 4px solid var(--accent-warm);
  animation: spin 1s linear infinite;
}

.loading-text {
  font-weight: 600;
  color: #fff;
}

.help-strip {
  margin: 0 24px 24px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}

.site-footer {
  margin: 0 24px 32px;
  padding: 18px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.footer-meta {
  max-width: 520px;
}

body.qr-mode .stage-card {
  display: none;
}

body.qr-mode .canvas-meta {
  display: none;
}

body.qr-mode .canvas-body {
  min-height: 360px;
}

.help-title {
  font-weight: 600;
  color: var(--ink);
}

#passportCustomRow,
#passportUnitRow,
#sheetCustomRow,
#sheetUnitRow {
  display: none;
}

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

.blog-page .app-shell {
  grid-template-rows: auto 1fr;
}

.blog-shell {
  padding: 24px;
  display: grid;
  gap: 24px;
}

.blog-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 24px;
  align-items: center;
  background: linear-gradient(135deg, #fff3e2, #f2f8f7);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.hero-label {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 12px;
  color: var(--muted);
}

.blog-hero h1 {
  font-family: "Fraunces", serif;
  font-size: 32px;
  margin: 10px 0;
}

.blog-hero p {
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 18px;
}

.hero-card {
  background: #ffffff;
  border-radius: 18px;
  padding: 18px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow);
  animation: floatUp 0.6s ease both;
}

.hero-stat-title {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-stat-value {
  font-weight: 600;
}

.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.blog-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.6s ease both;
}

.blog-card:nth-child(2) { animation-delay: 0.08s; }
.blog-card:nth-child(3) { animation-delay: 0.16s; }
.blog-card:nth-child(4) { animation-delay: 0.24s; }

.blog-card h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.blog-card p {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 12px;
}

.blog-card ol {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 14px;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes floatUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .topbar {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }
  .brand {
    justify-content: center;
    text-align: center;
    width: 100%;
    order: 1;
  }
  .mobile-menu-bar {
    display: flex;
    padding: 0 24px 8px;
    justify-content: flex-start;
  }

  .menu-toggle {
    display: inline-flex;
  }
  .brand-name {
    font-size: 18px;
  }
  .brand-tag {
    font-size: 12px;
  }
  .tool-switch {
    display: none;
    order: 3;
  }
  .tool-select {
    display: none;
    order: 3;
  }
  .nav {
    display: none;
  }

  .mobile-menu-backdrop,
  .mobile-menu {
    display: grid;
  }
  .nav-links {
    display: none;
  }
  .nav-select {
    display: block;
    width: 100%;
  }

  .blog-hero {
    grid-template-columns: 1fr;
  }
  .blog-hero h1 {
    font-size: 26px;
  }
}
