:root {
  --bg: #f4f2f3;          /* 薄いグレー（背景） */
  --panel: #ffffff;
  --border: #ece6ea;
  --text: #40383c;        /* 濃いめのグレー（文字） */
  --muted: #a2969c;
  --primary: #e07a9b;     /* ピンク（アクセント） */
  --primary-dark: #cf6488;
  --danger: #d76575;
  --done: #6bbf9a;        /* 完了（やわらかい緑） */
  --shadow: 0 2px 12px rgba(64, 56, 60, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ---- ヘッダー ---- */
.site-header {
  background: linear-gradient(135deg, #eeb2c8, #e58ba8);
  color: #fff;
  padding: 20px 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.site-header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.logo-icon {
  font-weight: 400;
  margin-right: 2px;
}
.subtitle {
  margin: 6px 0 0;
  opacity: 0.95;
  font-size: 0.98rem;
  font-weight: 500;
}
.status-line {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.82rem;
  opacity: 0.95;
}
.status-sep {
  opacity: 0.6;
}
#clock {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ---- レイアウト ---- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

/* ---- ダッシュボード ---- */
.dashboard {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 16px;
  text-align: center;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.stat-card.highlight {
  background: linear-gradient(135deg, #fdeef3, #fbdfe9);
  border-color: #f5cdda;
}
.stat-label {
  font-size: 0.85rem;
  color: var(--muted);
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
}
.stat-card.highlight .stat-value {
  color: var(--primary-dark);
}

/* 最新の振り返り（ダッシュボード内） */
.latest-reflection {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
}
.lr-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-dark);
}
.lr-week {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}
.lr-comment {
  margin: 0;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.lr-comment.is-empty {
  color: var(--muted);
}

/* ---- カレンダー（左） ＆ 検索・その日の予定（右） ---- */
.tools {
  display: grid;
  grid-template-columns: 300px 1fr; /* 左：カレンダー / 右：検索＋予定 */
  gap: 20px;
  align-items: start;
  margin-bottom: 24px;
}
.tools-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}
.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(224, 122, 155, 0.18);
}
.search-icon {
  opacity: 0.7;
}
.search-box input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
}
.search-clear {
  border: none;
  background: #f0eaed;
  color: var(--muted);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
  flex-shrink: 0;
}
.search-clear:hover {
  background: #e6dde2;
}
.search-hint {
  margin: 8px 2px 0;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ミニカレンダー */
.calendar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cal-title {
  font-weight: 600;
  font-size: 0.95rem;
}
.cal-nav {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--text);
}
.cal-nav:hover {
  background: #faf0f4;
  border-color: var(--primary);
  color: var(--primary-dark);
}
.cal-weekdays,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal-weekdays {
  gap: 2px;
  margin-bottom: 4px;
}
.cal-weekdays span {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 2px 0;
}
.cal-grid {
  gap: 2px;
}
.cal-cell {
  position: relative;
  border: none;
  background: transparent;
  cursor: pointer;
  min-height: 36px;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
.cal-cell.empty {
  cursor: default;
}
.cal-cell:not(.empty):hover {
  background: #faf0f4;
}
.cal-cell.today {
  background: #fdeef4;
  font-weight: 700;
  color: var(--primary-dark);
}
.cal-cell.selected {
  background: var(--primary);
  color: #fff;
}
.cal-dot {
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
}
.cal-cell.selected .cal-dot {
  background: #fff;
}
.cal-dot.overdue {
  background: var(--danger);
}
.cal-legend {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.cal-legend .cal-dot {
  position: static;
  transform: none;
  display: inline-block;
  margin: 0 2px 0 8px;
}

/* ---- その日の予定パネル（カレンダー右） ---- */
.day-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.day-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--primary-dark);
}
.day-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.day-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: #faf8f9;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.day-item:hover {
  background: #fdeef4;
  border-color: #f3cdda;
}
.day-item-icon {
  flex-shrink: 0;
}
.day-item-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.day-task.done .day-item-text {
  text-decoration: line-through;
  color: var(--muted);
}
.day-item-tag {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
}
.day-task .day-item-tag {
  background: #fce1ea;
  color: #cf6488;
}
.day-memo .day-item-tag {
  background: #e5eefb;
  color: #5578b0;
}
.day-empty {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

/* クリックで該当項目へ移動したときの点滅ハイライト */
.memo-item.flash,
.task-item.flash {
  animation: flash-highlight 1.6s ease-out;
}
@keyframes flash-highlight {
  0%, 25% { box-shadow: 0 0 0 3px var(--primary); border-color: var(--primary); }
  100% { box-shadow: 0 0 0 0 rgba(224, 122, 155, 0); }
}

/* メモの日付 */
.memo-date {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-dark);
  margin: 4px 0;
}

/* ---- 2カラム ---- */
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
}

/* ---- フォーム ---- */
.form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.form input,
.form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
}
.form input:focus,
.form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(224, 122, 155, 0.18);
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: -4px;
}
.form-actions {
  display: flex;
  gap: 8px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-dark);
}
.btn-ghost {
  background: #f2ecef;
  color: var(--text);
}
.btn-ghost:hover {
  background: #e8e0e5;
}

/* ---- 一覧 ---- */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.empty {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 8px 0;
}

/* 「解除」ボタン（その日の予定パネル） */
.chip-clear {
  border: none;
  background: transparent;
  color: var(--primary-dark);
  cursor: pointer;
  font-size: 0.8rem;
  text-decoration: underline;
  flex-shrink: 0;
}

/* タグ */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 8px;
}
.tag {
  font-size: 0.74rem;
  color: var(--primary-dark);
  background: #fdeef4;
  border: 1px solid #f6d2e0;
  padding: 2px 8px;
  border-radius: 999px;
  cursor: pointer;
}
.tag:hover {
  background: #fbdfeb;
}

/* 添付ファイル */
.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}
.attach-img {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.attach-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.attach-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  font-size: 0.8rem;
  color: var(--primary-dark);
  background: #faf6f8;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  text-decoration: none;
}
.attach-file:hover {
  background: #fdeef4;
  border-color: #f3cdda;
}
.attach-size {
  color: var(--muted);
  font-size: 0.72rem;
}
.form input[type="file"] {
  padding: 8px;
  font-size: 0.85rem;
  background: #fbfafb;
}
/* 編集中の「現在の添付」 */
.attach-editing {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: #faf6f8;
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.attach-editing-label {
  width: 100%;
  font-size: 0.78rem;
  color: var(--muted);
}
.attach-keep-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 6px 2px 10px;
  max-width: 100%;
}
.attach-keep-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}
.attach-remove {
  border: none;
  background: #f0eaed;
  color: var(--muted);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
  flex-shrink: 0;
}
.attach-remove:hover {
  background: var(--danger);
  color: #fff;
}

/* メモカード */
.memo-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #faf8f9;
}
.memo-item h3 {
  margin: 0 0 4px;
  font-size: 1rem;
  word-break: break-word;
}
.memo-item p {
  margin: 0 0 8px;
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.timestamp {
  font-size: 0.78rem;
  color: var(--muted);
}

/* タスク行 */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #faf8f9;
}
.task-item.done {
  background: #f3faf6;
  border-color: #d3ecdf;
}
.task-checkbox {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  cursor: pointer;
  accent-color: var(--done);
  flex-shrink: 0;
}
.task-body {
  flex: 1;
  min-width: 0;
}
.task-text {
  font-size: 0.95rem;
  word-break: break-word;
}
.task-item.done .task-text {
  text-decoration: line-through;
  color: var(--muted);
}
.task-meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-top: 2px;
}
.due {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}
.due.overdue {
  color: var(--danger);
}
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}
.badge-done {
  background: #d9f2e6;
  color: #3f9d75;
}
.badge-todo {
  background: #fce1ea;
  color: #cf6488;
}

/* 操作ボタン（編集・削除） */
.item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.btn-edit {
  background: transparent;
  color: var(--primary-dark);
  border: 1px solid transparent;
  padding: 4px 8px;
  font-size: 0.8rem;
  border-radius: 6px;
  cursor: pointer;
}
.btn-edit:hover {
  background: #fdecf2;
  border-color: #f3cdda;
}
.btn-delete {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  padding: 4px 8px;
  font-size: 0.8rem;
  border-radius: 6px;
  cursor: pointer;
}
.btn-delete:hover {
  background: #fdecef;
  border-color: #f5ccd4;
}

/* ---- 週次の振り返り ---- */
.reflection-panel {
  margin-top: 20px;
}
.reflection-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #faf8f9;
}
.reflection-week {
  margin: 0 0 4px;
  font-size: 0.98rem;
  word-break: break-word;
}
.reflection-item p {
  margin: 0 0 8px;
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- レスポンシブ（タブレット・スマホ） ---- */
@media (max-width: 860px) {
  .tools {
    grid-template-columns: 1fr; /* カレンダーを上、予定パネルを下に縦積み */
  }
}
@media (max-width: 700px) {
  .columns {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 460px) {
  .container {
    padding: 16px 12px 48px;
  }
  .site-header h1 {
    font-size: 1.2rem;
  }
  .stats {
    gap: 8px;
  }
  .stat-card {
    padding: 14px 8px;
  }
  .stat-value {
    font-size: 1.6rem;
  }
  .stat-label {
    font-size: 0.74rem;
  }
  .panel {
    padding: 16px;
  }
  .cal-cell {
    min-height: 40px;
  }
}
