:root {
  --cream: #FFF8EE;
  --coral: #FF6F91;
  --coral-soft: #FFE3E9;
  --turquoise: #22C3BE;
  --turquoise-soft: #DFF6F5;
  --plum: #7B5EA7;
  --plum-soft: #EEE7F7;
  --yellow: #FFC93C;
  --yellow-soft: #FFF3D6;
  --navy: #2D2A4A;
  --navy-soft: #8B87A8;
  --white: #FFFFFF;
  --amber-text: #C9931B;
}

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

html, body {
  height: 100%;
}

body {
  background: linear-gradient(180deg, #FDF4E7 0%, var(--cream) 40%);
  font-family: 'Zen Maru Gothic', sans-serif;
  color: var(--navy);
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
a { color: inherit; }

/* ---------- レイアウト ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
  max-width: 1180px;
  margin: 0 auto;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  padding: 32px 20px;
  display: none;
  flex-direction: column;
  gap: 6px;
}

.logo {
  font-family: 'Fredoka', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--coral);
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-dot {
  width: 30px; height: 30px;
  background: var(--turquoise);
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

.side-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 14px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--navy-soft);
  text-align: left;
  width: 100%;
}

.side-item.active {
  background: var(--coral);
  color: white;
  box-shadow: 0 6px 14px rgba(255,111,145,0.35);
}

.main-col {
  flex: 1;
  min-width: 0;
  padding: 8px 16px 100px;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px 18px;
  gap: 10px;
}

.greeting, .page-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 22px;
  font-weight: 600;
}
.greeting span { color: var(--coral); }

.date-pill, .streak-pill {
  font-size: 12px;
  color: var(--navy-soft);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  background: var(--white);
  padding: 6px 12px;
  border-radius: 20px;
  white-space: nowrap;
}
.streak-pill { color: var(--coral); background: var(--coral-soft); }

/* ---------- ここあカード(サイニチャー要素) ---------- */
.kokoa-card {
  background: linear-gradient(135deg, var(--turquoise) 0%, #1CAFAA 100%);
  border-radius: 26px;
  padding: 18px 20px;
  display: flex;
  gap: 14px;
  align-items: center;
  box-shadow: 0 10px 24px rgba(34, 195, 190, 0.3);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  transition: background 0.4s;
}
.kokoa-card::after {
  content: "";
  position: absolute;
  right: -30px; top: -30px;
  width: 110px; height: 110px;
  background: rgba(255,255,255,0.14);
  border-radius: 50%;
}
.kokoa-card.celebrate { background: linear-gradient(135deg, var(--plum) 0%, #6449A0 100%); box-shadow: 0 10px 24px rgba(123,94,167,0.35); }
.kokoa-card.nudge { background: linear-gradient(135deg, var(--coral) 0%, #F0587A 100%); box-shadow: 0 10px 24px rgba(255,111,145,0.35); }

.kokoa-avatar {
  width: 54px; height: 54px; flex-shrink: 0;
  background: var(--white); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.kokoa-bubble {
  background: rgba(255,255,255,0.95);
  border-radius: 18px;
  padding: 13px 16px;
  flex: 1;
  position: relative;
}
.kokoa-name { font-family: 'Fredoka', sans-serif; font-size: 12px; font-weight: 600; color: var(--turquoise); margin-bottom: 3px; }
.kokoa-card.celebrate .kokoa-name { color: var(--plum); }
.kokoa-card.nudge .kokoa-name { color: var(--coral); }
.kokoa-text { font-size: 14px; line-height: 1.6; font-weight: 500; }
.kokoa-text b { color: var(--coral); }

/* ---------- セクション ---------- */
.section-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 15px;
  font-weight: 600;
  margin: 22px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}
.section-count {
  font-size: 11px;
  background: var(--coral-soft);
  color: var(--coral);
  padding: 2px 9px;
  border-radius: 10px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
}

.grid { display: grid; grid-template-columns: 1fr; gap: 20px; }

.panel { /* デスクトップ幅でのみ白カードになる(@media 900px〜参照) */ }

/* ---------- タスクカード ---------- */
.task-card {
  background: var(--white);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  box-shadow: 0 3px 10px rgba(45, 42, 74, 0.06);
}
.checkbox {
  width: 24px; height: 24px; border-radius: 50%; border: 2.5px solid var(--turquoise); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: white; font-size: 13px; background: none;
}
.checkbox.done { background: var(--turquoise); }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14px; font-weight: 700; font-family: 'Nunito', sans-serif; word-break: break-word; }
.task-title.done { text-decoration: line-through; color: var(--navy-soft); font-weight: 600; }
.task-meta { font-size: 11px; color: var(--navy-soft); display: flex; gap: 8px; align-items: center; margin-top: 3px; flex-wrap: wrap; }
.priority { padding: 2px 8px; border-radius: 8px; font-weight: 700; font-family: 'Nunito', sans-serif; }
.priority.high { background: var(--coral-soft); color: var(--coral); }
.priority.mid { background: var(--yellow-soft); color: var(--amber-text); }
.priority.low { background: var(--turquoise-soft); color: var(--turquoise); }
.del-btn { background: none; color: var(--navy-soft); font-size: 16px; padding: 4px; opacity: 0.5; flex-shrink: 0; }
.del-btn:hover { opacity: 1; }

/* ---------- 撮影予定カード ---------- */
.shoot-card {
  background: var(--plum-soft);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.shoot-date {
  background: var(--plum); color: white; border-radius: 12px; padding: 6px 10px; text-align: center;
  font-family: 'Fredoka', sans-serif; line-height: 1.1; flex-shrink: 0;
}
.shoot-date .m { font-size: 10px; display: block; }
.shoot-date .d { font-size: 18px; font-weight: 600; }
.shoot-body { flex: 1; min-width: 0; }
.shoot-title { font-size: 13px; font-weight: 700; font-family: 'Nunito', sans-serif; }
.shoot-sub { font-size: 11px; color: var(--navy-soft); margin-top: 2px; }

.add-btn {
  margin-top: 12px;
  width: 100%;
  padding: 11px;
  border-radius: 14px;
  background: var(--cream);
  color: var(--coral);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  border: 2px dashed var(--coral-soft);
}

.empty-note { font-size: 12px; color: var(--navy-soft); text-align: center; padding: 20px 0; }

/* ---------- 健康ページ ---------- */
.card { background: var(--white); border-radius: 22px; padding: 18px; margin-bottom: 16px; box-shadow: 0 4px 14px rgba(45,42,74,0.06); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title { font-family: 'Fredoka', sans-serif; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-icon { width: 34px; height: 34px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.icon-bike { background: var(--turquoise-soft); }
.icon-squat { background: var(--yellow-soft); }
.icon-meal { background: var(--coral-soft); }
.bike-today { display: flex; align-items: baseline; gap: 6px; margin-bottom: 4px; }
.bike-num { font-family: 'Fredoka', sans-serif; font-size: 34px; font-weight: 700; color: var(--turquoise); }
.bike-unit { font-size: 13px; color: var(--navy-soft); font-weight: 700; font-family: 'Nunito', sans-serif; }
.goal-note { font-size: 11px; color: var(--navy-soft); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.goal-edit { font-size: 11px; color: var(--turquoise); font-weight: 700; background: none; text-decoration: underline; }
.progress-track { height: 10px; background: var(--turquoise-soft); border-radius: 6px; overflow: hidden; margin-bottom: 6px; }
.progress-fill { height: 100%; background: var(--turquoise); border-radius: 6px; transition: width 0.4s; }
.log-btn { margin-top: 14px; width: 100%; padding: 11px; border-radius: 14px; background: var(--turquoise); color: white; text-align: center; font-family: 'Nunito', sans-serif; font-weight: 700; font-size: 13px; }
.log-btn.squat { background: #E9A912; }
.log-btn.meal { background: var(--coral); }
.squat-count { font-family: 'Fredoka', sans-serif; font-size: 30px; font-weight: 700; color: #E9A912; }
.squat-sets { font-size: 12px; color: var(--navy-soft); font-family: 'Nunito', sans-serif; font-weight: 700; margin-left: 6px; }
.meal-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #F3EEE3; }
.meal-item:last-child { border-bottom: none; }
.meal-time { font-size: 11px; color: var(--navy-soft); font-family: 'Nunito', sans-serif; font-weight: 700; width: 40px; flex-shrink: 0; }
.meal-text { font-size: 13px; font-weight: 600; }

.week-bars { display: flex; align-items: flex-end; justify-content: space-between; height: 60px; margin: 10px 0 6px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; }
.bar { width: 16px; border-radius: 6px 6px 3px 3px; background: var(--turquoise-soft); min-height: 4px; }
.bar.filled { background: var(--turquoise); }
.bar-label { font-size: 9px; color: var(--navy-soft); font-family: 'Nunito', sans-serif; font-weight: 700; }

/* ---------- 設定ページ ---------- */
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 6px; border-bottom: 1px solid #F3EEE3;
}
.settings-row:last-of-type { border-bottom: none; }
.settings-row-main { font-size: 14px; font-weight: 700; font-family: 'Nunito', sans-serif; }
.settings-row-sub { font-size: 11px; color: var(--navy-soft); margin-top: 2px; }
.toggle { width: 42px; height: 24px; border-radius: 14px; background: #E5E0D3; position: relative; flex-shrink: 0; }
.toggle.on { background: var(--turquoise); }
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: white; transition: left 0.2s;
}
.toggle.on::after { left: 21px; }
.template-rule-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.template-rule-row .field-input { margin-bottom: 0; }
.small-btn {
  padding: 8px 12px; border-radius: 10px; background: var(--cream); color: var(--coral);
  font-family: 'Nunito', sans-serif; font-weight: 700; font-size: 12px; border: 1.5px solid var(--coral-soft);
}

/* ---------- チャット入力 ---------- */
.chat-box { display: flex; gap: 8px; margin-bottom: 18px; }
.chat-input {
  flex: 1; padding: 12px 16px; border-radius: 20px; border: 2px solid #EFE6D6; background: white; font-size: 13px;
}
.chat-send { width: 44px; height: 44px; border-radius: 50%; background: var(--turquoise); color: white; font-size: 16px; flex-shrink: 0; }
.chat-reply {
  background: var(--turquoise-soft); border-radius: 14px; padding: 10px 14px; font-size: 12.5px;
  margin: -8px 0 18px; color: var(--navy); line-height: 1.5;
}

/* ---------- ボトムナビ・FAB ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-radius: 24px 24px 0 0;
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-around;
  box-shadow: 0 -6px 20px rgba(45,42,74,0.08);
  z-index: 10;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10px;
  font-family: 'Nunito', sans-serif; font-weight: 700; color: var(--navy-soft);
  padding: 4px 10px;
}
.nav-item.active { color: var(--coral); }

.fab {
  position: fixed;
  bottom: calc(84px + env(safe-area-inset-bottom));
  right: 20px;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--coral); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 400;
  box-shadow: 0 8px 18px rgba(255, 111, 145, 0.45);
  z-index: 10;
}
.fab.hidden { display: none; }

/* ---------- モーダル ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(45,42,74,0.4); display: none;
  align-items: flex-end; justify-content: center; z-index: 30;
}
.modal-overlay.show { display: flex; }
.modal-sheet {
  background: var(--cream); width: 100%; max-width: 480px; border-radius: 28px 28px 0 0; padding: 22px 22px 28px;
  max-height: 88vh; overflow-y: auto;
}
.modal-title { font-family: 'Fredoka', sans-serif; font-size: 17px; font-weight: 600; margin-bottom: 16px; }
.field-label { font-size: 11px; font-weight: 700; color: var(--navy-soft); font-family: 'Nunito', sans-serif; margin-bottom: 6px; display: block; }
.field-input {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 2px solid #EFE6D6; background: white;
  font-size: 14px; margin-bottom: 14px; color: var(--navy);
}
.field-checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 13px; font-weight: 700; }
.priority-select { display: flex; gap: 8px; margin-bottom: 14px; }
.prio-opt {
  flex: 1; padding: 9px; text-align: center; border-radius: 10px; font-size: 12px; font-weight: 700;
  font-family: 'Nunito', sans-serif; background: white; border: 2px solid #EFE6D6; color: var(--navy-soft);
}
.prio-opt.selected.high { background: var(--coral-soft); border-color: var(--coral); color: var(--coral); }
.prio-opt.selected.mid { background: var(--yellow-soft); border-color: #E9A912; color: var(--amber-text); }
.prio-opt.selected.low { background: var(--turquoise-soft); border-color: var(--turquoise); color: var(--turquoise); }
.modal-btn-row { display: flex; gap: 10px; }
.modal-btn { flex: 1; padding: 12px; border-radius: 14px; font-weight: 700; font-family: 'Nunito', sans-serif; font-size: 13px; }
.modal-btn.cancel { background: white; color: var(--navy-soft); }
.modal-btn.save { background: var(--coral); color: white; }
.modal-error { color: var(--coral); font-size: 12px; font-weight: 700; margin: -8px 0 12px; }

/* ---------- ログインゲート ---------- */
.gate-screen {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center; gap: 16px;
}
.gate-card {
  background: var(--white); border-radius: 24px; padding: 28px 26px; max-width: 320px; width: 100%;
  box-shadow: 0 10px 30px rgba(45,42,74,0.1);
}
.gate-logo { font-family: 'Fredoka', sans-serif; font-size: 26px; font-weight: 700; color: var(--coral); margin-bottom: 6px; }
.gate-sub { font-size: 12px; color: var(--navy-soft); margin-bottom: 18px; }

.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: white; padding: 10px 18px; border-radius: 20px;
  font-size: 12.5px; font-weight: 700; z-index: 50; box-shadow: 0 6px 18px rgba(0,0,0,0.2);
  opacity: 0; transition: opacity 0.25s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

.push-banner {
  background: var(--yellow-soft); border-radius: 16px; padding: 12px 14px; margin-bottom: 16px;
  font-size: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.push-banner button {
  background: var(--yellow); color: var(--navy); font-weight: 700; padding: 8px 14px; border-radius: 10px; font-size: 12px;
  font-family: 'Nunito', sans-serif;
}

/* ---------- レスポンシブ ---------- */
@media (min-width: 900px) {
  .sidebar { display: flex; }
  .main-col { padding: 32px 32px 32px 12px; }
  .bottom-nav { display: none; }
  .fab { bottom: 32px; }
  .grid.grid-2col { grid-template-columns: 1.4fr 1fr; }
  .kokoa-card { grid-column: 1 / -1; padding: 22px 26px; }
  .modal-overlay { align-items: center; }
  .modal-sheet { border-radius: 24px; }

  .panel {
    background: var(--white);
    border-radius: 22px;
    padding: 20px;
    box-shadow: 0 4px 16px rgba(45,42,74,0.06);
  }
  .panel .task-card {
    box-shadow: none;
    padding: 12px 6px;
    margin-bottom: 0;
    border-bottom: 1px solid #F3EEE3;
    border-radius: 0;
  }
  .panel .task-card:last-of-type { border-bottom: none; }
}

@media (max-width: 899.98px) {
  .main-col { padding-bottom: 110px; }
}
