:root {
  --bg: #0f1117;
  --panel: #171a22;
  --panel-2: #1e222c;
  --line: #2a2f3a;
  --text: #e6e8ee;
  --muted: #8a90a0;
  --accent: #e9c46a;
  --accent-2: #f2cc8f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Vazirmatn', sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(233,196,106,0.10), transparent 60%),
    radial-gradient(900px 500px at 0% 100%, rgba(29,53,87,0.35), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-wrap { max-width: 1200px; margin: 0 auto; padding: 24px 18px 60px; }

/* header */
.hdr { text-align: center; margin-bottom: 26px; animation: fadeDown .6s ease both; }
.hdr-title {
  font-weight: 900; font-size: clamp(28px, 5vw, 46px); margin: 0;
  background: linear-gradient(120deg, var(--accent), #fff 55%, var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: -1px;
}
.hdr-sub { color: var(--muted); margin: 8px 0 0; font-size: 15px; font-weight: 300; }

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

/* layout */
.main-grid {
  display: grid; grid-template-columns: 1fr 380px; gap: 22px; align-items: start;
}
@media (max-width: 860px) {
  .main-grid { grid-template-columns: 1fr; }
}

/* preview */
.preview-col {
  position: sticky; top: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
@media (max-width: 860px) { .preview-col { position: static; } }

.preview-stage {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
.res-badge {
  position: absolute; top: 12px; left: 12px; z-index: 3;
  background: rgba(0,0,0,0.55); color: var(--accent);
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--line);
}
.checker {
  background-image:
    linear-gradient(45deg, #2b2f3a 25%, transparent 25%),
    linear-gradient(-45deg, #2b2f3a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2b2f3a 75%),
    linear-gradient(-45deg, transparent 75%, #2b2f3a 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-color: #22262f;
  border-radius: 10px; overflow: hidden; line-height: 0;
}
.preview-canvas { max-width: 100%; height: auto; display: block; }
.loading-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(15,17,23,0.85); border-radius: 18px; color: var(--accent); font-weight: 700;
}

.dl-btn {
  border: none; cursor: pointer; border-radius: 14px; padding: 16px;
  font-family: inherit; font-weight: 900; font-size: 17px; color: #1a1400;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 30px rgba(233,196,106,0.35);
  transition: transform .15s ease, box-shadow .15s ease, opacity .2s;
}
.dl-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 40px rgba(233,196,106,0.5); }
.dl-btn:active:not(:disabled) { transform: translateY(0); }
.dl-btn:disabled { opacity: .6; cursor: wait; }

.rnd-btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 12px; padding: 12px; cursor: pointer; font-family: inherit;
  font-weight: 500; transition: background .15s, border-color .15s;
}
.rnd-btn:hover { background: #262b36; border-color: var(--accent); }

/* controls */
.controls-col {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 6px 18px 18px; display: flex; flex-direction: column;
}
.ctrl-section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.ctrl-section:last-child { border-bottom: none; }
.ctrl-title { font-weight: 700; font-size: 14px; color: var(--accent); margin-bottom: 12px; }

.txt-area {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; color: var(--text); font-family: inherit;
  font-size: 18px; resize: vertical; line-height: 1.7;
}
.txt-area:focus { outline: none; border-color: var(--accent); }

/* font chips */
.font-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.font-chip {
  flex: 1 1 46%; padding: 12px 8px; border-radius: 10px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  font-size: 16px; transition: all .15s;
}
.font-chip:hover { border-color: var(--muted); }
.font-chip.active { border-color: var(--accent); background: rgba(233,196,106,0.12); color: var(--accent); }

/* align + weight */
.align-grp, .weight-grp { display: flex; gap: 6px; margin-bottom: 14px; }
.align-btn, .weight-btn {
  flex: 1; padding: 9px 4px; border-radius: 9px; cursor: pointer; font-family: inherit;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-size: 13px;
  transition: all .15s;
}
.align-btn.active, .weight-btn.active {
  border-color: var(--accent); background: rgba(233,196,106,0.14); color: var(--accent); font-weight: 700;
}

/* sliders */
.slider-row { margin: 12px 0; }
.slider-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; color: var(--muted); }
.slider-val { color: var(--accent); font-weight: 700; }
.range { width: 100%; accent-color: var(--accent); height: 6px; cursor: pointer; }

/* colors */
.color-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-size: 14px; }
.color-row label { min-width: 78px; display: flex; align-items: center; gap: 6px; }
.color-row input[type=color] {
  width: 46px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; padding: 2px;
}
.hex { font-size: 12px; color: var(--muted); direction: ltr; }
.chk { accent-color: var(--accent); width: 16px; height: 16px; }

.grad-block { margin-top: 8px; }
.grad-toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.grad-controls { margin-top: 10px; padding-top: 6px; border-top: 1px dashed var(--line); }

/* presets */
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.preset-chip {
  width: 44px; height: 44px; border-radius: 10px; cursor: pointer; font-weight: 900; font-size: 18px;
  border: 1px solid var(--line); transition: transform .12s;
}
.preset-chip:hover { transform: scale(1.08); border-color: var(--accent); }

/* resolution */
.res-grid { display: flex; flex-direction: column; gap: 8px; }
.res-btn {
  padding: 11px; border-radius: 10px; cursor: pointer; font-family: inherit; font-size: 14px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text); transition: all .15s;
}
.res-btn.active { border-color: var(--accent); background: rgba(233,196,106,0.14); color: var(--accent); font-weight: 700; }

/* footer */
.ftr {
  margin-top: 40px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); padding-top: 18px;
}
.ftr a { color: var(--accent); text-decoration: none; font-weight: 700; }
.ftr a:hover { text-decoration: underline; }