/* ===== リセット & 基本 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #EF6C6C;
  --primary-light: #FFF0F0;
  --today-bg:      #EF6C6C;
  --today-text:    #ffffff;
  --sun-color:     #E53935;
  --sat-color:     #1976D2;
  --border:        #E8E8E8;
  --text:          #333333;
  --text-light:    #aaaaaa;
  --bg:            #F5F5F5;
  --cell-bg:       #ffffff;
  --header-bg:     #ffffff;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Meiryo', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ===== ログイン画面 ===== */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #FFF5F5, #FFE4E4);
}
.login-box {
  text-align: center;
  background: white;
  padding: 48px 40px;
  border-radius: 20px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.login-box h1 { font-size: 28px; margin-bottom: 12px; color: var(--primary); }
.login-box p  { color: var(--text-light); margin-bottom: 28px; font-size: 15px; }
.login-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 14px 32px;
  border-radius: 50px;
  font-size: 16px;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.2s;
}
.login-btn:hover { opacity: 0.85; }

/* ===== アプリ全体 ===== */
#app { width: 100%; overflow-x: hidden; }

/* ===== ヘッダー共通 ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--header-bg);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.header-center {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-spacer { width: 72px; }

#month-title, #day-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
}

.nav-btn {
  background: none;
  border: none;
  font-size: 26px;
  color: #cccccc;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 8px;
  line-height: 1;
}

.today-btn {
  background: var(--primary-light);
  color: var(--primary);
  border: 1.5px solid var(--primary);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 700;
}

/* 日表示 戻るボタン */
.day-back-btn {
  display: flex;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  white-space: nowrap;
}
.day-back-arrow { font-size: 22px; line-height: 1; color: #cccccc; }

/* ===== 天気バー（月表示） ===== */
.weather-bar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}
.weather-bar::-webkit-scrollbar { display: none; }
.weather-loading { color: var(--text-light); font-size: 13px; }
.weather-week { display: flex; gap: 4px; min-width: max-content; }
.weather-day-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 8px;
  border-radius: 10px;
  min-width: 46px;
}
.weather-day-item.today { background: var(--primary-light); }
.weather-day-label { font-size: 10px; color: var(--text-light); font-weight: 700; }
.weather-day-emoji { font-size: 18px; line-height: 1.2; }
.weather-day-temp  { font-size: 10px; white-space: nowrap; }
.weather-day-temp span:first-child { color: #E53935; font-weight: 700; }
.weather-day-temp span:last-child  { color: #1976D2; }

/* ===== 曜日ヘッダー ===== */
.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: white;
  border-bottom: 1px solid var(--border);
  width: 100%;
}
.weekday { text-align: center; padding: 6px 0; font-size: 11px; font-weight: 700; color: var(--text-light); }
.weekday.sun { color: var(--sun-color); }
.weekday.sat { color: var(--sat-color); }

/* ===== カレンダーグリッド ===== */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--border);
  gap: 1px;
  width: 100%;
}

/* ===== セル ===== */
.day-cell {
  background: var(--cell-bg);
  min-height: 120px;
  min-width: 0;
  overflow: hidden;
  padding: 2px 0;
  position: relative;
  cursor: pointer;
  transition: background 0.1s;
}
.day-cell:active { background: #FFF5F5; }
.day-cell.other-month { background: #F8F8F8; }
.day-cell.other-month .date-number { color: #DDDDDD; }
.day-cell.today .date-number {
  background: var(--today-bg);
  color: var(--today-text);
  border-radius: 50%;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 5px rgba(239,108,108,0.4);
  margin: 0 0 1px 2px;
}
.date-number {
  font-size: 13px; font-weight: 700; color: var(--text);
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 0 1px 2px;
}
/* 月曜始まり：6列目=土、7列目=日 */
.day-cell:nth-child(7n+6) .date-number { color: var(--sat-color); }
.day-cell:nth-child(7n+6).today .date-number { color: white; }
.day-cell:nth-child(7n)   .date-number { color: var(--sun-color); }
.day-cell:nth-child(7n).today   .date-number { color: white; }

/* 天気アイコン（右上） */
.cell-weather {
  position: absolute; top: 3px; right: 1px;
  display: flex; flex-direction: column; align-items: center;
  pointer-events: none;
}
.cell-weather-icon { font-size: 13px; line-height: 1.1; }
.cell-weather-temp { font-size: 8.5px; line-height: 1.2; text-align: center; white-space: nowrap; }
.cell-weather-temp .temp-max { color: #E53935; font-weight: 700; }
.cell-weather-temp .temp-min { color: #1976D2; }

/* イベントピル */
.events-list { margin-top: 1px; display: flex; flex-direction: column; gap: 1px; width: 100%; overflow: hidden; }
.event-pill {
  display: block; font-size: 9px; padding: 1px 3px; border-radius: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 600; color: white; width: 100%; max-width: 100%; line-height: 1.45;
}
.cal-hasumi  { background: #4A90E2; }
.cal-yuji    { background: #5BAD6F; }
.cal-aoki    { background: #F5A623; }
.cal-haruki  { background: #FF6B9D; }
.cal-yakyu   { background: #9B59B6; }
.cal-default { background: #90A4AE; }

/* ===== 日表示ビュー ===== */
.day-weather-card {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}
.day-weather-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}
.day-w-emoji  { font-size: 28px; }
.day-w-temps  { font-size: 16px; }
.day-w-temps .temp-max { color: #E53935; font-weight: 700; }
.day-w-temps .temp-min { color: #1976D2; }

.day-events-list {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
}

.day-event-card {
  display: flex;
  align-items: stretch;
  background: white;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  padding: 12px 16px 12px 0;
  transition: background 0.1s;
  gap: 0;
}
.day-event-card:active { background: #F9F9F9; }

.day-event-color-bar {
  width: 4px;
  border-radius: 2px;
  margin: 0 12px 0 16px;
  flex-shrink: 0;
}

.day-event-info { flex: 1; min-width: 0; }
.day-event-time {
  font-size: 11px;
  color: var(--text-light);
  margin-bottom: 2px;
}
.day-event-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.day-event-cal {
  font-size: 11px;
  margin-top: 2px;
  font-weight: 600;
}

.day-event-chevron {
  font-size: 20px;
  color: #CCCCCC;
  display: flex;
  align-items: center;
  padding-left: 8px;
}

.day-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}
.day-empty p     { font-size: 16px; }
.day-empty-hint  { font-size: 13px; margin-top: 8px; }

/* ===== FAB ===== */
.fab {
  position: fixed;
  bottom: 24px;
  right: 20px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 28px;
  border: none;
  box-shadow: 0 4px 14px rgba(239,108,108,0.45);
  cursor: pointer;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab:active { transform: scale(0.93); box-shadow: 0 2px 8px rgba(239,108,108,0.3); }

/* ===== 同期・ログアウトエリア ===== */
.bottom-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 24px auto 80px;
}

.sync-btn {
  background: #E8F5E9;
  color: #2E7D32;
  border: 1.5px solid #A5D6A7;
  padding: 10px 28px;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  letter-spacing: 0.02em;
}
.sync-btn:active  { transform: scale(0.96); opacity: 0.8; }
.sync-btn:disabled { opacity: 0.55; cursor: default; }

/* ===== ログアウト ===== */
.logout-btn {
  display: block;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-light);
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
}

/* ===== モーダル共通 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: flex;
  align-items: flex-end;
}
.modal-sheet {
  background: white;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  animation: slideUp 0.22s ease;
}
@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; justify-content: center; }
  .modal-sheet   { border-radius: 16px; max-width: 460px; width: 100%; }
}
.modal-drag-handle {
  width: 36px; height: 4px;
  background: #E0E0E0; border-radius: 2px;
  margin: 12px auto 0;
}
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 20px;
  border-top: 1px solid var(--border);
}
.modal-footer-right { display: flex; gap: 8px; }

/* ===== 予定詳細 ===== */
.detail-color-bar { height: 5px; margin-top: 6px; }
.detail-body      { padding: 12px 16px 16px; }
.detail-cal-name  { font-size: 12px; font-weight: 700; color: var(--text-light); margin-bottom: 6px; }
.detail-title     { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 8px; line-height: 1.3; }
.detail-meta      { font-size: 14px; color: var(--text-light); }
.detail-memo      {
  font-size: 14px; color: var(--text);
  white-space: pre-wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ===== ボタン ===== */
.btn-primary {
  background: var(--primary); color: white;
  border: none; padding: 9px 20px;
  border-radius: 20px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.btn-secondary {
  background: none; color: var(--text-light);
  border: 1px solid var(--border); padding: 8px 18px;
  border-radius: 20px; font-size: 14px; cursor: pointer;
}
.btn-danger-text { background: none; border: none; color: #E53935; font-size: 14px; cursor: pointer; padding: 8px 4px; }

/* ===== 予定フォーム（Google Calendar風） ===== */
.form-sheet { border-radius: 20px 20px 0 0; }

.form-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
}
.form-topbar span {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.form-cancel-x {
  background: none; border: none;
  font-size: 18px; color: var(--text-light);
  cursor: pointer; padding: 4px 8px;
  line-height: 1;
}
.form-save-top {
  background: var(--primary); color: white;
  border: none; padding: 7px 18px;
  border-radius: 20px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.form-save-top:disabled { opacity: 0.6; }

.form-body { padding: 0 0 24px; }

/* タイトル行 */
.form-title-row {
  display: flex;
  align-items: center;
  padding: 14px 16px 12px;
  border-bottom: 2px solid var(--primary);
  gap: 14px;
}
.form-icon-placeholder { width: 22px; flex-shrink: 0; }
.form-title-input {
  flex: 1;
  font-size: 20px;
  font-weight: 600;
  border: none;
  outline: none;
  background: none;
  color: var(--text);
  font-family: inherit;
}
.form-title-input::placeholder { color: #CCCCCC; font-weight: 400; }

/* フォーム各行 */
.form-row {
  display: flex;
  align-items: flex-start;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  gap: 14px;
}
.form-row:last-child { border-bottom: none; }

/* カレンダー選択 */
.form-icon-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 1px;
  background: #4A90E2;
}
.form-cal-display {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  color: var(--text);
  cursor: pointer;
  position: relative;
}
.form-cal-arrow { color: var(--text-light); font-size: 14px; }
.form-cal-select-hidden {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  opacity: 0;
  font-size: 16px;
  cursor: pointer;
}

/* select が form-cal-row の中に収まるよう position:relative を付ける */
#form-cal-row {
  position: relative;
}

/* 日時行 */
.form-row-datetime { align-items: flex-start; }
.form-icon-cal { font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.form-datetime-fields { flex: 1; display: flex; flex-direction: column; gap: 10px; }

.form-allday-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.form-allday-label { font-size: 16px; color: var(--text); }

.form-date-row { }
.form-date-input {
  font-size: 16px;
  color: var(--text);
  border: none;
  outline: none;
  background: none;
  font-family: inherit;
  width: 100%;
  cursor: pointer;
}

.form-time-row { display: flex; align-items: center; gap: 8px; }
.form-time-input {
  font-size: 16px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  outline: none;
  background: none;
  font-family: inherit;
  cursor: pointer;
  flex: 1;
}
.form-time-sep { font-size: 14px; color: var(--text-light); }

/* メモ行 */
.form-row-memo { align-items: flex-start; }
.form-icon-note { font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.form-memo-input {
  flex: 1;
  font-size: 15px;
  border: none;
  outline: none;
  background: none;
  resize: none;
  font-family: inherit;
  color: var(--text);
  line-height: 1.5;
}
.form-memo-input::placeholder { color: #CCCCCC; }

/* トグルスイッチ */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px; height: 26px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #ccc; border-radius: 26px;
  transition: 0.2s; cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 3px;
  background: white; border-radius: 50%;
  transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider             { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before     { transform: translateX(18px); }

/* ===== レスポンシブ（PC） ===== */
@media (min-width: 768px) {
  #app { max-width: 900px; margin: 0 auto; }
  .day-cell    { min-height: 120px; padding: 6px 0; }
  .date-number { font-size: 15px; width: 28px; height: 28px; }
  .day-cell.today .date-number { width: 28px; height: 28px; }
  .event-pill  { font-size: 12px; padding: 2px 5px; border-radius: 4px; }
  .cell-weather-icon { font-size: 16px; }
  .cell-weather-temp { font-size: 9px; }
  #month-title { font-size: 20px; }
  .fab { right: calc(50% - 430px); }
}
