:root {
  --ink: #0a0d13;
  --panel: #121826;
  --panel-2: #0e1420;
  --text: #eae4d6;
  --muted: rgba(234, 228, 214, 0.6);
  --gold: #d9ac55;
  --gold-soft: rgba(217, 172, 85, 0.16);
  --line: rgba(217, 172, 85, 0.14);
  --bull: #38c99a;
  --bear: #e4604e;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
}

.mono, input#price, .ledger, .q-level {
  font-family: "IBM Plex Mono", monospace;
  font-variant-numeric: tabular-nums;
}

/* خلفية شبكة قطبية خافتة — إشارة لهندسة الزوايا */
.polar-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 120%, rgba(217,172,85,0.06), transparent 55%),
    repeating-radial-gradient(circle at 50% 120%, transparent 0 79px, rgba(217,172,85,0.045) 79px 80px);
}

/* =====================
   Sections — قابلة للتمرير (إصلاح مشكلة القص)
===================== */
.section {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 32px 16px 48px;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

@media (min-height: 760px) {
  #landing.section { align-items: center; }
}

.section-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.97);
}
.section-visible {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

/* =====================
   Landing
===================== */
.landing-content {
  text-align: center;
  max-width: 520px;
  margin: auto 0;
  animation: rise 0.7s ease both;
}

.hero-dial {
  width: min(260px, 60vw);
  margin: 0 auto 8px;
  opacity: 0.9;
}

.dial-ring { fill: none; stroke: var(--gold); stroke-opacity: 0.5; stroke-width: 1; }
.dial-ring.dim { stroke-opacity: 0.18; }
.dial-hub { fill: var(--gold); }
.dial-spoke { stroke: var(--gold); stroke-opacity: 0.35; stroke-width: 1; }
.dial-spin { transform-origin: 160px 160px; animation: spin 60s linear infinite; }

.eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.35em;
  color: var(--gold);
  margin: 0 0 10px;
}

h1 {
  font-size: clamp(28px, 6vw, 40px);
  font-weight: 700;
  margin: 0 0 12px;
  line-height: 1.3;
}

.sub {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.9;
  margin: 0 0 28px;
}

/* =====================
   Buttons
===================== */
button { cursor: pointer; font-family: inherit; }

.btn-gold {
  width: 100%;
  max-width: 320px;
  padding: 15px 28px;
  font-size: 16px;
  font-weight: 700;
  color: #17130a;
  background: linear-gradient(160deg, #e8c477, var(--gold));
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(217, 172, 85, 0.22);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-gold:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(217,172,85,0.3); }
.btn-gold:active { transform: translateY(0) scale(0.985); }

.btn-ghost {
  width: 100%;
  margin-top: 14px;
  padding: 13px;
  font-size: 15px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.btn-ghost:hover { border-color: var(--gold); background: var(--gold-soft); }

button:focus-visible, input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* =====================
   Tool Card
===================== */
.tool-card {
  width: 100%;
  max-width: 460px;
  padding: 26px 22px 22px;
  border-radius: 24px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  animation: rise 0.5s ease both;
}

.card-head { text-align: center; margin-bottom: 18px; }
.card-head h2 { font-size: 20px; margin: 0; }

.instructions {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 18px;
}
.rule-line { display: flex; align-items: center; gap: 8px; }
.rule-line b { color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.bull-dot { background: var(--bull); }
.bear-dot { background: var(--bear); }

.field-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 0 4px 6px;
}

input#price {
  width: 100%;
  padding: 14px 16px;
  font-size: 18px;
  direction: ltr;
  text-align: left;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: border-color 0.2s ease;
}
input#price::placeholder { color: rgba(234,228,214,0.25); }
input#price:focus { border-color: var(--gold); outline: none; }
input#price::-webkit-outer-spin-button,
input#price::-webkit-inner-spin-button { -webkit-appearance: none; }

/* Segmented direction */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 12px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.seg {
  padding: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 12px;
  transition: background 0.2s ease, color 0.2s ease;
}
.seg.active[data-value="bull"] { background: rgba(56, 201, 154, 0.16); color: var(--bull); }
.seg.active[data-value="bear"] { background: rgba(228, 96, 78, 0.16); color: var(--bear); }

#calcBtn { margin-top: 16px; max-width: none; }

.error {
  margin: 12px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--bear);
}

/* =====================
   Question flow
===================== */
.question {
  margin-top: 20px;
  padding: 18px 16px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  animation: rise 0.35s ease both;
}

.progress { display: flex; justify-content: center; gap: 8px; margin-bottom: 12px; }
.progress i {
  width: 26px; height: 3px;
  border-radius: 2px;
  background: var(--line);
  transition: background 0.3s ease;
}
.progress i.done { background: var(--gold); }
.progress i.now { background: var(--text); }

.q-label { font-size: 12px; color: var(--muted); margin: 0 0 4px; }
.q-level {
  font-size: 26px;
  font-weight: 600;
  color: var(--gold);
  direction: ltr;
  margin: 0 0 6px;
}
.q-ask { font-size: 15px; margin: 0 0 14px; }

.question-actions { display: flex; gap: 10px; }
.answer-btn {
  flex: 1;
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 14px;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.answer-btn:active { transform: scale(0.96); filter: brightness(1.15); }
.answer-btn.yes { background: rgba(56, 201, 154, 0.18); color: var(--bull); border: 1px solid rgba(56,201,154,0.35); }
.answer-btn.no  { background: rgba(228, 96, 78, 0.16); color: var(--bear); border: 1px solid rgba(228,96,78,0.35); }

/* =====================
   Results
===================== */
.results { margin-top: 20px; }

.dial-wrap { width: min(240px, 70vw); margin: 0 auto 14px; }

.result-title {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px;
}
.result-title b { color: var(--gold); font-family: "IBM Plex Mono", monospace; direction: ltr; unicode-bidi: embed; }

.ledger { border-top: 1px solid var(--line); }
.ledger .result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 6px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  cursor: pointer;
  opacity: 0;
  animation: rowIn 0.4s ease forwards;
  transition: background 0.15s ease;
}
.ledger .result-row:hover { background: var(--gold-soft); }
.ledger .angle { color: var(--muted); font-size: 13px; }
.ledger .price { direction: ltr; font-weight: 600; }
.ledger .result-row.origin .price { color: var(--muted); font-weight: 400; }
.ledger .result-row.target .price { color: var(--gold); }

.hint {
  text-align: center;
  font-size: 11px;
  color: rgba(234, 228, 214, 0.35);
  margin: 10px 0 0;
}

/* Result dial */
.tick { stroke: var(--gold); stroke-opacity: 0.35; stroke-width: 1; }
.tick-label { fill: var(--muted); font: 10px "IBM Plex Mono", monospace; }
.needle {
  stroke: var(--gold);
  stroke-width: 2;
  stroke-linecap: round;
  transform-origin: 160px 160px;
  transition: transform 1.4s cubic-bezier(0.25, 0.8, 0.3, 1);
}
.center-price { fill: var(--text); font: 600 22px "IBM Plex Mono", monospace; }
.center-label { fill: var(--muted); font: 11px "IBM Plex Sans Arabic", sans-serif; }
.angle-dot { fill: var(--gold); opacity: 0; animation: dotIn 0.3s ease forwards; }

/* =====================
   Toast
===================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 50%;
  transform: translate(50%, 20px);
  padding: 10px 20px;
  font-size: 13px;
  background: var(--gold);
  color: #17130a;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 10;
}
.toast.show { opacity: 1; transform: translate(50%, 0); }

.hidden { display: none !important; }

/* =====================
   Animations
===================== */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes rowIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes dotIn {
  from { opacity: 0; r: 0; }
  to   { opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
