/* ============================================================
   体育記録帳（カルーセル式） v2.0.0
   固定ヘッダー + 全画面ステージ + 右下ツールバー構成
   ブランドカラー: 白ベース / 紺 #1e3a5f / 金 #d4af37
   ============================================================ */

.pe-record-carousel-root {
    /* 修正: 全画面アプリ化（Cocoonテーマのレイアウトから独立させる） */
    position: fixed !important;
    inset: 0 !important;
    z-index: 999999 !important;
    background: #f4f6f9 !important;
    font-family: "BIZ UDGothic", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
    color: #1e3a5f;
    line-height: 1.5;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
}

.pe-record-carousel-root *,
.pe-record-carousel-root *::before,
.pe-record-carousel-root *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.pe-record-carousel-root button {
    font-family: inherit !important;
    cursor: pointer !important;
    border: none !important;
    background: none !important;
    color: inherit !important;
}

.pe-record-carousel-root input,
.pe-record-carousel-root select,
.pe-record-carousel-root textarea {
    font-family: inherit !important;
    font-size: 16px !important;
    color: #1e3a5f !important;
    border: 2px solid #d7dde6 !important;
    border-radius: 10px !important;
    padding: 10px 12px !important;
    background: #fff !important;
    width: 100% !important;
}

.pe-record-carousel-root input:focus,
.pe-record-carousel-root select:focus,
.pe-record-carousel-root textarea:focus {
    outline: none !important;
    border-color: #d4af37 !important;
}

.pe-hidden-input {
    display: none !important;
}
/* ============ 共通ボタン ============ */
.pe-record-carousel-root .pe-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 12px !important;
    font-size: 17px !important;
    font-weight: 700 !important;
    padding: 13px 22px !important;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}
.pe-record-carousel-root .pe-btn:active {
    transform: scale(0.97) !important;
}
.pe-record-carousel-root .pe-btn-primary {
    background: #1e3a5f !important;
    color: #fff !important;
    box-shadow: 0 3px 10px rgba(30, 58, 95, 0.25) !important;
}
.pe-record-carousel-root .pe-btn-primary:hover {
    background: #27496f !important;
}
.pe-record-carousel-root .pe-btn-ghost {
    background: #fff !important;
    color: #1e3a5f !important;
    border: 2px solid #d7dde6 !important;
}
.pe-record-carousel-root .pe-btn-ghost:hover {
    border-color: #1e3a5f !important;
}
.pe-record-carousel-root .pe-btn-danger-ghost {
    background: #fff !important;
    color: #b04040 !important;
    border: 2px solid #ecd3d3 !important;
    font-size: 15px !important;
}
.pe-record-carousel-root .pe-btn-danger-ghost:hover {
    border-color: #b04040 !important;
}

/* ============ セットアップ（一本道ステップ） ============ */
.pe-setup {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #f4f6f9 0%, #e9edf4 100%);
    padding: 20px;
    overflow-y: auto;
    z-index: 20;
}

.pe-setup.active {
    display: flex;
}

.pe-setup-card {
    background: #fff;
    border-radius: 20px;
    border-top: 6px solid #d4af37;
    box-shadow: 0 10px 40px rgba(30, 58, 95, 0.15);
    width: 100%;
    max-width: 460px;
    padding: 28px 26px 26px;
}

.pe-setup-brand {
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: #1e3a5f;
}

.pe-setup-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 14px 0 20px;
}
.pe-record-carousel-root .pe-dot {
    width: 10px !important;
    height: 10px !important;
    border-radius: 50% !important;
    background: #d7dde6 !important;
    transition: background 0.2s !important;
}
.pe-record-carousel-root .pe-dot.active {
    background: #d4af37 !important;
}

.pe-setup-step {
    display: none;
}

.pe-setup-step.active {
    display: block;
}

.pe-setup-heading {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 14px;
    color: #1e3a5f;
}

.pe-setup-note {
    font-size: 13px;
    color: #6b7a8d;
    margin-bottom: 8px;
}

.pe-setup-textarea {
    min-height: 160px;
    resize: vertical;
    line-height: 1.8;
}

.pe-field-row {
    display: flex;
    gap: 10px;
}

.pe-field {
    flex: 1;
    min-width: 0;
}

.pe-field label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #6b7a8d;
    margin-bottom: 5px;
}

.pe-setup-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.pe-setup-actions .pe-btn {
    flex: 1;
}

.pe-details {
    margin-top: 14px;
    border: 2px solid #eef1f6;
    border-radius: 10px;
    padding: 10px 12px;
}

.pe-details summary {
    font-size: 14px;
    font-weight: 700;
    color: #6b7a8d;
    cursor: pointer;
    user-select: none;
}

.pe-details-body {
    padding-top: 10px;
}

/* ============ メイン画面 ============ */
.pe-main {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
}

.pe-main.active {
    display: flex;
}

/* --- 固定ヘッダー --- */
.pe-header {
    flex-shrink: 0;
    height: 54px;
    background: #1e3a5f;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.3);
}

.pe-header-title {
    color: #fff;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.06em;
    margin-right: auto;
    white-space: nowrap;
}
.pe-record-carousel-root .pe-chip {
    display: inline-flex !important;
    align-items: center !important;
    height: 34px !important;
    padding: 0 14px !important;
    border-radius: 17px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
}
.pe-record-carousel-root .pe-chip-sport {
    background: #d4af37 !important;
    color: #1e3a5f !important;
    transition: background 0.12s !important;
}
.pe-record-carousel-root .pe-chip-sport::after {
    content: "▾" !important;
    margin-left: 6px !important;
    font-size: 11px !important;
}
.pe-record-carousel-root .pe-chip-sport:active {
    background: #b8941f !important;
}
.pe-record-carousel-root .pe-chip-lap {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
}

/* --- ステージ --- */
.pe-stage {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 10px 12px 12px;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
}

/* --- カルーセル --- */
.pe-carousel-wrapper {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 2px 8px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

.pe-carousel-wrapper::-webkit-scrollbar {
    height: 4px;
}

.pe-carousel-wrapper::-webkit-scrollbar-thumb {
    background: #d7dde6;
    border-radius: 2px;
}
.pe-record-carousel-root .pe-student-card {
    flex-shrink: 0 !important;
    scroll-snap-align: center !important;
    width: 108px !important;
    background: #fff !important;
    border: 2px solid #d7dde6 !important;
    border-radius: 12px !important;
    padding: 8px 6px !important;
    text-align: center !important;
    cursor: pointer !important;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s !important;
}
.pe-record-carousel-root .pe-student-card.active {
    border-color: #d4af37 !important;
    box-shadow: 0 3px 12px rgba(212, 175, 55, 0.35) !important;
    transform: translateY(-2px) !important;
}
.pe-record-carousel-root .pe-student-card.completed {
    background: #f2f6fb !important;
    border-color: #b9c7d8 !important;
}
.pe-record-carousel-root .pe-student-card.skipped {
    background: #f5f5f5 !important;
    opacity: 0.65 !important;
}

.pe-card-no {
    font-size: 11px;
    color: #6b7a8d;
    font-weight: 700;
}

.pe-card-name {
    font-size: 14px;
    font-weight: 800;
    color: #1e3a5f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pe-card-lap {
    font-size: 11px;
    color: #b8941f;
    font-weight: 700;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- 入力エリア --- */
.pe-input-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.pe-student-header {
    flex-shrink: 0;
    text-align: center;
    padding: 4px 0 2px;
}

.pe-group-switch {
    display: inline-flex;
    background: #e9edf4;
    border-radius: 16px;
    padding: 3px;
    gap: 2px;
    margin-bottom: 6px;
}
.pe-record-carousel-root .pe-group-btn {
    border-radius: 13px !important;
    padding: 5px 16px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    color: #6b7a8d !important;
    transition: background 0.15s, color 0.15s !important;
}
.pe-record-carousel-root .pe-group-btn.active {
    background: #1e3a5f !important;
    color: #fff !important;
}

.pe-student-name {
    font-size: clamp(22px, 4.5vw, 30px);
    font-weight: 800;
    color: #1e3a5f;
}

.pe-student-sub {
    display: flex;
    justify-content: center;
    gap: 14px;
    font-size: 13px;
    color: #6b7a8d;
    font-weight: 700;
    min-height: 20px;
}

.pe-previous-record {
    color: #b8941f;
}

/* ============ iOS風ドラムピッカー ============ */
.pe-picker-box {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    position: relative;
    min-height: 200px;
    margin: 4px 0;
    /* 中央の選択バー */
}

.pe-picker-box::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(100%, 420px);
    height: 48px;
    background: rgba(30, 58, 95, 0.06);
    border-top: 2px solid #d4af37;
    border-bottom: 2px solid #d4af37;
    border-radius: 10px;
    pointer-events: none;
}

.pe-wheel {
    position: relative;
    width: 64px;
    height: 240px;
    overflow: hidden;
    touch-action: none;
    cursor: grab;
    /* 上下フェード（iOS風） */
    -webkit-mask-image: linear-gradient(to bottom,
        transparent 0%,
        rgba(0, 0, 0, 0.9) 28%,
        #000 45%, #000 55%,
        rgba(0, 0, 0, 0.9) 72%,
        transparent 100%);
    mask-image: linear-gradient(to bottom,
        transparent 0%,
        rgba(0, 0, 0, 0.9) 28%,
        #000 45%, #000 55%,
        rgba(0, 0, 0, 0.9) 72%,
        transparent 100%);
}

.pe-wheel:active {
    cursor: grabbing;
}

.pe-wheel-track {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    will-change: transform;
}

.pe-wheel-item {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: 700;
    color: #8fa0b3;
    font-variant-numeric: tabular-nums;
    transition: color 0.12s, transform 0.12s;
    transform: scale(0.82);
    user-select: none;
    -webkit-user-select: none;
}

.pe-wheel-item.on {
    color: #1e3a5f;
    font-weight: 800;
    transform: scale(1.08);
}

.pe-separator {
    font-size: 32px;
    font-weight: 800;
    color: #1e3a5f;
    padding-bottom: 4px;
    align-self: center;
    z-index: 1;
}

.pe-unit {
    font-size: 20px;
    font-weight: 800;
    color: #b8941f;
    align-self: center;
    margin-left: 6px;
    z-index: 1;
}

/* --- ボタンエリア --- */
.pe-button-area {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding-bottom: 4px;
}
.pe-record-carousel-root .pe-btn-confirm {
    min-width: 200px !important;
    font-size: 20px !important;
    padding: 15px 30px !important;
}

/* --- 名簿未登録 --- */
.pe-empty {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: #f4f6f9;
    z-index: 5;
}

.pe-empty.active {
    display: flex;
}

.pe-empty-text {
    font-size: 17px;
    font-weight: 700;
    color: #6b7a8d;
}

/* --- 完了画面 --- */
.pe-complete-screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: #f4f6f9;
    z-index: 6;
}

.pe-complete-screen.active {
    display: flex;
}

.pe-complete-text {
    font-size: 28px;
    font-weight: 800;
    color: #1e3a5f;
}

.pe-complete-text::before {
    content: "";
    display: block;
    width: 56px;
    height: 6px;
    background: #d4af37;
    border-radius: 3px;
    margin: 0 auto 14px;
}

.pe-complete-subtext {
    font-size: 15px;
    color: #6b7a8d;
    font-weight: 700;
}

/* ============ 右下ツールバー ============ */
.pe-toolbar {
    position: absolute;
    right: 14px;
    bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10;
}
.pe-record-carousel-root .pe-tool-btn {
    width: 50px !important;
    height: 50px !important;
    border-radius: 50% !important;
    background: #fff !important;
    border: 2px solid #d7dde6 !important;
    font-size: 21px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 3px 10px rgba(30, 58, 95, 0.15) !important;
    transition: transform 0.12s, border-color 0.12s !important;
}
.pe-record-carousel-root .pe-tool-btn:hover {
    border-color: #d4af37 !important;
}
.pe-record-carousel-root .pe-tool-btn:active {
    transform: scale(0.94) !important;
}

/* ============ オーバーレイ共通 ============ */
.pe-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(30, 58, 95, 0.45);
    padding: 18px;
    z-index: 30;
}

.pe-overlay.active {
    display: flex;
}

.pe-overlay-panel {
    background: #fff;
    border-radius: 18px;
    border-top: 6px solid #d4af37;
    width: 100%;
    max-width: 620px;
    max-height: 92%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 44px rgba(30, 58, 95, 0.3);
    overflow: hidden;
}

.pe-overlay-narrow {
    max-width: 420px;
}

.pe-overlay-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 10px;
}

.pe-overlay-head-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.pe-overlay-head h2 {
    font-size: 18px;
    font-weight: 800;
    color: #1e3a5f;
}
.pe-record-carousel-root .pe-close-btn {
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    background: #eef1f6 !important;
    font-size: 20px !important;
    font-weight: 700 !important;
    color: #6b7a8d !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.12s !important;
}
.pe-record-carousel-root .pe-close-btn:hover {
    background: #d7dde6 !important;
}

.pe-overlay-body {
    overflow-y: auto;
    padding: 4px 20px 20px;
    -webkit-overflow-scrolling: touch;
}

.pe-overlay-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

/* --- 欠席・見学 選択オーバーレイ --- */
.pe-skip-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 6px 20px 20px;
}
.pe-record-carousel-root .pe-skip-choice {
    width: 100% !important;
    font-size: 17px !important;
    padding: 15px 20px !important;
}

/* --- 種目グリッド --- */
.pe-sport-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 6px 20px 20px;
}
.pe-record-carousel-root .pe-sport-btn {
    background: #f4f6f9 !important;
    border: 2px solid #d7dde6 !important;
    border-radius: 12px !important;
    padding: 16px 8px !important;
    font-size: 16px !important;
    font-weight: 800 !important;
    color: #1e3a5f !important;
    transition: border-color 0.12s, background 0.12s, transform 0.12s !important;
}
.pe-record-carousel-root .pe-sport-btn:active {
    transform: scale(0.97) !important;
}
.pe-record-carousel-root .pe-sport-btn.active {
    background: #1e3a5f !important;
    border-color: #1e3a5f !important;
    color: #fff !important;
}

/* --- 記録一覧 --- */
.pe-table-scroll {
    overflow-x: auto;
    border: 2px solid #eef1f6;
    border-radius: 10px;
}

.pe-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    white-space: nowrap;
}

.pe-data-table th {
    background: #1e3a5f;
    color: #fff;
    font-weight: 700;
    padding: 8px 12px;
    text-align: left;
    position: sticky;
    top: 0;
}

.pe-data-table td {
    padding: 7px 12px;
    border-bottom: 1px solid #eef1f6;
}

.pe-data-table tr:nth-child(even) td {
    background: #f8fafc;
}

.pe-table-empty {
    text-align: center;
    color: #6b7a8d;
    padding: 20px;
    font-size: 14px;
}

/* --- 設定オーバーレイ内 --- */
.pe-settings-section {
    padding: 14px 0;
    border-bottom: 2px solid #eef1f6;
}

.pe-settings-section:last-child {
    border-bottom: none;
}

.pe-settings-section h3 {
    font-size: 15px;
    font-weight: 800;
    color: #1e3a5f;
    margin-bottom: 10px;
    padding-left: 10px;
    border-left: 4px solid #d4af37;
}

.pe-mode-toggle {
    display: inline-flex;
    background: #e9edf4;
    border-radius: 14px;
    padding: 3px;
    gap: 2px;
    margin-bottom: 10px;
}
.pe-record-carousel-root .pe-mode-btn {
    border-radius: 11px !important;
    padding: 6px 16px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    color: #6b7a8d !important;
}
.pe-record-carousel-root .pe-mode-btn.active {
    background: #1e3a5f !important;
    color: #fff !important;
}

.pe-input-area {
    display: none;
}

.pe-input-area.active {
    display: block;
}

.pe-input-area textarea {
    min-height: 120px;
    resize: vertical;
    margin-bottom: 10px;
    line-height: 1.8;
}

.pe-add-row {
    display: flex;
    gap: 8px;
}

.pe-add-row input {
    flex: 1;
}

.pe-add-row .pe-btn {
    flex-shrink: 0;
}

.pe-student-list {
    max-height: 260px;
    overflow-y: auto;
    border: 2px solid #eef1f6;
    border-radius: 10px;
    margin-bottom: 10px;
}

.pe-student-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-bottom: 1px solid #eef1f6;
}

.pe-student-item:last-child {
    border-bottom: none;
}

.pe-student-item-no {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 700;
    color: #6b7a8d;
    width: 44px;
}

.pe-student-item-name {
    flex: 1;
    font-size: 15px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pe-record-carousel-root .pe-student-gender {
    width: 64px !important;
    flex-shrink: 0 !important;
    padding: 5px 6px !important;
    font-size: 14px !important;
}
.pe-record-carousel-root .pe-item-delete {
    flex-shrink: 0 !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    color: #b04040 !important;
    border: 1px solid #ecd3d3 !important;
    border-radius: 8px !important;
    padding: 5px 10px !important;
}
.pe-record-carousel-root .pe-item-delete:hover {
    border-color: #b04040 !important;
}

.pe-list-empty {
    text-align: center;
    color: #6b7a8d;
    padding: 16px;
    font-size: 14px;
}

.pe-data-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.pe-data-cell {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pe-data-label {
    font-size: 13px;
    font-weight: 700;
    color: #6b7a8d;
}

.pe-hint-text {
    font-size: 12px;
    color: #6b7a8d;
    margin-top: 10px;
}

/* ============ レスポンシブ ============ */
@media (max-width: 480px) {
    .pe-header-title {
        font-size: 15px;
    }

    .pe-wheel {
        width: 52px;
        height: 216px;
    }

    .pe-wheel-item {
        font-size: 26px;
    }
.pe-record-carousel-root .pe-btn-confirm {
    min-width: 150px !important;
}

    .pe-data-grid {
        grid-template-columns: 1fr;
    }

    .pe-field-row {
        flex-direction: column;
    }
}

@media (max-height: 620px) {
    .pe-picker-box {
        min-height: 160px;
    }

    .pe-wheel {
        height: 192px;
    }
}

/* ============ 表示/非表示トグル用ユーティリティ ============ */
/* 修正: JSがボタン等を style.display で隠しても、
   Cocoon対策で .pe-btn に付けた display:inline-flex !important に
   負けて消えなかったため、専用クラスで確実に隠せるようにする。
   （このルールをファイル末尾に置き、.pe-btn 系より後勝ちさせる） */
.pe-record-carousel-root .pe-hidden {
    display: none !important;
}
