* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
    color: #333;
    background: #f4f6f8;
}

header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 24px;
    background: #e53935;
    color: #fff;
    padding: 16px 24px;
}

header h1 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 1.4rem;
}

.header-icon {
    width: 32px;
    height: 32px;
}

main {
    flex: 1;
    width: 100%;
    max-width: 640px;
    margin: 32px auto;
    padding: 24px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

main.view-three {
    max-width: 1100px;
}

main.view-year {
    max-width: 1200px;
}

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

.view-year .calendar-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.calendar caption {
    padding-bottom: 6px;
    font-weight: bold;
    font-size: 1.05rem;
}

.calendar caption a {
    color: inherit;
    text-decoration: none;
    padding: 2px 8px;
    border-radius: 6px;
}

.calendar caption a:hover {
    background: #f4f6f8;
    color: #e53935;
    text-decoration: underline;
}

.calendar-grid .calendar th {
    height: 28px;
    font-size: 0.8rem;
}

.calendar-grid .calendar td {
    height: 44px;
    font-size: 0.85rem;
}

.calendar-grid .calendar td small {
    display: none;
}

.calendar-grid .calendar td.today span {
    width: 1.9em;
    height: 1.9em;
    line-height: 1.9em;
}

.month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.month-nav h2 {
    margin: 0;
    font-size: 1.5rem;
}

.month-nav a {
    padding: 6px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    color: #333;
    text-decoration: none;
    font-size: 0.9rem;
}

.month-nav a:hover {
    background: #f4f6f8;
}

.back-to-today {
    margin: -8px 0 16px;
    text-align: center;
    font-size: 0.9rem;
}

.back-to-today a {
    color: #e53935;
}

.calendar {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.calendar th,
.calendar td {
    height: 64px;
    text-align: center;
    vertical-align: middle;
    border: 1px solid #e0e0e0;
}

.calendar th {
    height: 40px;
    background: #fafafa;
    font-weight: bold;
}

.calendar .sun {
    color: #e53935;
}

.calendar .sat {
    color: #1e66d0;
}

.calendar td.holiday {
    color: #e53935;
    background: #fff5f5;
}

.calendar td small {
    display: block;
    margin-top: 2px;
    font-size: 0.65rem;
    line-height: 1.2;
}

.calendar td.today.holiday span {
    color: #fff;
}

.calendar td.empty {
    background: #fafafa;
}

.calendar td.today span {
    display: inline-block;
    width: 2.2em;
    height: 2.2em;
    line-height: 2.2em;
    border-radius: 50%;
    background: #e53935;
    color: #fff;
    font-weight: bold;
}

footer {
    padding: 16px;
    text-align: center;
    font-size: 0.85rem;
    color: #777;
}

.view-switch {
    display: flex;
    gap: 20px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.view-switch a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    padding-bottom: 2px;
    border-bottom: 2px solid transparent;
}

.view-switch a:hover {
    color: #fff;
}

.view-switch a.active {
    color: #fff;
    font-weight: bold;
    border-bottom-color: #fff;
}

footer p {
    margin: 0;
}

@media (max-width: 480px) {
    main {
        margin: 16px 8px;
        padding: 12px;
    }

    .calendar th,
    .calendar td {
        height: 48px;
    }
}

/* 祝日名の吹き出し(script.js) */
.calendar-grid td[data-holiday] {
    cursor: help;
}

.tooltip {
    position: absolute;
    z-index: 100;
    padding: 6px 10px;
    border-radius: 6px;
    background: #333;
    color: #fff;
    font-size: 0.8rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s;
}

.tooltip.visible {
    opacity: 1;
}

.tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: var(--arrow-x, 50%);
    margin-left: -5px;
    border: 5px solid transparent;
    border-top-color: #333;
}

.tooltip.below::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #333;
}
