/* =========================================
   基本設定・変数定義
   ========================================= */
:root {
    --cell-width: 18px;
    --primary-color: #b0466b;
    --accent-color: #d06d8c;
    --bg-color: #fff0f5;
    --line-color: #e0e0e0;
    --now-line-color: #ff0000;
    --ticket-color: #ff9800;
    --watch-color: #2196f3;
    
    /* フォント設定 */
    --font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
}

body {
    font-family: var(--font-family);
    background: var(--bg-color);
    margin: 0;
    padding: 10px;
    padding-bottom: 120px;
    overflow-x: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    overscroll-behavior-y: none;
    color: #333;
    transition: background-color 0.3s, color 0.3s;
}

/* Z-Index 管理 */
.date-display { z-index: 100 !important; position: relative; }

/* =========================================
   ログイン画面
   ========================================= */
#loginOverlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-color); z-index: 99999;
    display: flex; justify-content: center; align-items: center; flex-direction: column;
}
.login-card {
    background: white; padding: 30px; border-radius: 16px;
    box-shadow: 0 10px 40px rgba(176, 70, 107, 0.2);
    width: 85%; max-width: 320px; text-align: center; box-sizing: border-box;
}
.login-title { color: var(--primary-color); font-size: 1.4rem; margin-bottom: 20px; font-weight: bold; }
.login-input {
    width: 100%; padding: 12px; margin-bottom: 15px; border: 1px solid #ccc;
    border-radius: 8px; font-size: 1rem; box-sizing: border-box;
}
.login-btn {
    width: 100%; padding: 12px; background: var(--primary-color); color: white;
    border: none; border-radius: 8px; font-weight: bold; font-size: 1rem;
    cursor: pointer; transition: opacity 0.2s;
}
.login-btn:active { opacity: 0.8; }
#loginError { color: #d32f2f; margin-top: 10px; font-size: 0.9rem; min-height: 1.2em; }
#loginNotice {
    margin-bottom: 15px; padding: 10px; background: #fff8e1;
    border: 2px solid #ffb74d; border-radius: 8px; color: #d84315;
    font-weight: bold; font-size: 0.9rem; display: none;
    animation: flash-border 2s infinite;
}
#loginClockDisplay {
    margin-top: 15px; padding-top: 15px; border-top: 1px dashed #eee;
    color: #666; font-family: monospace; line-height: 1.4; font-size: 0.9rem;
}

/* =========================================
   エリアカラー定義 (ライトモード)
   ========================================= */
.color-row {
    display: flex; justify-content: flex-start; gap: 15px;
    margin-left: -15px; margin-right: -15px; width: calc(100% + 30px);
    padding: 15px 0; overflow-x: auto; white-space: nowrap;
    -webkit-overflow-scrolling: touch; align-items: center; min-height: 55px;
    scrollbar-width: none; -ms-overflow-style: none;
}
.color-row::-webkit-scrollbar { display: none; }
.color-row::before, .color-row::after { content: ""; display: block; width: 0px; flex-shrink: 0; }

.color-check {
    width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
    border: 2px solid white; box-shadow: 0 0 0 1px #ccc; flex-shrink: 0; transition: transform 0.1s;
}
.color-check.selected { box-shadow: 0 0 0 2px #333; transform: scale(1.1); }

/* 背景色設定 */
.bg-village { background-color: #ffcce0; }
.bg-tree    { background-color: #d0f0fd; }
.bg-marchen { background-color: #ffecb3; }
.bg-fairy   { background-color: #c8e6c9; }
.bg-hall    { background-color: #b2dfdb; }
.bg-residence { background-color: #e1bee7; }
.bg-other   { background-color: #f5f5f5; }
.bg-apricot { background-color: #ffe0b2; }
.bg-muscat  { background-color: #f0f4c3; }
.bg-latte   { background-color: #d7ccc8; }

/* イベントバー用配色 (ライトモード) */
.color-village { background: #ffcce0 !important; border-left-color: #ff6699 !important; }
.color-tree    { background: #d0f0fd !important; border-left-color: #4fc3f7 !important; }
.color-marchen { background: #ffecb3 !important; border-left-color: #ffca28 !important; }
.color-fairy   { background: #c8e6c9 !important; border-left-color: #66bb6a !important; }
.color-hall    { background: #b2dfdb !important; border-left-color: #009688 !important; }
.color-residence { background: #e1bee7 !important; border-left-color: #ab47bc !important; }
.color-other   { background: #f5f5f5 !important; border-left-color: #9e9e9e !important; }
.color-apricot { background: #ffe0b2 !important; border-left-color: #ffb74d !important; }
.color-muscat  { background: #f0f4c3 !important; border-left-color: #dce775 !important; }
.color-latte   { background: #d7ccc8 !important; border-left-color: #a1887f !important; }
/* 誕生日専用 */
.color-birthday {
    background-color: #f3e5f5 !important;
    border-left: 5px solid #9c27b0 !important;
    color: #4a148c !important;
    font-weight: bold !important;
    box-shadow: 0 2px 5px rgba(156, 39, 176, 0.2);
}
.color-birthday::after {
    content: '✨'; position: absolute; right: 5px; top: 2px; font-size: 0.7rem; opacity: 0.6;
}

/* エリアタブのアクティブ色 */
.area-tab.active[data-color="color-village"] { background: #ffcce0; border-color: #ff6699; color: #b0466b; }
.area-tab.active[data-color="color-tree"] { background: #b3e5fc; border-color: #4fc3f7; color: #01579b; }
.area-tab.active[data-color="color-marchen"] { background: #ffecb3; border-color: #ffca28; color: #ff6f00; }
.area-tab.active[data-color="color-fairy"] { background: #c8e6c9; border-color: #66bb6a; color: #1b5e20; }
.area-tab.active[data-color="color-hall"] { background: #b2dfdb; border-color: #80cbc4; color: #004d40; }
.area-tab.active[data-color="color-residence"] { background: #e1bee7; border-color: #ab47bc; color: #4a148c; }
.area-tab.active[data-color="color-other"] { background: #e0e0e0; border-color: #9e9e9e; color: #212121; }

/* =========================================
   ヘッダー・メインUI
   ========================================= */
.header-extra {
    max-height: 0; overflow: hidden; opacity: 0; transition: all 0.3s ease-out;
    margin-top: 0; border-top: none; padding-top: 0;
}
.header-extra.open {
    max-height: 500px; opacity: 1; margin-top: 5px;
    border-top: 1px dashed #ddd; padding-top: 5px;
}
.toggle-header-btn {
    background: #f8f8f8; border: 1px solid #ccc; color: #666;
    border-radius: 15px; padding: 4px 10px; font-size: 0.75rem;
    font-weight: bold; cursor: pointer; display: flex; align-items: center;
    gap: 3px; transition: all 0.2s; white-space: nowrap;
}
.toggle-header-btn:active { background: #e0e0e0; }
.toggle-header-btn.open { background: #d06d8c; color: white; border-color: #d06d8c; }
.toggle-header-btn .arrow { display: inline-block; transition: transform 0.3s; }
.toggle-header-btn.open .arrow { transform: rotate(180deg); }

/* ボタン共通 */
.action-btn {
    width: 100%; height: 44px; border-radius: 8px; font-size: 12px;
    font-weight: bold; display: flex; align-items: center; justify-content: center;
    border: 1px solid #ccc; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 0; white-space: nowrap; background: #f5f5f5; color: #333;
}

.header-top {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px dashed #eee; padding-bottom: 5px; margin-bottom: 2px;
}
.app-title { font-weight: bold; color: var(--primary-color); font-size: 1rem; display: flex; align-items: center; gap: 5px; }
.app-title::before { content: "🌈"; }
.logout-btn { background: #f5f5f5; color: #666; border: 1px solid #ccc; border-radius: 4px; padding: 2px 8px; font-size: 0.7rem; cursor: pointer; }

.top-row { display: flex; justify-content: space-between; align-items: center; gap: 5px; flex-wrap: wrap; }
.date-control { display: flex; align-items: center; gap: 5px; flex-grow: 1; justify-content: flex-start; }
.date-display {
    font-size: 1.0rem; font-weight: bold; color: #333; cursor: pointer;
    display: flex; align-items: center; gap: 3px; background: #fff;
    padding: 5px 8px; border-radius: 6px; border: 1px solid #ccc; letter-spacing: -0.5px;
}
.date-btn {
    background: #fff; border: 1px solid #ccc; border-radius: 6px;
    padding: 6px 10px; font-weight: bold; cursor: pointer; color: #555; font-size: 1rem;
}
.date-btn:active { background: #f0f0f0; transform: scale(0.95); }
.date-btn.today { color: var(--primary-color); border-color: var(--primary-color); font-size: 0.8rem; padding: 6px 8px; }

.priority-status-btn {
    display: flex; align-items: center; gap: 5px; padding: 6px 12px;
    border-radius: 20px; border: 1px solid #ccc; background: #f9f9f9;
    color: #666; font-size: 0.8rem; font-weight: bold; cursor: pointer;
    transition: all 0.2s; white-space: nowrap; max-width: 100%; overflow: hidden;
}
.priority-status-btn.active {
    border-color: #ff9800; background: #fff8e1; color: #e65100;
    box-shadow: 0 2px 5px rgba(255,152,0,0.2);
}
.priority-status-btn.inactive { border-color: #ddd; background: #e0e0e0; color: #999; }
.priority-status-btn.locked::after { content: "🔒"; font-size: 0.8rem; margin-left: 2px; }

.link-btn {
    text-decoration: none; background: #fff; color: #b0466b; border: 1px solid #b0466b;
    padding: 5px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: bold;
    white-space: nowrap; margin-left: auto;
}

.btn-group {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
    width: 100%; margin-top: 5px; justify-content: center;
}

/* 個別ボタンカラー */
.btn-ticket { background: #fff3e0; color: #e65100; border-color: #ffb74d; }
.btn-copy { background: #e3f2fd; color: #0277bd; border-color: #4fc3f7; }
.btn-data { background: #f3e5f5; color: #7b1fa2; border-color: #ba68c8; }
.btn-setting { background: #eceff1; color: #455a64; border-color: #cfd8dc; }
.btn-pdf { background: var(--primary-color); color: white; border: none; }
.btn-search { background: #e0f7fa; color: #006064; border-color: #0097a7; }

.birthday-banner {
    background: #fff; border: 2px dashed #ffb7c5; border-radius: 8px;
    padding: 8px 12px; font-size: 0.85rem; color: #d0466b; line-height: 1.4;
    display: none; margin-top: 5px;
}
.top-bar {
    background: white; padding: 5px 8px; border-radius: 12px;
    border: 2px solid var(--accent-color); margin-bottom: 5px;
    display: flex; flex-direction: column; gap: 4px;
    box-shadow: 0 4px 10px rgba(176, 70, 107, 0.15); position: relative; z-index: 50;
}
.simple-birthday {
    text-align: center; font-size: 0.8rem; color: #d0466b;
    background: #fff0f5; border-radius: 15px; padding: 2px 8px;
    margin: 0 2px; border: 1px dashed #ffb7c5; display: none; animation: fadeIn 0.5s ease;
}
.simple-birthday.show { display: block; }
.simple-birthday.hide-by-menu { display: none !important; }

/* 誕生日当日の特別演出 */
.today-is-birthday {
    background: linear-gradient(135deg, #fff0f5 0%, #ffe4e1 50%, #fff0f5 100%) !important;
    position: relative; overflow: hidden;
}
.birthday-decoration {
    display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; background-image: radial-gradient(circle, rgba(255,105,180,0.2) 2px, transparent 2px);
    background-size: 30px 30px; z-index: 0;
}
.is-celebration .birthday-decoration { display: block; animation: bgSlide 20s linear infinite; }
@keyframes bgSlide { from { background-position: 0 0; } to { background-position: 60px 60px; } }

/* =========================================
   スケジュール表 (タイムライン)
   ========================================= */
.schedule-wrapper {
    overflow-x: auto; background: white; border: 2px solid var(--primary-color);
    border-radius: 8px; position: relative; -webkit-overflow-scrolling: touch;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05); margin-top: 5px; min-height: 200px;
}
.grid-row { display: flex; width: max-content; border-bottom: 1px solid var(--line-color); height: 65px; }
.header-row {
    background-color: #ffdbe6; position: sticky; top: 0; z-index: 20;
    height: 30px; border-bottom: 2px solid var(--accent-color);
}
.corner-cell, .theater-name {
    flex: 0 0 85px; width: 85px; background-color: #ffdbe6;
    position: sticky; left: 0; z-index: 30; font-weight: bold;
    color: var(--primary-color); display: flex; align-items: center;
    justify-content: center; border-right: 2px solid var(--accent-color);
    font-size: 0.7rem; text-align: center; box-sizing: border-box;
    line-height: 1.2; padding: 2px;
}
.theater-name {
    position: sticky; left: 0; background-color: #fff0f5; z-index: 10;
    font-size: 0.75rem; border-bottom: 1px solid #e0c0d0; flex-shrink: 0; width: 80px;
}
.time-scale-container { display: flex; flex: 1; position: relative; cursor: pointer; }
.events-container {
    display: flex; flex: 1; position: relative; cursor: pointer;
    background-image: linear-gradient(to right, #f0f0f0 1px, transparent 1px);
    background-size: calc(var(--cell-width) * 2) 100%; background-color: #fff;
}
.time-label {
    width: calc(var(--cell-width) * 6); font-size: 10px; border-left: 1px solid #aaa;
    padding-left: 2px; height: 100%; flex-shrink: 0; box-sizing: border-box;
    color: #666; display: flex; align-items: center;
}

#currentTimeBar {
    position: absolute; top: 0; bottom: 0; width: 2px;
    background-color: var(--now-line-color); z-index: 40; pointer-events: none; display: none;
}
#currentTimeBar::after {
    content: "▼"; color: var(--now-line-color); position: absolute;
    top: -10px; left: -5px; font-size: 10px;
}

.event-bar {
    position: absolute; top: 4px; bottom: 4px; border-radius: 4px;
    background-color: #f0f0f0; color: #333; font-size: 0.7rem; font-weight: bold;
    display: flex; flex-direction: column; justify-content: center;
    padding: 0 4px; box-shadow: 1px 1px 3px rgba(0,0,0,0.2); z-index: 5;
    overflow: hidden; line-height: 1.1; white-space: nowrap;
    text-overflow: ellipsis; cursor: pointer; border-left-width: 5px; border-left-style: solid;
}

/* チケットありの強調 */
.event-bar.has-ticket {
    animation: flash-border 1.5s infinite ease-in-out !important;
    border-width: 2px 2px 2px 6px !important; 
}
.event-bar.has-ticket::after {
    content: "★"; position: absolute; top: 0; right: 2px;
    color: #bf360c !important; text-shadow: 0 0 3px white; font-size: 0.8rem;
}
@keyframes flash-border {
    0% { box-shadow: 0 0 8px #e65100; border-color: #e65100; }
    50% { box-shadow: 0 0 50px #ff3d00; border-color: #ff3d00; }
    100% { box-shadow: 0 0 8px #e65100; border-color: #e65100; }
}

.event-bar.is-watch { border: 2px solid var(--watch-color); box-shadow: 0 0 5px rgba(33, 150, 243, 0.5); }
.event-bar.is-watch::before { content: "👀"; position: absolute; top: 0; right: 2px; font-size: 0.7rem; }
.memo-icon {
    position: absolute; bottom: 1px; right: 2px; font-size: 0.8rem;
    cursor: pointer; background: rgba(255,255,255,0.7); border-radius: 3px;
    line-height: 1; z-index: 10; padding: 1px;
}

/* =========================================
   通知・メモ・ボトムエリア
   ========================================= */
.notification-banner {
    position: fixed; top: 0; left: 0; right: 0;
    background: rgba(255, 152, 0, 0.98); color: white; padding: 12px;
    z-index: 9999; text-align: center; font-weight: bold; display: none;
    flex-direction: column; align-items: center; gap: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2); animation: slideDown 0.3s ease-out;
}
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }
.noti-ok-btn {
    background: white; color: #e65100; border: none; border-radius: 20px;
    padding: 6px 20px; font-weight: bold; font-size: 0.9rem;
    cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.daily-memo-area {
    background: white; border: 2px solid #ddd; border-radius: 12px;
    margin-top: 10px; padding: 10px; box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.daily-memo-header {
    font-size: 0.85rem; font-weight: bold; color: #666;
    margin-bottom: 5px; display: flex; justify-content: space-between; align-items: center;
}
.daily-memo-content {
    font-size: 0.9rem; min-height: 40px; color: #333;
    white-space: pre-wrap; background: #f9f9f9; padding: 8px;
    border-radius: 8px; border: 1px solid #eee;
}

.bottom-area {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: white; box-shadow: 0 -4px 15px rgba(0,0,0,0.15);
    border-top: 1px solid #ddd; padding: 8px 15px;
    padding-bottom: max(15px, env(safe-area-inset-bottom));
    display: flex; justify-content: space-between; align-items: center;
}
.status-info { font-size: 0.85rem; font-weight: bold; color: #333; line-height: 1.2; }
#liveClock { font-size: 1.1rem; font-family: monospace; letter-spacing: -0.5px; color: #b0466b; }

.bottom-btn-group { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.big-add-btn {
    background: var(--primary-color); color: white; border: none;
    border-radius: 25px; padding: 8px 24px; font-weight: bold;
    font-size: 1rem; box-shadow: 0 4px 10px rgba(176, 70, 107, 0.4);
    cursor: pointer; display: flex; align-items: center; gap: 5px; transition: transform 0.1s;
}
.big-add-btn:active { transform: scale(0.95); }
.sub-add-btn {
    background: var(--accent-color); color: white; border: none;
    border-radius: 20px; font-size: 0.75rem; font-weight: bold;
    padding: 6px 12px; cursor: pointer; box-shadow: 0 2px 5px rgba(176, 70, 107, 0.3);
    display: flex; align-items: center; gap: 4px; transition: transform 0.1s;
}
.sub-add-btn:active { transform: scale(0.95); opacity: 0.9; }

/* =========================================
   モーダル・ピッカー・フォーム
   ========================================= */
.pop-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); display: none; justify-content: center;
    align-items: center; backdrop-filter: blur(3px); z-index: 3000;
}
.pop-overlay.z-normal { z-index: 3000; }
.pop-overlay.z-picker { z-index: 4000; }
.pop-overlay.z-alert { z-index: 5000; }
.pop-card {
    background: white; width: 90%; max-width: 400px; border-radius: 16px;
    padding: 15px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); display: flex;
    flex-direction: column; gap: 10px; max-height: 75vh; max-height: 75dvh;
    overflow-y: auto; position: relative; animation: popIn 0.2s ease-out;
    box-sizing: border-box; margin: auto;
}
@keyframes popIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.pop-header {
    font-weight: bold; color: var(--primary-color); border-bottom: 1px solid #eee;
    padding-bottom: 8px; font-size: 1.1rem; text-align: center; margin-bottom: 0px; flex-shrink: 0;
}

.area-tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 5px; -webkit-overflow-scrolling: touch; flex-shrink: 0; }
.area-tab {
    padding: 6px 12px; border-radius: 20px; border: 1px solid #ccc;
    font-size: 0.75rem; white-space: nowrap; cursor: pointer;
    font-weight: bold; color: #555; background: #f5f5f5;
}
.preset-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px;
    max-height: 120px; overflow-y: auto; padding: 2px; flex-shrink: 0;
}
.preset-btn {
    background: #f8f8f8; border: 1px solid #ddd; padding: 10px;
    border-radius: 8px; font-size: 0.8rem; cursor: pointer;
    text-align: center; font-weight: bold; color: #444;
}
.preset-btn.special { background: #fff0f5; border-color: #ffb7c5; color: #d0466b; order: -1; }

.form-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; flex-shrink: 0; }
.form-group { display: flex; flex-direction: column; flex: 1; min-width: 70px; }
.form-label { font-size: 0.75rem; font-weight: bold; color: #555; margin-bottom: 4px; padding-left: 2px; }
.form-input {
    width: 100%; height: 40px; border: 1px solid #ccc; border-radius: 8px;
    padding: 0 10px; font-size: 1rem; text-align: center; background: #fff;
    -webkit-appearance: none; box-sizing: border-box;
}
.clickable-input { cursor: pointer; background-color: #fff; color: #333; caret-color: transparent; }
.clickable-input:active { background-color: #f0f0f0; }

.modal-actions { display: flex; gap: 8px; margin-top: 10px; flex-shrink: 0; }
.btn-save { flex: 2; background: var(--primary-color); color: white; border: none; padding: 12px; border-radius: 10px; font-weight: bold; font-size: 1rem; cursor: pointer; }
.btn-sub { flex: 1; background: #eee; color: #333; border: none; padding: 12px; border-radius: 10px; font-weight: bold; font-size: 0.9rem; cursor: pointer; }
.btn-del { flex: 1; background: white; color: #d32f2f; border: 1px solid #d32f2f; padding: 12px; border-radius: 10px; font-weight: bold; font-size: 0.9rem; cursor: pointer; }

/* スイッチUI */
.ticket-area { background: #fff8e1; border: 1px solid #ffe082; padding: 10px; border-radius: 10px; flex-shrink: 0; }
.ticket-toggle { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.toggle-switch {
    width: 44px; height: 22px; background: #ddd; border-radius: 11px;
    position: relative; transition: 0.3s; flex-shrink: 0;
}
.toggle-switch::after {
    content: ''; position: absolute; top: 2px; left: 2px; width: 18px;
    height: 18px; background: white; border-radius: 50%; transition: 0.3s;
}
input[type="checkbox"]:checked + .toggle-switch { background: #ff9800; }
input[type="checkbox"]:checked + .toggle-switch.blue { background: #2196f3; }
input[type="checkbox"]:checked + .toggle-switch::after { left: 24px; }
.watch-toggle-wrap {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-top: 8px; background: #e3f2fd; padding: 8px 10px;
    border-radius: 8px; border: 1px solid #bbdefb; flex-shrink: 0; cursor: pointer;
}
.ticket-body { margin-top: 8px; display: none; }
.ticket-list-item {
    background: #fff3e0; border-left: 5px solid #ff9800; padding: 12px;
    margin-bottom: 10px; border-radius: 6px; font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); display: flex;
    justify-content: space-between; align-items: center;
}
.ticket-list-item.used { background: #eee; border-left-color: #999; color: #999; text-decoration: line-through; }
.ticket-chk { transform: scale(1.5); }

/* 確認・アラート・詳細 */
.confirm-msg { font-size: 1rem; text-align: center; margin: 20px 0; color: #333; line-height: 1.5; }
.confirm-warning { color: #d32f2f; font-weight: bold; text-align: center; margin: 10px 0; font-size: 0.9rem; }
.confirm-code {
    font-size: 1.8rem; font-family: monospace; text-align: center;
    letter-spacing: 5px; margin: 15px 0; color: #333; font-weight: bold;
    background: #f5f5f5; padding: 10px; border-radius: 8px;
}
.detail-row { display: flex; border-bottom: 1px solid #eee; padding: 10px 0; font-size: 0.95rem; }
.detail-label { width: 80px; font-weight: bold; color: #666; font-size: 0.8rem; }
.detail-val { flex: 1; color: #333; }
.detail-memo-box {
    background: #f5f5f5; padding: 10px; border-radius: 8px;
    font-size: 0.9rem; margin-top: 5px; color: #444; white-space: pre-wrap;
}
.quick-memo-popup {
    position: fixed; background: #333; color: white; padding: 8px 12px;
    border-radius: 8px; font-size: 0.8rem; z-index: 6000; max-width: 200px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3); pointer-events: none; opacity: 0; transition: opacity 0.2s;
}

/* ピッカー・カレンダー */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 10px; text-align: center; }
.cal-header { font-weight: bold; font-size: 0.8rem; color: #666; padding-bottom: 5px; }
.cal-day { padding: 10px 0; border-radius: 8px; cursor: pointer; font-weight: bold; position: relative; }
.cal-day:hover { background: #f0f0f0; }
.cal-day.today { color: var(--primary-color); border: 1px solid var(--primary-color); }
.cal-day.selected { background: var(--primary-color); color: white; }
.cal-day.has-event::after { content: "•"; color: #2196f3; position: absolute; bottom: 0; left: 0; right: 0; font-size: 1.2rem; line-height: 0.5; }
.cal-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 1.1rem; font-weight: bold; }
.picker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; max-height: 50vh; overflow-y: auto; }
.picker-grid.two-col { grid-template-columns: repeat(2, 1fr); }
.picker-btn {
    padding: 12px; background: #f5f5f5; border: 1px solid #ccc; border-radius: 8px;
    font-size: 1rem; font-weight: bold; cursor: pointer; text-align: center;
}
.picker-btn:active { background: #ddd; }
.picker-btn.selected { background: var(--primary-color); color: white; border-color: var(--primary-color); }

/* スキャンアニメーション */
@keyframes scanAnimation { 0% { top: 0%; } 50% { top: 100%; } 100% { top: 0%; } }
#scanFrame[style*="border-color: rgb(0, 255, 0)"] .scan-line { display: none; }

/* 検索結果・リスト */
.edit-list-row { display: flex; gap: 5px; margin-bottom: 5px; align-items: center; }
.result-item { padding: 10px; border-bottom: 1px solid #eee; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.result-item:hover { background: #f9f9f9; }
#dateJumpModal, #textShareModal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 9999; display: none;
    align-items: center; justify-content: center; flex-direction: column;
}
.jump-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 10px; }
.jump-btn { background: #fff; border: 1px solid #ddd; padding: 15px 0; border-radius: 8px; font-weight: bold; color: #333; cursor: pointer; text-align: center; }
.year-selector { display: flex; justify-content: center; align-items: center; gap: 20px; font-size: 1.5rem; font-weight: bold; margin-bottom: 10px; color: #333; }

/* メディアクエリ */
@media screen and (max-width: 360px) {
    .action-btn { padding: 6px 8px; font-size: 0.7rem; }
    .theater-name, .corner-cell { flex: 0 0 75px; width: 75px; font-size: 0.65rem; }
    .pop-card { padding: 12px; gap: 6px; }
}
@media screen and (max-height: 600px) {
    .pop-card { max-height: 95vh; padding: 10px; }
}

body.dark-mode {
    --bg-color: #121212;       /* 背景：目に優しいダークグレー */
    --primary-color: #ff8fb1;  /* アクセント：明るめのピンク */
    --accent-color: #d06d8c;
    --card-bg: #1e1e1e;        /* カード背景：少し浮いた黒 */
    --text-main: #ffffff;      /* メイン文字：真っ白 */
    --text-sub: #b0b0b0;       /* サブ文字：明るいグレー */
    --border-color: #333333;   /* 枠線：暗いグレー */
    --input-bg: #2c2c2c;       /* 入力欄背景 */
    color: var(--text-main);
}

/* --- 1. 日付・ヘッダー操作周りの修正 (ここが重要) --- */
/* 日付表示ボックスと中身のinput */
body.dark-mode .date-display,
body.dark-mode #datePicker {
    background-color: #2c2c2c !important; /* 少し明るいグレーで枠を認識させる */
    color: #ffffff !important;            /* 文字は白 */
    border-color: #555 !important;
    color-scheme: dark !important;        /* ブラウザ標準のカレンダーもダークモードにする */
}

/* 日付操作ボタン（< > 今日） */
body.dark-mode .date-btn {
    background-color: #2c2c2c !important;
    color: #ffffff !important;
    border-color: #555 !important;
}

/* 「今日」ボタンの強調 */
body.dark-mode .date-btn.today {
    border-color: var(--primary-color) !important;
    color: var(--primary-color) !important;
    font-weight: bold !important;
}

/* ヘッダーのトップバー背景 */
body.dark-mode .top-bar {
    background-color: #1a1a1a !important;
    border-bottom-color: #444 !important;
}

/* リンクボタンやログアウトボタン */
body.dark-mode .link-btn,
body.dark-mode .toggle-header-btn,
body.dark-mode .logout-btn {
    background-color: #2c2c2c !important;
    border-color: #555 !important;
    color: #fff !important;
}

/* --- 2. 基本テキスト色の強制上書き --- */
/* JSで色が指定されている箇所を白で上書き */
body.dark-mode .status-info,
body.dark-mode .detail-val,
body.dark-mode .daily-memo-content,
body.dark-mode .confirm-msg,
body.dark-mode .year-selector,
body.dark-mode .result-item div,
body.dark-mode .ticket-list-item div {
    color: var(--text-main) !important;
}

/* サブテキスト */
body.dark-mode .detail-label,
body.dark-mode .cal-header,
body.dark-mode .form-label,
body.dark-mode .h-info,
body.dark-mode #detTime div:first-child { 
    color: var(--text-sub) !important;
}

/* --- 3. 背景色・カードデザイン --- */
body.dark-mode .pop-card, 
body.dark-mode .login-card, 
body.dark-mode .daily-memo-area,
body.dark-mode .bottom-area,
body.dark-mode .schedule-wrapper,
body.dark-mode .result-item,
body.dark-mode .ticket-list-item {
    background-color: var(--card-bg) !important;
    border-color: var(--border-color) !important;
}

/* --- 4. 詳細画面・入力フォーム --- */
/* 時刻表示を大きく白く */
body.dark-mode #detTime div:last-child {
    color: #ffffff !important;
    text-shadow: 0 0 2px rgba(0,0,0,0.5);
}
/* メモ欄 */
body.dark-mode .detail-memo-box {
    background-color: #2a2a2a !important; 
    border: 1px solid #444 !important;
    color: #eee !important;
}
/* チケット情報エリア */
body.dark-mode #detTicketArea div {
    color: #ffccbc !important; /* 薄いオレンジで見やすく */
}

/* 入力フォーム全般 */
body.dark-mode .form-input, 
body.dark-mode .login-input, 
body.dark-mode textarea, 
body.dark-mode select {
    background-color: var(--input-bg) !important;
    border-color: #555 !important;
    color: #fff !important;
}
body.dark-mode ::placeholder { color: #777 !important; }

/* --- 5. スケジュール表 --- */
body.dark-mode .header-row,
body.dark-mode .corner-cell, 
body.dark-mode .theater-name {
    background-color: #252525 !important;
    border-bottom-color: #444 !important;
    border-right-color: #444 !important;
    color: var(--primary-color) !important;
}
body.dark-mode .events-container {
    background-color: #121212 !important;
    background-image: linear-gradient(to right, #2a2a2a 1px, transparent 1px) !important;
}
body.dark-mode .time-label {
    color: #aaa !important;
    border-left-color: #444 !important;
}
/* イベントバー（白文字でくっきり） */
body.dark-mode .event-bar { 
    color: #fff !important; 
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    border: 1px solid rgba(255,255,255,0.2); 
}

/* --- 6. リスト・検索結果の視認性 --- */
body.dark-mode .result-item {
    border-bottom: 1px solid #333 !important;
}
body.dark-mode .result-item:hover {
    background-color: #2a2a2a !important;
}
/* 日付部分（元がピンクや赤の箇所）を明るく */
body.dark-mode .result-item div[style*="color:#b0466b"] {
    color: #ff8fb1 !important;
}

/* --- 7. エリアカラー（ダークモード用調整） --- */
body.dark-mode .color-village { background: #5c3a45 !important; border-left-color: #ff80ab !important; }
body.dark-mode .color-tree    { background: #2c3e50 !important; border-left-color: #4fc3f7 !important; }
body.dark-mode .color-marchen { background: #4e342e !important; border-left-color: #ffca28 !important; }
body.dark-mode .color-fairy   { background: #1b5e20 !important; border-left-color: #9ccc65 !important; }
body.dark-mode .color-hall    { background: #004d40 !important; border-left-color: #26a69a !important; }
body.dark-mode .color-residence { background: #4a148c !important; border-left-color: #ea80fc !important; }
body.dark-mode .color-other   { background: #424242 !important; border-left-color: #bdbdbd !important; }
/* 誕生日専用カラー（ダークモード） */
body.dark-mode .color-birthday {
    background-color: #311b92 !important;
    border-left-color: #b388ff !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(179, 136, 255, 0.3) !important;
}

/* ボタン類 */
body.dark-mode .btn-sub, 
body.dark-mode .preset-btn,
body.dark-mode .picker-btn,
body.dark-mode .jump-btn,
body.dark-mode .action-btn {
    background-color: #333 !important;
    border-color: #555 !important;
    color: #fff !important;
}

/* =========================================
   印刷・縦/横一覧ビュー設定
   ========================================= */
body.timeline-overlay-active { overflow: hidden !important; }

/* 縦一覧 (画面表示用) */
#printableTimeline {
    display: none; background-color: white !important; color: #333 !important;
    padding: 20px !important; font-family: var(--font-family) !important;
}
.timeline-overlay-active #printableTimeline {
    display: block !important; position: fixed !important; top: 0 !important; left: 0 !important;
    width: 100vw !important; height: 100vh !important; overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch !important; z-index: 30000 !important;
    background: white !important; padding: 20px !important; padding-bottom: 120px !important; box-sizing: border-box !important;
}

/* 横一覧 (画面表示用) */
#printableHorizontalTimeline {
    display: none; background: white !important; color: #333 !important;
    font-family: var(--font-family) !important; padding: 20px !important; box-sizing: border-box;
}
body.mode-horizontal #printableHorizontalTimeline {
    display: block !important; position: fixed !important; top: 0 !important; left: 0 !important;
    width: 100vw !important; height: 100vh !important; overflow-y: scroll !important;
    z-index: 30000 !important; padding-bottom: 120px !important; background: white !important;
    page: horizontal-page;
}

/* 縦・横切り替え */
body.mode-vertical #printableTimeline { display: block !important; position: fixed !important; top: 0 !important; left: 0 !important; width: 100vw !important; height: 100vh !important; overflow-y: scroll !important; z-index: 30000 !important; padding-bottom: 120px !important; }

/* 閉じるボタン */
#timelineCloseBtn {
    display: none; position: fixed !important; bottom: 30px !important; right: 30px !important;
    background: #b0466b !important; color: white !important; padding: 16px 32px !important;
    border-radius: 50px !important; font-weight: bold !important; box-shadow: 0 6px 20px rgba(0,0,0,0.5) !important;
    border: 2px solid white !important; z-index: 40000 !important; cursor: pointer !important;
}
.timeline-overlay-active #timelineCloseBtn { display: block !important; }

/* タイムライン装飾 (共通) */
#printableTimeline .p-header, .h-header { border-bottom: 3px solid #b0466b; margin-bottom: 20px; padding-bottom: 8px; }
#printableTimeline .p-title, .h-title { font-size: 24px; font-weight: bold; color: #b0466b; }
#printableTimeline .p-timeline-row { display: flex; break-inside: avoid; border-bottom: 1px solid #eee; padding: 12px 0; }
#printableTimeline .p-time-col { width: 75px; font-size: 18px; font-weight: bold; text-align: right; padding-right: 15px; border-right: 2px solid #ddd; color: #333; }
#printableTimeline .p-content-col { flex: 1; padding-left: 15px; }

/* 横型テーブル装飾 */
.h-info { font-size: 12px; color: #666; }
.h-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; font-size: 12px; }
.h-table th, .h-table td { border: 1px solid #ccc; padding: 4px; text-align: center; vertical-align: middle; height: 35px; }
.h-col-header { width: 180px; text-align: left !important; background: #fff0f5; }
.h-area-badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 10px; color: #333; margin-bottom: 2px; }
.h-show-name { font-weight: bold; font-size: 11px; display: block; line-height: 1.2; }
.h-time-header { background: #eee; font-weight: bold; width: 40px; }
.h-cell-filled { font-weight: bold; color: #333; position: relative; }
.h-cell-filled span { position: relative; z-index: 2; font-size: 11px; }
.h-footer-list { margin-top: 20px; border-top: 1px dashed #ccc; padding-top: 10px; }
.h-list-title { font-weight: bold; font-size: 14px; margin-bottom: 8px; color: #555; }
.h-list-item { font-size: 11px; margin-bottom: 4px; line-height: 1.4; color: #333; }
.h-list-label { display: inline-block; padding: 1px 5px; border-radius: 4px; color: white; margin-right: 5px; font-size: 10px; font-weight: bold; }

/* 縦一覧の特別装飾 */
#printableTimeline .p-info-box.p-print-pri { background: #fffdf0 !important; border: 2px dashed #ffb74d !important; border-radius: 16px !important; padding: 18px !important; margin-bottom: 15px !important; box-shadow: 2px 2px 10px rgba(255, 152, 0, 0.1) !important; }
#printableTimeline .pri-label { background: #ffa726 !important; color: white !important; font-size: 12px !important; font-weight: bold !important; padding: 4px 12px !important; border-radius: 20px !important; display: inline-block !important; margin-bottom: 12px !important; }
#printableTimeline .pri-time-area { text-align: center; background: white !important; padding: 10px !important; border-radius: 12px !important; border: 1px solid #ffcc80 !important; min-width: 100px; }
#printableTimeline .pri-number { font-size: 32px !important; font-weight: bold !important; color: #e65100 !important; line-height: 1; }
#printableTimeline .p-info-box.p-print-day { background: #f0f7ff !important; border: 2px dashed #64b5f6 !important; border-radius: 16px !important; padding: 15px 18px !important; margin-bottom: 20px !important; box-shadow: 2px 2px 10px rgba(33, 150, 243, 0.1) !important; }
#printableTimeline .p-info-box.p-print-day::before { content: "📌 今日の全体メモ"; display: block; font-size: 11px; font-weight: bold; color: #1976d2; margin-bottom: 6px; }
#printableTimeline .p-event-detail.p-memo { background: #fff5f7 !important; color: #d81b60 !important; padding: 10px 14px !important; border-radius: 12px !important; margin-top: 10px !important; font-size: 13px !important; display: inline-block !important; border: 2px dashed #f48fb1 !important; line-height: 1.5 !important; box-shadow: 2px 2px 5px rgba(216, 27, 96, 0.1) !important; }
#printableTimeline .p-event-detail.p-memo::before { content: "📝"; margin-right: 6px; }

/* =========================================
   印刷時の強制スタイル (Media Print)
   ========================================= */
@page { margin: 5mm; }
@page horizontal-page { size: landscape; margin: 5mm; }

@media print {
    /* 色調整強制 */
    *, *::before, *::after { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color-adjust: exact !important; }
    
    /* UI非表示 */
    body > * { display: none !important; }
    
    /* 閉じるボタン抹消 */
    #timelineCloseBtn, .timeline-overlay-active #timelineCloseBtn, body.timeline-overlay-active #timelineCloseBtn {
        display: none !important; visibility: hidden !important; opacity: 0 !important; width: 0 !important; height: 0 !important; pointer-events: none !important;
    }

    /* ページリセット */
    body, html { width: 100% !important; height: auto !important; margin: 0 !important; padding: 0 !important; background: white !important; overflow: visible !important; }

    /* 縦モード */
    body.mode-vertical #printableTimeline { display: block !important; position: absolute !important; top: 0 !important; left: 0 !important; width: 100% !important; height: auto !important; overflow: visible !important; }
    body.mode-vertical .p-timeline-row { page-break-inside: avoid !important; }
    body.mode-vertical #printableHorizontalTimeline { display: none !important; }

    /* 横モード */
    body.mode-horizontal #printableHorizontalTimeline { display: block !important; position: absolute !important; top: 0 !important; left: 0 !important; width: 100% !important; height: auto !important; overflow: visible !important; page: horizontal-page; }
    body.mode-horizontal .h-table { width: 100% !important; border-collapse: collapse !important; table-layout: auto !important; }
    body.mode-horizontal .h-time-header, body.mode-horizontal .h-table td { font-size: 9px !important; padding: 2px !important; white-space: nowrap !important; }
    body.mode-horizontal .h-col-header { width: 120px !important; font-size: 9px !important; }
    body.mode-horizontal #printableTimeline { display: none !important; }
}

/* ラピッド・エディタ用スタイル */
.rapid-container { display: flex; flex-direction: column; gap: 10px; height: 100%; }
.rapid-tabs { display: flex; background: #ddd; border-radius: 8px; padding: 4px; gap: 4px; }
.rapid-tab { flex: 1; text-align: center; padding: 8px; border-radius: 6px; font-size: 0.9rem; cursor: pointer; color: #666; }
.rapid-tab.active { background: #fff; color: #b0466b; font-weight: bold; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

/* 時間コントローラー */
.time-controller { display: flex; align-items: center; justify-content: center; background: #fff0f5; padding: 10px; border-radius: 8px; gap: 15px; border: 2px solid #f8bbd0; }
.time-btn { width: 40px; height: 40px; border-radius: 50%; border: none; background: #fff; color: #b0466b; font-size: 1.2rem; font-weight: bold; box-shadow: 0 2px 5px rgba(0,0,0,0.1); cursor: pointer; }
.time-display { font-size: 1.8rem; font-weight: bold; color: #333; font-variant-numeric: tabular-nums; }

/* 演目ボタンエリア */
.preset-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; overflow-y: auto; max-height: 250px; padding: 4px; }
.rapid-btn { padding: 12px; border: 1px solid #eee; border-radius: 8px; background: #fff; text-align: left; font-size: 0.85rem; cursor: pointer; position: relative; overflow: hidden; }
.rapid-btn:active { transform: scale(0.98); background: #fce4ec; }
.rapid-btn-code { position: absolute; top: 2px; right: 4px; font-size: 0.65rem; color: #999; font-weight: bold; }

/* リスト表示エリア */
.added-list { background: #fafafa; border: 1px solid #eee; border-radius: 8px; padding: 8px; max-height: 150px; overflow-y: auto; }
.added-item { display: flex; justify-content: space-between; align-items: center; padding: 6px; border-bottom: 1px solid #eee; font-size: 0.9rem; }
.added-item:last-child { border-bottom: none; }

/* コード入力エリア */
.code-input-area { width: 100%; height: 150px; padding: 10px; border: 1px solid #ccc; border-radius: 8px; font-family: monospace; font-size: 1rem; resize: none; }
