@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-VF.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #05030f;
  --violet: #8b5cf6;
  --cyan: #22d3ee;
  --pink: #f472b6;
  --gold: #fbbf24;
  --text: #ede9fe;
  --muted: #a39bc9;
  --glass: rgba(18, 12, 44, .58);
  --glass-line: rgba(167, 139, 250, .28);
  --grad: linear-gradient(120deg, var(--cyan), var(--violet) 55%, var(--pink));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Vazirmatn", Tahoma, sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 60% at 15% 10%, rgba(139, 92, 246, .28), transparent 60%),
    radial-gradient(ellipse 70% 60% at 90% 30%, rgba(34, 211, 238, .16), transparent 60%),
    radial-gradient(ellipse 80% 70% at 50% 110%, rgba(244, 114, 182, .22), transparent 60%),
    var(--bg);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: clamp(16px, 5vw, 56px) 14px 40px;
  overflow-x: hidden;
}

#space {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--glass-line);
  border-radius: 28px;
  padding: clamp(18px, 4vw, 36px);
  box-shadow: 0 0 0 1px rgba(255,255,255,.03) inset, 0 30px 90px rgba(0, 0, 0, .55), 0 0 80px rgba(139, 92, 246, .18);
  animation: rise .8s cubic-bezier(.2,.8,.2,1) both;
}
.card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(from var(--ang, 0deg), transparent 0 60%, rgba(34,211,238,.9), rgba(244,114,182,.9), transparent 90%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: spin 9s linear infinite;
  pointer-events: none;
  opacity: .8;
}
@property --ang { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes spin { to { --ang: 360deg; } }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }

h1 {
  margin: 0 0 4px;
  font-size: clamp(1.7rem, 6vw, 2.4rem);
  font-weight: 800;
  text-align: center;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(139, 92, 246, .55));
}
.subtitle { margin: 0 0 22px; text-align: center; color: var(--muted); font-size: .95rem; }

/* ---------- انتخاب حالت ---------- */
.modes {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 5px;
  margin: 0 auto 18px;
  max-width: 420px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--glass-line);
  border-radius: 999px;
}
.modes .thumb {
  position: absolute;
  top: 5px; bottom: 5px;
  inset-inline-start: 5px;
  width: calc(50% - 5px);
  border-radius: 999px;
  background: var(--grad);
  box-shadow: 0 0 24px rgba(139, 92, 246, .6);
  transition: transform .35s cubic-bezier(.3,.9,.3,1);
}
.modes[data-mode="num"] .thumb { transform: translateX(-100%); }
.mode {
  position: relative;
  z-index: 1;
  font: inherit;
  font-weight: 600;
  font-size: .95rem;
  padding: 10px 8px;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: color .25s;
}
.mode.active { color: #fff; }

/* ---------- ورودی ---------- */
.search { display: flex; gap: 10px; }
.search input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1.3rem;
  text-align: center;
  color: var(--text);
  padding: 14px 18px;
  background: rgba(0, 0, 0, .35);
  border: 1.5px solid var(--glass-line);
  border-radius: 16px;
  outline: none;
  transition: border-color .25s, box-shadow .25s;
}
.search input::placeholder { color: rgba(163, 155, 201, .55); }
.search input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, .15), 0 0 30px rgba(34, 211, 238, .25);
}

/* ---------- نتیجه ---------- */
.result { margin-top: 22px; text-align: center; display: none; }
.result.show { display: block; animation: fade .4s ease; }
.result .word { font-size: 1.15rem; color: var(--muted); }
.result .value {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 34px;
  font-size: clamp(2.8rem, 12vw, 4.4rem);
  font-weight: 800;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(120deg, #fff, var(--cyan) 40%, var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 22px rgba(34, 211, 238, .5));
}
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- تنظیمات ---------- */
.options {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.options.hidden { display: none; }
.opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--glass-line);
  border-radius: 16px;
  cursor: pointer;
  user-select: none;
  transition: background .25s, border-color .25s, box-shadow .25s, transform .15s;
}
.opt:hover { background: rgba(255, 255, 255, .08); transform: translateY(-1px); }
.opt:has(input:checked) {
  border-color: rgba(34, 211, 238, .6);
  background: linear-gradient(135deg, rgba(34, 211, 238, .12), rgba(139, 92, 246, .14));
  box-shadow: 0 0 22px rgba(34, 211, 238, .14);
}
.opt-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.opt-title { font-weight: 600; font-size: .92rem; }
.opt-state { font-size: .78rem; color: var(--muted); line-height: 1.5; }

.opt input {
  -webkit-appearance: none;
  appearance: none;
  width: 46px;
  height: 26px;
  margin: 0;
  flex-shrink: 0;
  position: relative;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  cursor: pointer;
  transition: background .3s, box-shadow .3s;
}
.opt input::before {
  content: "";
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
  transition: transform .3s cubic-bezier(.3,.9,.3,1);
}
.opt input:checked { background: var(--grad); box-shadow: 0 0 14px rgba(34, 211, 238, .55); }
.opt input:checked::before { transform: translateX(-20px); }
.opt input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

/* ---------- کلمات هم‌ابجد ---------- */
.similar { display: none; margin-top: 22px; text-align: center; }
.similar.show { display: block; }

.load-btn {
  font: inherit;
  font-weight: 700;
  padding: 12px 32px;
  color: #fff;
  background: var(--grad);
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 6px 30px rgba(139, 92, 246, .45);
  transition: transform .15s, box-shadow .25s, filter .25s;
}
.load-btn:hover { filter: brightness(1.12); box-shadow: 0 8px 40px rgba(34, 211, 238, .45); }
.load-btn:active { transform: scale(.97); }

.sim-status { margin-top: 12px; color: var(--muted); font-size: .95rem; }
.sim-status:empty { display: none; }

.tabs { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.tab {
  font: inherit;
  font-weight: 600;
  padding: 8px 22px;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .05);
  color: var(--muted);
  cursor: pointer;
  transition: all .25s;
}
.tab:hover { color: var(--text); border-color: var(--cyan); }
.tab.active { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 0 18px rgba(139, 92, 246, .5); }

.words {
  margin: 14px 0 0;
  padding: 12px;
  max-height: 340px;
  overflow-y: auto;
  text-align: right;
  background: rgba(0, 0, 0, .25);
  border: 1px solid var(--glass-line);
  border-radius: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--violet) transparent;
}
.words:empty { display: none !important; }

.pill {
  display: inline-block;
  padding: 5px 14px;
  margin: 4px 3px;
  background: rgba(139, 92, 246, .18);
  border: 1px solid rgba(167, 139, 250, .25);
  color: var(--text);
  border-radius: 999px;
  font-size: .95rem;
  animation: pop .35s ease both;
  transition: background .2s, transform .15s, box-shadow .2s;
}
.pill:hover { background: rgba(34, 211, 238, .22); transform: translateY(-2px); box-shadow: 0 0 14px rgba(34, 211, 238, .4); }
.pill.alt { background: rgba(244, 114, 182, .16); border-color: rgba(244, 114, 182, .28); }
@keyframes pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }

.more-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  font: inherit;
  font-weight: 600;
  font-size: .95rem;
  padding: 10px;
  color: var(--cyan);
  background: rgba(34, 211, 238, .06);
  border: 1px dashed rgba(34, 211, 238, .5);
  border-radius: 12px;
  cursor: pointer;
  transition: background .2s;
}
.more-btn:hover { background: rgba(34, 211, 238, .14); }
.more-btn:disabled { opacity: .6; cursor: wait; }

@media (max-width: 560px) {
  .options { grid-template-columns: 1fr; }
  .card { border-radius: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .card::before, .pill { animation: none; }
}
