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

:root {
    --bg-main: #dadadc;
    --card-bg: #ffffff;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
    --shadow-hover: 0 10px 25px rgba(0, 0, 0, 0.18);

    /* モノトーン主体のアクセント */
    --accent-dark: #000000;
    --accent-light: #e2e8f0;

    /* 状態カラー（モノトーンベースの微かな色分け） */
    --status-normal: #edf2f7;
    --status-normal-text: #718096;
    --status-out: #2d3748;
    --status-trip: #4a5568;
    --status-sick: #1a202c;
    --status-vacation: #ffffff;
    --status-am-off: #ffffff;
    --status-pm-off: #ffffff;
    --status-delay: #2d3748;
    --status-direct-go: #1a202c;
}

body {
    font-family: 'Inter', 'Segoe UI', 'Yu Gothic UI', 'Meiryo', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 2rem;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
}

/* Horizontal Header - Left Aligned Flow */
header {
    display: flex;
    justify-content: flex-start; /* 右に詰めない */
    align-items: center;
    margin-bottom: 2.5rem;
    gap: 4rem; /* ほどよい間隔で横並びに */
    background: #fff;
    padding: 2.5rem 3rem;
    border-bottom: 1px solid var(--accent-light);
    box-shadow: var(--shadow);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo-icon {
    width: 64px;
    height: 64px;
    border: 3px solid #000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 800;
    font-size: 1.5rem;
    font-family: 'Outfit', sans-serif;
}

.header-title-box h1 {
    font-size: 2.2rem;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 0.3rem;
    letter-spacing: -0.01em;
}

.header-title-box .current-date {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.header-right-memos {
    flex: 1; /* 残りの空間をすべて使う */
    display: flex;
    gap: 1.5rem;
}

.header-memo {
    flex: 1; /* 2つのメモで領域を均等に分け合う */
    background: #fbfbfb;
    border: 1px solid #eee;
    padding: 1.2rem;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.memo-title {
    font-size: 0.75rem;
    font-weight: 800;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.8rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.3rem;
}

textarea {
    width: 100%;
    height: 60px;
    border: none;
    background: transparent;
    font-size: 1rem;
    font-weight: 500;
    resize: none;
}
textarea:focus { outline: none; }

@media (max-width: 1200px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        padding: 2rem;
        gap: 1.5rem;
    }
    .header-right-memos {
        width: 100%;
        flex-direction: column; /* スマホでは縦並びに復元 */
        gap: 1rem;
    }
}

.memo-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #4a5568;
    margin-bottom: 6px;
    padding-left: 4px;
}

#memoInput,
#importantMemoInput {
    width: 100%;
    height: 100px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: none;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-primary);
    background: #fff;
    transition: all 0.2s ease;
}

#importantMemoInput {
    border: 2px solid #000; /* 黒の少し太枠で強調 */
}

#memoInput:focus,
#importantMemoInput:focus {
    outline: none;
    border-color: var(--accent-dark);
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.memo-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-height: 1.1rem;
    margin-top: 2px;
    padding-left: 5px;
    /* absoluteにして下の余白に影響させない */
    position: absolute;
}

@media (max-width: 1200px) {
    .header-memo {
        width: 100%;
        max-width: 500px;
        margin-top: 0;
    }

    #memoInput,
    #importantMemoInput {
        height: 200px;
        /* スマホでは縦に長くして広々使う */
        font-size: 1.2rem;
    }

    .memo-status {
        display: none;
    }
}

.legend {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.badge-normal {
    background: #edf2f7;
    color: #4a5568;
}

.badge-break {
    background: #4a5568;
    color: white;
}

.badge-out {
    background: #2d3748;
    color: white;
}

.badge-trip {
    background: #4a5568;
    color: white;
}

.badge-sick {
    background: #1a202c;
    color: white;
}

.badge-vacation {
    background: #e2e8f0;
    color: #1a202c;
}

.badge-am-off {
    background: #f1f1f1;
    color: #2d3748;
}

.badge-pm-off {
    background: #f1f1f1;
    color: #2d3748;
}

.badge-delay {
    background: #2d3748;
    color: white;
}

#board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.department-section {
    background: #ffffff;
    border: 1px solid var(--accent-light);
    border-radius: 12px;
    padding: 2rem 1.2rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.department-section:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.department-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 4px solid var(--accent-dark);
    text-transform: uppercase;
}

.department-subheading {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    padding: 0.2rem 0.8rem;
    background: #f4f4f4;
    border-left: 4px solid var(--accent-dark);
    border-radius: 2px;
}

.employee-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.employee-card {
    background: #ffffff;
    border: 1px solid #a0aec0; /* ここに明確な枠線を設定 */
    border-radius: 8px;
    padding: 1rem 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.employee-card:hover {
    transform: translateX(3px);
    border-color: var(--accent-dark);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.employee-card:active {
    transform: scale(0.98);
}

.employee-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
    flex-shrink: 0;
    margin-right: 10px;
}

.status-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    justify-content: flex-end;
}

.home-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary); /* 黒系統に統一 */
    padding: 0;
    margin-right: 8px;
    display: flex;
    align-items: center;
    transition: transform 0.2s ease, opacity 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.home-icon:hover {
    opacity: 0.7;
    transform: scale(1.1);
}

.home-icon:active {
    transform: scale(0.95);
}

.employee-status {
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
    width: auto;
}

/* 状態別スタイル */
.employee-card[data-status="normal"] .employee-status {
    background: transparent;
    color: var(--text-secondary);
}

.employee-card[data-status="break"] .employee-status {
    background: #4a5568;
    color: white;
}

.employee-card[data-status="out"] .employee-status {
    background: #2d3748;
    color: white;
}

.employee-card[data-status="trip"] .employee-status {
    background: #4a5568;
    color: white;
}

.employee-card[data-status="sick"] .employee-status {
    background: #1a202c;
    color: white;
}

.employee-card[data-status="vacation"] .employee-status {
    background: #e2e8f0;
    color: #1a202c;
}

.employee-card[data-status="am_off"] .employee-status {
    background: #f1f1f1;
    color: #2d3748;
    border: 1px solid #ddd;
}

.employee-card[data-status="pm_off"] .employee-status {
    background: #f1f1f1;
    color: #2d3748;
    border: 1px solid #ddd;
}

.employee-card[data-status="delay"] .employee-status {
    background: #2d3748;
    color: white;
}

.employee-card[data-status="direct_go"] .employee-status {
    background: #1a202c;
    color: white;
}

/* direct_return uses separate logic or gradient */
.employee-card[data-status="direct_return"] .employee-status {
    background: var(--status-direct-return);
    color: white;
}

/* レスポンシブデザイン */
@media (max-width: 1400px) {
    #board {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.5rem;
    }

    #board {
        grid-template-columns: 1fr;
    }

    .legend-item {
        font-size: 0.8rem;
    }
}

/* アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.department-section {
    animation: fadeIn 0.5s ease-out;
}

.employee-card {
    animation: fadeIn 0.3s ease-out;
}

/* モーダルダイアログ */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    /* 画面からはみ出さないように制限 */
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
    margin-bottom: env(safe-area-inset-bottom);
    /* スマホの下部バー対策 */
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid #e2e8f0;
}

.modal-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.3s ease;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    /* コンテンツが多い場合はスクロール */
}

/* 注意書きメッセージ */
.home-icon-notice {
    background: #fff5f5;
    border: 2px solid #feb2b2;
    color: #c53030;
    padding: 12px 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.5;
    /* display: flex; align-items: center; gap: 8px; は不要なら削除 */
}

.status-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.status-option {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    background: #fff;
}

.status-option:not(.disabled):hover {
    border-color: #000;
    background: #fdfdfd;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

/* 選択された状態の強調 */
.status-option:has(input[type="radio"]:checked) {
    border-color: #000;
    background: #fdfdfd;
    box-shadow: inset 0 0 0 1px #000, 0 4px 15px rgba(0, 0, 0, 0.1);
}

.status-option:has(input[type="radio"]:checked) .status-label {
    font-weight: 800;
}

/* ロック（無効）状態の視覚化 */
.status-option.disabled {
    opacity: 0.35;
    background: repeating-linear-gradient(
        -45deg,
        #f8f9fa,
        #f8f9fa 4px,
        #fff 4px,
        #fff 8px
    );
    border: 2px dashed #cbd5e0;
    cursor: not-allowed;
    pointer-events: none;
    -webkit-filter: grayscale(1);
    filter: grayscale(1);
    color: #a0aec0;
}

/* ロックアイコンをSVGで右側に追加 */
.status-option.disabled::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%234a5568' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2' ry='2'%3E%3C/rect%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'%3E%3C/path%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.5;
}

.status-option input[type="radio"] {
    margin-right: 12px;
    cursor: pointer;
    accent-color: #000;
}

.status-label {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.status-label.badge-normal { background: #edf2f7; color: #4a5568; }
.status-label.badge-break { background: #4a5568; color: white; }
.status-label.badge-out { background: #2d3748; color: white; }
.status-label.badge-trip { background: #4a5568; color: white; }
.status-label.badge-sick { background: #1a202c; color: white; }
.status-label.badge-vacation { background: #e2e8f0; color: #1a202c; }
.status-label.badge-am-off { background: #f1f1f1; color: #2d3748; }
.status-label.badge-pm-off { background: #f1f1f1; color: #2d3748; }
.status-label.badge-delay { background: #2d3748; color: white; }
.status-label.badge-direct-go { background: #1a202c; color: white; }

.input-field {
    margin-top: 15px;
    padding: 15px;
    background: #f7fafc;
    border-radius: 10px;
}

.input-field label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 600;
}

.input-field input[type="time"],
.input-field input[type="date"] {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.input-field input[type="time"]:focus,
.input-field input[type="date"]:focus {
    outline: none;
    border-color: #667eea;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 25px;
    border-top: 2px solid #e2e8f0;
}

.btn {
    padding: 10px 25px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-cancel {
    background: #e2e8f0;
    color: var(--text-primary);
}

.btn-cancel:hover {
    background: #cbd5e0;
}

.btn-save {
    background: var(--accent-dark);
    background: #333;
    color: white;
}

.btn-save:hover {
    background: #333;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        /* スマホでキーボードやブラウザバーが出てもボタンが隠れないように調整 */
        max-height: 75dvh;
        margin-bottom: 20vh;
        /* 下部に大きな余白を確保して全体を上に持ち上げる */
    }

    .status-options {
        grid-template-columns: 1fr;
    }
}

/* Added Styles for Direct Go/Return */
:root {
    --status-direct-go: #319795;
    /* --status-direct-return: #d53f8c; removed */
}

.badge-direct-go {
    background: var(--status-direct-go);
    color: white;
}

/*
.badge-direct-return {
background: var(--status-direct-return);
color: white;
}
*/
.employee-card[data-status="direct_go"] .employee-status {
    background: var(--status-direct-go);
    color: white;
}

/*
.employee-card[data-status="direct_return"] .employee-status {
background: var(--status-direct-return);
color: white;
}
*/