/* ==================================================
   V2 Calendar Styles
   ================================================== */

/* V2 ページ全体を全幅表示 */
body.page-template-page-v2mypage .content,
body.page-template-page-v2mypage .main-content,
body.page-template-page-v2mypage #main,
body.page-template-page-v2mypage .container,
body.page-template-page-v2mypage #inner-content,
body.page-template-page-v2mypage .entry-content,
body.page-template-page-v2mypage article,
body.page-id-40785 .content,
body.page-id-40785 .main-content,
body.page-id-40785 #main,
body.page-id-40785 .container,
body.page-id-40785 #inner-content,
body.page-id-40785 .entry-content,
body.page-id-40785 article,
body[class*="v2"] .content,
body[class*="v2"] .main-content,
body[class*="v2"] #main,
body[class*="v2"] .container,
body[class*="v2"] #inner-content,
body[class*="v2"] .entry-content,
body[class*="v2"] article {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Section Header - 不要な余白削除 */
.v2-section-header {
    display: none;
}

/* Calendar Container */
.v2-calendar-container {
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    margin: 0 auto;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 100%;
    border: 2px solid #e0e0e0;
    min-height: 100px;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

/* Calendar Header */
.skill-calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.calendar-month-title,
h2.calendar-month-title,
#v2-calendar-month-title {
    margin: 0 !important;
    padding: 0 !important;
    font-size: clamp(1.2em, 3vw, 1.8em) !important;
    color: #333 !important;
    font-weight: bold !important;
    text-align: center !important;
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.v2-calendar-nav-btn {
    background: #5c6bc0;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: all 0.3s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.v2-calendar-nav-btn svg {
    width: 20px;
    height: 20px;
    display: block;
}

.v2-calendar-nav-btn:hover {
    background: #3f51b5;
    transform: scale(1.1);
}

.v2-calendar-nav-btn:active {
    transform: scale(0.95);
}

/* Loading */
.calendar-loading {
    text-align: center;
    padding: 40px 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 15px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #5c6bc0;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.1em;
    color: #666;
}

/* Calendar Grid */
.v2-calendar-grid {
    display: -ms-grid !important;
    display: -webkit-grid !important;
    display: grid !important;
    -ms-grid-columns: (1fr)[7];
    -webkit-grid-template-columns: repeat(7, 1fr);
    grid-template-columns: repeat(7, 1fr) !important;
    gap: 5px;
    -webkit-gap: 5px;
    width: 100%;
    min-height: 50px;
}

/* 星バナーメッセージ（グリッド内・全幅） */
.v2-calendar-star-message {
    grid-column: 1 / -1;
    text-align: center;
    background: linear-gradient(135deg, #fff9c4 0%, #ffeb3b 100%);
    color: #333;
    padding: 10px;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.star-message-line1 {
    margin-bottom: 5px;
}

.star-message-line1::first-letter,
.star-message-line2::first-letter {
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.5);
    animation: starPulse 2s ease-in-out infinite;
}

@keyframes starPulse {
    0%, 100% {
        transform: scale(1);
        text-shadow: 0 0 10px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.5);
    }
    50% {
        transform: scale(1.2);
        text-shadow: 0 0 15px rgba(255, 215, 0, 1), 0 0 30px rgba(255, 215, 0, 0.7);
    }
}

.v2-calendar-day-header {
    text-align: center;
    font-weight: bold;
    padding: 5px;
    color: #666;
    font-size: 1.1em;
}

.v2-calendar-day-header.saturday {
    color: #3b82f6; /* 土曜日 - 青 */
}

.v2-calendar-day-header.sunday {
    color: #ef4444; /* 日曜日 - 赤 */
}

.v2-calendar-day {
    aspect-ratio: 2 / 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s;
    background: #f5f5f5;
    color: #999;
    padding: 3px;
    min-width: 0 !important;
    overflow: hidden;
}

.v2-calendar-day.v2-current-month {
    background: #fff;
    color: #333;
    border: 1px solid #e0e0e0;
}

.v2-calendar-day.v2-has-activity {
    background: #e3f2fd;
    color: #1976d2;
    font-weight: bold;
    border: 2px solid #1976d2;
}

.v2-calendar-day.v2-today {
    border: 3px solid #f44336 !important;
}

.v2-calendar-day:hover.v2-current-month {
    background: #f0f0f0;
    transform: scale(1.05);
}

/* 日付と星のヘッダー行 */
.v2-calendar-day-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.v2-calendar-day-number {
    font-weight: bold;
    font-size: 1em;
}

/* 星のアニメーション */
.v2-calendar-day-stars {
    font-size: 1em;
    line-height: 1;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.6), 0 0 15px rgba(255, 215, 0, 0.4);
    animation: starTwinkle 3s ease-in-out infinite;
}

@keyframes starTwinkle {
    0%, 100% {
        opacity: 1;
        text-shadow: 0 0 8px rgba(255, 215, 0, 0.6), 0 0 15px rgba(255, 215, 0, 0.4);
    }
    50% {
        opacity: 0.7;
        text-shadow: 0 0 12px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.6);
    }
}

/* コース詳細（PC専用） */
.v2-calendar-day-details {
    font-size: 0.75em;
    color: #666;
    text-align: left;
    margin-top: 4px;
    line-height: 1.3;
    word-wrap: break-word;
    max-width: 100%;
    display: none;
}

/* PC/タブレットではコース詳細を表示 */
@media (min-width: 1025px) {
    .v2-calendar-day-details {
        display: block;
    }
}

/* カレンダー項目のバッジ表示（PC専用） */
.v2-day-info {
    width: 100%;
    margin-top: 1px;
    display: flex;
    flex-wrap: wrap;
    row-gap: 0.5px;
    column-gap: 1px;
}

.v2-calendar-item {
    font-size: 10px !important;
    padding: 2px 4px !important;
    border-radius: 4px !important;
    white-space: nowrap !important;
    color: #fff !important;
    font-weight: bold;
    line-height: 1.2;
}

/* スマホ用星マーク */
.v2-calendar-stars {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    justify-content: flex-start;
    padding: 0 2px;
}

.v2-calendar-star {
    font-size: 10px !important;
    line-height: 1 !important;
}

.v2-day-star-count {
    margin-left: 4px;
    font-size: 0.9em;
}

/* 単語学習（朱色系） */
.type-vocab { background: #D75A30 !important; }
.v2-calendar-star.type-vocab { color: #D75A30 !important; background: none !important; }

/* 短文穴埋め（青系） */
.type-eiken_quiz { background: #3b82f6 !important; }
.v2-calendar-star.type-eiken_quiz { color: #3b82f6 !important; background: none !important; }

/* リーディング系（緑系） */
.type-reading_quiz, .type-email_quiz, .type-passage_quiz { background: #10b981 !important; }
.v2-calendar-star.type-reading_quiz, .v2-calendar-star.type-email_quiz, .v2-calendar-star.type-passage_quiz { color: #10b981 !important; background: none !important; }

/* リスニング系（紫系） */
.type-listening_conv, .type-listening_dialog, .type-listening_mono, .type-listening_sit { background: #8b5cf6 !important; }
.v2-calendar-star.type-listening_conv, .v2-calendar-star.type-listening_dialog, .v2-calendar-star.type-listening_mono, .v2-calendar-star.type-listening_sit { color: #8b5cf6 !important; background: none !important; }

/* AI添削（ピンク系） */
.type-ai_writing { background: #ec4899 !important; }
.v2-calendar-star.type-ai_writing { color: #ec4899 !important; background: none !important; }

/* AI添削 - 意見文（金色・黒背景） */
.type-ai_opinion { background: #000 !important; color: #D4AF37 !important; }
.v2-calendar-star.type-ai_opinion { color: #D4AF37 !important; background: none !important; }

/* AI添削 - 要約（金色・黒背景） */
.type-ai_summary { background: #000 !important; color: #D4AF37 !important; }
.v2-calendar-star.type-ai_summary { color: #D4AF37 !important; background: none !important; }

/* 文法スキルリスト（オレンジ系） */
.type-grammar_skill { background: #f59e0b !important; }
.v2-calendar-star.type-grammar_skill { color: #f59e0b !important; background: none !important; }

/* Skill Practice（オレンジ系） */
.type-skill_practice { background: #ff9800 !important; }
.v2-calendar-star.type-skill_practice { color: #ff9800 !important; background: none !important; }

/* PC/SP出し分け */
.v2-sp-only { display: none !important; }
.v2-pc-only { display: block !important; }

@media (max-width: 1024px) {
    .v2-sp-only { display: block !important; }
    .v2-pc-only { display: none !important; }
}

.v2-calendar-day-count {
    font-size: 0.8em;
    color: #1976d2;
    margin-top: 2px;
}

.calendar-note {
    font-size: 0.85em;
    color: #999;
    text-align: center;
    margin: 5px 0 20px 0;
}

/* 月間合計の表示 */
.v2-monthly-star-count {
    font-size: 0.7em;
    color: #1976d2;
    font-weight: bold;
    margin-left: 8px;
}

/* 流れ星アニメーション */
.shooting-star {
    position: absolute;
    font-size: 2em;
    pointer-events: none;
    z-index: 1000;
    animation: shootingStar 1s ease-out forwards;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.5);
}

@keyframes shootingStar {
    0% {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translate(300px, 400px) rotate(360deg);
    }
}

/* 日記エリア */
.diary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.diary-header h4 {
    margin: 0;
}

#v2-diary-content {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    resize: vertical;
    transition: border 0.3s;
}

#v2-diary-content:focus {
    outline: none;
    border-color: #5c6bc0;
}

.v2-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.v2-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Modal */
.v2-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    overflow: auto;
}

.v2-modal-content {
    background: white;
    margin: 5% auto;
    width: 90%;
    max-width: 700px;
    height: 80vh;
    max-height: 80vh;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s;
    display: flex;
    flex-direction: column;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.v2-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    border-bottom: 2px solid #f9a825;
    background: linear-gradient(135deg, #fff59d 0%, #ffeb3b 100%);
    border-radius: 12px 12px 0 0;
    color: #333;
}

.v2-modal-header h3 {
    margin: 0;
    font-size: 1.3em;
    color: #333;
}

.v2-modal-close {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #666;
}

.v2-modal-close:hover {
    color: #333;
}

.v2-modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-section {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    margin: 0;
    background: transparent;
}

.modal-section h4 {
    display: none;
}

#v2-history-list {
    padding-bottom: 10px;
}

#v2-diary-section {
    padding: 15px 20px 20px 20px;
    border-top: 2px solid #eee;
    background: #fafafa;
}

#v2-diary-section h4 {
    display: block !important;
    margin: 0 0 10px 0 !important;
}

#v2-diary-content {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    min-height: 80px;
}

#v2-diary-save-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #4caf50;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10001;
}

.modal-section h4 {
    margin: 0 0 10px 0;
    font-size: 1.1em;
    color: #333;
}

/* 履歴アコーディオン */
.history-accordion {
    margin-bottom: 8px;
}

.history-accordion summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.history-accordion summary::-webkit-details-marker {
    display: none;
}

.history-item-summary {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    background: #fafafa;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.history-header-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-detail-btn {
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.3s;
}

.history-detail-btn:hover {
    background: #fb8c00;
}

.history-accordion[open] .history-detail-btn {
    background: #757575;
}

.history-detail-content {
    padding: 12px;
    margin-top: 4px;
}

.history-item {
    padding: 4px;
    border-bottom: 1px solid #e0e0e0;
    background: #fafafa;
    border-radius: 6px;
    margin-bottom: 4px;
}

.history-item:last-child {
    margin-bottom: 0;
}

/* PC版デフォルト: 1行レイアウト */
.history-header {
    margin-bottom: 6px;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.history-header-top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.history-answers {
    display: flex;
    gap: 2px;
    align-items: center;
    justify-content: center;
}

/* PC版も history-type 非表示 */
.history-type {
    display: none;
}

.history-answer-item {
    display: flex;
    align-items: center;
    gap: 1px;
}

.history-type {
    display: inline-block;
    background: #5c6bc0;
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.85em;
}

.history-title {
    font-weight: bold;
    color: #333;
    margin-left: 8px;
    display: inline-flex;
    gap: 2px;
    align-items: center;
    flex-wrap: nowrap;
    max-width: 100%;
    overflow: hidden;
}

.history-title-part {
    display: inline-block;
    padding: 2px 6px;
    margin: 0 2px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f5f5f5;
    font-size: 0.85em;
    font-weight: bold;
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
}

.history-detail {
    color: #666;
    font-size: 0.9em;
    font-style: italic;
}

.history-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-score {
    color: #1976d2;
    font-weight: bold;
}

.history-time {
    color: #999;
    font-size: 0.85em;
}

.history-score-time {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Mode Badges - skill-list完全コピー対応 */
.history-item-mode {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: bold;
    margin-left: 6px;
}

.history-item-mode.choice {
    background: #e8f5e9;
    color: #2e7d32;
}

.history-item-mode.reorder {
    background: #fff3e0;
    color: #ef6c00;
}

.history-item-mode.input {
    background: #fce4ec;
    color: #c2185b;
}

/* Detail Box - skill-list完全コピー対応 */
.history-detail-box {
    margin: 8px 0;
    padding: 8px;
    background: #fff;
    border-radius: 4px;
    font-size: 0.85em;
    border: 1px solid #eee;
}

.history-q {
    color: #666;
    margin-bottom: 4px;
}

.history-a {
    font-weight: bold;
    margin-bottom: 2px;
}

.res-correct {
    color: #2e7d32;
}

.res-incorrect {
    color: #c62828;
}

.history-correct {
    color: #5c6bc0;
    margin-top: 2px;
    font-size: 0.9em;
}

/* Answers Log (⭕️❌) */
.answers-log {
    display: inline-block;
    font-family: monospace;
    letter-spacing: 2px;
    margin: 6px 0;
    padding: 4px 8px;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 1.1em;
}

/* Accordion for Wrong Items */
.wrong-items-container {
    margin-top: 4px;
}

.wrong-items-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.wrong-items-header:hover {
    background: rgba(0,0,0,0.05);
}

.wrong-label {
    padding: 2px 8px;
    background: #fff3e0;
    border-radius: 6px;
    border: 1px solid #ffb74d;
    font-weight: bold;
    color: #e65100;
    font-size: 0.8em;
    white-space: nowrap;
}

.detail-button {
    background: #ff9800;
    color: white;
    padding: 2px 12px;
    border-radius: 4px;
    font-size: calc(0.85em - 1px);
    font-weight: bold;
    white-space: nowrap;
    cursor: pointer;
    border: none;
    flex-shrink: 0;
}

.detail-button:hover {
    background: #f57c00;
}

.wrong-items-content {
    margin-top: 4px;
    padding: 8px;
    background: #fff3e0;
    border-radius: 6px;
    border: 1px solid #ffb74d;
}

.wrong-items-content ul {
    margin: 0;
    padding-left: 0;
    list-style: none;
}

.wrong-items-content li {
    margin: 4px 0;
    color: #333;
    line-height: 1.5;
    font-size: 0.85em;
}

.wrong-items[open] summary {
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid #ffb74d;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .v2-calendar-container {
        padding: 5px;
    }

    .calendar-month-title {
        font-size: clamp(1em, 4vw, 1.5em);
    }

    .v2-calendar-nav-btn {
        width: 30px;
        height: 30px;
        font-size: 1.1em;
    }

    .v2-calendar-grid {
        gap: 2px;
    }

    .v2-calendar-day {
        padding: 1px;
        font-size: 0.65em;
    }
}

@media (min-width: 1025px) {
    .calendar-note {
        display: none;
    }
}

/* ==========================================
   Skill Practice (V1再現用スタイル)
   ========================================== */
.history-item-container { margin-bottom: 16px; }

/* アコーディオン */
.sp-accordion {
    margin-bottom: 12px;
}

.sp-accordion summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.sp-accordion summary::-webkit-details-marker {
    display: none;
}

.sp-stat-header {
    background: #f1f8f4;
    border: 2px solid #4a90e2;
    border-radius: 10px;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sp-stat-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.sp-stat-title {
    font-weight: bold;
    color: #2e7d32;
    font-size: 14px;
}

.sp-stat-score {
    font-weight: bold;
    color: #333;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sp-detail-btn {
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.3s;
}

.sp-detail-btn:hover {
    background: #fb8c00;
    transform: translateY(-1px);
}

.sp-accordion[open] .sp-detail-btn {
    background: #757575;
}

.sp-detail-container {
    margin-top: 8px;
}
/* 削除: 新しいスタイルに統合済み */

.sp-history-detail-box {
    margin: 0 0 8px 10px;
    padding: 10px;
    background: #fff;
    border-radius: 4px;
    font-size: 13px;
    border: 1px solid #eee;
    border-left: 3px solid #ccc;
}
.sp-detail-badges { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.sp-badge-correct { background: #e8f5e9; color: #2e7d32; padding: 2px 6px; border-radius: 3px; font-size: 11px; font-weight: bold; }
.sp-badge-incorrect { background: #ffebee; color: #c62828; padding: 2px 6px; border-radius: 3px; font-size: 11px; font-weight: bold; }

/* Rainbow Text & Growth Badges */
.rainbow-text {
    background: linear-gradient(to right, #ff0000, #ff8800, #ffff00, #00ff00, #0088ff, #0000ff, #ff00ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 900;
    font-size: 16px;
    display: inline-block;
    animation: rainbow-blink 1.5s ease-in-out infinite;
}

@keyframes rainbow-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
.sp-badge-growth {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    color: white;
    font-weight: bold;
    font-size: 12px;
}
.sp-badge-green { background-color: #4caf50; }
.sp-badge-orange { background-color: #ff9800; }
.sp-badge-yellow { background-color: #fdd835; color: #333; }
.sp-badge-red { background-color: #f44336; }
.sp-badge-gray { background-color: #9e9e9e; }

.blinking-badge { animation: sp-blink 1.9s infinite; }
@keyframes sp-blink {
    0%, 73% { opacity: 1; }
    74%, 100% { opacity: 0; }
}

.sp-badge-perfect {
    display: inline-block;
    padding: 4px 8px;
    font-size: 16px;
}

.twinkle-star {
    animation: twinkle 1s ease-in-out infinite;
    font-size: 18px;
}

@keyframes twinkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* =========================================================
   V2カレンダー：PC幅最適化（ナビ幅に合わせる）＆ スマホ7列死守
   ページID: 40785 (V2マイページ)
   ========================================================= */

/* 1. PC：画面一杯ではなく、テーマの標準幅（ナビ幅）に収める */
body.page-id-40785 .inner,
body.page-id-40785 .wrap,
body.page-id-40785 #main {
    width: 100% !important;
    max-width: 1160px !important; /* JSTORKの標準ナビ幅に固定 */
    margin: 0 auto !important;     /* 中央寄せ */
    float: none !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
}

/* カレンダーの外枠：余計な位置調整を完全リセット */
.v2-calendar-container {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    position: static !important;
    margin: 20px 0 !important;
    padding: 15px !important;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

/* 2. グリッド：7列を絶対等分にする */
.v2-calendar-grid {
    display: grid !important;
    grid-template-columns: repeat(7, 1fr) !important; /* 7列を1frで等分 */
    width: 100% !important;
    gap: 4px !important;
    box-sizing: border-box !important;
}

/* 3. セル：文字数に負けずに7列を維持する（見切れ防止の要） */
.v2-calendar-day {
    min-width: 0 !important;      /* 文字が長くてもセルを太らせない */
    width: 100% !important;
    aspect-ratio: 2 / 1;          /* PCでは綺麗な横長 */
    overflow: hidden !important;  /* はみ出しをカット */
    box-sizing: border-box !important;
    padding: 4px !important;
}

/* 4. スマホ・タブレット専用の極限チューニング (1024px以下) */
@media (max-width: 1024px) {
    /* 親要素の余白を削って、カレンダーの「使える幅」を最大化する */
    body.page-id-40785 .inner,
    body.page-id-40785 .wrap,
    body.page-id-40785 #main {
        padding-left: 5px !important;
        padding-right: 5px !important;
    }

    .v2-calendar-container {
        padding: 6px !important; /* 枠内の余白も最小限に */
    }

    .v2-calendar-grid {
        gap: 2px !important;     /* セル同士を詰め寄せる */
    }

    .v2-calendar-day {
        aspect-ratio: auto !important; /* スマホでは高さを自由にして文字潰れを防ぐ */
        min-height: 40px !important;
        padding: 2px !important;
    }

    /* 文字サイズの微調整：7列を維持するために必要です */
    .v2-calendar-day-number {
        font-size: 10px !important;
    }

    .v2-calendar-day-count {
        font-size: 8px !important;
        line-height: 1.1;
        display: block;
        transform: scale(0.85);   /* 文字を少しだけ縮小して1行に収める */
        transform-origin: left top;
        width: 115% !important;
    }
}

/* =========================================================
   スマホ専用：7列（1週間）を画面幅に強制的に収める修正
   ========================================================= */

/* ================================================
   スマホ版: 既存カレンダーを非表示
   ================================================ */
@media (max-width: 768px) {
    /* 全ての親要素の余白を完全削除 */
    body.page-id-40785 #content,
    body.page-id-40785 #inner-content,
    body.page-id-40785 #main,
    body.page-id-40785 article,
    body.page-id-40785 .entry-content,
    body.page-id-40785 .wrap,
    body.page-id-40785 .inner {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* 既存カレンダーコンテナ全体を完全に非表示 */
    .v2-calendar-container {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        opacity: 0 !important;
    }

    #v2-calendar-grid {
        display: none !important;
    }

    .skill-calendar-header {
        display: none !important;
    }
}

/* ================================================
   新しいスマホ専用カレンダー
   ================================================ */
@media (max-width: 768px) {
    /* 新カレンダーコンテナ */
    #v2-mobile-calendar {
        background: #fff;
        border: 3px solid #4caf50;
        border-radius: 16px;
        padding: 3px;
        margin: 3px;
        transition: background-color 0.3s, border-color 0.3s;
    }

    /* ヘッダー（月タイトル + ナビゲーション） */
    .v2-mobile-calendar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
    }

    .v2-mobile-month-title {
        font-size: 16px;
        font-weight: bold;
        color: #333;
        text-align: center;
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        white-space: nowrap;
        overflow: hidden;
    }

    .v2-mobile-month-title .v2-mobile-star-count {
        font-size: 13px;
        color: #5c6bc0;
        font-weight: bold;
        display: inline;
    }

    .v2-mobile-nav-btn {
        background: transparent;
        border: none;
        width: 36px;
        height: 36px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 10;
        position: relative;
        padding: 0;
    }

    .v2-mobile-nav-btn svg {
        display: block;
        width: 24px;
        height: 24px;
    }

    .v2-mobile-nav-btn svg path {
        stroke: #333;
        stroke-width: 3;
    }

    /* 星カウント（タイトル内に統合したため削除）*/

    /* バナー */
    .v2-mobile-banner {
        background: linear-gradient(135deg, #fff9c4 0%, #ffeb3b 100%);
        padding: 8px;
        border-radius: 8px;
        text-align: center;
        font-size: 11px;
        font-weight: bold;
        margin-bottom: 8px;
        line-height: 1.4;
    }

    /* グリッド */
    .v2-mobile-calendar-grid {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 2px;
    }

    /* 曜日ヘッダー */
    .v2-mobile-day-header {
        text-align: center;
        font-size: 12px;
        font-weight: bold;
        padding: 8px 4px;
        color: #333;
    }

    .v2-mobile-day-header.saturday {
        color: #3b82f6;
    }

    .v2-mobile-day-header.sunday {
        color: #ef4444;
    }

    /* 日付セル */
    .v2-mobile-day {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        border: 1px solid #e0e0e0;
        border-radius: 4px;
        font-size: clamp(9px, 2.5vw, 12px);
        font-weight: 500;
        background: #fafafa;
        color: #999;
        padding: 2px;
        padding-left: 4px;
        min-width: 0;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: clip;
    }

    .v2-mobile-day.current-month {
        background: #fff;
        color: #333;
    }

    .v2-mobile-day.has-activity {
        background: #e3f2fd;
        border-color: #2196f3;
        color: #1976d2;
        font-weight: bold;
        cursor: pointer;
    }

    .v2-mobile-day.today {
        border: 2px solid #f44336 !important;
    }

    /* 土曜日・日曜日の色 */
    .v2-mobile-day.saturday {
        color: #3b82f6 !important;
    }

    .v2-mobile-day.saturday.has-activity {
        color: #1976d2 !important;
    }

    .v2-mobile-day.sunday {
        color: #ef4444 !important;
    }

    .v2-mobile-day.sunday.has-activity {
        color: #c62828 !important;
    }

    /* 日付番号・星のスタイルは不要（直接テキストとして表示） */
}

/* =========================================================
   V2カレンダー：PC(項目表示)とスマホ(星表示)の出し分け
   ========================================================= */

/* 基本の出し分け設定 */
.v2-sp-only { display: none !important; }
.v2-pc-only { display: block !important; }

@media (max-width: 1024px) {
    .v2-sp-only { display: block !important; }
    .v2-pc-only { display: none !important; }
}

/* 日付番号と星の横並び表示 */
.v2-calendar-day-number {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
}

.v2-day-star-count {
    font-size: 1em !important;
    color: #ffa500;
    white-space: nowrap;
    font-weight: bold;
}

/* 【PC】カレンダー項目のデザイン（テキスト幅でボタン並べ） */
.v2-day-info {
    width: 100%;
    margin-top: 1px;
    display: flex;
    flex-wrap: wrap;
    row-gap: 0.5px;
    column-gap: 1px;
    align-content: flex-start;
}

.v2-calendar-item {
    font-size: 10px !important;
    padding: 2px 4px !important;
    border-radius: 4px !important;
    white-space: nowrap !important;
    color: #fff !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    display: inline-block;
    box-sizing: border-box;
    border: 0.5px solid rgba(255, 255, 255, 0.8) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
}

/* 【スマホ】星マークのデザイン（V1の完コピ） */
.v2-calendar-stars {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    justify-content: flex-start;
    padding: 0 2px;
}

.v2-calendar-star {
    font-size: 10px !important;
    line-height: 1 !important;
}

/* ---------------------------------------------------------
   問題タイプ別のカラー設定（項目背景色＆星の色）
   --------------------------------------------------------- */
/* 基礎文法・スキル（オレンジ系） */
.type-skill_practice { background: #ff9800 !important; }
.v2-calendar-star.type-skill_practice { color: #ff9800 !important; background: none !important; }

/* 単語学習（朱色系） */
.type-vocab { background: #D75A30 !important; }
.v2-calendar-star.type-vocab { color: #D75A30 !important; background: none !important; }

/* 短文穴埋め（青系） */
.type-eiken_quiz { background: #3b82f6 !important; }
.v2-calendar-star.type-eiken_quiz { color: #3b82f6 !important; background: none !important; }

/* リーディング系（緑系） */
.type-reading_quiz, .type-email_quiz, .type-passage_quiz { background: #10b981 !important; }
.v2-calendar-star.type-reading_quiz, .v2-calendar-star.type-email_quiz, .v2-calendar-star.type-passage_quiz { color: #10b981 !important; background: none !important; }

/* リスニング系（紫系） */
.type-listening_conv, .type-listening_dialog, .type-listening_mono, .type-listening_sit { background: #8b5cf6 !important; }
.v2-calendar-star.type-listening_conv, .v2-calendar-star.type-listening_dialog, .v2-calendar-star.type-listening_mono, .v2-calendar-star.type-listening_sit { color: #8b5cf6 !important; background: none !important; }

/* AI添削 - 意見文（金色・黒背景） */
.type-ai_opinion { background: #000 !important; color: #D4AF37 !important; }
.v2-calendar-star.type-ai_opinion { color: #D4AF37 !important; background: none !important; }

/* AI添削 - 要約（金色・黒背景） */
.type-ai_summary { background: #000 !important; color: #D4AF37 !important; }
.v2-calendar-star.type-ai_summary { color: #D4AF37 !important; background: none !important; }

/* 日記セクション - 全幅レイアウト */
#v2-diary-section {
    padding: 15px 20px 20px 20px;
    border-top: 2px solid #eee;
    background: #fafafa;
}

#v2-diary-section h4 {
    display: block !important;
    margin: 0 0 10px 0 !important;
}

#v2-diary-content {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    min-height: 80px;
}

#v2-diary-save-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #4caf50;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10001;
}

/* モバイル版: 2行レイアウト */
@media (max-width: 768px) {
    .history-header {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 8px;
    }

    .history-header-top {
        flex: 0 0 auto;
        order: 1;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .history-score-time {
        flex: 0 0 auto;
        order: 2;
        margin-left: auto;
        display: flex;
        gap: 8px;
        align-items: center;
    }

    .history-answers {
        flex: 0 0 100%;
        order: 3;
        display: flex;
        gap: 4px;
        align-items: center;
        flex-wrap: wrap;
    }

    /* スマホ版専用パディング調整 */
    #v2-diary-section {
        padding: 3px;
    }

    #v2-diary-section h4 {
        padding: 3px 0;
        margin: 0 !important;
        font-size: 0.9em;
    }

    .v2-modal-header {
        padding: 3px 15px;
    }

    #v2-modal-date-title {
        margin: 3px 0 !important;
    }

    .wrong-items-container {
        margin: 3px 0;
    }

    .history-item {
        padding: 2px;
    }

    .history-title-part {
        font-size: 0.8em;
    }

    .v2-modal-close {
        margin: 3px 0;
    }

    .history-header-top {
        flex-wrap: nowrap;
        overflow: hidden;
    }

    .history-title {
        flex-shrink: 1;
        min-width: 0;
        max-width: none;
    }

    .history-score-time {
        flex-shrink: 0;
    }
}
