/* ---------- Kurdish Calendar ---------- */

/* Shared section sizing — every block uses the same padding + radius +
   bottom-margin so the visual rhythm is even.  */
:root {
  --cal-card-pad: 16px;
  --cal-card-radius: 8px;
  --cal-section-gap: 22px;
}

.cal-today,
.cal-newroz,
.cal-converter,
.cal-month-section,
.cal-days-section,
.cal-figures-section,
.cal-poem-section {
  margin: 0 0 var(--cal-section-gap);
}

/* Bordered "card" surface used by newroz, converter, and poem. */
.cal-newroz,
.cal-converter,
.cal-poem,
.cal-poem-saved {
  padding: var(--cal-card-pad);
  border: 1px dashed var(--btn-border);
  border-radius: var(--cal-card-radius);
  background: var(--btn-bg);
}

.cal-today {
  margin: 0 0 var(--cal-section-gap);
}

.cal-today-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.cal-today-card {
  padding: var(--cal-card-pad);
  border: 1px solid var(--btn-border);
  border-radius: var(--cal-card-radius);
  background: var(--btn-bg);
}

.cal-today-label {
  font-size: 0.72em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 6px;
}

.cal-today-date {
  font-size: 1.4em;
  line-height: 1.15;
}

.cal-today-sub {
  font-size: 0.85em;
  opacity: 0.85;
  margin-top: 4px;
}

/* ==========================================================================
   کوردی mode (data-kurd-script="two")
   Every section that contains Arabic-script Kurdish text:
     - Vazirmatn font
     - RTL direction
     - 5% font-size downscale to match Vazir's physically larger render
   Other sections (Gregorian, Latin transliteration, English translation,
   calendar grid, form pickers) keep the user's chosen Latin font.
   ========================================================================== */

/* (1) Vazirmatn + RTL applied to every container of Kurdish content.
       !important guards against page-cached older overrides and any inline
       font-family that might have been set in earlier turns. */
[data-kurd-script="two"] .kurd,
[data-kurd-script="two"] .kurd *,
[data-kurd-script="two"] [data-ar],
[data-kurd-script="two"] [data-ar] *,
[data-kurd-script="two"] .cal-newroz,
[data-kurd-script="two"] .cal-newroz *,
[data-kurd-script="two"] .cal-newroz-text,
[data-kurd-script="two"] .cal-newroz-text *,
[data-kurd-script="two"] .cal-newroz-date,
[data-kurd-script="two"] .cal-day-name[dir="rtl"],
[data-kurd-script="two"] .cal-day-name[dir="rtl"] *,
[data-kurd-script="two"] .fig-name[dir="rtl"],
[data-kurd-script="two"] .fig-name[dir="rtl"] *,
[data-kurd-script="two"] .fig-role[dir="rtl"],
[data-kurd-script="two"] .fig-role[dir="rtl"] *,
[data-kurd-script="two"] .fig-detail,
[data-kurd-script="two"] .fig-detail *,
[data-kurd-script="two"] .fig-detail p[dir="rtl"],
[data-kurd-script="two"] .fig-detail p[dir="rtl"] *,
[data-kurd-script="two"] h1[data-ar],
[data-kurd-script="two"] h2[data-ar],
[data-kurd-script="two"] .back-link[data-ar],
[data-kurd-script="two"] [data-ar-placeholder]::placeholder,
/* (1b) Elements whose textContent gets translated to Kurdish by JS but
       have no .kurd or [data-ar] marker. These all show Kurdish month or
       day names / Kurdish action labels in کوردی mode. */
[data-kurd-script="two"] #g-date,
[data-kurd-script="two"] #g-day,
[data-kurd-script="two"] #conv-g,
[data-kurd-script="two"] #month-title,
[data-kurd-script="two"] .cal-dow,
[data-kurd-script="two"] .cal-day-when,
[data-kurd-script="two"] .fig-when,
[data-kurd-script="two"] #poem-actions,
[data-kurd-script="two"] #poem-actions *,
[data-kurd-script="two"] .cal-poem-saved,
[data-kurd-script="two"] .cal-poem-saved *,
[data-kurd-script="two"] .seg[data-control="conv-dir"] button {
  font-family: 'Vazirmatn', 'Tahoma', sans-serif !important;
}
[data-kurd-script="two"] .kurd,
[data-kurd-script="two"] .cal-newroz,
[data-kurd-script="two"] .cal-newroz-text,
[data-kurd-script="two"] .cal-newroz-date,
[data-kurd-script="two"] .cal-day-name[dir="rtl"],
[data-kurd-script="two"] .fig-name[dir="rtl"],
[data-kurd-script="two"] .fig-role[dir="rtl"],
[data-kurd-script="two"] .fig-detail p[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

/* (2) Newroz banner: parent flex flips so the icon sits on the right and
   the text flows نەورۆز → لە → ٣٢٨ → ڕۆژدا → (date) right-to-left. */
[data-kurd-script="two"] .cal-newroz { flex-direction: row-reverse; }
[data-kurd-script="two"] .cal-newroz-text { direction: rtl; text-align: right; }

/* (3) Size compensation — apply ONLY at outer container level so children
   inherit and don't compound (0.95 × 0.95 ≠ 0.95). */
[data-kurd-script="two"] .kurd,
[data-kurd-script="two"] .cal-newroz-text,
[data-kurd-script="two"] .cal-day-name[dir="rtl"],
[data-kurd-script="two"] .fig-name[dir="rtl"],
[data-kurd-script="two"] .fig-role[dir="rtl"],
[data-kurd-script="two"] .fig-detail p[dir="rtl"],
[data-kurd-script="two"] h1[data-ar],
[data-kurd-script="two"] h2[data-ar],
[data-kurd-script="two"] .cal-today-label[data-ar],
[data-kurd-script="two"] .conv-label[data-ar],
[data-kurd-script="two"] label[data-ar],
[data-kurd-script="two"] button[data-ar],
[data-kurd-script="two"] .back-link[data-ar],
[data-kurd-script="two"] input[data-ar-placeholder],
/* Same size compensation for the JS-translated dynamic-content elements. */
[data-kurd-script="two"] #g-date,
[data-kurd-script="two"] #g-day,
[data-kurd-script="two"] #conv-g,
[data-kurd-script="two"] #month-title,
[data-kurd-script="two"] .cal-dow,
[data-kurd-script="two"] .cal-day-when,
[data-kurd-script="two"] .fig-when,
[data-kurd-script="two"] #poem-actions,
[data-kurd-script="two"] .cal-poem-saved,
[data-kurd-script="two"] .seg[data-control="conv-dir"] button {
  font-size: 0.88em;
}

/* (4a) Important days list in کوردی mode: date on the right, title on
       the left. The 86px/1fr grid columns reverse with direction: rtl. */
[data-kurd-script="two"] .cal-days-list li {
  direction: rtl;
  text-align: right;
}
[data-kurd-script="two"] .cal-day-when,
[data-kurd-script="two"] .cal-day-name { text-align: right; }

/* (4a-2) Section heads in کوردی mode flow right-to-left across the board:
        title on the right, controls on the left. Applied to every section
        with a cal-month-head, plus the page header (back-link + h1). */
[data-kurd-script="two"] .page-header,
[data-kurd-script="two"] .cal-days-section > .cal-month-head,
[data-kurd-script="two"] .cal-figures-section > .cal-month-head,
[data-kurd-script="two"] .cal-poem-section > .cal-month-head,
[data-kurd-script="two"] .cal-converter > .cal-month-head,
[data-kurd-script="two"] .cal-month-section > .cal-month-head,
/* Date-picker rows (Pick a Gregorian / Kurdish Calendar date) — label on
   right, picker on left in کوردی mode. */
[data-kurd-script="two"] .conv-row {
  direction: rtl;
}

/* Force Vazirmatn on <select> elements in کوردی mode — the closed/selected
   display normally falls back to the system default; this overrides it. */
[data-kurd-script="two"] select,
[data-kurd-script="two"] select option {
  font-family: 'Vazirmatn', 'Tahoma', sans-serif !important;
}

/* (4) Figures section in کوردی mode:
       - Whole row flips to RTL so the date sits on the right, name in the
         middle, and title (role) on the left — reading right-to-left:
         date → name → title.
       - .fig-role's hard-coded text-align: right is overridden so the title
         aligns naturally in RTL flow. */
[data-kurd-script="two"] .fig-summary {
  direction: rtl;
  text-align: right;
}
[data-kurd-script="two"] .fig-when,
[data-kurd-script="two"] .fig-name,
[data-kurd-script="two"] .fig-role {
  text-align: right;
}
[data-kurd-script="two"] .fig-mark { margin-right: 0; margin-left: 6px; }

/* (5) Search inputs auto-detect direction based on what's typed —
       so کورد flows right-to-left while "kurd" stays left-to-right. */
.cal-search { unicode-bidi: plaintext; }
/* Reset on nested elements so the 0.95em doesn't compound into children. */
[data-kurd-script="two"] .cal-newroz-text [data-ar],
[data-kurd-script="two"] .cal-newroz-text > *,
[data-kurd-script="two"] [dir="rtl"] [data-ar],
[data-kurd-script="two"] [dir="rtl"] [dir="rtl"] {
  font-size: inherit;
}

@media (max-width: 700px) {
  .cal-today-grid { grid-template-columns: 1fr; }
}

/* ---------- mobile-first calendar polish ---------- */

@media (max-width: 600px) {
  /* page */
  .page { padding: 0 12px; margin: 24px auto; font-size: 16px; }
  .page-header { margin-bottom: 8px; }
  .page-header h1 { font-size: 1.7em; margin: 4px 0 8px; }
  .back-link { font-size: 0.85em; }

  /* reader controls — each .seg can scroll horizontally if it overflows */
  .reader-controls { gap: 6px; margin-bottom: 14px; }
  .seg {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { padding: 7px 10px; min-width: 34px; font-size: 0.95em; flex-shrink: 0; }

  /* today card — single column, tight */
  .cal-today-card { padding: 10px 12px; }
  .cal-today-date { font-size: 1.2em; }
  .cal-today-sub { font-size: 0.82em; }

  /* converter heading — toggle wraps under the title */
  .cal-converter {
    padding: 12px 12px;
    overflow: hidden;          /* prevent any child from overshooting the card */
    max-width: 100%;
    box-sizing: border-box;
  }
  #conv-mode-g2k, #conv-mode-k2g { max-width: 100%; box-sizing: border-box; }
  .cal-converter .conv-out { grid-template-columns: 1fr; gap: 8px; }
  .cal-converter .conv-card { padding: 8px 10px; max-width: 100%; box-sizing: border-box; }
  /* Strip OS-supplied min widths from the date input on iOS Safari & Android */
  .cal-converter input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
  }
  .cal-converter .conv-value { font-size: 1em; word-break: break-word; }
  .cal-converter .conv-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    max-width: 100%;
    box-sizing: border-box;
  }
  .cal-converter .conv-row label { margin-bottom: 2px; }
  .cal-converter select,
  .cal-converter input[type="date"] {
    padding: 8px 10px;
    font-size: 1em;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  /* K2G three-picker row: let the year/month/day selects shrink as small as
     they need to so they all fit the row instead of overflowing the card. */
  #conv-mode-k2g .conv-row {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    overflow: hidden;
  }
  #conv-mode-k2g select {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    padding: 8px 6px;
  }

  /* month grid */
  .cal-month-section { margin-bottom: 18px; }
  .cal-month-head { gap: 6px; flex-wrap: nowrap; }
  .cal-month-title { font-size: 0.95em; }
  .cal-nav { padding: 6px 10px; min-width: 36px; }
  .cal-grid { gap: 3px; font-size: 0.82em; }
  .cal-cell, .cal-dow { padding: 5px 1px; min-height: 36px; }
  .cal-num-greg { font-size: 0.95em; }
  .cal-num-ku { font-size: 0.62em; right: 2px; top: 1px; }
  .cal-cell .cal-star { font-size: 0.55em; left: 2px; bottom: 0; }

  /* days/figures section heads — search on its own row */
  .cal-month-head { flex-wrap: wrap; }
  .cal-search { width: 100%; flex: 1 0 100%; order: 99; }
  .cal-month-head .cal-section-title { flex: 1 1 auto; min-width: 0; }

  /* important-days list */
  .cal-days-list li {
    grid-template-columns: 64px 1fr;
    gap: 8px;
    padding: 10px 0;
  }
  .cal-day-when { font-size: 0.78em; }
  .cal-day-name { font-size: 0.92em; }
  .cal-day-name .cal-day-sub { font-size: 0.74em; }

  /* figures: drop the right-aligned role column */
  .fig-summary { grid-template-columns: 56px 1fr; padding: 10px 0; gap: 8px; }
  .fig-role { display: none; }
  .fig-detail { padding: 4px 0 12px 0; font-size: 0.9em; }
  .fig-when { font-size: 0.78em; }
  .fig-name { font-size: 0.92em; }

  /* poem */
  .cal-poem { padding: 12px 12px; }
  .poem-orig { font-size: 1em; line-height: 1.55; }
  .poem-trans { font-size: 0.9em; }
  .poem-attr { font-size: 0.76em; gap: 6px; flex-direction: column; align-items: flex-end; }
  .poem-attr > span:last-child { align-self: flex-start; }
}

@media (max-width: 380px) {
  /* really tiny screens */
  .page { padding: 0 10px; font-size: 15px; }
  .cal-grid { font-size: 0.76em; gap: 2px; }
  .cal-cell, .cal-dow { padding: 4px 0; min-height: 32px; }
  .cal-num-ku { display: none; }
  .cal-today-date { font-size: 1.1em; }
  .cal-month-title { font-size: 0.88em; }
  /* (note: above was unrelated tiny-screen tweak, leaving at 0.88) */
}

[hidden] { display: none !important; }

.cal-newroz {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88em;
}

.cal-fire { font-size: 1.4em; }

.cal-newroz-date {
  opacity: 0.75;
  margin-left: 6px;
  font-size: 0.85em;
}

/* ---------- Sun & Time card ------------------------------------------- */
.cal-suncard {
  padding: var(--cal-card-pad);
  border: 1px dashed var(--btn-border);
  border-radius: 6px;
  margin-bottom: var(--cal-section-gap, 18px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(180deg, rgba(135, 165, 200, 0.06), transparent 60%);
}
.suncard-head {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.suncard-head .cal-section-title { flex: 1 1 auto; margin: 0; }
.suncard-city {
  font-family: inherit;
  font-size: 0.9em;
  background: var(--btn-bg);
  color: var(--fg);
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  padding: 4px 8px;
  height: 34px;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.suncard-city-wrap {
  position: relative;
  flex: 0 1 240px;
  min-width: 0;
}
.suncard-city-wrap .suncard-city { width: 100%; }
.suncard-city-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  max-height: 280px;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  z-index: 50;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}
.suncard-city-list .group-label {
  font-size: 0.75em;
  opacity: 0.55;
  padding: 6px 12px 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  pointer-events: none;
}
.suncard-city-list .group-label:not(:first-child) { border-top: 1px dashed var(--rule); margin-top: 4px; }
.suncard-city-list li.opt {
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.92em;
}
.suncard-city-list li.opt:hover,
.suncard-city-list li.opt[aria-selected="true"] { background: var(--btn-bg-strong, var(--btn-bg)); }
.suncard-city-list li.opt.is-active { background: var(--btn-bg-strong, var(--btn-bg)); outline: 1px dashed var(--btn-border); outline-offset: -3px; }
.suncard-city-list .empty { padding: 10px 12px; opacity: 0.6; font-size: 0.88em; }
.suncard-arc-wrap {
  width: 100%;
  max-width: 360px;
  margin: 4px auto 0;
}
.suncard-arc { width: 100%; height: auto; display: block; }
#suncard-marker .sun-body { transition: cx 1s linear, cy 1s linear; }
.suncard-clock {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.suncard-time {
  font-size: 1.4em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.suncard-zone { font-size: 0.78em; opacity: 0.7; }
.suncard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.suncard-cell {
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 6px 10px;
}
.suncard-cell-label { font-size: 0.78em; opacity: 0.7; }
.suncard-cell-value { font-size: 1em; font-variant-numeric: tabular-nums; }
@media (max-width: 460px) {
  .suncard-grid { grid-template-columns: 1fr 1fr; }
  .suncard-cell-value { font-size: 0.9em; }
}

/* In کوردی mode the suncard contents flow RTL with Vazirmatn font; the
   arc itself stays LTR so sunrise (east) is on the left and sunset (west)
   on the right — astronomically correct regardless of script. */
[data-kurd-script="two"] .cal-suncard,
[data-kurd-script="two"] .suncard-head,
[data-kurd-script="two"] .suncard-grid,
[data-kurd-script="two"] .suncard-cell,
[data-kurd-script="two"] .suncard-clock,
[data-kurd-script="two"] .suncard-time,
[data-kurd-script="two"] .suncard-zone,
[data-kurd-script="two"] .suncard-cell-label,
[data-kurd-script="two"] .suncard-cell-value,
[data-kurd-script="two"] .suncard-city,
[data-kurd-script="two"] .suncard-city-list,
[data-kurd-script="two"] .suncard-city-list * {
  font-family: 'Vazirmatn', 'Tahoma', sans-serif !important;
}
[data-kurd-script="two"] .suncard-city-list { direction: rtl; text-align: right; }
[data-kurd-script="two"] .cal-suncard,
[data-kurd-script="two"] .suncard-head,
[data-kurd-script="two"] .suncard-grid,
[data-kurd-script="two"] .suncard-cell { direction: rtl; text-align: right; }
[data-kurd-script="two"] .suncard-arc-wrap { direction: ltr; }

/* .cal-converter sizing comes from the shared card rule above */

.cal-converter .conv-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.cal-converter .conv-row label {
  font-size: 0.85em;
  opacity: 0.85;
}

.cal-converter input[type="date"],
.cal-converter select {
  font-family: inherit;
  font-size: 1em;
  background: var(--btn-bg-strong, var(--btn-bg));
  color: var(--fg);
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  padding: 4px 8px;
}

.cal-converter .conv-out {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.cal-converter .conv-card {
  padding: 10px 12px;
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  background: var(--btn-bg-strong, var(--btn-bg));
}

.cal-converter .conv-label {
  font-size: 0.7em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 4px;
}

.cal-converter .conv-value {
  font-size: 1.1em;
}

.cal-converter .conv-out {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 700px) {
  .cal-converter .conv-out { grid-template-columns: 1fr; }
}

/* ---------- Figures ---------- */

/* margin from shared section rule */

.cal-figures-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.fig-item {
  border-bottom: 1px dashed var(--rule);
}

.fig-item:last-child { border-bottom: none; }

.fig-summary {
  display: grid;
  grid-template-columns: 86px 1fr auto;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  background: transparent;
  color: var(--fg);
  border: 0;
  padding: 8px 0;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  text-align: left;
}

.fig-summary:hover .fig-name { border-bottom: 1px dotted var(--fg); }

.fig-when { font-size: 0.85em; opacity: 0.85; }
.fig-name { font-size: 0.95em; border-bottom: 1px dotted transparent; padding-bottom: 1px; }
.fig-mark { color: var(--accent); margin-right: 6px; }
.fig-role { font-size: 0.78em; opacity: 0.7; text-align: right; }

.fig-detail {
  display: none;
  padding: 4px 0 12px 96px;
  font-size: 0.92em;
  line-height: 1.5;
  opacity: 0.92;
}

.fig-detail p { margin: 0 0 0.6em; }
.fig-detail a { color: var(--fg); text-decoration: underline; text-decoration-style: dotted; }
.fig-detail a:hover { text-decoration-style: solid; }

.fig-item.expanded .fig-detail { display: block; }

.fig-item.today {
  background: var(--btn-bg-strong);
  border-radius: 4px;
}

.fig-item.today .fig-when::after {
  content: ' ▸ today';
  color: var(--accent);
  font-weight: 600;
}

.cal-search {
  font-family: inherit;
  font-size: 0.9em;
  background: var(--btn-bg);
  color: var(--fg);
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  padding: 0 12px;
  width: 160px;
  height: 34px;
  box-sizing: border-box;
  line-height: normal;
}

.cal-search::placeholder { opacity: 0.6; }
.cal-search:focus { outline: 1px dashed var(--btn-border); outline-offset: 1px; }

/* Vazirmatn is used ONLY for elements that contain Arabic-script Kurdish.
   It renders ~5% physically larger than Inter/Lora at the same numeric
   font-size, so we ship a small downscale to keep visual sizes matched. */
.kurd-ar {
  font-family: 'Vazirmatn', 'Tahoma', sans-serif;
  font-size: 0.88em;
  direction: rtl;
  text-align: right;
}
.kurd-ar .cal-day-sub,
.kurd-ar .fig-when,
.kurd-ar .fig-mark { font-size: inherit; }

/* Unified control heights — buttons, search inputs, date input, and selects
   in the calendar all sit on the same baseline. */
.cal-month-head .btn,
.cal-month-head .cal-search,
.conv-row input,
.conv-row select,
.seg button {
  height: 34px;
  box-sizing: border-box;
  font-size: 0.9em;
  line-height: 1;
  vertical-align: middle;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cal-month-head .btn { padding: 0 12px; }
.conv-row input[type="date"],
.conv-row select {
  font-family: inherit;
  background: var(--btn-bg);
  color: var(--fg);
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  padding: 0 10px;
}

@media (max-width: 600px) {
  .fig-summary { grid-template-columns: 60px 1fr; }
  .fig-role { display: none; }
  .fig-detail { padding-left: 70px; }
}

/* ---------- Poem ---------- */

/* .cal-poem-section + .cal-poem sizing come from the shared rule above */

/* Each poem renders as two sibling blocks (Arabic, then Latin transliteration),
   each block being: title → body → attribution. */
.poem-block { margin: 0 0 14px; }
.poem-block + .poem-block {
  padding-top: 14px;
  border-top: 1px dotted var(--rule);
}

.poem-title,
.poem-title-lat {
  font-weight: 700;
  margin: 0 0 8px;
  line-height: 1.3;
}
.poem-title {
  font-size: 1.25em;
  font-family: 'Vazirmatn','Tahoma',sans-serif;
  /* Inherit dir/text-align from the .kurd-ar parent block */
}
.poem-title-lat {
  font-size: 1.1em;
  text-align: left;
  direction: ltr;
}
.poem-title:empty,
.poem-title-lat:empty { display: none; }

.poem-orig {
  white-space: pre-line;
  font-size: 1em;
  line-height: 1.6;
  margin: 0 0 8px;
}

.poem-attr-ar,
.poem-attr-lat {
  font-size: 0.85em;
  opacity: 0.85;
  margin: 0;
}
.poem-attr-ar { font-family: 'Vazirmatn','Tahoma',sans-serif; }

/* Per-poem direction is set inline via JS (poem.dir) */

.poem-latin {
  white-space: pre-line;
  font-size: 0.98em;
  line-height: 1.55;
  padding-top: 10px;
  margin-top: 4px;
  border-top: 1px dotted var(--rule);
  opacity: 0.92;
  direction: ltr;
  text-align: left;
}

.poem-trans {
  white-space: pre-line;
  font-style: italic;
  opacity: 0.85;
  font-size: 0.88em;
  line-height: 1.5;
  padding-top: 8px;
  border-top: 1px dotted var(--rule);
}

/* Share menu */
.poem-share-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.poem-share-menu {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 14px;
  min-width: 240px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.poem-share-menu .poem-share-link {
  display: block;
  text-align: left;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--fg);
  padding: 8px 12px;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.poem-share-menu .poem-share-link:hover {
  border-color: var(--fg);
}
.poem-share-menu .poem-share-close {
  margin-top: 4px;
  background: transparent;
  border: 0;
  color: var(--fg);
  opacity: 0.7;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  align-self: flex-end;
  padding: 4px 8px;
}

.poem-attr {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  font-size: 0.82em;
  opacity: 0.85;
}

/* Action buttons row, separate from attribution */
.poem-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dotted var(--rule);
  font-size: 0.85em;
}
.poem-actions button,
.poem-actions a {
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--fg);
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: pointer;
}
.poem-actions a:hover,
.poem-actions button:hover { opacity: 1; color: var(--accent); }
.poem-actions .poem-bookmark {
  font-size: 1.25em;
  line-height: 1;
  text-decoration: none;
}
.poem-actions .poem-bookmark:hover { color: var(--accent); }

.cal-poem-saved {
  list-style: none;
  margin: 0 0 14px;
  max-height: 280px;
  overflow-y: auto;
  /* padding/border/radius/bg from shared card rule */
}

.cal-poem-saved[hidden] { display: none; }

.cal-poem-saved .poem-saved-empty {
  padding: 12px 14px;
  opacity: 0.7;
  font-size: 0.9em;
  text-align: center;
}

.poem-saved-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border-bottom: 1px dashed var(--rule);
}

.poem-saved-item:last-child { border-bottom: none; }

.poem-saved-load {
  background: transparent;
  border: 0;
  font-family: inherit;
  font-size: inherit;
  color: var(--fg);
  text-align: right;
  cursor: pointer;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-family: 'Vazirmatn', 'Tahoma', sans-serif;
  direction: rtl;
  width: 100%;
}

.poem-saved-load:hover { background: var(--btn-bg-strong); }

.poem-saved-title { font-size: 0.95em; }
.poem-saved-meta { font-size: 0.78em; opacity: 0.75; }

.poem-saved-remove {
  background: transparent;
  border: 0;
  color: var(--fg);
  opacity: 0.5;
  font-size: 1.2em;
  padding: 6px 12px;
  cursor: pointer;
}

.poem-saved-remove:hover { opacity: 1; color: var(--error); }

/* .cal-month-section margin from shared section rule */

.cal-month-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
}

.cal-month-title {
  flex: 1 1 auto;
  text-align: center;
  font-size: 1.15em;
  font-weight: normal;
  margin: 0;
  opacity: 0.95;
}

.cal-nav { padding: 4px 10px; font-size: 0.95em; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  font-size: 0.9em;
}

.cal-cell, .cal-dow {
  padding: 8px 4px;
  text-align: center;
  border-radius: 3px;
  background: var(--btn-bg);
  position: relative;
  min-height: 42px;
}

button.cal-cell-btn {
  font-family: inherit;
  font-size: inherit;
  color: var(--fg);
  border: 0;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

button.cal-cell-btn:hover {
  background: var(--btn-bg-strong);
}

.cal-num-greg {
  display: block;
  font-size: 1em;
  line-height: 1.1;
}

.cal-num-ku {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.7em;
  opacity: 0.6;
  font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

.cal-dow {
  background: transparent;
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
  padding: 4px;
  min-height: 0;
}

.cal-cell.empty {
  background: transparent;
}

.cal-cell.today {
  background: var(--btn-bg-strong);
  outline: 2px solid var(--accent);
}

.cal-cell.has-event {
  background: var(--accent);
  color: var(--accent-2, #2b0a00);
}

[data-theme="dark"] .cal-cell.has-event { color: #111; }

.cal-cell .cal-dot {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.cal-cell.has-event .cal-dot { display: none; }

.cal-cell .cal-star {
  position: absolute;
  bottom: 1px;
  left: 4px;
  font-size: 0.65em;
  color: var(--accent);
  line-height: 1;
}

.cal-cell.has-event .cal-star { color: var(--accent-2, #2b0a00); opacity: 0.8; }
[data-theme="dark"] .cal-cell.has-event .cal-star { color: #111; }

.cal-section-title {
  font-size: 1.1em;
  font-weight: normal;
  margin: 0 0 8px;
  opacity: 0.95;
}

.cal-days-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.cal-days-list li {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--rule);
  align-items: baseline;
}

.cal-days-list li:last-child { border-bottom: none; }

.cal-day-when {
  font-size: 0.85em;
  opacity: 0.85;
}

.cal-day-name {
  font-size: 0.88em;
}

.cal-day-name .cal-day-sub {
  display: block;
  font-size: 0.78em;
  opacity: 0.7;
  margin-top: 2px;
}

a.cal-day-name {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px dotted transparent;
  display: block;
}

a.cal-day-name:hover {
  border-bottom-color: var(--fg);
}

.cal-day-when.upcoming { color: var(--accent); opacity: 1; font-weight: 600; }
