:root {
  --bg-deep: #051c10;
  --bg-mid: #0d4620;
  --bg-soft: #17592b;
  --gold: #e1ba57;
  --gold-soft: #f8e2a7;
  --ink: #f7f3e7;
  --ink-soft: rgba(247, 243, 231, 0.72);
  --card: rgba(7, 35, 17, 0.8);
  --card-line: rgba(239, 208, 123, 0.22);
  --shadow: 0 28px 72px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Tajawal", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(225, 186, 87, 0.16), transparent 20%),
    radial-gradient(circle at 15% 18%, rgba(255, 255, 255, 0.06), transparent 16%),
    linear-gradient(135deg, var(--bg-deep), var(--bg-mid) 50%, #062513);
}

button,
input {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.page-shell {
  width: min(1760px, calc(100% - 36px));
  margin: 0 auto;
  padding: 24px 0 28px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  padding: 22px 26px;
  margin-bottom: 18px;
  border-radius: 28px;
  border: 1px solid rgba(255, 239, 189, 0.14);
  background:
    linear-gradient(145deg, rgba(13, 70, 32, 0.92), rgba(10, 43, 22, 0.84)),
    radial-gradient(circle at 78% 20%, rgba(255, 241, 185, 0.08), transparent 22%);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold-soft);
  font-size: 0.88rem;
  font-weight: 700;
}

.hero-brand {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  column-gap: 14px;
}

.hero-logo {
  width: clamp(88px, 8.2vw, 116px);
  height: auto;
  display: block;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.22));
  margin-top: 4px;
}

.hero h1 {
  margin: 0;
  font-family: "Amiri", serif;
  font-size: clamp(2.2rem, 4vw, 4.2rem);
  line-height: 0.98;
  color: #fff1bf;
}

.hero-badge {
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 239, 189, 0.22);
  background: rgba(255, 255, 255, 0.04);
  color: #fff1bf;
  font-weight: 700;
  white-space: nowrap;
}

.layout {
  display: block;
}

.preview-card {
  padding: 18px;
  display: grid;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.preview-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.preview-label {
  margin: 0 0 6px;
  color: rgba(255, 240, 181, 0.86);
  font-weight: 700;
}

.preview-meta h2 {
  margin: 0;
  font-size: 1.34rem;
}

.status-text {
  margin: 0;
  color: rgba(247, 243, 231, 0.74);
  font-size: 0.92rem;
}

.controls-strip {
  display: grid;
  gap: 12px;
  align-items: start;
}

.template-switcher {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 24px;
  border: 1px solid rgba(255, 240, 181, 0.12);
  background: rgba(255, 255, 255, 0.03);
}

.template-switcher-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.template-switcher-title {
  margin: 0;
  color: #fff1bf;
  font-size: 1rem;
  font-weight: 800;
}

.template-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.template-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px;
  border: 1px solid rgba(255, 240, 181, 0.14);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 245, 214, 0.05), rgba(255, 255, 255, 0.01)),
    rgba(5, 33, 24, 0.28);
  color: inherit;
  cursor: pointer;
  text-align: right;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease,
    background 160ms ease;
}

.template-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 240, 181, 0.28);
}

.template-card.is-active {
  border-color: rgba(255, 240, 181, 0.46);
  background:
    linear-gradient(180deg, rgba(255, 240, 181, 0.14), rgba(255, 255, 255, 0.02)),
    rgba(9, 52, 38, 0.44);
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.16);
}

.template-card-thumb {
  display: block;
  width: 72px;
  aspect-ratio: 1;
  border-radius: 14px;
  border: 1px solid rgba(255, 240, 181, 0.14);
  object-fit: cover;
  background: rgba(255, 255, 255, 0.05);
}

.template-card-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.template-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.template-card-title {
  color: #fff3c7;
  font-weight: 800;
}

.template-card-text {
  color: rgba(247, 243, 231, 0.68);
  font-size: 0.82rem;
}

.template-card-badge {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 240, 181, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(247, 243, 231, 0.68);
  font-size: 0.75rem;
  font-weight: 800;
}

.template-card.is-active .template-card-badge {
  border-color: rgba(255, 240, 181, 0.24);
  background: rgba(255, 240, 181, 0.12);
  color: #fff3c7;
}

.template-card-metric {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 240, 181, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(247, 243, 231, 0.72);
  font-size: 0.75rem;
  font-weight: 700;
}

.template-card-metric-label {
  white-space: nowrap;
}

.template-card-metric strong {
  color: #fff3c7;
  font-size: 0.82rem;
  font-weight: 800;
}

.quick-controls {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.quick-actions-stack {
  display: grid;
  gap: 8px;
}

.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.field-label {
  color: rgba(255, 240, 181, 0.92);
  font-weight: 700;
  font-size: 0.95rem;
}

.field input[type="text"] {
  width: 100%;
  min-height: 52px;
  border-radius: 18px;
  border: 1px solid rgba(255, 231, 167, 0.18);
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
}

.field input[type="text"]::placeholder {
  color: rgba(247, 243, 231, 0.44);
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

.upload-file-name {
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 240, 181, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(247, 243, 231, 0.72);
  font-size: 0.82rem;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 13px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  background: linear-gradient(135deg, #fff0b7, #d8a52c);
  color: #17320f;
  box-shadow: 0 14px 30px rgba(216, 165, 44, 0.24);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 240, 181, 0.18);
  color: var(--ink);
}

.ghost-button {
  background: transparent;
  border-color: rgba(255, 240, 181, 0.18);
  color: rgba(247, 243, 231, 0.86);
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: none;
}

.preview-workbench {
  display: grid;
  gap: 16px;
  align-items: start;
}

.canvas-frame {
  padding: 14px;
  border-radius: 24px;
  border: 1px solid rgba(255, 240, 181, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 235, 181, 0.05), rgba(255, 255, 255, 0)),
    rgba(0, 0, 0, 0.18);
}

.canvas-frame canvas {
  display: block;
  width: min(100%, 880px);
  height: auto;
  margin: 0 auto;
  border-radius: 18px;
  background: #0d3818;
}

.preview-tools {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid rgba(255, 240, 181, 0.12);
  background: rgba(255, 255, 255, 0.03);
}

.tools-button,
.download-button {
  width: 100%;
}

.preview-footer {
  display: flex;
  justify-content: flex-start;
}

.page-tail {
  display: flex;
  justify-content: center;
  margin-top: 16px;
  padding-bottom: 8px;
}

.usage-stats {
  display: flex;
  justify-content: center;
}

.usage-stat {
  display: grid;
  gap: 3px;
  min-width: 184px;
  padding: 12px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 240, 181, 0.14);
  background: rgba(255, 255, 255, 0.03);
  text-align: center;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.12);
}

.usage-stat-label {
  color: rgba(247, 243, 231, 0.74);
  font-size: 0.78rem;
  font-weight: 700;
}

.usage-stat strong {
  color: #fff1bf;
  font-size: 1.08rem;
  line-height: 1;
}

@media (min-width: 1180px) {
  .controls-strip {
    grid-template-columns: minmax(0, 1.4fr) minmax(340px, 0.95fr);
  }

  .preview-workbench {
    grid-template-columns: minmax(0, 1fr) 320px;
  }

  .canvas-frame canvas {
    width: min(100%, 920px);
  }
}

@media (max-width: 900px) {
  .page-shell {
    width: min(100% - 18px, 100%);
    padding-top: 14px;
  }

  .hero,
  .preview-meta,
  .quick-controls,
  .template-switcher-head {
    flex-direction: column;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .hero {
    padding: 18px;
  }

  .hero-brand {
    grid-template-columns: 84px minmax(0, 1fr);
    column-gap: 12px;
  }

  .hero-logo {
    width: 84px;
    margin-top: 2px;
  }

  .quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .preview-footer {
    justify-content: stretch;
  }

  .usage-stats {
    justify-content: stretch;
  }

  .usage-stat {
    min-width: 0;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .template-selector {
    grid-auto-flow: column;
    grid-auto-columns: minmax(240px, 82vw);
    grid-template-columns: none;
    overflow-x: auto;
    padding-bottom: 4px;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline proximity;
  }

  .template-card {
    grid-template-columns: 64px minmax(0, 1fr);
    scroll-snap-align: start;
  }
}
