:root {
  --green-900: #063f32;
  --green-700: #0b5e4f;
  --green-100: #e9f3ef;
  --gold-500: #d4a13a;
  --gold-100: #fff5dd;
  --page: #f4f7f5;
  --white: #ffffff;
  --text: #10231d;
  --muted: #68766f;
  --border: rgba(11, 94, 79, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(212, 161, 58, 0.1), transparent 30%),
    var(--page);
  font-family: "Plus Jakarta Sans", sans-serif;
}

button,
input,
select,
a {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Header */
.page-header {
  height: 56px;
  padding: 7px 18px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: rgba(244, 247, 245, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--green-900);
  font-size: 1.15rem;
  font-weight: 800;
  text-decoration: none;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--green-900);
  background: var(--white);
  cursor: pointer;
  text-decoration: none;
  font-size: 1.2rem;
  line-height: 1;
}

.back-button {
  width: auto;
  min-height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-self: start;
  font-size: 0.85rem;
  font-weight: 700;
}

.back-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.close-button {
  justify-self: end;
}

/* Page */
.calendar-page {
  width: min(930px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 20px;
}

.today-section {
  min-height: 92px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-radius: 18px;
  color: var(--white);
  background: linear-gradient(135deg, var(--green-700), var(--green-900));
  box-shadow: 0 12px 32px rgba(6, 63, 50, 0.15);
}

.eyebrow {
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.today-section h1 {
  margin: 4px 0 3px;
  font-size: clamp(1.35rem, 3vw, 2rem);
}

.today-section p {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.8rem;
}

.today-meta {
  min-width: 150px;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.76rem;
  text-align: right;
}

.calendar-card {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--white);
  box-shadow: 0 12px 34px rgba(6, 63, 50, 0.09);
}

/* Month navigation */
.month-header {
  min-height: 48px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
}

.month-heading {
  min-width: 0;
  text-align: center;
}

.month-selectors {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.calendar-select,
.calendar-year-input {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--green-900);
  background: #fbfdfc;
  font-size: 0.75rem;
  font-weight: 700;
  outline: none;
}

.calendar-select {
  width: 120px;
  padding: 0 9px;
}

.calendar-year-input {
  width: 82px;
  padding: 0 7px;
  text-align: center;
}

.calendar-select:focus,
.calendar-year-input:focus {
  border-color: var(--green-700);
  box-shadow: 0 0 0 3px rgba(11, 94, 79, 0.1);
}

#hijriMonthTitle {
  min-height: 16px;
  margin: 4px 0 0;
  color: var(--gold-500);
  font-size: 0.66rem;
  font-weight: 700;
}

.month-button {
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--green-900);
  background: var(--green-100);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}

.month-button:hover {
  border-color: var(--green-700);
  background: #dcece6;
}

.calendar-actions {
  margin: 8px 0 10px;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.today-button,
.date-search-toggle {
  min-height: 31px;
  padding: 5px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.67rem;
  font-weight: 800;
}

.today-button {
  color: var(--green-900);
  background: var(--green-100);
}

.today-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.date-search-toggle {
  color: #866117;
  border-color: rgba(212, 161, 58, 0.35);
  background: var(--gold-100);
}

/* Date search */
.date-search-panel {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #f8fbf9;
}

.date-search-fields {
  display: grid;
  grid-template-columns: 75px minmax(130px, 1fr) 95px auto;
  align-items: end;
  gap: 8px;
}

.date-search-fields label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 700;
}

.date-search-fields input,
.date-search-fields select {
  width: 100%;
  height: 33px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: var(--white);
  font-size: 0.7rem;
}

.date-search-fields input {
  padding: 0 8px;
}

.date-search-fields select {
  padding: 0 7px;
}

.date-search-button {
  height: 33px;
  padding: 0 17px;
  border: 0;
  border-radius: 8px;
  color: var(--white);
  background: var(--green-700);
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 800;
}

.date-search-error {
  min-height: 14px;
  margin: 5px 0 0;
  color: #a7332e;
  font-size: 0.6rem;
}

/* Selected date */
.selected-date-card {
  margin-bottom: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(212, 161, 58, 0.35);
  border-radius: 11px;
  background: var(--gold-100);
}

.selected-date-label {
  color: #866117;
  font-size: 0.54rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.selected-date-card h3 {
  margin: 3px 0 2px;
  color: var(--green-900);
  font-size: 0.82rem;
}

.selected-date-card p {
  margin: 0;
  color: #866117;
  font-size: 0.68rem;
  font-weight: 700;
}

.selected-date-card button {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid rgba(212, 161, 58, 0.35);
  border-radius: 7px;
  color: #866117;
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 1rem;
}

/* Calendar */
.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row {
  margin: 6px 0;
}

.weekday-row span {
  padding: 5px 2px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.weekday-row .friday-label {
  color: var(--gold-500);
}

.calendar-grid {
  width: 100%;
  gap: 5px;
}

.calendar-day {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-width: 0;
  min-height: 62px;
  padding: 7px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  background: #fbfdfc;
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.calendar-day:not(.empty-day):hover {
  transform: translateY(-1px);
  border-color: var(--green-700);
  box-shadow: 0 4px 12px rgba(6, 63, 50, 0.08);
}

.gregorian-date {
  color: var(--green-900);
  font-size: 0.88rem;
  line-height: 1;
}

.hijri-date {
  margin-top: 7px;
  color: var(--gold-500);
  font-size: 0.61rem;
  font-weight: 700;
  white-space: nowrap;
}

.today-label,
.cell-friday-label {
  margin-top: auto;
  font-size: 0.5rem;
  font-weight: 800;
  text-transform: uppercase;
}

.calendar-day.is-friday:not(.is-today) {
  border-color: rgba(212, 161, 58, 0.38);
  background: var(--gold-100);
}

.cell-friday-label {
  color: #866117;
}

.calendar-day.is-today {
  border-color: var(--green-700);
  color: var(--white);
  background: var(--green-700);
  box-shadow: 0 6px 15px rgba(11, 94, 79, 0.2);
}

.calendar-day.is-today .gregorian-date,
.calendar-day.is-today .hijri-date,
.calendar-day.is-today .today-label {
  color: var(--white);
}

.calendar-day.is-selected {
  outline: 3px solid rgba(212, 161, 58, 0.7);
  outline-offset: 1px;
}

.calendar-day.is-today.is-selected {
  outline-color: var(--gold-500);
}

.empty-day {
  visibility: hidden;
  pointer-events: none;
}

.calendar-footer {
  margin-top: 9px;
  padding-top: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
}

.legend {
  display: flex;
  gap: 14px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.6rem;
}

.legend i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

.today-indicator {
  background: var(--green-700);
}

.friday-indicator {
  border: 1px solid var(--gold-500);
  background: var(--gold-100);
}

#calendarStatus {
  margin: 0;
  color: var(--muted);
  font-size: 0.6rem;
}

.moon-note {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.4;
  text-align: center;
}

.loading-calendar,
.calendar-error {
  min-height: 260px;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.calendar-error {
  flex-direction: column;
  gap: 5px;
}

/* Mobile */
@media (max-width: 600px) {
  .page-header {
    height: 52px;
    padding-inline: 10px;
  }

  .back-button {
    width: 34px;
    padding: 0;
    justify-content: center;
  }

  .back-button span {
    display: none;
  }

  .calendar-page {
    width: min(100% - 12px, 930px);
    padding-top: 8px;
  }

  .today-section {
    min-height: 78px;
    padding: 12px 14px;
    border-radius: 14px;
  }

  .today-section h1 {
    font-size: 1.18rem;
  }

  .today-section p {
    font-size: 0.67rem;
  }

  .today-meta {
    display: none;
  }

  .calendar-card {
    margin-top: 7px;
    padding: 8px;
    border-radius: 13px;
  }

  .month-header {
    grid-template-columns: 32px minmax(0, 1fr) 32px;
    gap: 5px;
  }

  .month-selectors {
    gap: 4px;
  }

  .calendar-select {
    width: 98px;
    font-size: 0.67rem;
  }

  .calendar-year-input {
    width: 68px;
    font-size: 0.67rem;
  }

  .calendar-actions {
    margin: 6px 0;
  }

  .date-search-fields {
    grid-template-columns: 55px minmax(95px, 1fr) 73px;
    gap: 5px;
  }

  .date-search-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .calendar-grid {
    gap: 3px;
  }

  .calendar-day {
    min-height: 53px;
    padding: 5px;
    border-radius: 7px;
  }

  .gregorian-date {
    font-size: 0.77rem;
  }

  .hijri-date {
    margin-top: 5px;
    font-size: 0.5rem;
  }

  .today-label,
  .cell-friday-label {
    font-size: 0.42rem;
  }

  .selected-date-card {
    padding: 8px 10px;
  }

  .calendar-footer {
    display: none;
  }

  .moon-note {
    font-size: 0.55rem;
  }
}