* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

.calendar-page {
    --calendar-hijri: #d4af37;
    --calendar-gregorian: #38bdf8;
    --calendar-solar: #f97316;
    --calendar-success: #10b981;
    min-height: 100vh;
}

.calendar-bg {
    background-size: cover;
    background-position: center;
    filter: blur(5px);
}

.calendar-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    transition: background-color 0.4s ease, opacity 0.4s ease;
}

.calendar-shell {
    position: relative;
    z-index: 1;
    width: min(94%, 1400px);
    margin: 0 auto;
    padding: 145px 0 70px;
    flex: 1;
}

.calendar-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.8fr);
    gap: 24px;
    align-items: stretch;
    margin-bottom: 24px;
}

.calendar-hero__copy,
.clock-card,
.date-summary__card,
.date-converter,
.month-card,
.today-events,
.events-panel {
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.16);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

.calendar-hero__copy {
    position: relative;
    overflow: hidden;
    min-height: 290px;
    padding: clamp(30px, 5vw, 70px);
    border-radius: 28px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.calendar-hero__copy::after {
    content: "☾";
    position: absolute;
    inset-inline-end: 5%;
    top: 50%;
    color: var(--gold-main);
    font-size: clamp(150px, 20vw, 270px);
    line-height: 1;
    opacity: 0.07;
    transform: translateY(-52%);
    pointer-events: none;
}

.section-kicker {
    display: block;
    color: var(--gold-main);
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 8px;
}

.calendar-hero h1 {
    position: relative;
    z-index: 1;
    margin: 0 0 12px;
    color: var(--text-main);
    font-size: clamp(34px, 5vw, 64px);
    line-height: 1.25;
}

.calendar-hero__copy p {
    position: relative;
    z-index: 1;
    max-width: 650px;
    margin: 0;
    color: var(--text-muted);
    font-size: clamp(14px, 2vw, 18px);
    line-height: 1.9;
}

.today-button {
    position: relative;
    z-index: 1;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    margin-top: 24px;
    padding: 9px 22px;
    color: #15120a;
    background: linear-gradient(135deg, var(--gold-light), var(--gold-main));
    border-radius: 999px;
    font-size: 13px;
    font-weight: 900;
    box-shadow: 0 10px 24px rgba(212, 175, 55, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.today-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(212, 175, 55, 0.28);
}

.clock-card {
    position: relative;
    overflow: hidden;
    border-radius: 28px;
    padding: 26px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.clock-stage {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.analog-clock {
    position: relative;
    width: min(215px, 52vw);
    aspect-ratio: 1;
    border: 8px solid #b89134;
    border-radius: 50%;
    background: #f7f1df;
    box-shadow:
        0 0 0 2px rgba(243, 229, 171, 0.6),
        0 0 0 7px rgba(184, 145, 52, 0.13),
        inset 0 0 0 1px rgba(17, 24, 39, 0.1),
        inset 0 5px 18px rgba(255, 255, 255, 0.8),
        0 18px 38px rgba(0, 0, 0, 0.24);
}

.analog-clock::before {
    content: "";
    position: absolute;
    inset: 10px;
    border: 1px solid rgba(83, 67, 33, 0.15);
    border-radius: 50%;
}

.hour-marker {
    position: absolute;
    inset: 14px;
    z-index: 1;
    transform: rotate(calc(var(--marker) * 30deg));
}

.hour-marker::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 50%;
    width: 2px;
    height: 9px;
    border-radius: 999px;
    background: #7b715e;
    transform: translateX(-50%);
}

.hour-marker--major::before {
    top: 0;
    width: 4px;
    height: 15px;
    background: #2f2a20;
}

.clock-hand {
    position: absolute;
    left: 50%;
    bottom: 50%;
    z-index: 4;
    border-radius: 10px;
    transform-origin: 50% 100%;
    transform: translateX(-50%) rotate(0deg);
    filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.25));
}

.clock-hand--hour {
    width: 7px;
    height: 27%;
    background: #24221d;
}

.clock-hand--minute {
    width: 4px;
    height: 37%;
    background: #4b463b;
}

.clock-hand--second {
    width: 2px;
    height: 41%;
    background: #b8860b;
}

.clock-hand--second::after {
    content: "";
    position: absolute;
    top: calc(100% - 1px);
    left: 50%;
    width: 2px;
    height: 25px;
    border-radius: 999px;
    background: #b8860b;
    transform: translateX(-50%);
}

.clock-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    border: 4px solid #b8860b;
    border-radius: 50%;
    background: #2f2a20;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    transform: translate(-50%, -50%);
    z-index: 5;
}

.clock-details {
    width: 100%;
    margin-top: 24px;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: transparent;
}

.clock-caption {
    color: var(--text-main);
    font-size: 12px;
    font-weight: 900;
}

.digital-clock {
    direction: ltr;
    color: var(--gold-light);
    font-family: "Inter", "Courier New", monospace !important;
    font-size: clamp(29px, 4vw, 39px);
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px !important;
    line-height: 1.25;
    text-shadow: 0 0 18px rgba(212, 175, 55, 0.22);
}

.clock-date {
    min-height: 20px;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 10px;
}

.date-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.date-summary__card {
    min-width: 0;
    min-height: 104px;
    padding: 18px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.date-summary__icon {
    flex: 0 0 50px;
    height: 50px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    color: #111827;
    font-size: 25px;
    font-weight: 900;
}

.date-summary__card--hijri .date-summary__icon {
    background: var(--calendar-hijri);
}

.date-summary__card--gregorian .date-summary__icon {
    background: var(--calendar-gregorian);
}

.date-summary__card--solar .date-summary__icon {
    background: var(--calendar-solar);
}

.date-summary__card > div:last-child {
    min-width: 0;
}

.date-summary__card span {
    display: block;
    margin-bottom: 3px;
    color: var(--text-muted);
    font-size: 11px;
}

.date-summary__card strong {
    display: block;
    overflow: hidden;
    color: var(--text-main);
    font-size: clamp(14px, 1.7vw, 19px);
    line-height: 1.5;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.date-converter {
    overflow: hidden;
    margin-bottom: 55px;
    padding: 24px;
    border-radius: 24px;
}

.date-converter__head {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.date-converter__head h2 {
    margin: 0;
    color: var(--text-main);
    font-size: clamp(24px, 3vw, 34px);
    line-height: 1.35;
}

.date-converter__head p {
    max-width: 620px;
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.8;
}

.date-converter__weekday {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid rgba(212, 175, 55, 0.28);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    color: var(--gold-light);
    background: rgba(212, 175, 55, 0.08);
    font-size: 13px;
    font-weight: 900;
}

.date-converter__form {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) minmax(92px, 0.62fr) minmax(160px, 1fr) minmax(120px, 0.75fr) auto;
    gap: 12px;
    align-items: end;
}

.converter-field {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.converter-field span {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 900;
}

.converter-field select,
.converter-field input {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--surface-border);
    border-radius: 14px;
    padding: 0 14px;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
    font: inherit;
    font-size: 14px;
    font-weight: 800;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.converter-field select:focus,
.converter-field input:focus {
    border-color: var(--gold-main);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.16);
}

.light-mode .converter-field select,
.light-mode .converter-field input {
    background: rgba(15, 23, 42, 0.035);
}

.converter-button {
    min-height: 48px;
    border: none;
    border-radius: 14px;
    padding: 0 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #15120a;
    background: linear-gradient(135deg, var(--gold-light), var(--gold-main));
    font: inherit;
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(212, 175, 55, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.converter-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 32px rgba(212, 175, 55, 0.26);
}

.converter-button span {
    direction: ltr;
    font-family: Arial, sans-serif !important;
    font-size: 18px;
    line-height: 1;
}

.converter-error {
    margin: 16px 0 0;
    padding: 12px 14px;
    border: 1px solid rgba(239, 68, 68, 0.26);
    border-radius: 14px;
    color: #fecaca;
    background: rgba(239, 68, 68, 0.1);
    font-size: 13px;
    font-weight: 800;
    line-height: 1.7;
}

.light-mode .converter-error {
    color: #991b1b;
}

.converter-results {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.converter-result {
    min-width: 0;
    min-height: 86px;
    padding: 15px;
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: rgba(255, 255, 255, 0.045);
}

.light-mode .converter-result {
    background: rgba(15, 23, 42, 0.035);
}

.converter-result--hijri {
    border-top: 3px solid var(--calendar-hijri);
}

.converter-result--gregorian {
    border-top: 3px solid var(--calendar-gregorian);
}

.converter-result--solar {
    border-top: 3px solid var(--calendar-solar);
}

.converter-result span {
    margin-bottom: 5px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 800;
}

.converter-result strong {
    color: var(--text-main);
    font-size: clamp(15px, 1.7vw, 20px);
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.section-heading {
    margin-bottom: 22px;
    text-align: center;
}

.section-heading h2 {
    margin: 0;
    color: var(--text-main);
    font-size: clamp(26px, 4vw, 38px);
}

.section-heading p {
    margin: 8px auto 0;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.8;
}

.today-events {
    margin: -25px 0 55px;
    padding: 25px;
    border-radius: 24px;
}

.today-events__items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.today-event {
    padding: 14px 16px;
    color: var(--text-main);
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.22);
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.8;
}

.months-section {
    margin-bottom: 60px;
}

.months-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.month-card {
    overflow: hidden;
    min-width: 0;
    border-radius: 22px;
}

.month-card--hijri {
    border-top: 4px solid var(--calendar-hijri);
}

.month-card--gregorian {
    border-top: 4px solid var(--calendar-gregorian);
}

.month-card--solar {
    border-top: 4px solid var(--calendar-solar);
}

.month-card__head {
    min-height: 95px;
    padding: 18px;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    align-items: center;
    gap: 10px;
    text-align: center;
    border-bottom: 1px solid var(--surface-border);
}

.month-card__type {
    display: block;
    margin-bottom: 3px;
    color: var(--text-muted);
    font-size: 11px;
}

.month-card__head h3 {
    overflow: hidden;
    margin: 0;
    color: var(--text-main);
    font-size: clamp(16px, 2vw, 21px);
    line-height: 1.5;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.month-card__head h3 span {
    color: var(--gold-main);
    font-size: 0.8em;
}

.month-nav {
    width: 38px;
    height: 38px;
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
    font-family: Arial, sans-serif !important;
    font-size: 26px;
    line-height: 1;
    transition: background 0.2s ease, color 0.2s ease;
}

.month-nav:hover {
    color: #111827;
    background: var(--gold-main);
}

.month-weekdays,
.month-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.month-weekdays {
    padding: 12px 12px 4px;
}

.month-weekdays span {
    overflow: hidden;
    padding: 5px 1px;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 800;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.month-days {
    gap: 4px;
    padding: 5px 12px 16px;
}

.day-cell {
    position: relative;
    min-width: 0;
    aspect-ratio: 1;
    border: 1px solid transparent;
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.035);
    font-size: 12px;
    font-weight: 700;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.light-mode .day-cell {
    background: rgba(15, 23, 42, 0.035);
}

.day-cell:not(.day-cell--empty):hover {
    z-index: 2;
    border-color: var(--gold-main);
    transform: translateY(-2px);
}

.day-cell--empty {
    visibility: hidden;
}

.day-cell.is-selected {
    color: #111827;
    background: var(--gold-main);
    box-shadow: 0 8px 18px rgba(212, 175, 55, 0.24);
}

.day-cell.is-today::after {
    content: "";
    position: absolute;
    bottom: 4px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--calendar-success);
}

.day-cell.is-selected.is-today::after {
    background: #111827;
}

.events-section {
    margin-top: 10px;
}

.events-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.events-panel {
    overflow: hidden;
    min-width: 0;
    border-radius: 22px;
}

.events-panel__head {
    min-height: 78px;
    padding: 17px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    color: #111827;
}

.events-panel--hijri .events-panel__head {
    background: linear-gradient(135deg, #f3e5ab, var(--calendar-hijri));
}

.events-panel--gregorian .events-panel__head {
    background: linear-gradient(135deg, #bae6fd, var(--calendar-gregorian));
}

.events-panel__head span {
    font-size: 12px;
    font-weight: 700;
}

.events-panel__head strong {
    font-size: 17px;
}

.events-list {
    max-height: 470px;
    overflow-y: auto;
    margin: 0;
    padding: 0;
    list-style: none;
    scrollbar-width: thin;
    scrollbar-color: var(--gold-main) transparent;
}

.events-list li {
    min-height: 65px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: var(--text-main);
    font-size: 13px;
    line-height: 1.75;
}

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

.events-list li.is-current {
    background: rgba(212, 175, 55, 0.1);
    box-shadow: inset -3px 0 var(--gold-main);
}

.event-day {
    flex: 0 0 34px;
    height: 34px;
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: var(--gold-main);
    background: rgba(255, 255, 255, 0.04);
    font-weight: 900;
}

.event-text {
    flex: 1;
    min-width: 0;
}

.events-empty {
    justify-content: center;
    color: var(--text-muted) !important;
    text-align: center;
}

@media (max-width: 1100px) {
    .calendar-hero {
        grid-template-columns: minmax(0, 1.35fr) minmax(285px, 0.65fr);
    }

    .months-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .date-converter__form {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .converter-field:first-of-type,
    .converter-button {
        grid-column: span 2;
    }

    .month-card--solar {
        grid-column: 1 / -1;
        width: min(100%, 620px);
        justify-self: center;
    }
}

@media (max-width: 820px) {
    .calendar-shell {
        width: min(92%, 680px);
        padding-top: 125px;
    }

    .calendar-hero {
        grid-template-columns: 1fr;
    }

    .calendar-hero__copy {
        min-height: 250px;
    }

    .clock-card {
        padding: 22px;
    }

    .clock-stage {
        width: 100%;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        gap: 28px;
    }

    .analog-clock {
        width: min(190px, 38vw);
    }

    .clock-details {
        margin-top: 0;
    }

    .date-summary {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .date-converter__head {
        flex-direction: column;
    }

    .date-converter__weekday {
        align-self: flex-start;
    }

    .date-converter__form,
    .converter-results {
        grid-template-columns: 1fr;
    }

    .converter-field:first-of-type,
    .converter-button {
        grid-column: auto;
    }

    .date-summary__card {
        min-height: 84px;
    }

    .date-summary__card strong {
        font-size: 16px;
    }

    .months-grid,
    .events-grid {
        grid-template-columns: 1fr;
    }

    .month-card--solar {
        grid-column: auto;
        width: 100%;
    }
}

@media (max-width: 520px) {
    .calendar-shell {
        width: calc(100% - 24px);
        padding-top: 112px;
        padding-bottom: 45px;
    }

    .calendar-hero,
    .date-summary {
        margin-bottom: 24px;
    }

    .date-converter {
        margin-bottom: 38px;
        padding: 18px 14px;
    }

    .calendar-hero__copy,
    .clock-card,
    .date-converter,
    .month-card,
    .today-events,
    .events-panel {
        border-radius: 18px;
    }

    .calendar-hero__copy {
        min-height: 225px;
        padding: 28px 22px;
    }

    .calendar-hero h1 {
        font-size: 34px;
    }

    .clock-card {
        padding: 17px;
    }

    .clock-stage {
        display: flex;
        gap: 0;
    }

    .analog-clock {
        width: 185px;
        margin: 0 auto;
    }

    .digital-clock {
        font-size: 33px;
    }

    .date-summary__card {
        padding: 13px;
        border-radius: 16px;
    }

    .date-summary__icon {
        flex-basis: 44px;
        height: 44px;
        border-radius: 13px;
        font-size: 21px;
    }

    .today-events {
        margin-top: -10px;
        padding: 18px 14px;
    }

    .today-events__items {
        grid-template-columns: 1fr;
    }

    .month-card__head {
        min-height: 82px;
        padding: 13px;
    }

    .month-weekdays {
        padding-inline: 7px;
    }

    .month-weekdays span {
        font-size: 8px;
    }

    .month-days {
        gap: 3px;
        padding: 5px 7px 12px;
    }

    .day-cell {
        border-radius: 8px;
        font-size: 11px;
    }

    .events-panel__head {
        padding: 14px;
    }

    .events-panel__head strong {
        font-size: 14px;
    }

    .events-list {
        max-height: 410px;
    }

    .events-list li {
        padding: 11px 12px;
        font-size: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .calendar-page *,
    .calendar-page *::before,
    .calendar-page *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
