/* ---------------------------------------------------------------
   Token system — palette pulled from the Rahkar Farda logo:
   deep petrol/teal wordmark + a lighter teal gradient chevron mark,
   on a clean light ground.
------------------------------------------------------------------*/
:root{
  --bg: #F6F9F8;
  --surface: #FFFFFF;
  --surface-2: #EFF5F4;
  --ink: #16302D;
  --muted: #4F6E69;
  --muted-2: #7E9C97;
  --accent: #2E8B82;       /* mid teal, from the logo gradient */
  --accent-2: #16564F;     /* deep teal, from the logo gradient */
  --accent-soft: rgba(46,139,130,0.10);
  --border: rgba(22,48,45,0.12);
  --border-strong: rgba(22,48,45,0.22);
  --shadow: 0 20px 40px -24px rgba(22,48,45,0.28);
  --danger: #B3423A;

  --font-display: 'Vazirmatn', system-ui, sans-serif;
  --font-body: 'Vazirmatn', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

*{ box-sizing: border-box; }

html, body{
  margin:0; padding:0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* thin brand-color bar across the very top of the page */
.tile-band{
  height: 6px;
  width: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}

.pagewrap{
  min-height: 100vh;
  display:flex;
  justify-content:center;
  padding: 40px 20px 32px;
}

.wrap{
  width:100%;
  max-width: 640px;
  margin: 0 auto;
}

/* ---------------- header ---------------- */
.head{
  text-align:center;
  margin-bottom: 26px;
}

.brandmark{
  display:flex;
  justify-content:center;
  margin-bottom: 12px;
}

.head h1{
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(28px, 6vw, 38px);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  color: var(--accent-2);
}
.head h1 .arrow{
  color: var(--accent);
  display:inline-block;
  transform: scaleX(-1);
  margin: 0 4px;
}

.head .sub{
  margin:0;
  color: var(--muted);
  font-size: 15px;
}

/* ---------------- cards ---------------- */
.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.field{ margin-bottom: 16px; }
.field:last-of-type{ margin-bottom: 0; }

.field-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom: 8px;
}

.field-top label{
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.count{
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

textarea#input{
  width: 100%;
  min-height: 108px;
  max-height: 108px;   /* ~4 lines, then it scrolls internally */
  overflow-y: auto;
  resize: none;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea#input::placeholder{ color: var(--muted-2); }
textarea#input:focus{
  outline:none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.output{
  min-height: 108px;
  max-height: 160px;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 17px;
  line-height: 1.9;
  word-break: break-word;
}
.output .placeholder{ color: var(--muted-2); }
.output.is-pending{ opacity: 0.55; }

/* ---------------- actions ---------------- */
.actions, .factions{
  display:flex;
  flex-wrap: wrap;
  align-items:center;
  gap: 10px;
  margin-top: 18px;
}

.btn{
  display:inline-flex;
  align-items:center;
  gap: 7px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor:pointer;
  transition: transform .12s ease, filter .12s ease, opacity .12s ease;
}
.btn:hover{ filter: brightness(1.08); }
.btn:active{ transform: translateY(1px); }
.btn:focus-visible{ outline: 2px solid var(--accent-2); outline-offset: 2px; }
.btn:disabled{ opacity: 0.45; cursor: not-allowed; filter:none; }

.btn-ghost{
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover{ color: var(--ink); border-color: var(--accent); filter:none; }

.btn.is-done{ background: var(--accent-2); }

/* ---------------- feedback form ---------------- */
.feedback-card h2{
  font-size: 17px;
  margin: 0 0 6px;
  color: var(--accent-2);
}
.feedback-card .hint{
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13.5px;
}

.ffield{ margin-bottom: 14px; }
.ffield label{
  display:block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.ffield input, .ffield textarea{
  width: 100%;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.ffield textarea{ min-height: 64px; resize: vertical; }
.ffield input:focus, .ffield textarea:focus{
  outline:none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.ffield .err{
  display:block;
  color: var(--danger);
  font-size: 12.5px;
  margin-top: 5px;
}

.ok{
  color: var(--accent-2);
  font-size: 13.5px;
  font-weight: 600;
}

/* ---------------- direction toggle ---------------- */
.dir-toggle{
  display:flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 18px;
}
.dir-btn{
  flex: 1 1 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.dir-btn.active{
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

/* ---------------- wrong-script hint ---------------- */
.script-hint{
  display:flex;
  align-items:center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--danger);
}
.script-hint .link-btn{ color: var(--danger); }
.script-hint .link-btn:hover{ color: var(--accent-2); }

/* ---------------- profanity toggle ---------------- */
.toggle-row{
  display:flex;
  align-items:center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  cursor:pointer;
  user-select:none;
}
.toggle-row input{ accent-color: var(--accent-2); width:16px; height:16px; }

/* ---------------- example chips ---------------- */
.examples-row{
  display:flex;
  flex-wrap: wrap;
  align-items:center;
  gap: 7px;
  margin-top: 10px;
}
.examples-label{
  font-size: 12px;
  color: var(--muted-2);
  margin-inline-end: 2px;
}
.example-chip{
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity .12s ease, color .12s ease, border-color .12s ease;
}
.example-chip:hover{ opacity: 1; color: var(--accent-2); border-color: var(--accent); }
.example-refresh{
  border:none;
  background: transparent;
  color: var(--muted-2);
  cursor:pointer;
  font-size: 14px;
  padding: 4px 6px;
}
.example-refresh:hover{ color: var(--accent-2); }

/* ---------------- history panel ---------------- */
.history-box{
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.history-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  font-size: 12px;
  color: var(--muted-2);
  margin-bottom: 8px;
}
.history-clear{
  border:none; background:transparent; color: var(--muted-2);
  font-size: 11.5px; text-decoration: underline; cursor:pointer;
}
.history-clear:hover{ color: var(--danger); }
.history-list{
  list-style:none; margin:0; padding:0;
  display:flex; flex-direction:column; gap: 4px;
  max-height: 130px; overflow-y:auto;
}
.history-list li{
  display:flex; align-items:center; gap: 6px;
}
.history-item{
  flex:1;
  text-align: start;
  border:none; background: var(--surface-2);
  color: var(--muted);
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor:pointer;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  direction: ltr;
}
.history-item:hover{ color: var(--ink); }
.history-report{
  border:none; background:transparent; color: var(--muted-2);
  font-size: 13px; cursor:pointer; padding: 4px 6px;
}
.history-report:hover{ color: var(--danger); }

/* ---------------- report link (pinned to the far side of the actions row) ---------------- */
.report-link{
  margin-inline-start: auto;
  border:none;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor:pointer;
  padding: 6px 4px;
}
.report-link:hover{ color: var(--danger); }

/* ---------------- meta links + disclaimer ---------------- */
.meta-links{
  display:flex;
  justify-content:center;
  align-items:center;
  gap: 8px;
  margin-top: 16px;
}
.link-btn{
  border:none; background:transparent;
  color: var(--muted);
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor:pointer;
}
.link-btn:hover{ color: var(--accent-2); }
.meta-links .dot{ color: var(--border-strong); }

.disclaimer{
  margin: 10px 0 0;
  text-align:center;
  font-size: 11px;
  letter-spacing: .02em;
  color: var(--muted-2);
  opacity: 0.8;
}

/* ---------------- modal ---------------- */
.modal-backdrop{
  position: fixed; inset: 0;
  background: rgba(22,48,45,0.45);
  display:flex; align-items:center; justify-content:center;
  padding: 20px;
  z-index: 50;
}
.modal-panel{
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  max-width: 460px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-head{
  display:flex; justify-content:space-between; align-items:center;
  margin-bottom: 6px;
}
.modal-head h2{
  font-size: 17px; margin:0; color: var(--accent-2);
}
.modal-close{
  border:none; background: var(--surface-2);
  color: var(--muted);
  width: 28px; height: 28px; border-radius: 50%;
  cursor:pointer; font-size: 14px;
}
.modal-close:hover{ color: var(--ink); }
.modal-panel .hint{
  color: var(--muted); font-size: 13.5px; margin: 0 0 16px;
}
.modal-panel .rules-text, .modal-panel .help-text{
  font-size: 13.5px; line-height: 2; color: var(--ink);
}
.modal-panel .rules-text ul, .modal-panel .help-text ul{
  margin: 8px 0; padding-inline-start: 20px;
}
.modal-panel .rules-text li, .modal-panel .help-text li{ margin-bottom: 6px; }
.modal-panel .help-text .brand{ color: var(--accent-2); font-weight: 700; }

/* ---------------- stats ---------------- */
.stats{
  display:flex;
  justify-content:center;
  margin-bottom: 18px;
}
.stats table{
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.stats td{ padding: 4px 10px; }
.stat-label{ color: var(--muted-2); }
.stat-value{
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------------- footer ---------------- */
.foot{ text-align:center; }
.foot p{
  margin:0;
  font-size: 12.5px;
  color: var(--muted-2);
}
.foot a{
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.foot a:hover{ color: var(--accent-2); }

/* ---------------- responsive ---------------- */
@media (max-width: 480px){
  .pagewrap{ padding: 28px 14px 24px; }
  .card{ padding: 16px; border-radius: var(--radius-md); }
  .head h1{ font-size: 26px; }
  .actions{ gap: 8px; }
  .btn{ flex: 1 1 auto; justify-content:center; }
  .report-link{ margin-inline-start: 0; flex-basis: 100%; text-align:center; }
  .stats table{ font-size: 11px; }
  .modal-panel{ padding: 18px; }
}

@media (prefers-reduced-motion: reduce){
  .btn{ transition: none; }
}
