/* リセット & 基本スタイル */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Roboto', 'Noto Sans JP', sans-serif; transition: background-color 0.3s, color 0.3s; }

/* --- テーマ変数 --- */
:root {
  --primary: #4a90e2; --accent: #50e3c2; --danger: #e24a4a; --bg: #f5f7fa;
  --card: #fff; --text: #333; --text-muted: #999; --border: #eee;
  --progress-bg: #e0e0e0;
  --progress-fill: linear-gradient(90deg, #50e3c2, #4a90e2);
}
body.theme-ocean {
  --primary: #4a90e2; --accent: #50e3c2; --bg: #f5f7fa; --card: #fff; --text: #333;
}
body.theme-forest {
  --primary: #4caf50; --accent: #81c784; --bg: #f1f8e9; --card: #fff; --text: #2e3c30;
}
body.theme-dark {
  --primary: #64b5f6; --accent: #4dd0e1; --bg: #121212; --card: #1e1e1e; --text: #e0e0e0; --text-muted: #888; --border: #333;
}
body.theme-high-contrast {
  --primary: #00ff00; --accent: #00ff00; --bg: #000; --card: #0a0a0a; --text: #00ff00; --text-muted: #00cc00; --border: #0f0;
}
body.theme-sakura {
  --primary: #ff8fab; --accent: #f8c8dc; --bg: #fff0f5; --card: #fff; --text: #6b4b4b;
}
body.theme-sunset {
  --primary: #ff8a65; --accent: #ffb74d; --bg: #fff3e0; --card: #fff; --text: #4e342e;
}

/* --- コンテナとヘッダー --- */
body { background-color: var(--bg); color: var(--text); }
.container { max-width: 95%; margin: 20px auto; padding: 0 20px; }
header { text-align: center; margin-bottom: 20px; }
header h1 { font-weight: 500; color: var(--primary); }

/* --- ステータス表示 --- */
#status {
  position: relative; background-color: var(--card); padding: 20px; border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1); text-align: center; margin-bottom: 20px;
  min-height: 200px; display: flex; flex-direction: column; justify-content: center;
  font-size: calc(1rem * var(--font-size-multiplier, 1)); overflow: hidden;
}
.current-time {
  position: absolute;
  top: 10px;
  left: 15px;
  color: var(--text-muted);
  font-size: calc(1rem * var(--clock-font-size-multiplier, 1));
  z-index: 2;
  white-space: pre-line;
  line-height: 1.25;
  text-align: left;
}
.current-time .offset-inline {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.9em;
  opacity: 0.9;
  white-space: nowrap;
}

/* 臨時変更適応中の表示 */
.temp-status-display {
  position: absolute;
  top: 32px; /* current-timeの下 */
  left: 15px;
  font-size: 0.75rem;
  color: var(--danger);
  opacity: 0.8;
  z-index: 2;
  font-weight: 500;
}

/* 共通スタイル */
.current-subject { font-size: 1.2em; font-weight: 500; color: var(--primary); }
.status-message { font-size: 1.8em; font-weight: bold; transition: color 0.3s; }
.next-subject { font-size: 1.1em; color: var(--text-muted); }
.progress-bar-container { width: 100%; max-width: 400px; background-color: var(--progress-bg); border-radius: 8px; height: 20px; margin-top: 15px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--progress-fill); transition: width 0.5s ease-out; }
.pre-class-warning { color: var(--danger) !important; font-weight: bold; }

/* 多表示モード */
#multiDisplay { 
  display: grid; 
  grid-template-columns: 1fr;
  gap: 10px; 
  width: 100%; 
  height: auto;
}

/* 画面幅が600px以上の場合 */
@media (min-width: 600px) {
  #multiDisplay { 
    grid-template-columns: 0.7fr 1.8fr 1.5fr;
  }
}

/* 画面幅が900px未満の場合は2列レイアウト */
@media (min-width: 600px) and (max-width: 1200px) {
  #multiDisplay { 
    grid-template-columns: 1fr 2fr;
    gap: 12px;
  }
  #multiDisplay-left-side {
    grid-column: 1;
    grid-row: 1;
  }
  #multiDisplay-main {
    grid-column: 2;
    grid-row: 1 / 3;
  }
  #multiDisplay-side {
    grid-column: 1;
    grid-row: 2;
  }
}

/* 画面幅が1200px以上の場合は3列レイアウト */
@media (min-width: 1200px) {
  #multiDisplay { 
    grid-template-columns: 0.7fr 1.8fr 1.5fr;
  }
  #multiDisplay-left-side {
    grid-column: 1;
  }
  #multiDisplay-main {
    grid-column: 2;
  }
  #multiDisplay-side {
    grid-column: 3;
  }
}

#multiDisplay-left-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-grow: 1;
  height: auto;
}
#multiDisplay-top-widgets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}
#multiDisplay-main { 
  display: flex; 
  flex-direction: column; 
  justify-content: center; 
  align-items: center; 
  min-height: 250px;
  padding: 15px;
  width: 100%;
}
#multiDisplay-main .status-message { font-size: 2em; font-weight: bold; }
#multiDisplay-main .current-subject { font-size: 1.2em; }
#multiDisplay-main .next-subject { font-size: 1em; }
#multiDisplay-side {
  display: flex;
  flex-direction: row;
  gap: 12px;
  overflow-x: auto;
  max-height: auto;
  padding-right: 0;
  min-width: 320px;
  width: auto;
}

/* 画面幅が600px以上で列方向に変更 */
@media (min-width: 600px) {
  #multiDisplay-side {
    flex-direction: column;
    overflow-x: visible;
    overflow-y: auto;
    max-height: 100%;
    padding-right: 10px;
    min-width: 320px;
    width: auto;
    max-width: none;
    flex-shrink: 0;
  }
}
.side-panel-widget { 
  background: var(--bg); 
  padding: 10px; 
  border-radius: 6px; 
  position: relative;
  overflow: hidden;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.side-panel-widget { background: var(--bg); padding: 10px; border-radius: 6px; position: relative; }
.side-panel-widget h3 { font-size: 1rem; color: var(--primary); margin-bottom: 5px; border-bottom: 1px solid var(--border); padding-bottom: 5px; display: flex; justify-content: space-between; align-items: center; }
.widget-config-btn { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1rem; padding: 0 5px; }
.widget-config-btn:hover { color: var(--primary); }

#multiDisplay-timetableList { list-style: none; padding: 0; font-size: 0.9rem; }
#multiDisplay-timetableList li { display: flex; justify-content: space-between; padding: 4px; border-radius: 3px; }
#multiDisplay-timetableList li.current { background-color: var(--primary); color: white; }
#multiDisplay-timetableList li .period-name { font-weight: 500; }
#multiDisplay-timetableList li .subject-name { color: var(--text); }
#multiDisplay-timetableList li.current .subject-name { color: white; }
#multiDisplay-timetableList li .time-range { color: var(--text-muted); font-size: 0.8rem; }
#multiDisplay-timetableList li.current .time-range { color: rgba(255,255,255,0.8); }

/* イベントカウントダウンウィジェット */
#eventWidgetContent { text-align: center; padding: 10px 0; flex-grow: 1; display: flex; flex-direction: column; justify-content: center; }
.event-title { font-weight: bold; font-size: 1.1em; margin-bottom: 5px; color: var(--text); }
.event-countdown-wrapper { font-size: 1.4em; color: var(--primary); font-weight: bold; }
.event-countdown-unit { font-size: 0.6em; color: var(--text-muted); margin-left: 2px; }
.event-message { font-size: 0.9em; color: var(--text-muted); margin-bottom: 2px; }

/* 左サイドバーのステータスメッセージ */
#multiDisplay-left-statusMessage-content { font-size: 0.9rem; color: var(--text); width: auto; height: 100%; display: flex; flex-direction: column; }

/* ===== 時間割ウィジェット - シンプル再設計 ===== */
.timetable-widget {
  display: flex !important;
  flex-direction: column !important;
  padding: 8px !important;
  gap: 0 !important;
  height: 100% !important;
  min-height: 0 !important;
  --tt-font-size: 1rem;
  overflow: hidden !important;
}

.timetable-widget h3 {
  margin: 0 0 6px 0 !important;
  padding: 0 0 4px 0 !important;
  border-bottom: 2px solid var(--primary) !important;
  font-size: 0.95rem !important;
  font-weight: bold !important;
  color: var(--text) !important;
  flex-shrink: 0;
}

#timetable-content {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-height: 0;
  overflow-y: auto;
}

.tt-grid {
  display: grid;
  grid-template-columns: 1fr 0.75fr;
  gap: 6px;
  width: 100%;
  min-height: 100%;
  height: auto;
  overflow: visible;
}

.tt-column {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: visible;
  min-height: 0;
}

.tt-day-label {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--primary);
  text-align: center;
  padding: 2px 0;
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}

.tt-row {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 4px;
  padding: 3px 4px;
  border-left: 3px solid var(--border);
  overflow: hidden;
  line-height: 1.2;
  align-items: center;
  flex-shrink: 0;
}

.tt-row.tt-current {
  background: rgba(255, 193, 7, 0.35);
  border-left-color: var(--danger);
  border-left-width: 4px;
  font-weight: bold;
}

.tt-row.tt-tomorrow {
  opacity: 0.65;
  border-left-color: var(--text-muted);
}

.tt-period {
  font-weight: bold;
  font-size: calc(var(--tt-font-size) * 0.95);
  color: var(--primary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
}

.tt-subject {
  font-size: var(--tt-font-size);
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
}


/* サイドバーの幅自動調整 */
#multiDisplay-side { 
  width: auto;
  min-width: 280px;
  max-width: none;
  overflow-x: visible;
  flex-shrink: 0;
}
#multiDisplay-left-side {
  width: auto;
  max-width: none;
  min-width: 0;
}

#memoPad { width: 100%; min-height: 150px; resize: both; border: 1px solid var(--border); border-radius: 4px; padding: 5px; font-size: 0.9rem; background-color: white; color: var(--text); overflow: auto; }
#memoPad:disabled { cursor: not-allowed; resize: none; }
#memoHelpers { margin-top: 10px; }
#memoHelpers h4 { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 5px; text-align: left; }
#memoHelpers-buttons { display: flex; flex-wrap: wrap; gap: 5px; }
.memo-helper-btn { background: var(--bg); border: 1px solid var(--border); color: var(--primary); padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 0.8rem; }
.memo-helper-btn:hover { background-color: var(--border); }
.memo-helper-btn:disabled { background-color: #f0f0f0; color: #999; cursor: not-allowed; border-color: #ddd; }

/* --- ダークモード時のメモ帳スタイル --- */
#memoLockStatus { display: none; margin-right: 8px; color: var(--danger); font-weight: bold; font-size: 0.85em; }
#memoLockStatus.locked { display: inline; }
body.theme-dark #memoPad {
  background-color: var(--card); /* ダークモードのカード背景色 */
  color: var(--text); /* ダークモードのテキスト色 */
  border-color: var(--border); /* ダークモードのボーダー色 */
}


/* --- 全画面表示スタイル --- */
#status:fullscreen { display: grid; grid-template-columns: 1fr 3.5fr 1fr; gap: 1.5vw; align-items: stretch; background: var(--card); color: var(--text); padding: 1.5vw; height: 100vh; user-select: none; }
#exitFullscreenBtn { display: none; }
#status:fullscreen #exitFullscreenBtn { display: block; position: fixed; top: 20px; right: 20px; z-index: 1001; padding: 10px 20px; background: rgba(0,0,0,0.5); color: white; border: none; border-radius: 5px; cursor: pointer; }
#status:fullscreen .current-time { position: fixed; color: var(--text-muted); opacity: 0.7; }
/* 全画面時の臨時時間割表示 */
#status:fullscreen .temp-status-display { position: fixed; top: 50px; left: 20px; color: var(--danger); text-shadow: 0 0 2px rgba(0,0,0,0.5); }


/* 全画面 + 多表示モード */
#status:fullscreen #multiDisplay {
  display: contents;
}
#status:fullscreen #multiDisplay-left-side {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  gap: 1.2vw;
  flex-grow: 1;
}
#status:fullscreen #multiDisplay-main {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1.5vw;
}
#status:fullscreen #multiDisplay-side {
  grid-column: 3;
  display: flex;
  flex-direction: column;
  gap: 1.2vw;
  max-height: 100%;
}
#status:fullscreen #multiDisplay-main .status-message { font-size: 5.5vw; }
#status:fullscreen #multiDisplay-main .current-subject { font-size: 3vw; }
#status:fullscreen #multiDisplay-main .next-subject { font-size: 2.3vw; }
#status:fullscreen #memoPad { min-height: 250px; }
#status:fullscreen .side-panel-widget h3 { font-size: 1.5vw; }
#status:fullscreen .timetable-widget h3 { font-size: 1.5vw; }
#status:fullscreen .timetable-item { min-height: 50px; padding: 12px; }
#status:fullscreen .timetable-period { font-size: 1.2vw; }
#status:fullscreen .timetable-subject { font-size: 1vw; }
#status:fullscreen #multiDisplay-timetableList { font-size: 1.2vw; }
#status:fullscreen .event-countdown-wrapper { font-size: 2.5vw; }
#status:fullscreen .event-title { font-size: 1.5vw; }
#status:fullscreen #multiDisplay-left-statusMessage-content { font-size: 2.2vw; }


/* --- ボタン --- */
.main-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 20px; }
.toggle-btn { padding: 10px 20px; background: var(--primary); color: #fff; border: none; border-radius: 50px; cursor: pointer; font-size: 0.9rem; }

/* --- 設定パネル --- */
.config-panel { background-color: var(--card); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); overflow: hidden; max-height: 0; transition: all 0.5s ease-in-out; }
.config-panel.open { max-height: 150vh; overflow-y: auto; }
.unsaved-warning { color: var(--danger); text-align: center; font-weight: 500; margin-bottom: 10px; font-size: 0.9rem; }
.preset-manager { padding: 20px; }
.preset-manager:first-child { border-top: none; margin-top: 0; }
.preset-manager h2 { font-size: 1.2rem; color: var(--primary); text-align: center; margin-bottom: 15px; }
.preset-controls, .preset-save-new, .subject-preset-controls { display: flex; gap: 10px; justify-content: center; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
select, input[type="text"], input[type="time"], input[type="number"], input[type="datetime-local"] { padding: 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 1rem; background-color: var(--bg); color: var(--text); }
.preset-btn { background-color: var(--primary); color: white; border: none; cursor: pointer; padding: 8px 12px; border-radius: 4px; }
.preset-btn.danger { background-color: var(--danger); }
.save-btn { display: block; width: 100%; margin: 10px auto; padding: 12px 24px; background: var(--accent); color: var(--text); border-radius: 50px; font-size: 1rem; font-weight: 500; border: none; cursor: pointer; }

/* --- 設定パネル タブ --- */
.config-tabs { display: flex; border-bottom: 2px solid var(--border); padding: 0 20px; }
.config-tab-btn { padding: 10px 15px; cursor: pointer; border: none; background-color: transparent; color: var(--text-muted); font-size: 1rem; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.config-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }
.config-tab-panel { display: none; } .config-tab-panel.active { display: block; }

/* --- 使い方タブのスタイル --- */
#tab-how-to { padding: 16px 20px 24px; }
.how-to-section {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.how-to-section:last-child { border-bottom: none; margin-bottom: 0; }
.how-to-section h3 {
  color: var(--primary);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 10px;
}
.how-to-section p {
  line-height: 1.75;
  margin-bottom: 8px;
  font-size: 0.9rem;
}
.how-to-section ul {
  list-style: none;
  padding-left: 0;
  margin: 6px 0 8px;
}
.how-to-section li {
  position: relative;
  padding-left: 1.2em;
  margin-bottom: 6px;
  line-height: 1.65;
  font-size: 0.9rem;
}
.how-to-section li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
}
.how-to-section strong { color: var(--text); font-weight: 600; }
.how-to-section code {
  background: var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.85em;
  font-family: monospace;
}
.how-to-note {
  background: var(--bg);
  border-left: 3px solid var(--primary);
  border-radius: 0 6px 6px 0;
  padding: 8px 12px;
  margin-top: 8px;
  font-size: 0.88rem;
  line-height: 1.65;
}

/* --- テーブル & 教科エディタ --- */
#time-config-wrapper, #tab-subjects > .preset-manager { border-top: none; }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: center; padding: 12px; color: var(--primary); font-weight: 500; }
tbody tr:nth-child(odd) { background-color: rgba(0,0,0,0.02); }
tbody td { padding: 8px; text-align: center; } input[type="checkbox"] { transform: scale(1.3); cursor: pointer; }
#subject-editor-wrapper { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 15px; }
.subject-card { background-color: var(--bg); border-radius: 8px; padding: 15px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.subject-card.disabled { opacity: 0.6; }
.subject-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.subject-card-header .period-label { font-weight: 500; color: var(--primary); }
.subject-card-header .enable-toggle { display: flex; align-items: center; gap: 5px; }
.subject-card-body input { width: 100%; }
.subject-card-body input.custom-subject-input { margin-top: 8px; }

/* --- カスタムセレクト --- */
.cs-wrap { position: relative; width: 100%; }
.cs-trigger {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--bg); color: var(--text);
  font-size: 1rem; cursor: pointer; text-align: left;
  transition: border-color 0.15s;
}
.cs-trigger:hover:not(:disabled) { border-color: var(--primary); }
.cs-wrap.cs-open .cs-trigger { border-color: var(--primary); }
.cs-arrow { font-size: 0.75rem; color: var(--text-muted); transition: transform 0.2s; flex-shrink: 0; margin-left: 6px; }
.cs-wrap.cs-open .cs-arrow { transform: rotate(180deg); }
.cs-display { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-dropdown {
  display: none;
  position: fixed;
  z-index: 500;
  background: var(--card);
  border: 1px solid var(--primary);
  border-radius: 4px;
  max-height: 220px; overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.cs-wrap.cs-open .cs-dropdown { display: block; }
.cs-option {
  padding: 8px 10px; cursor: pointer; font-size: 0.95rem;
  transition: background 0.1s;
}
.cs-option:hover { background: var(--bg); }
.cs-option.cs-selected { color: var(--primary); font-weight: 600; }
.cs-disabled .cs-trigger { opacity: 0.55; cursor: not-allowed; }
.final-time-config { text-align: center; padding: 12px 0; }
.Clockbutton { z-index: 1000; background-color: var(--card); border: 1px solid var(--primary); color: var(--primary); padding: 8px 15px; text-decoration: none; border-radius: 5px; }

/* --- 詳細設定モーダル --- */
.modal-overlay { 
  position: fixed; 
  top: 0; 
  left: 0; 
  width: 100%; 
  height: 100%; 
  background: rgba(0,0,0,0.6); 
  display: flex; 
  justify-content: center; 
  align-items: center; 
  z-index: 999999; 
  user-select: auto;
  pointer-events: auto;
}
.modal-content { background: var(--card); color: var(--text); padding: 20px; border-radius: 8px; width: 90%; max-width: 500px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); max-height: 90vh; overflow-y: auto;}
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 20px; }
.modal-header h2 { color: var(--primary); }
.close-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }
.setting-section { margin-bottom: 20px; }
.setting-section h3 { margin-bottom: 10px; border-bottom: 1px solid var(--border); padding-bottom: 5px; color: var(--primary); }
.setting-section p { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 10px; }
.setting-control { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.setting-control-check { display: flex; align-items: center; gap: 10px; margin-bottom: 10px;}
.radio-group label { display: flex; align-items: center; gap: 5px; }
.modal-footer { margin-top: 20px; }
.theme-switcher { display: flex; justify-content: flex-start; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.theme-btn { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; background-clip: content-box; position: relative; }
.theme-btn.active { border-color: var(--primary); }
.theme-btn span { display: none; }
.theme-btn[data-theme="ocean"] { background-color: #4a90e2; }
.theme-btn[data-theme="forest"] { background-color: #4caf50; }
.theme-btn[data-theme="dark"] { background-color: #1e1e1e; }
.theme-btn[data-theme="high-contrast"] { background-color: #000; }
.theme-btn[data-theme="sakura"] { background-color: #ff8fab; }
.theme-btn[data-theme="sunset"] { background-color: #ff8a65; }

/* --- 臨時時間割用のスタイル --- */
.original-subject {
  text-decoration: line-through;
  color: var(--text-muted);
  font-size: 0.8em;
  margin-right: 5px;
}

.temp-subject {
  color: var(--danger);
  font-weight: bold;
}

/* 臨時変更エディタのスタイル */
#temp-schedule-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
  margin-bottom: 20px;
}

.temp-editor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  background-color: var(--bg);
  border-radius: 5px;
  border: 1px solid var(--border);
}

.temp-editor-label {
  font-weight: bold;
  flex: 1;
  color: var(--primary);
}

.temp-enable-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

.temp-enable-toggle input[type="checkbox"] {
  transform: scale(1);
}

.temp-editor-row.temp-editor-row-disabled {
  opacity: 0.7;
}

.temp-editor-input-group {
  flex: 2;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* 多表示モードリスト内での調整 */
#multiDisplay-timetableList li .subject-wrapper {
    display: inline-block;
}

/* --- レスポンシブデザイン --- */
/* タブレット・中サイズ: 1024px未満 */
@media (max-width: 1024px) {
  #multiDisplay {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  #multiDisplay-left-side {
    grid-column: 1;
  }
  #multiDisplay-main {
    grid-column: 1;
    min-height: 180px;
  }
  #multiDisplay-side {
    grid-column: 1;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
  #multiDisplay-main .status-message { font-size: 1.6em; }
  #multiDisplay-main .current-subject { font-size: 1em; }
}

/* スマートフォン・小サイズ: 768px未満 */
@media (max-width: 768px) {
  #multiDisplay {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  #multiDisplay-top-widgets {
    grid-template-columns: 1fr;
  }
  #multiDisplay-main {
    min-height: 150px;
    padding: 15px;
  }
  #multiDisplay-side {
    grid-template-columns: 1fr;
  }
  #multiDisplay-main .status-message { font-size: 1.5em; }
  #multiDisplay-main .current-subject { font-size: 1em; }
  #multiDisplay-main .next-subject { font-size: 0.9em; }
  .side-panel-widget {
    padding: 8px;
  }
  #memoPad {
    min-height: 60px;
  }
}

/* 超小サイズ: 480px以下 */
@media (max-width: 480px) {
  #multiDisplay {
    gap: 8px;
  }
  #multiDisplay-main {
    min-height: 120px;
    padding: 10px;
  }
  #multiDisplay-main .status-message { font-size: 1.2em; }
  #multiDisplay-main .current-subject { font-size: 0.9em; }
  .side-panel-widget h3 {
    font-size: 0.9rem;
  }
  #multiDisplay-timetableList { font-size: 0.8rem; }
  #memoPad {
    min-height: 50px;
    font-size: 0.8rem;
  }
}

/* イベント関連のスタイル */
.events-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
  padding: 10px;
  background-color: var(--bg);
  border-radius: 4px;
}

.event-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  justify-content: space-between;
}

.event-item-title {
  font-weight: 500;
  color: var(--text);
  flex-grow: 1;
}

.event-item-info {
  font-size: 0.8em;
  color: var(--text-muted);
}

.event-edit-btn {
  padding: 6px 12px;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background-color 0.2s;
}

.event-edit-btn:hover {
  background-color: #3a7bc8;
}

.event-countdown-wrapper {
  font-size: 1.2em;
  font-weight: bold;
  color: var(--primary);
  margin-top: 8px;
}

.event-countdown-unit {
  font-size: 0.8em;
  font-weight: normal;
  margin-left: 2px;
  margin-right: 8px;
  color: var(--text-muted);
}

/* イベントウィジェット用スタイル */
.event-widget-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.event-widget-item {
  padding: 12px;
  background-color: var(--bg);
  border-left: 3px solid var(--primary);
  border-radius: 2px;
  line-height: 1.4;
}

.event-widget-item.disabled {
  border-left-color: var(--text-muted);
  opacity: 0.6;
}

.event-widget-title {
  font-weight: 600;
  color: var(--primary);
  font-size: 1em;
  margin-bottom: 4px;
}

.event-widget-message {
  font-size: 0.85em;
  color: var(--text);
  margin-bottom: 6px;
}

.event-widget-countdown {
  font-size: 1.2em;
  font-weight: bold;
  color: var(--primary);
  margin-top: 6px;
  padding: 6px 0;
}

.event-widget-countdown span {
  display: inline-block;
  font-size: 0.75em;
  font-weight: normal;
  margin: 0 2px;
  color: var(--text-muted);
}

/* =================== Time Picker =================== */

/* テーブル内の時刻ボタン */
.time-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: 'Roboto', monospace;
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  min-width: 90px;
  transition: border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.time-btn::after {
  content: '▾';
  font-size: 0.75em;
  opacity: 0.45;
  margin-left: 2px;
}
.time-btn:hover, .time-btn:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
  outline: none;
}

/* バックドロップ */
.tp-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.35);
}
.tp-backdrop.tp-open { display: block; }

/* ポップアップカード */
.tp-popup {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9001;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px 24px 18px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
  min-width: 220px;
  text-align: center;
}
.tp-popup.tp-open { display: block; }

/* ヘッダーラベル */
.tp-header {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

/* スピナー行 */
.tp-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 14px;
}
.tp-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* ＋ / － ボタン */
.tp-arrow {
  width: 56px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.tp-arrow:hover, .tp-arrow:active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* 数値表示 + 単位ラベル */
.tp-val-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.tp-val {
  font-size: 2.6rem;
  font-weight: 700;
  font-family: 'Roboto', monospace;
  color: var(--text);
  min-width: 56px;
  text-align: center;
  cursor: ns-resize;
  user-select: none;
  -webkit-user-select: none;
  line-height: 1.15;
}
.tp-unit {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.tp-colon {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text);
  padding-bottom: 20px;
}

/* 分プリセット */
.tp-min-presets {
  margin-bottom: 12px;
}
.tp-preset-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
.tp-preset-btns {
  display: flex;
  gap: 5px;
  justify-content: center;
}
.tp-min-preset {
  flex: 1;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
  font-family: 'Roboto', monospace;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.tp-min-preset:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.tp-min-preset.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
}

/* リアルタイムプレビュー */
.tp-preview {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
  letter-spacing: 0.05em;
}

/* 操作ボタン行 */
.tp-actions {
  display: flex;
  gap: 8px;
}
.tp-cancel {
  flex: 1;
  padding: 11px 0;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
}
.tp-cancel:hover { background: var(--border); }
.tp-ok {
  flex: 1.6;
  padding: 11px 0;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.tp-ok:hover { opacity: 0.85; }