* { box-sizing: border-box; }

/* 夏の海辺のアルバムジャケットの「海の青」だけを基調にした配色：
   ウルトラマリンの海 #0f2884（深い）→ #2446a0 → #3b5fad（明るい）→ #2a6197（波打ち際） */
:root {
  --bg: #eef2fb;
  --card: #fff;
  --text: #0d1a4a;
  --muted: #5a6b98;
  --border: #d6deef;
  --primary: #2446a0;
  --primary-dark: #0f2884;
  --lagoon: #3b5fad;
  --accent: #3b5fad;
  --sea-pale: #c9d5f2;
  --danger: #f2604e;
  --success: #1a9a9a;
  --input-bg: #f5f7fd;
  --shadow: 0 1px 2px rgba(15, 30, 110, .06), 0 4px 14px rgba(15, 30, 110, .1);
}

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  background: linear-gradient(180deg, #d2dcf4 0, var(--bg) 380px) no-repeat, var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ---- ヘッダー ---- */
header {
  background: linear-gradient(90deg, #0f2884 0%, #2446a0 55%, #3b5fad 100%);
  color: #fff;
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 10px rgba(15, 40, 132, .3);
}
.header-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
/* 写真を丸く切り抜く。images/face/ には、元の写真から顔まわりを表示サイズぴったりに高画質で切り抜いた画像がある。
   拡大・縮小せずにそのまま表示する（ブラウザで拡大・縮小するとぼやけるため） */
.face {
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
}
.face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.header-avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, .9);
}
header h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: .08em;
  color: #fff;
}
.header-date { margin-left: auto; font-size: .85rem; color: rgba(255, 255, 255, .88); }

main { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; }

/* ---- 秘書からのあいさつ（ジャケットの海。枠の下端を波の形に切り抜く） ---- */
.greeting {
  position: relative;
  display: flex;
  align-items: center;
  gap: 24px;
  /* 色は app.js が時刻に合わせて --sea1〜--sea4 を書き換える（下の値は昼の色） */
  background: linear-gradient(180deg,
    var(--sea1, #1e7fe0) 0%, var(--sea2, #39a0f0) 45%, var(--sea3, #7cc7f7) 82%, var(--sea4, #1a6fc4) 100%);
  border-radius: 16px 16px 0 0;
  padding: 20px 24px 36px;
  margin-bottom: 20px;
  /* 上部は四角のまま、下端 26px だけ波の形のマスクで切り抜く */
  -webkit-mask:
    linear-gradient(#000 0 0) top / 100% calc(100% - 25px) no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 26' preserveAspectRatio='none'%3E%3Cpath d='M0 0 H1200 V12 Q1050 26 900 12 T600 12 T300 12 T0 12 Z' fill='%23000'/%3E%3C/svg%3E") bottom / 100% 26px no-repeat;
  mask:
    linear-gradient(#000 0 0) top / 100% calc(100% - 25px) no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 26' preserveAspectRatio='none'%3E%3Cpath d='M0 0 H1200 V12 Q1050 26 900 12 T600 12 T300 12 T0 12 Z' fill='%23000'/%3E%3C/svg%3E") bottom / 100% 26px no-repeat;
}
/* 夜の星空（app.js が星を作り、時刻に合わせて --star-opacity で濃さを変える） */
.stars {
  position: absolute;
  inset: 0 0 26px 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--star-opacity, 0);
  transition: opacity 3s ease;
  /* うっすらとした天の川の光の帯 */
  background:
    linear-gradient(160deg, transparent 18%, rgba(180, 200, 255, .10) 34%, rgba(220, 225, 255, .16) 42%, rgba(180, 200, 255, .10) 50%, transparent 66%);
}
.star {
  position: absolute;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 calc(var(--size) * 2) rgba(220, 230, 255, .9);
  opacity: var(--glow);
  animation: twinkle var(--duration) ease-in-out var(--delay) infinite;
}
/* 明るい星には光の十字を付ける */
.star.bright::before,
.star.bright::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .85), transparent);
  transform: translate(-50%, -50%);
}
.star.bright::before { width: calc(var(--size) * 6); height: 1px; }
.star.bright::after { width: 1px; height: calc(var(--size) * 6); background: linear-gradient(transparent, rgba(255, 255, 255, .85), transparent); }
@keyframes twinkle {
  0%, 100% { opacity: var(--glow); transform: scale(1); }
  50% { opacity: calc(var(--glow) * .2); transform: scale(.6); }
}
@media (prefers-reduced-motion: reduce) {
  .star { animation: none; }
}
.portrait {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  padding: 4px;
  background: linear-gradient(135deg, var(--sea-pale), #ffffff 50%, var(--sea-pale));
}
.portrait .face {
  width: 100%;
  height: 100%;
  border: 3px solid #fff;
}
.bubble {
  position: relative;
  z-index: 1;
  flex: 1;
  background: #fff;
  border-radius: 14px;
  padding: 16px 20px;
  box-shadow: 0 4px 16px rgba(5, 10, 60, .35);
}
.bubble::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  border: 10px solid transparent;
  border-left: 0;
  border-right-color: #fff;
}
.bubble p { margin: 0; }
.bubble-title { font-weight: bold; font-size: 1.05rem; color: var(--primary-dark); margin-bottom: 4px !important; }
.bubble-text { color: var(--text); }

@media (max-width: 560px) {
  .greeting { flex-direction: column; text-align: center; padding: 20px 16px 36px; gap: 16px; }
  .portrait { width: 112px; height: 112px; }
  .bubble::before {
    left: 50%;
    top: -10px;
    transform: translateX(-50%);
    border: 10px solid transparent;
    border-top: 0;
    border-bottom-color: #fff;
  }
  .header-date { display: none; }
}

/* ---- ダッシュボード ---- */
.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.stat {
  background: var(--card);
  border-radius: 12px;
  border-top: 4px solid var(--primary);
  padding: 14px 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
/* 見出し：枠の色と同じ色の太字にし、薄い同系色の帯で目立たせる */
.stat .label {
  font-size: 1rem;
  font-weight: bold;
  letter-spacing: .04em;
  color: var(--primary-dark);
  background: #e6ecfa;
  padding: 2px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.stat .value { font-size: 2rem; font-weight: bold; line-height: 1.3; margin-top: 4px; color: var(--primary-dark); }
.stat.highlight { border-top-color: var(--danger); }
.stat.highlight .label { color: #d8402e; background: #fde8e5; }
.stat.highlight .value { color: var(--danger); }
.stat.deleted { border-top-color: #8a99c4; }
.stat.deleted .label { color: #4f5f8f; background: #eceff7; }
.stat.deleted .value { color: var(--muted); }
.stat.completed { border-top-color: var(--success); }
.stat.completed .label { color: #12807f; background: #e0f3f2; }
.stat.completed .value { color: var(--success); }
@media (max-width: 560px) {
  .dashboard { gap: 8px; }
  .stat { padding: 12px 4px; }
  .stat .label { font-size: .72rem; padding: 2px 6px; letter-spacing: 0; }
  .stat .value { font-size: 1.6rem; }
}

/* ---- 最新の振り返り ---- */
.latest-review {
  background: var(--card);
  border-radius: 12px;
  border-left: 4px solid var(--lagoon);
  padding: 14px 20px;
  margin: 0 0 32px;
  box-shadow: var(--shadow);
}
.latest-review-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.latest-review-label { font-weight: bold; color: var(--primary-dark); }
.latest-review-text {
  margin: 6px 0 0;
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.latest-review-text.empty-text { color: #98a6c8; font-size: .9rem; }
.link { margin-left: auto; font-size: .85rem; color: var(--primary); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ---- 縦並びレイアウト ---- */
.columns { display: flex; flex-direction: column; gap: 32px; }

.group-title {
  margin: 0 0 12px;
  padding-left: 10px;
  border-left: 4px solid var(--lagoon);
  font-size: 1.15rem;
  color: var(--primary-dark);
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card:last-child { margin-bottom: 0; }
.card h2 {
  margin: 0 0 12px;
  font-size: .95rem;
  color: var(--primary);
}

/* ---- フォーム ---- */
form { display: flex; flex-direction: column; gap: 10px; }
form.inline { flex-direction: row; }
form.inline input { flex: 1; min-width: 0; }
#memoForm button { align-self: flex-end; }

input, textarea {
  font: inherit;
  color: var(--text);
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(36, 70, 160, .2);
}
textarea { resize: vertical; }

button {
  font: inherit;
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { opacity: .85; }
button.danger { background: var(--danger); }
button.secondary { background: #6f84bd; }
button.small { padding: 4px 12px; font-size: .85rem; }

/* ---- 一覧 ---- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--border); padding: 12px 0; }
.list li:first-child { padding-top: 0; }
.list li:last-child { border-bottom: none; padding-bottom: 0; }
.empty { color: #98a6c8; font-size: .9rem; text-align: center; padding: 8px 0; }

.memo { display: flex; align-items: flex-start; gap: 12px; }
.memo .body { flex: 1; min-width: 0; }
.memo-title { font-weight: bold; }
.memo-content { white-space: pre-wrap; margin: 2px 0 4px; }
.meta { font-size: .8rem; color: var(--muted); }

.task { display: flex; align-items: center; gap: 12px; }
.task .body { flex: 1; min-width: 0; }
.actions { display: flex; gap: 6px; }

/* ---- 完了タスク（履歴） ---- */
.history { max-height: 360px; overflow-y: auto; }
/* 表示期間：枠の幅いっぱいの絞り込みバー。日付欄は残りの幅を等分して伸びる */
.period {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 8px 12px;
  margin-bottom: 14px;
  background: #f3f6fd;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: .9rem;
}
.period label {
  font-size: .8rem;
  font-weight: bold;
  color: var(--primary);
  white-space: nowrap;
}
.period select, .period input {
  font: inherit;
  color: var(--text);
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.period select:focus, .period input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 70, 160, .15);
}
.period-custom { flex: 1 1 260px; min-width: 0; display: flex; align-items: center; gap: 6px; color: var(--muted); }
/* 日付欄：年月日を欄の中央に置く。カレンダーのアイコンは右端に重ねて、中央寄せの邪魔をしない */
.period-custom input {
  flex: 1;
  min-width: 0;
  position: relative;
  /* 左右に同じ余白を取り、右側の余白にアイコンを置く（中央を保ったまま文字と重ならない） */
  padding: 5px 26px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: .03em;
}
.period-custom input::-webkit-datetime-edit { display: flex; justify-content: center; }
.period-custom input::-webkit-calendar-picker-indicator {
  position: absolute;
  right: 6px;
  width: 14px;
  height: 14px;
  padding: 0;
  cursor: pointer;
  opacity: .6;
}
@media (max-width: 560px) {
  .period-custom { flex-basis: 100%; }
  .period-custom input { width: 0; padding: 5px 20px; font-size: .85rem; letter-spacing: 0; }
  .period-custom input::-webkit-calendar-picker-indicator { right: 4px; width: 12px; height: 12px; }
}
.period-custom[hidden] { display: none; }
.list li.history-day {
  border-bottom: none;
  padding: 10px 0 2px;
  font-size: .8rem;
  font-weight: bold;
  color: var(--primary);
}
.list li.history-day:first-child { padding-top: 0; }
.list li.history-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0 6px 4px;
}
.history-time { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.history-title { flex: 1; min-width: 0; }
.history-name::before { content: "✓ "; color: var(--success); font-weight: bold; }
.history.deleted .history-name::before,
.history.reviews .history-name::before { content: none; }
.history.deleted .history-title { color: var(--muted); }
.history-detail {
  display: block;
  font-size: .85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- 週次の振り返り ---- */
#reviews { scroll-margin-top: 72px; }
.week-nav { display: flex; align-items: center; justify-content: center; gap: 12px; }
.week-label { font-weight: bold; color: var(--primary-dark); text-align: center; }
.week-summary { text-align: center; margin: 4px 0 12px; }
button:disabled { opacity: .35; cursor: default; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

.history-item.selected .history-name::after {
  content: "編集中";
  font-size: .75rem;
  font-weight: normal;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 10px;
  background: #e1e8f7;
  color: var(--primary);
}
