:root {
  --bg: #f7f7f5;
  --paper: rgba(255, 255, 255, 0.88);
  --paper-solid: #ffffff;
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.16);
  --text: #111827;
  --muted: #6b7280;
  --accent: #0f766e;
  --accent-soft: #d9f2ee;
  --danger: #b91c1c;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.95), rgba(247, 247, 245, 0.9) 34%, rgba(238, 244, 243, 0.9) 100%),
    linear-gradient(135deg, #fafaf9, #f3f4f6);
  font-family: "Poppins", "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(0deg, rgba(255, 255, 255, 0.66), rgba(255, 255, 255, 0.66)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' viewBox='0 0 220 220'%3E%3Cg fill='none' stroke='rgba(15,23,42,0.05)' stroke-width='1'%3E%3Cpath d='M20 20h180v180H20z'/%3E%3Cpath d='M0 110h220M110 0v220'/%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.8;
  pointer-events: none;
}

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

.page-shell {
  position: relative;
  z-index: 1;
  max-width: 1780px;
  margin: 0 auto;
  padding: 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 28px;
}

.brand h1,
.form-header h1 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(2.3rem, 4vw, 4rem);
  font-weight: 600;
  letter-spacing: -0.04em;
}

.brand p,
.form-header p,
.card-intro {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 720px;
  line-height: 1.6;
}

.admin-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
}

.editor-layout {
  min-height: calc(100vh - 180px);
}

.panel,
.canvas-panel,
.download-panel,
.hero-card {
  background: var(--paper);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
}

.left-rail,
.right-rail {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 56px);
  overflow: auto;
}

.panel h2,
.canvas-panel h2,
.hero-card h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.section-note {
  color: var(--muted);
  margin: 0 0 18px;
  font-size: 0.95rem;
}

.stack {
  display: grid;
  gap: 16px;
}

.field-grid {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
  color: var(--text);
}

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

input,
select,
textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.92);
  padding: 13px 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

textarea {
  resize: vertical;
  min-height: 110px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(15, 118, 110, 0.45);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.button,
button {
  border: 0;
  border-radius: 16px;
  padding: 13px 18px;
  background: linear-gradient(135deg, #0f766e, #14532d);
  color: white;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.18);
}

button:hover {
  transform: translateY(-1px);
}

button.secondary,
.button.secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.canvas-panel {
  padding: 24px;
  min-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
}

.canvas-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}

.preview-frame {
  position: relative;
  background:
    linear-gradient(0deg, rgba(255,255,255,0.04), rgba(255,255,255,0.04)),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(180deg, #1d232f, #121722);
  background-size: auto, 24px 24px, 24px 24px, auto;
  border: 1px solid rgba(15, 23, 42, 0.18);
  border-radius: 24px;
  min-height: 720px;
  overflow: hidden;
  padding: 24px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

.editor-stage {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  grid-template-rows: 36px minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 670px;
}

.canvas-stage {
  position: relative;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 16px;
  min-height: 620px;
}

.ruler {
  background: rgba(9, 13, 20, 0.88);
  border: 1px solid rgba(255,255,255,0.08);
}

.ruler-top {
  grid-column: 2;
  grid-row: 1;
  width: 100%;
  height: 36px;
}

.ruler-left {
  grid-column: 1;
  grid-row: 2;
  width: 36px;
  height: 100%;
}

#templateCanvas {
  width: auto;
  max-width: 100%;
  max-height: 100%;
  display: block;
  cursor: default;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.26);
  background: #fff;
  touch-action: none;
}

.zoom-tools {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.format-display {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  min-width: 180px;
}

.format-display strong {
  font-size: 0.98rem;
}

.format-display span {
  display: inline-flex;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 600;
}

.zoom-tools label {
  min-width: 110px;
}

.format-note {
  margin-top: -6px;
}

.align-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.layer-item.active {
  border-color: rgba(15, 118, 110, 0.4);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.08);
  background: linear-gradient(180deg, rgba(219, 245, 240, 0.8), rgba(255,255,255,0.96));
}

.layer-item.primary {
  border-color: rgba(15, 118, 110, 0.8);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
}

.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.9rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend i {
  width: 12px;
  height: 12px;
  display: inline-block;
  border-radius: 999px;
}

.legend .text-dot { background: #0f766e; }
.legend .seal-dot { background: #b45309; }
.legend .footer-dot { background: #4338ca; }

.layers-shell {
  display: grid;
  gap: 12px;
}

.rail-card {
  padding-bottom: 4px;
}

.rail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.layers-panel {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.layer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  text-align: left;
}


.layer-item strong {
  font-size: 0.95rem;
}

.layer-item span {
  color: var(--muted);
  font-size: 0.84rem;
}

.status {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.canvas-hints {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.canvas-hints span {
  display: inline-flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

.form-layout {
  max-width: 1160px;
  margin: 0 auto;
  padding: 32px;
  position: relative;
  z-index: 1;
}

.hero-card {
  padding: 26px;
  margin-bottom: 28px;
}

.form-card {
  background: rgba(255,255,255,0.86);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 28px;
  padding: 28px;
}

.form-columns {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
}

.form-malas {
  display: grid;
  gap: 16px;
}

.double {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.muted-box,
.download-panel {
  background: rgba(250,250,249,0.9);
  border: 1px dashed rgba(15, 23, 42, 0.14);
  border-radius: 22px;
  padding: 18px;
}

.download-panel {
  display: none;
}

.download-panel.visible {
  display: block;
}

.download-links {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.download-links a {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: #fff;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
  display: none;
}

.button.loading .spinner {
  display: inline-block;
}

.button.loading .button-text {
  opacity: 0.9;
}

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

@media (max-width: 1080px) {
  .admin-grid,
  .form-columns {
    grid-template-columns: 1fr;
  }

  .left-rail,
  .right-rail {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .page-shell,
  .form-layout {
    padding: 18px;
  }

  .preview-frame {
    min-height: 520px;
  }
}

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

  .button-row {
    flex-direction: column;
  }
}
