:root {
  --bg-0: #07140f;
  --bg-1: #0b1d16;
  --card: rgba(255, 255, 255, 0.06);
  --card-2: rgba(255, 255, 255, 0.08);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.68);
  --muted-2: rgba(255, 255, 255, 0.52);
  --border: rgba(255, 255, 255, 0.12);
  --shadow: rgba(0, 0, 0, 0.35);
  --green: #2bd4a3;
  --green-2: #1aa97f;
  --gold: #d9b35a;
  --danger: #ff6b6b;
  --ok: #6ee7b7;

  --radius: 18px;
  --radius-2: 14px;

  --font-latin: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --font-arabic: "Noto Naskh Arabic", Amiri, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  background: linear-gradient(180deg, var(--bg-0), var(--bg-1));
  overflow-x: hidden;
}

body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, rgba(43, 212, 163, 0.18), transparent 55%),
    radial-gradient(1200px 700px at 90% 0%, rgba(217, 179, 90, 0.18), transparent 60%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1));
  font-family: var(--font-latin);
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100dvh;
  text-rendering: optimizeLegibility;
}

html[lang="ar"] body,
body[dir="rtl"] {
  font-family: var(--font-arabic);
}

.textarea,
.input,
.btn,
.chip {
  font-family: inherit;
}

.textarea {
  font-size: 15px;
  line-height: 1.7;
}

html[lang="ar"] .textarea {
  font-size: 18px;
  line-height: 1.9;
}

.textarea[readonly] {
  background: rgba(7, 20, 15, 0.32);
}

.textarea::placeholder,
.input::placeholder {
  color: rgba(255, 255, 255, 0.42);
}

.textarea:focus::placeholder,
.input:focus::placeholder {
  color: rgba(255, 255, 255, 0.32);
}

.muted code {
  font-family: var(--font-mono);
  font-size: 0.95em;
}

.bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.06) 1px, transparent 0);
  background-size: 22px 22px;
  mask-image: radial-gradient(circle at 50% 10%, rgba(0, 0, 0, 0.75), transparent 70%);
  opacity: 0.7;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  flex-wrap: wrap;
  backdrop-filter: blur(10px);
  background: linear-gradient(180deg, rgba(7, 20, 15, 0.92), rgba(7, 20, 15, 0.55));
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
}

.mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(43, 212, 163, 0.18), rgba(217, 179, 90, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
}

.mark-inner {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: inset 0 0 0 3px rgba(217, 179, 90, 0.18);
  position: relative;
}

.mark-inner::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 999px;
  border: 1px dashed rgba(255, 255, 255, 0.28);
  transform: rotate(18deg);
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-weight: 700;
  letter-spacing: 0.2px;
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
}

.chip {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.chip:hover {
  background: rgba(255, 255, 255, 0.08);
}

.chip:active {
  transform: translateY(1px);
}

.chip-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--green), var(--gold));
  box-shadow: 0 0 0 5px rgba(43, 212, 163, 0.14);
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 18px 42px;
  display: grid;
  gap: 18px;
}

.grid {
  align-items: stretch;
}

.card {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.04));
  border-radius: var(--radius);
  box-shadow: 0 16px 50px var(--shadow);
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: var(--radius);
  padding: 1px;
  background: linear-gradient(120deg, rgba(43, 212, 163, 0.28), rgba(217, 179, 90, 0.12), rgba(255, 255, 255, 0.1));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.card-head {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.2px;
}

.h2 {
  margin: 0 0 8px;
  font-size: 16px;
  letter-spacing: 0.2px;
}

#t_hint {
  margin-top: 0;
  margin-bottom: 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
  color: var(--muted-2);
}

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

@media (min-width: 960px) {
  .grid {
    grid-template-columns: 1fr 1fr;
  }
}

.field {
  display: grid;
  gap: 8px;
  align-content: start;
}

.label {
  font-weight: 700;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.82);
}

.textarea,
.input {
  width: 100%;
  border-radius: var(--radius-2);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(7, 20, 15, 0.38);
  color: var(--text);
  padding: 12px 12px;
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.22);
}

.textarea {
  resize: vertical;
  min-height: 210px;
  font-family: inherit;
}

.textarea:focus,
.input:focus {
  border-color: rgba(43, 212, 163, 0.42);
  box-shadow: 0 0 0 4px rgba(43, 212, 163, 0.12);
}

.field-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Make the bottom rows visually align across the two columns. */
.field-row .status {
  min-height: 38px;
}

.actions {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  position: relative;
  overflow: hidden;
  transition: transform 120ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn.primary {
  background: linear-gradient(135deg, rgba(43, 212, 163, 0.92), rgba(26, 169, 127, 0.82));
  border-color: rgba(43, 212, 163, 0.55);
  color: rgba(7, 20, 15, 0.98);
  box-shadow: 0 18px 50px rgba(43, 212, 163, 0.22);
  padding: 12px 16px;
  min-width: 160px;
}

.btn.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(43, 212, 163, 0.98), rgba(26, 169, 127, 0.92));
  border-color: rgba(43, 212, 163, 0.7);
  transform: translateY(-1px);
  box-shadow: 0 22px 60px rgba(43, 212, 163, 0.28);
}

.btn.primary:active:not(:disabled) {
  background: linear-gradient(135deg, rgba(43, 212, 163, 0.92), rgba(26, 169, 127, 0.82));
  transform: translateY(0px);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.04);
}

.btn.primary:focus-visible,
.btn:focus-visible,
.chip:focus-visible,
.link:focus-visible,
.a:focus-visible,
.textarea:focus-visible,
.input:focus-visible {
  outline: 3px solid rgba(217, 179, 90, 0.35);
  outline-offset: 3px;
}

.link {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.86);
  cursor: pointer;
  padding: 0;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: rgba(217, 179, 90, 0.45);
  text-underline-offset: 4px;
}

.link:hover {
  color: white;
  text-decoration-color: rgba(43, 212, 163, 0.65);
}

.status {
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
  display: flex;
  align-items: center;
}

.status.ok {
  color: rgba(110, 231, 183, 0.95);
}

.status.err {
  color: rgba(255, 107, 107, 0.95);
}

.status.small {
  font-size: 12px;
  color: var(--muted-2);
  min-height: 38px;
}

.btn.btn-sm {
  padding: 9px 12px;
  border-radius: 12px;
}

.advanced {
  margin-top: 10px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.advanced-summary {
  list-style: none;
  padding: 12px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  position: relative;
  padding-right: 44px;
}

html[dir="rtl"] .advanced-summary {
  padding-right: 12px;
  padding-left: 44px;
}

.advanced-summary::-webkit-details-marker {
  display: none;
}

.chev {
  position: absolute;
  right: 14px;
  top: 50%;
  width: 22px;
  height: 22px;
  display: block;
  transform: translateY(-50%);
  stroke: rgba(255, 255, 255, 0.72);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

html[dir="rtl"] .chev {
  right: auto;
  left: 14px;
}

details[open] .chev {
  transform: translateY(-50%) rotate(180deg);
}

.advanced-body {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: grid;
  gap: 12px;
}

.row {
  display: grid;
  gap: 10px;
}

.settings {
  grid-template-columns: 1fr;
}

@media (min-width: 960px) {
  .settings {
    grid-template-columns: 1fr 1fr 0.9fr 0.9fr;
    align-items: end;
  }
}

.field.inline {
  gap: 6px;
}

.toggle {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(7, 20, 15, 0.28);
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-ui {
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  position: relative;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.18);
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(217, 179, 90, 0.55));
  transition: left 160ms ease, background 160ms ease;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.25);
}

.toggle input:checked + .toggle-ui {
  background: rgba(43, 212, 163, 0.16);
  border-color: rgba(43, 212, 163, 0.38);
}

.toggle input:checked + .toggle-ui::after {
  left: 21px;
  background: linear-gradient(135deg, rgba(43, 212, 163, 0.95), rgba(217, 179, 90, 0.65));
}

.toggle-text {
  font-weight: 700;
  color: rgba(255, 255, 255, 0.86);
  font-size: 13px;
}

.footer-row {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}

@media (min-width: 720px) {
  .footer-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.card.mini {
  padding: 14px 16px;
}

@media (max-width: 520px) {
  .topbar {
    padding: 14px 14px 12px;
  }
  .container {
    padding: 14px 14px 34px;
  }
  .card {
    padding: 14px;
  }
  .brand-title {
    font-size: 16px;
  }
  .brand-subtitle {
    font-size: 12px;
  }
  .btn.primary {
    width: 100%;
    min-width: 0;
    justify-content: center;
  }
  .footer-row {
    align-items: stretch;
  }
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.a {
  display: inline-flex;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  font-weight: 700;
}

.a:hover {
  background: rgba(255, 255, 255, 0.07);
}

.loading {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(7, 20, 15, 0.55);
  backdrop-filter: blur(10px);
  z-index: 999;
}

.loading[data-open="true"] {
  display: grid;
}

.loading-card {
  width: min(520px, calc(100% - 34px));
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(7, 20, 15, 0.72);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: flex-start;
}

.spinner {
  width: 56px;
  height: 56px;
  position: relative;
  flex: 0 0 auto;
}

.spinner-ring {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: rgba(43, 212, 163, 0.85);
  border-right-color: rgba(217, 179, 90, 0.65);
  animation: spin 1.1s linear infinite;
}

.spinner-star {
  position: absolute;
  inset: 10px;
  background: conic-gradient(
    from 0deg,
    rgba(43, 212, 163, 0.65),
    rgba(217, 179, 90, 0.55),
    rgba(255, 255, 255, 0.12),
    rgba(43, 212, 163, 0.65)
  );
  clip-path: polygon(
    50% 0%,
    61% 25%,
    88% 25%,
    67% 42%,
    74% 68%,
    50% 54%,
    26% 68%,
    33% 42%,
    12% 25%,
    39% 25%
  );
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.25));
  animation: pulse 1.6s ease-in-out infinite;
}

.loading-title {
  font-weight: 800;
  letter-spacing: 0.2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(0.96);
    opacity: 0.88;
  }
  50% {
    transform: scale(1.06);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner-ring,
  .spinner-star {
    animation: none;
  }
}
