<style>
    .ical-flex {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: stretch;
        gap: 0.5em;
        max-width: 700px;
        width: 100%;
    }

    .ical-flex .summary-block {
        flex: 1 1 0%;
    }

    .ical-flex .calendar-block {
        flex: none;
        margin-left: auto;
    }

    @media (max-width: 599px) {
        .ical-flex {
            flex-direction: column;
        }

        .ical-flex>div.summary-block {
            margin-bottom: 0.5em;
            margin-left: 0;
        }

        .ical-flex>div.calendar-block {
            margin-left: 0;
        }
    }
</style>
<div class="ical-flex">
    <div class="summary-block"
        style="background:#f7f7f7; border-radius:8px; box-shadow:0 2px 8px #bbb; padding:16px 18px; margin:0 0 8px 0; min-width:220px; max-width:700px; font-size:15px; color:#222;">
        <div
            style="display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: 0.5em; width: 100%;">
            <div style="flex: 1 1 220px; min-width: 180px;">
                <div style="font-size:17px; font-weight:bold; margin-bottom:8px; color:#333;"><b>Summary:</b> {{ summary
                    }}</div>
                <div style="margin-bottom:4px;"><b>Start:</b> {{ local_fmt_start }}</div>
                <div style="margin-bottom:4px;"><b>End:</b> {{ local_fmt_end }}</div>
                {% if !recurrence_display.is_empty() %}
                <div style="margin-bottom:4px;">
                    <b>Repeats:</b> {{ recurrence_display }}
                </div>
                {% endif %}
                {% if !organizer_cn.is_empty() %}
                <div style="margin-bottom:4px;"><b>Organizer:</b> {{ organizer_cn }}</div>
                {% elif !organizer.is_empty() %}
                <div style="margin-bottom:4px;"><b>Organizer:</b> {{ organizer }}</div>
                {% endif %}
            </div>
            {% if all_days.len() > 0 %}
            <div class="calendar-block" style="flex: none; margin-left: auto; min-width: 180px;">
                <table class="ical-month"
                    style="border-collapse:collapse; min-width:220px; background:#fff; box-shadow:0 2px 8px #bbb; font-size:14px; margin:0;">
                    <caption
                        style="caption-side:top; text-align:center; font-weight:bold; font-size:16px; padding-bottom:8px 0;">
                        {{ caption }}</caption>
                    <thead>
                        <tr>
                            {% for wd in ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] %}
                            <th
                                style="padding:4px 6px; border-bottom:1px solid #ccc; color:#666; font-weight:600; background:#f7f7f7">
                                {{ wd }}</th>
                            {% endfor %}
                        </tr>
                    </thead>
                    <tbody>
                        {% for week in all_days|batch(7) %}
                        <tr>
                            {% for day in week %}
                            {% if event_days.contains(day) %}
                            <td
                                data-event-day="{{ day.format("%Y-%m-%d") }}"
                                style="background:#ffd700; color:#222; font-weight:bold; border:1px solid #aaa; border-radius:4px; text-align:center;">
                                {{ day.day() }}
                            </td>
                            {% elif today.is_some() && today.unwrap() == day %}
                            <td
                                style="border:2px solid #2196f3; border-radius:4px; text-align:center; background:#e3f2fd; color:#222; box-shadow:0 0 0 2px #2196f3;">
                                {{ day.day() }}
                            </td>
                            {% else %}
                            <td style="border:1px solid #eee; text-align:center;background:#f7f7f7;color:#bbb;">
                                {{ day.day() }}
                            </td>
                            {% endif %}
                            {% endfor %}
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
            {% endif %}
        </div>
    </div>
</div>
{% if !description_paragraphs.is_empty() %}
<div style="max-width:700px; width:100%;">
    {% for p in description_paragraphs %}
    <p style="margin: 0 0 8px 0; color:#444;">{{ p }}</p>
    {% endfor %}
</div>
{% endif %}
