* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
    background: #f0f2f7;
    color: #333;
    padding-top: 0;
}

/* ── Page header ───────────────────────────── */
.page-header {
    padding: 14px 16px 10px;
    background: #f0f2f7;
}

h1 {
    font-size: 1.25rem;
    color: #1a2444;
}

/* ── Sticky selector bar ───────────────────── */
.selector-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #fff;
    border-bottom: 2px solid #dde1ea;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.selector-bar label {
    font-size: 0.88rem;
    font-weight: bold;
    color: #444;
    white-space: nowrap;
}

.nav-back-top {
    color: #2c3e6b;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: bold;
    white-space: nowrap;
    padding: 8px 14px;
    border-radius: 8px;
    border: 2px solid #2c3e6b;
    background: white;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.nav-back-top:active { background: #e8edf5; }

.summary-btn {
    white-space: nowrap;
    padding: 8px 14px;
    background: #2c3e6b;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: bold;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.summary-btn:active { background: #1a2a50; }

#member-select {
    flex: 1;
    min-width: 100px;
    padding: 10px 12px;
    border: 2px solid #b0b8d0;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    background: #f8f9fb;
    color: #222;
    cursor: pointer;
    appearance: auto;
}

#member-select:focus {
    outline: none;
    border-color: #2c3e6b;
}

#save-status {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 12px;
    white-space: nowrap;
    min-height: 26px;
}

#save-status.success { background: #d4edda; color: #155724; }
#save-status.error   { background: #f8d7da; color: #721c24; }

/* ── A: Progress bar ───────────────────────── */
.progress-bar-wrap {
    padding: 8px 16px 10px;
    background: #f0f2f7;
}

.progress-info {
    font-size: 0.8rem;
    color: #555;
    margin-bottom: 4px;
}

.progress-track {
    height: 6px;
    background: #d8dce8;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2c3e6b, #4a6fa5);
    border-radius: 3px;
    transition: width 0.4s ease;
    width: 0%;
}

/* ── C: No-selection guide ─────────────────── */
.no-selection-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    z-index: 5;
    background: rgba(255,255,255,0.92);
    padding: 16px 24px;
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.guide-arrow {
    font-size: 2rem;
    color: #2c3e6b;
    animation: bounce-up 1.2s infinite;
}

.guide-text {
    font-size: 0.95rem;
    font-weight: bold;
    color: #2c3e6b;
    white-space: nowrap;
}

.no-selection-guide.guide-hidden {
    display: none !important;
}

@keyframes bounce-up {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-6px); }
}

/* ── Table wrapper ─────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#schedule-table {
    border-collapse: collapse;
    background: white;
    white-space: nowrap;
    width: 100%;
}

/* ── Headers ───────────────────────────────── */
thead th {
    background: #2c3e6b;
    color: white;
    font-size: 0.78rem;
    padding: 8px 4px;
    min-width: 58px;
    font-weight: normal;
    line-height: 1.4;
    text-align: center;
    border: 1px solid #1e2f56;
}

th.member-col {
    background: #1a2444;
    text-align: left;
    padding: 10px 12px;
    min-width: 72px;
    position: sticky;
    left: 0;
    z-index: 10;
    border: 1px solid #111c38;
}

/* D: セル切替アニメーション */
@keyframes cell-pop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.avail-cell {
    transition: background-color 0.15s;
}

.avail-cell.cell-pop {
    animation: cell-pop 0.22s ease;
}

/* ── Name cells ────────────────────────────── */
td.member-name {
    text-align: left;
    padding: 0 10px;
    font-size: 0.9rem;
    font-weight: bold;
    background: #f8f9fb;
    position: sticky;
    left: 0;
    z-index: 1;
    min-width: 72px;
    border: 1px solid #e0e4ee;
    height: 56px;
}

tr:nth-child(even) td.member-name { background: #f0f3f8; }

tr.current-member td.member-name {
    background: #fff0a0 !important;
    color: #4a3600;
    border-left: 4px solid #f5c518;
}

/* ── Availability cells ────────────────────── */
.avail-cell {
    width: 58px;
    height: 56px;
    font-size: 1.25rem;
    line-height: 56px;
    text-align: center;
    border: 1px solid #e0e4ee;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    transition: filter 0.1s;
}

.avail-cell.editable {
    cursor: pointer;
}

.avail-cell.editable:active {
    filter: brightness(0.80);
    transform: scale(0.94);
}

.avail-yes   { background: #c6f5c2; color: #165c12; }
.avail-maybe { background: #fff3b0; color: #7a5c00; }
.avail-no    { background: #fdd5d5; color: #8b1a1a; }
.avail-empty { background: #f5f5f7; color: transparent; }

tr.current-member .avail-cell.editable.avail-empty {
    background: #fafae8;
    color: transparent;
}

/* ── Footer (summary) ──────────────────────── */
tfoot tr:first-child td {
    background: #2c3e6b;
    color: white;
    font-size: 0.78rem;
    padding: 8px 4px;
    font-weight: normal;
    line-height: 1.4;
    text-align: center;
    border: 1px solid #1e2f56;
}

tfoot tr:first-child td.member-name {
    background: #1a2444;
    border: 1px solid #111c38;
}

tfoot tr:nth-child(2) td {
    background: #e4eaf5;
    font-size: 0.8rem;
    padding: 6px 2px;
    font-weight: bold;
    color: #333;
    text-align: center;
    border: 1px solid #cdd4e8;
}

tfoot tr:nth-child(3) td {
    background: #d2daf0;
    font-size: 0.8rem;
    padding: 6px 2px;
    font-weight: bold;
    color: #333;
    text-align: center;
    border: 1px solid #bbc7e0;
}

tfoot tr:nth-child(4) td {
    background: #c8d2e8;
    font-size: 0.8rem;
    padding: 6px 2px;
    font-weight: bold;
    color: #333;
    text-align: center;
    border: 1px solid #aab6d8;
}

tfoot td.member-name {
    font-size: 0.78rem;
    position: sticky;
    left: 0;
    text-align: left;
}

tfoot tr:nth-child(2) td.member-name { background: #d5daea; }
tfoot tr:nth-child(3) td.member-name { background: #c5cedf; }
tfoot tr:nth-child(4) td.member-name { background: #b8c4d8; }

/* ── Legend ────────────────────────────────── */
.legend {
    display: flex;
    gap: 10px;
    padding: 14px 16px 24px;
    flex-wrap: wrap;
}

.chip {
    padding: 5px 14px;
    border-radius: 14px;
    font-size: 0.85rem;
    font-weight: bold;
}

.chip.avail-yes   { background: #c6f5c2; color: #165c12; }
.chip.avail-maybe { background: #fff3b0; color: #7a5c00; }
.chip.avail-no    { background: #fdd5d5; color: #8b1a1a; }

/* ── Desktop tweaks ────────────────────────── */
@media (min-width: 640px) {
    body { padding: 20px 16px 0; }
    .page-header { padding: 0 0 12px; background: transparent; }
    .selector-bar {
        position: static;
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0 0 8px;
        margin-bottom: 4px;
    }
    .hint { padding: 0 0 12px; }
    .table-wrapper {
        border-radius: 8px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    }
}
