:root {
  color-scheme: light;
  --bg: #f3f0e8;
  --bg-deep: #e7e1d6;
  --surface: #fffcf7;
  --ink: #1b2430;
  --muted: #3f4d5e;
  --line: #ddd4c6;
  --blue: #0c3d66;
  --blue-press: #082c4a;
  --blue-soft: #e7eef5;
  --accent: #8a4b28;
  --focus: #0c3d66;
  --error: #8d1d32;
  --ok: #0f5c45;
  --shadow: 0 16px 40px rgba(28, 39, 54, 0.06);
  --radius: 18px;
  --font: "SF Arabic", "Geeza Pro", "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 100% 0, rgba(12, 61, 102, 0.06), transparent 32rem),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.75;
}

body, .page { overflow-x: clip; }

a { color: var(--blue); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  inset-inline-start: 1rem;
  top: -4rem;
  background: var(--surface);
  color: var(--ink);
  padding: 0.5rem 0.8rem;
  z-index: 5;
}

.skip:focus { top: 0.75rem; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(46rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0 0.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 750;
  font-size: 1.35rem;
  letter-spacing: 0;
}

.brand svg { color: var(--blue); display: block; }

.top { flex-wrap: wrap; }

.menu {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.1rem 0.85rem;
}

.nav-link {
  color: var(--blue);
  text-decoration: none;
  font-weight: 650;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.nav-link[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.28rem; }

.date-block {
  border: 0;
  margin: 0.85rem 0 0;
  padding: 0;
}

.date-block legend {
  font-weight: 750;
  margin-bottom: 0.35rem;
  padding: 0;
}

.today-row { margin: 0.85rem 0 0.35rem; }

#use-today {
  min-height: 44px;
  border-radius: 11px;
  border: 1px solid #cfc6b8;
  background: #fff;
  color: var(--blue);
  font-weight: 700;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
}

.page {
  width: min(46rem, calc(100% - 2rem));
  margin: 0 auto;
  padding-bottom: 3rem;
}

h1 {
  margin: 0.35rem 0 0.85rem;
  font-size: clamp(1.8rem, 1.4rem + 1.5vw, 2.35rem);
  line-height: 1.25;
  font-weight: 750;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.notice {
  margin: 0 0 0.85rem;
  padding: 0.75rem 0.9rem;
  background: #fff6e8;
  border: 1px solid #ead7b8;
  border-radius: 12px;
}

.direction {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  padding: 0.3rem;
  background: var(--blue-soft);
  border-radius: 14px;
}

.direction button {
  min-height: 48px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.35;
  padding: 0.55rem 0.45rem;
  cursor: pointer;
}

.direction button[aria-checked="true"] {
  background: var(--surface);
  color: var(--blue);
  box-shadow: 0 1px 2px rgba(12, 61, 102, 0.14);
}

.caption {
  margin: 0.9rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.fields {
  display: grid;
  grid-template-columns: minmax(4.4rem, 0.72fr) minmax(0, 1.45fr) minmax(5.4rem, 0.9fr);
  gap: 0.65rem;
}

label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 700;
  font-size: 0.95rem;
}

input, select, button { font: inherit; }

input, select {
  width: 100%;
  min-height: 48px;
  border: 1px solid #cfc6b8;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 0.4rem 0.7rem;
}

input { text-align: center; }

select {
  appearance: none;
  text-align: start;
  padding-inline: 0.75rem 2rem;
  background: transparent;
  position: relative;
  z-index: 1;
}

.month-field { position: relative; }

.month-field::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset-inline: 0;
  bottom: 0;
  height: 48px;
  border: 1px solid #cfc6b8;
  border-radius: 12px;
  background: #fff;
  pointer-events: none;
}

.month-field select { border-color: transparent; }

.month-field::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset-inline-end: 1rem;
  bottom: 18px;
  width: 8px;
  height: 8px;
  border: solid var(--blue);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  pointer-events: none;
}

input[aria-invalid="true"], select[aria-invalid="true"] {
  border-color: var(--error);
}

.convert {
  width: 100%;
  margin-top: 0.9rem;
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
}

.convert:hover { background: var(--blue-press); }

.range {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.form-error {
  margin: 0.85rem 0 0;
  color: var(--error);
  font-weight: 700;
}

.result {
  margin-top: 0.9rem;
  padding: 0.95rem 1rem;
  border-radius: 14px;
  background: #f7f5f0;
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--accent);
}

.weekday {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.primary-west {
  margin: 0.1rem 0 0;
  font-size: 1.65rem;
  font-weight: 750;
  line-height: 1.4;
}

.num {
  direction: ltr;
  unicode-bidi: isolate;
}

.umq {
  margin: 0.45rem 0 0;
  color: var(--accent);
  font-weight: 750;
}

.result, .primary-west, .copy-fallback {
  user-select: text;
  -webkit-user-select: text;
}

.copy-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.copy-row button {
  flex: 1 1 11rem;
  text-align: center;
}

.copy-row button, .text-link {
  min-height: 44px;
  border-radius: 11px;
  border: 1px solid #cfc6b8;
  background: #fff;
  color: var(--blue);
  font-weight: 700;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
}

.copy-status {
  margin: 0.45rem 0 0;
  color: var(--ok);
  font-weight: 700;
}

.copy-status.is-error { color: var(--ink); }

.copy-fallback {
  margin: 0.45rem 0 0;
  padding: 0.55rem 0.7rem;
  border: 1px dashed #cfc6b8;
  border-radius: 10px;
  background: #fff;
  line-height: 1.6;
}

.copy-status:empty { display: none; }

.prose { margin-top: 1.35rem; }

.prose h2 {
  margin: 1.2rem 0 0.35rem;
  font-size: 1.2rem;
}

.prose p, .prose li { color: var(--ink); }

.prose ol, .prose ul { padding-inline-start: 1.2rem; }

.foot {
  width: min(46rem, calc(100% - 2rem));
  margin: 0 auto 2rem;
  padding-top: 0.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
}

.foot a { color: var(--muted); font-weight: 700; }

.license {
  white-space: pre-wrap;
  direction: ltr;
  text-align: left;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  overflow-x: auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 380px) {
  .direction button { font-size: 0.9rem; }
  .primary-west { font-size: 1.35rem; }
}

@media (min-width: 900px) {
  .card { padding: 1.25rem 1.35rem 1.15rem; }
  .page { padding-top: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
