/* KMSP Event Calendar v8.1 */
.kmsp-calendar-wrap {
    max-width: 1100px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.kmsp-calendar-header h1 {
    font-size: 1.6rem;
    margin-bottom: 8px;
}

.kmsp-calendar-header h2 {
    font-size: 1.6rem;
    margin-bottom: 12px;
}

.kmsp-calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.kmsp-calendar-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.kmsp-cal-title {
    font-size: 1.25rem;
    font-weight: 700;
    min-width: 140px;
    text-align: center;
}

.kmsp-calendar-filters {
    display: flex;
    align-items: center;
    gap: 12px;
}

.kmsp-calendar-filters select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9rem;
}

.kmsp-cal-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.9rem;
    cursor: pointer;
}

.kmsp-btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f7f7f7;
    cursor: pointer;
    transition: all .2s;
}
.kmsp-btn-sm:hover {
    background: #e74c3c;
    color: #fff;
    border-color: #e74c3c;
}

/* Calendar Grid */
.kmsp-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.kmsp-cal-day-header {
    background: #2c3e50;
    color: #fff;
    text-align: center;
    padding: 8px 4px;
    font-weight: 600;
    font-size: 0.85rem;
}

.kmsp-cal-day {
    background: #fff;
    min-height: 90px;
    padding: 4px 6px;
    position: relative;
}

.kmsp-cal-day.empty {
    background: #f9f9f9;
}

.kmsp-cal-day.today {
    background: #fff3e0;
}

.kmsp-cal-day-num {
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 2px;
}

.kmsp-cal-day.today .kmsp-cal-day-num {
    color: #e74c3c;
    font-weight: 800;
}

.kmsp-cal-event-dot {
    display: block;
    font-size: 0.7rem;
    padding: 1px 4px;
    margin-bottom: 2px;
    border-radius: 3px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    text-decoration: none;
    transition: opacity .2s;
}
.kmsp-cal-event-dot:hover {
    opacity: 0.8;
}

/* Style-based event colors */
.kmsp-cal-event-dot.style-mma { background: #e74c3c; }
.kmsp-cal-event-dot.style-kickboxing,
.kmsp-cal-event-dot[data-style*="キックボクシング"] { background: #e67e22; }
.kmsp-cal-event-dot.style-boxing,
.kmsp-cal-event-dot[data-style*="ボクシング"] { background: #2980b9; }
.kmsp-cal-event-dot.style-karate,
.kmsp-cal-event-dot[data-style*="空手"] { background: #27ae60; }
.kmsp-cal-event-dot.style-bjj,
.kmsp-cal-event-dot[data-style*="柔術"] { background: #8e44ad; }
.kmsp-cal-event-dot.style-judo,
.kmsp-cal-event-dot[data-style*="柔道"] { background: #16a085; }
.kmsp-cal-event-dot.style-default { background: #7f8c8d; }

/* List View */
.kmsp-cal-list {
    max-width: 1100px;
}

.kmsp-cal-list-item {
    display: flex;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid #eee;
    align-items: flex-start;
    transition: background .2s;
}
.kmsp-cal-list-item:hover {
    background: #f8f9fa;
}

.kmsp-cal-list-date {
    min-width: 80px;
    font-weight: 700;
    color: #e74c3c;
    font-size: 0.95rem;
}

.kmsp-cal-list-body {
    flex: 1;
}

.kmsp-cal-list-body h4 {
    margin: 0 0 4px;
    font-size: 1rem;
}
.kmsp-cal-list-body h4 a {
    color: #2c3e50;
    text-decoration: none;
}
.kmsp-cal-list-body h4 a:hover {
    color: #e74c3c;
}

.kmsp-cal-list-meta {
    font-size: 0.85rem;
    color: #777;
}

.kmsp-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    background: #7f8c8d;
    margin-right: 6px;
}

.kmsp-no-events {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 1.1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .kmsp-calendar-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .kmsp-calendar-nav {
        justify-content: center;
    }
    .kmsp-calendar-filters {
        justify-content: center;
        flex-wrap: wrap;
    }
    .kmsp-cal-day {
        min-height: 60px;
    }
    .kmsp-cal-event-dot {
        font-size: 0.6rem;
    }
    .kmsp-cal-list-item {
        flex-direction: column;
        gap: 4px;
    }
}

/* =====================================================
 * v8.1 Calendar Enhancements
 * ===================================================== */

/* Event count badge */
.kmsp-cal-count-badge {
    display: inline-block;
    padding: 2px 10px;
    background: #e74c3c;
    color: #fff;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    vertical-align: middle;
    margin-left: 6px;
}

/* Today button */
#kmsp-cal-today {
    background: #fff;
    border: 2px solid #e74c3c;
    color: #e74c3c;
    font-weight: 600;
}
#kmsp-cal-today:hover {
    background: #e74c3c;
    color: #fff;
}

/* Today pulse animation */
.kmsp-cal-pulse {
    animation: kmspPulse 0.6s ease;
}
@keyframes kmspPulse {
    0% { box-shadow: 0 0 0 0 rgba(231,76,60,0.5); }
    50% { box-shadow: 0 0 0 8px rgba(231,76,60,0); }
    100% { box-shadow: 0 0 0 0 rgba(231,76,60,0); }
}

/* Month transition */
.kmsp-cal-fade {
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s, transform 0.15s;
}

/* Sunday/Saturday coloring */
.kmsp-cal-day-header.sunday { color: #ff6b6b; }
.kmsp-cal-day-header.saturday { color: #4dabf7; }
.kmsp-cal-day.sunday .kmsp-cal-day-num { color: #e74c3c; }
.kmsp-cal-day.saturday .kmsp-cal-day-num { color: #2980b9; }

/* More events badge */
.kmsp-cal-more {
    display: block;
    font-size: 0.65rem;
    color: #e74c3c;
    font-weight: 700;
    cursor: pointer;
    padding: 1px 4px;
}

/* Additional style colors */
.kmsp-cal-event-dot.style-muaythai { background: #d35400; }
.kmsp-cal-event-dot.style-wrestling { background: #1abc9c; }
.kmsp-cal-event-dot.style-taekwondo { background: #3498db; }
.kmsp-cal-event-dot.style-shorinji { background: #f39c12; }
.kmsp-cal-event-dot.style-aikido { background: #9b59b6; }
.kmsp-cal-event-dot.style-kungfu { background: #e67e22; }

/* Error message */
.kmsp-cal-error {
    padding: 12px 16px;
    background: #fff5f5;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #c0392b;
    font-size: 0.9rem;
    display: none;
    position: relative;
}
.kmsp-btn-close {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: #c0392b;
}

/* Enhanced loading */
.kmsp-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    gap: 12px;
}
.kmsp-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e0e0;
    border-top-color: #e74c3c;
    border-radius: 50%;
    animation: kmspSpin 0.8s linear infinite;
}
@keyframes kmspSpin {
    to { transform: rotate(360deg); }
}

/* Enhanced list view */
.kmsp-cal-list-group { margin-bottom: 8px; }
.kmsp-cal-list-group.past { opacity: 0.6; }
.kmsp-cal-list-date-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f0f4f8;
    border-radius: 6px;
    margin-bottom: 4px;
}
.kmsp-cal-list-date-header time {
    font-weight: 700;
    color: #e74c3c;
    font-size: 0.95rem;
}
.kmsp-cal-list-count {
    font-size: 0.75rem;
    padding: 2px 8px;
    background: #e74c3c;
    color: #fff;
    border-radius: 10px;
}
.kmsp-tag-pref {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #2980b9;
    background: #ebf5fb;
    margin-right: 6px;
}
.kmsp-cal-list-location,
.kmsp-cal-list-org {
    font-size: 0.8rem;
    color: #888;
    margin-left: 6px;
}
.kmsp-cal-list-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-top: 12px;
    border-top: 1px solid #eee;
    font-size: 0.9rem;
    color: #666;
}

/* No events empty state */
.kmsp-no-events {
    text-align: center;
    padding: 48px 20px;
    color: #999;
}
.kmsp-no-events-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}
.kmsp-no-events p {
    font-size: 1.1rem;
    margin-bottom: 16px;
}

/* Prefecture dropdown */
#kmsp-cal-pref {
    max-width: 180px;
}

/* =====================================================
 * F1: Upcoming Events + Recently Added (v8.1)
 * ===================================================== */
.kmsp-cal-desc {
    color: #555; font-size: 1rem; margin: 0 0 16px; line-height: 1.7;
}
.kmsp-cal-upcoming,
.kmsp-cal-recent,
.kmsp-cal-styles,
.kmsp-cal-seo {
    margin-top: 32px; padding-top: 24px; border-top: 1px solid #eee;
}
.kmsp-cal-upcoming h2,
.kmsp-cal-recent h2,
.kmsp-cal-styles h2,
.kmsp-cal-seo h2 {
    font-size: 1.3rem; margin-bottom: 16px;
}

/* Event Cards */
.kmsp-event-cards {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px; margin-bottom: 16px;
}
.kmsp-event-card {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px; border: 1px solid #e0e0e0; border-radius: 8px;
    text-decoration: none; color: #333; transition: all 0.2s;
    background: #fff;
}
.kmsp-event-card:hover {
    border-color: #e74c3c; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
.kmsp-ec-emoji { font-size: 2rem; flex-shrink: 0; }
.kmsp-ec-body { display: flex; flex-direction: column; gap: 4px; }
.kmsp-ec-body strong { font-size: 0.95rem; color: #2c3e50; }
.kmsp-ec-body time, .kmsp-ec-body span { font-size: 0.8rem; color: #666; }
.kmsp-ec-style { color: #e74c3c !important; font-weight: 600; }

/* Recent list */
.kmsp-recent-list { list-style: none; padding: 0; }
.kmsp-recent-list li {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 0; border-bottom: 1px solid #f0f0f0;
}
.kmsp-recent-list li a { color: #2c3e50; text-decoration: none; font-weight: 500; flex: 1; }
.kmsp-recent-list li a:hover { color: #e74c3c; }
.kmsp-recent-list time { font-size: 0.8rem; color: #999; white-space: nowrap; }

/* Style quick links */
.kmsp-style-links {
    display: flex; flex-wrap: wrap; gap: 10px;
}
.kmsp-style-link {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border: 1px solid #ddd; border-radius: 20px;
    text-decoration: none; color: #333; font-size: 0.9rem;
    transition: all 0.2s; background: #fafafa;
}
.kmsp-style-link:hover { border-color: #e74c3c; color: #e74c3c; background: #fff5f5; }
.kmsp-style-link small { color: #999; font-size: 0.75rem; }

/* SEO section */
.kmsp-cal-seo p { color: #555; line-height: 1.8; margin-bottom: 12px; }
.kmsp-cal-seo a { color: #e74c3c; }

/* =====================================================
 * F2: Event List (v8.1)
 * ===================================================== */
.kmsp-evlist { max-width: 900px; margin: 0 auto; }
.kmsp-evlist h1 { font-size: 1.6rem; margin-bottom: 16px; }
.kmsp-evlist-filters {
    display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
    padding: 12px; background: #f8f9fa; border-radius: 8px;
}
.kmsp-evlist-filters select {
    padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px;
    background: #fff; font-size: 0.9rem;
}
.kmsp-evlist-count { color: #666; margin-bottom: 12px; font-size: 0.9rem; }
.kmsp-evlist-items { display: flex; flex-direction: column; gap: 8px; }
.kmsp-evlist-item {
    display: flex; gap: 16px; padding: 16px; border: 1px solid #e8e8e8;
    border-radius: 8px; background: #fff; transition: border-color 0.2s;
}
.kmsp-evlist-item:hover { border-color: #e74c3c; }
.kmsp-evlist-date {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-width: 60px; padding: 8px; background: #f0f0f0; border-radius: 8px;
}
.kmsp-evdate-d { font-size: 1.6rem; font-weight: 700; color: #e74c3c; }
.kmsp-evdate-m { font-size: 0.75rem; color: #999; }
.kmsp-evlist-body { flex: 1; }
.kmsp-evlist-body h3 { margin: 0 0 6px; font-size: 1.05rem; }
.kmsp-evlist-body h3 a { color: #2c3e50; text-decoration: none; }
.kmsp-evlist-body h3 a:hover { color: #e74c3c; }
.kmsp-evlist-loc, .kmsp-evlist-org { display: block; font-size: 0.85rem; color: #777; margin-top: 4px; }
.kmsp-evlist-pagination { text-align: center; margin: 24px 0; }
.kmsp-evlist-pagination .page-numbers {
    display: inline-block; padding: 6px 12px; margin: 0 2px;
    border: 1px solid #ddd; border-radius: 4px; text-decoration: none; color: #333;
}
.kmsp-evlist-pagination .page-numbers.current { background: #e74c3c; color: #fff; border-color: #e74c3c; }
.kmsp-evlist-seo { margin-top: 24px; padding-top: 20px; border-top: 1px solid #eee; }
.kmsp-evlist-seo p { color: #555; line-height: 1.7; }

/* =====================================================
 * F5: Event Single Page (v8.1)
 * ===================================================== */
.kmsp-event-infobox {
    margin-bottom: 24px; padding: 20px; background: #f8f9fa;
    border-radius: 10px; border-left: 4px solid #e74c3c;
}
.kmsp-event-infobox h2 { margin: 0 0 12px; font-size: 1.2rem; }
.kmsp-event-table { width: 100%; border-collapse: collapse; }
.kmsp-event-table th {
    text-align: left; padding: 8px 12px; width: 120px; color: #555;
    border-bottom: 1px solid #eee; font-weight: 600; white-space: nowrap;
}
.kmsp-event-table td { padding: 8px 12px; border-bottom: 1px solid #eee; }
.kmsp-event-table a { color: #e74c3c; }

.kmsp-event-nearby, .kmsp-event-yt, .kmsp-event-links {
    margin-top: 28px; padding-top: 20px; border-top: 1px solid #eee;
}
.kmsp-event-nearby h2, .kmsp-event-yt h2, .kmsp-event-links h2 {
    font-size: 1.2rem; margin-bottom: 14px;
}
.kmsp-related-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px;
}
.kmsp-related-card {
    display: flex; flex-direction: column; gap: 4px; padding: 12px;
    border: 1px solid #e0e0e0; border-radius: 8px; text-decoration: none;
    color: #333; transition: border-color 0.2s;
}
.kmsp-related-card:hover { border-color: #e74c3c; }
.kmsp-related-card .kmsp-stars { font-size: 0.85rem; color: #f39c12; }
.kmsp-related-card .kmsp-addr { font-size: 0.8rem; color: #999; }

.kmsp-yt-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px;
}
.kmsp-yt-item { text-align: center; }
.kmsp-yt-item iframe { border-radius: 8px; max-width: 100%; }
.kmsp-yt-item p { margin: 6px 0 0; }
.kmsp-yt-item a { color: #2c3e50; font-size: 0.9rem; }

.kmsp-event-links ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.kmsp-event-links li a {
    display: inline-block; padding: 6px 14px; border: 1px solid #ddd;
    border-radius: 18px; text-decoration: none; color: #333; font-size: 0.85rem;
    transition: all 0.2s;
}
.kmsp-event-links li a:hover { border-color: #e74c3c; color: #e74c3c; }

/* Responsive */
@media (max-width: 768px) {
    .kmsp-event-cards { grid-template-columns: 1fr; }
    .kmsp-evlist-item { flex-direction: column; }
    .kmsp-evlist-filters { flex-direction: column; }
    .kmsp-related-grid { grid-template-columns: 1fr; }
    .kmsp-yt-grid { grid-template-columns: 1fr; }
    .kmsp-event-table th { width: 90px; font-size: 0.85rem; }
}
