:root {
  /* パステルピンクから水色への可愛いグラデーション */
  --bg-gradient: linear-gradient(135deg, #fbc2eb 0%, #a6c1ee 100%);
  --glass-bg: rgba(255, 255, 255, 0.6);
  --glass-border: rgba(0, 0, 0, 0.1);
  /* パステルテーマに合わせ、区切り線を白ではなく薄いグレーに変更 */
  --primary-color: #ff8eaa;
  /* 可愛いピンク */
  --secondary-color: #a6c1ee;
  /* 水色 */
  --completed-color: #ff1493;
  /* ショッキングピンク（以前はパステルグリーン #a8e6cf） */
  --box-size: 32px;
}

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: #4a4a4a;
  /* ダークグレーのテキストで可読性を確保 */
  margin: 0;
  height: 100vh;
  /* iOS Safari fallback */
  height: -webkit-fill-available;
  height: 100dvh;
  overflow: hidden;
  /* ページ全体のスクロールを禁止 */
}

/* 全体レイアウトの固定化 */
.container-fluid {
  height: 100vh;
  /* iOS Safari fallback */
  height: -webkit-fill-available;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: 0 !important;
}

header {
  flex-shrink: 0;
  /* ヘッダーの高さを維持 */
}

.footer-controls {
  flex-shrink: 0;
  /* フッターの高さを維持 */
  padding-top: 0.5rem;
  padding-bottom: 0.5rem !important;
  background: var(--bg-gradient);
  /* 背景を透けないようにする */
  z-index: 10;
}

.bg-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
  /* 影を薄く柔らかく */
}

/* メインの中央タスク一覧エリアのみスクロールさせる */
.main-content {
  flex-grow: 1;
  overflow-y: auto;
  overflow-x: auto;
  min-height: 0;
  /* Flexbox内でコンテンツが溢れた際にスクロールバーを出すための必須設定 */
}

.logo-title {
  background: linear-gradient(to right, #ff8eaa, #84aef2);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
  font-size: 2.0rem;
  /* メインロゴを大きく目立たせる */
  margin-bottom: 0;
}

.line-height-1 {
  line-height: 1;
}

/* Modal Styling */
.modal-content {
  background: rgba(255, 255, 255, 0.95);
  color: #555;
  border: 1px solid var(--glass-border);
}

.modal-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* Grid Layout for Tasks */
.stack-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-bottom: 1rem;
  width: max-content;
  /* 子要素の最大幅に合わせる */
  min-width: 100%;
  /* コンテナより小さい場合は100% */
}

.task-row,
.calendar-header {
  display: flex;
  align-items: stretch;
  width: 100%;
  /* stack-grid の幅いっぱいに広げる */
  border-bottom: 1px solid var(--glass-border);
  /* 行の区切り線 */
}

.calendar-header {
  font-size: 0.85rem;
  color: #777;
  margin-bottom: 0;
  position: sticky;
  top: 0;
  z-index: 10;
  background: #ffffff;
  border-bottom: 2px solid var(--glass-border);
  padding-top: 0.5rem;
}

/* Left Section: Task Info */
.task-info {
  position: sticky;
  left: 0;
  background: #ffffff;
  z-index: 2;
  width: 250px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  /* 高さを圧縮 */
  border-radius: 0;
  border-right: 2px solid rgba(0, 0, 0, 0.15);
  margin-right: 0;
  transition: background 0.2s ease;
}

/* ドロップダウンメニューのキャレットを非表示にする（任意） */
.task-menu-dropdown .dropdown-toggle::after {
  display: none;
}

.task-row:hover .task-info,
.task-row:focus-within .task-info {
  background: #fdfdfd;
  z-index: 20;
  /* 下の行の設定(z-index:2)より上に表示させ、ドロップダウンが隠れないようにする */
}

.calendar-header .task-info {
  background: #ffffff;
  border: none;
  box-shadow: none;
  padding: 0;
  justify-content: flex-end;
  z-index: 11;
  /* 左側（横スクロール固定）かつ上部（縦スクロール固定）のため一番手前に */
}

/* Drag & Drop Handle */
.drag-handle {
  cursor: grab;
  color: #bbb;
  font-size: 1.2rem;
  padding-right: 8px;
  display: flex;
  align-items: center;
  transition: color 0.2s;
  touch-action: none;
  /* スマホでドラッグ時に画面スクロールするのを防ぐ */
}

.drag-handle:hover {
  color: var(--primary-color);
}

.drag-handle:active {
  cursor: grabbing;
}

/* SortableJS Ghost & Drag states */
.sortable-ghost {
  opacity: 0.4;
  background-color: #f0f4ff;
}

.sortable-drag {
  cursor: grabbing !important;
}

.task-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: #4a4a4a;
  margin-bottom: 0.25rem;
}

/* Section Header Styles - Refined as a thin colored bar */
.task-row.section-header {
  height: 12px;
  /* 最小限の高さ */
  background: rgba(166, 193, 238, 0.4);
  /* パステルブルーの透過 */
  border: none;
  min-height: 12px;
}

.task-row.section-header .task-info {
  background: transparent !important;
  /* 行の背景色を活かす */
  border-right: none;
  width: 250px;
  height: 12px;
  padding: 0;
  overflow: visible;
}

/* セクション名のテキストとメニューを通常は隠す */
.task-row.section-header .task-name,
.task-row.section-header .task-menu-dropdown {
  display: none;
}

/* ホバー時に操作できるようにする */
.task-row.section-header:hover {
  height: 32px;
  /* 操作しやすい高さに広げる */
  background: rgba(166, 193, 238, 0.8);
}

.task-row.section-header:hover .task-info {
  background: #ffffff !important;
  border-right: 2px solid var(--secondary-color);
  height: 32px;
  padding: 0.25rem 0.5rem;
}

.task-row.section-header:hover .task-name,
.task-row.section-header:hover .task-menu-dropdown,
.task-row.section-header:hover .drag-handle {
  display: block !important;
}

.task-row.section-header:hover .task-name {
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--secondary-color);
}

.task-row.section-header .calendar-days {
  flex-grow: 1;
  background: transparent;
  position: relative;
  height: 100%;
}

.task-row.section-header:hover .calendar-days {
  background: repeating-linear-gradient(90deg,
      transparent,
      transparent calc(var(--box-size) - 1px),
      rgba(0, 0, 0, 0.05) calc(var(--box-size) - 1px),
      rgba(0, 0, 0, 0.05) var(--box-size));
}

.task-total {
  color: var(--primary-color);
  font-weight: 700;
}

/* Right Section: Calendar Grid */
.calendar-days {
  display: flex;
  gap: 0;
  /* マス目を繋げるためにgapを0に */
  align-items: stretch;
  /* 縦線を上下に繋げるためにstretchに変更 */
}

.day-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: var(--box-size);
  border-right: 1px solid var(--glass-border);
  /* 列の区切り線 */
  padding: 4px 0;
  /* 少し余白を持たせる */
}

/* 月替わりの境界線（翌月1日の左側）を少し目立たせる */
.day-column.month-divider,
.day-header.month-divider {
  border-left: 2px solid rgba(0, 0, 0, 0.15);
}

.day-header {
  width: var(--box-size);
  text-align: center;
  border-right: 1px solid var(--glass-border);
  /* ヘッダーの列区切り線 */
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.day-name {
  font-size: 0.65rem;
  font-weight: normal;
}

.day-box {
  width: calc(var(--box-size) - 2px);
  height: calc(var(--box-size) - 2px);
  border-radius: 4px;
  /* セルっぽさを出すために少しだけ角丸にする */
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.75rem;
  /* 枠内の目標量テキストサイズ */
  color: #88a;
}

.day-box:hover {
  background: rgba(255, 255, 255, 0.8);
  z-index: 10;
}

/* ロック状態のマス目（未完了） */
.day-box.locked:not(.completed) {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ロック状態のマス目（完了済みの過去日） */
.day-box.locked.completed {
  cursor: not-allowed;
  opacity: 1;
  /* 色を薄くしない！ */
}

.day-box.completed {
  background: var(--completed-color);
  border-color: var(--completed-color);
  color: #ffffff;
  /* 完了時はテキスト色を白にしてくっきり見せる */
  font-weight: bold;
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.3);
  /* 明るい内側のシャドウ */
  transform: none;
  /* Scaleをやめることで罫線崩れを防ぐ */
}

/* ⚪︎×型（記録のみ）の強調表示 */
.day-box[data-task-type="check"] {
  font-weight: bold;
}

.day-box[data-task-type="check"].completed {
  font-size: 1.5rem;
  font-weight: 900;
}

/* 達成時に弾ける累積バブルのアニメーションとスタイル */
.total-bubble {
  position: absolute;
  bottom: 70%;
  /* セルの少し上からスタート */
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #ff1493, #ff69b4);
  color: white;
  font-weight: 900;
  font-size: 0.85rem;
  padding: 4px 12px;
  border-radius: 20px;
  box-shadow: 0 4px 15px rgba(255, 20, 147, 0.6);
  pointer-events: none;
  /* クリックを邪魔しない */
  white-space: nowrap;
  animation: bubbleBurst 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  z-index: 100;
}

@keyframes bubbleBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px) scale(0.5);
  }

  20% {
    opacity: 1;
    transform: translate(-50%, -15px) scale(1.2);
  }

  80% {
    opacity: 0.9;
    transform: translate(-50%, -25px) scale(1.1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -45px) scale(1.5);
  }
}

/* Today Highlighter */
.day-header.today {
  color: var(--primary-color);
  font-weight: bold;
}

.day-box.today:not(.completed) {
  border-color: var(--primary-color);
}

/* Celebration Animation for Box */
@keyframes superPop {
  0% {
    transform: scale(0.8) translateY(0);
    opacity: 0.5;
    box-shadow: 0 0 0 rgba(255, 20, 147, 0);
  }

  40% {
    transform: scale(1.3) translateY(-8px) rotate(-3deg);
    background-color: #ff3399;
    /* さらに明るいピンク */
    box-shadow: 0 0 20px rgba(255, 20, 147, 0.8), 0 0 40px rgba(255, 20, 147, 0.4);
    opacity: 1;
  }

  70% {
    transform: scale(0.95) translateY(2px) rotate(2deg);
    box-shadow: 0 0 10px rgba(255, 20, 147, 0.5);
  }

  100% {
    transform: scale(1) translateY(0) rotate(0deg);
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.3);
  }
}

.day-box.animating {
  animation: superPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  position: relative;
  z-index: 10;
  /* 他のセルより前面に出す */
}

/* Scrollbar customization */
::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* =========================================================================
   Responsive Design (Smartphone screens)
   ========================================================================= */
@media (max-width: 768px) {
  :root {
    --box-size: 36px;
    /* スマホではタップしやすく少し大きくする */
  }

  /* 画面全体の余白を減らす */
  .container-fluid {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }

  .main-content {
    padding: 0 !important;
    border-radius: 12px;
  }

  /* ヘッダーの折り返しレイアウト最適化 */
  header {
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center !important;
    text-align: center;
  }

  header>div {
    flex-wrap: wrap;
    justify-content: center;
  }

  #current-month-display {
    font-size: 1.2rem;
  }

  /* 左側のタスク情報エリアのコンパクト化 */
  .task-info {
    width: 120px;
    /* 大幅に縮小してカレンダー領域を確保 */
    padding: 0.5rem;
  }

  .task-name {
    font-size: 0.95rem;
    white-space: normal;
    word-break: break-all;
    line-height: 1.2;
    margin-bottom: 0.2rem;
  }



  /* 削除ボタンの微調整 */
  .delete-task-btn {
    font-size: 0.8rem;
    padding: 0 4px !important;
  }
}

/* Bootstrap Overrides for Pastel Theme */
.btn-primary {
  background-color: var(--primary-color) !important;
  border-color: var(--primary-color) !important;
  color: #fff !important;
}

.btn-primary:hover {
  background-color: #ff7597 !important;
  border-color: #ff7597 !important;
}

.text-danger {
  color: #ff8eaa !important;
  /* 日曜日などを柔らかい赤(ピンク)に */
}

.text-info {
  color: #84aef2 !important;
  /* 土曜日などを柔らかい水色に */
}

/* Update Notification Toast */
.update-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(150px);
  z-index: 1050;
  /* モーダルより手前に表示可能なら手前。ただモーダル裏でも許容 */
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  width: 90%;
  max-width: 400px;
  pointer-events: none;
  /* 非表示時はクリック干渉しない */
}

.update-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
  /* 表示時はクリック有効化 */
}