/* ===========================
   ریست و متغیرها
=========================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #f0f2f8;
  --surface:  #ffffff;
  --primary:  #4a6fa5;
  --primary-light: #dce8f7;
  --op:       #fde8cc;
  --op-hover: #fbd4a4;
  --eq:       #4a6fa5;
  --eq-text:  #ffffff;
  --clear:    #fcd5d5;
  --clear-hover: #f9b0b0;
  --num-hover: #e2e7f4;
  --text:     #1a1d2e;
  --muted:    #7a8299;
  --border:   #e2e6ef;
  --step-bg:  #f7f9fd;
  --step-border: #dce8f7;
  --radius:   12px;
  --shadow:   0 4px 20px rgba(74,111,165,.10);
}

/* ===========================
   لایه‌بندی صفحه
=========================== */
body {
  font-family: Tahoma, 'Segoe UI', sans-serif;
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  direction: rtl;
}

.app-title {
  text-align: center;
  margin-bottom: 20px;
  color: var(--primary);
  font-size: 15px;
  font-weight: bold;
  letter-spacing: .02em;
}

.container {
  width: 100%;
  max-width: 860px;
}

.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ===========================
   کارت‌ها
=========================== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h3 {
  font-size: 15px;
  color: var(--text);
  font-weight: bold;
}

.nav { display: flex; gap: 8px; }

/* ===========================
   نمایشگر
=========================== */
.display {
  background: var(--step-bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 22px;
  direction: ltr;
  text-align: right;
  min-height: 52px;
  word-break: break-all;
  color: var(--text);
  font-family: 'Courier New', monospace;
  letter-spacing: .04em;
}

/* ===========================
   صفحه‌کلید
=========================== */
.keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

button {
  padding: 14px 8px;
  border-radius: 8px;
  border: none;
  background: var(--surface);
  font-size: 17px;
  cursor: pointer;
  transition: background .15s, transform .08s;
  color: var(--text);
  font-family: inherit;
  border: 1.5px solid var(--border);
}

button:hover { background: var(--num-hover); }
button:active { transform: scale(.95); }

button.op   { background: var(--op); border-color: #f5c89a; }
button.op:hover { background: var(--op-hover); }

button.eq {
  grid-column: span 2;
  background: var(--eq);
  color: var(--eq-text);
  border-color: var(--eq);
  font-weight: bold;
  font-size: 20px;
}
button.eq:hover { background: #3a5a8c; border-color: #3a5a8c; }

button.clear { background: var(--clear); border-color: #f0b0b0; }
button.clear:hover { background: var(--clear-hover); }

button.small-btn {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 7px;
}

/* ===========================
   راهنما
=========================== */
.hint {
  font-size: 12px;
  color: var(--muted);
  background: var(--step-bg);
  border-radius: 7px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  line-height: 1.7;
}

/* ===========================
   پنل مراحل
=========================== */
.steps-box {
  flex: 1;
  overflow-y: auto;
  max-height: 380px;
  background: var(--step-bg);
  border: 1.5px solid var(--step-border);
  border-radius: 8px;
  padding: 10px;
}

.step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 6px;
  border-bottom: 1px dashed var(--border);
  font-size: 13.5px;
  color: var(--text);
  direction: rtl;
  line-height: 1.6;
}
.step:last-child { border-bottom: none; }

.step-num {
  min-width: 22px;
  height: 22px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
}

/* ===========================
   تُست (اعلان)
=========================== */
#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 14px;
  opacity: 0;
  transition: all .3s;
  pointer-events: none;
  z-index: 99;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===========================
   موبایل
=========================== */
@media (max-width: 680px) {
  .panels { grid-template-columns: 1fr; }

  .card.hidden { display: none; }

  #backBtn, #showStepsBtn { display: inline-flex; }
}

@media (min-width: 681px) {
  .card.hidden { display: flex !important; }
  #backBtn, #showStepsBtn { display: none; }
}
