:root {
  /* 赤基調。色を変えるときはここだけを編集する。
   * パソコン版もクラウド版もこのファイルを共通で使うので、両方の見た目が同じになる */
  --bg: #fbeeef;
  --panel: #ffffff;
  --panel-2: #fdf6f6;
  --line: #f0d4d7;
  --text: #33141a;
  --text-muted: #8a5f66;
  --text-body: #6b454c;
  --accent: #d63a4a;
  --accent-strong: #b0202f;
  --accent-soft: #fbe0e3;
  --header-from: #a3182a;
  --header-to: #ec5a64;
  --danger: #c0392b;
  --done: #b0202f;
  --pending: #a35f06;

  /* 薄い差し色（完了カードの背景、入力欄の薄い文字、完了タスクの枠や取り消し線、空のときのイラスト） */
  --tint: #fdf3f4;
  --placeholder: #c49aa1;
  --muted-edge: #e6c3c8;
  --panel-done: #fdfbfb;
  --strike: #cf9aa2;
  --empty-line: #f1d7da;

  /* ヘッダー：写真にかけるベール、イラストの丘と木、見出しの影 */
  --veil-strong: rgba(92, 12, 24, 0.86);
  --veil-mid: rgba(150, 24, 40, 0.42);
  --veil-light: rgba(214, 58, 74, 0.16);
  --hill-mid: rgba(90, 10, 22, 0.28);
  --hill-front: rgba(74, 8, 18, 0.45);
  --trees: rgba(74, 8, 18, 0.55);
  --header-text-shadow: rgba(50, 0, 10, 0.3);

  /* 付箋の色。メモはIDから決まる4色を順に使う */
  --note-1: #fff6d4;
  --note-2: #e2f2ff;
  --note-3: #ffe7ee;
  --note-4: #e6f7dd;
  --note-1-edge: #f0d071;
  --note-2-edge: #8fc9ef;
  --note-3-edge: #f0a2bb;
  --note-4-edge: #9dd07d;

  --shadow-sm: 0 1px 2px rgba(176, 32, 47, 0.07);
  --shadow-md: 0 4px 14px rgba(176, 32, 47, 0.10);
  --shadow-lg: 0 10px 28px rgba(176, 32, 47, 0.14);
}

* { box-sizing: border-box; }

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

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px;
}

/* アイコンの原本は非表示 */
.icon-defs { display: none; }

/* 共通のアイコン描画。線画をそろえる */
svg use,
.stat-icon svg,
.h-icon svg,
.btn-icon,
.icon-btn svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- ヘッダー ---------- */
.app-header {
  position: relative;
  overflow: hidden;
  min-height: 190px;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(150deg, var(--header-from), var(--header-to));
  color: #fff;
  margin-bottom: 28px;
}
/* イラストと写真は同じ場所に重ね、写真があれば写真を優先する */
.hero-art,
.hero-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.hero-photo {
  object-fit: cover;
  object-position: center;
}
/* 写真のときは帯を高くする。縦長の写真でも細切れに見えないように */
body.has-hero-photo .app-header { min-height: 260px; }

/* 写真の上に文字を載せるので、色つきのベールをかけて可読性を確保する */
body.has-hero-photo .app-header::after {
  content: "";
  position: absolute;
  inset: 0;
  /* 文字がある左下だけ濃く、右上ほど薄くして写真を見せる */
  background: linear-gradient(
    to top right,
    var(--veil-strong),
    var(--veil-mid) 52%,
    var(--veil-light)
  );
}
body.has-hero-photo .hero-art { display: none; }

.hero-art .sun { fill: #ffe08a; }
.hero-art .sun-glow { fill: rgba(255, 224, 138, 0.22); }
.hero-art .cloud ellipse { fill: rgba(255, 255, 255, 0.32); }
.hero-art .bird {
  fill: none;
  stroke: rgba(255, 255, 255, 0.6);
  stroke-width: 2.5;
  stroke-linecap: round;
}
.hero-art .hill-3 { fill: rgba(255, 255, 255, 0.12); }
.hero-art .hill-2 { fill: var(--hill-mid); }
.hero-art .hill-1 { fill: var(--hill-front); }
.hero-art .trees path { fill: var(--trees); }

.header-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 30px 20px 26px;
}
.greeting {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.85);
}
.app-header h1 {
  margin: 2px 0 0;
  font-size: 1.85rem;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 10px var(--header-text-shadow);
}
.subtitle {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.88rem;
}

/* ---------- ダッシュボード ---------- */
.dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.stat {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 18px 16px 66px;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-task .stat-icon { background: #e3f1ff; color: #2b6fa8; }
.stat-done .stat-icon { background: var(--accent-strong); color: #fff; }

.stat-done {
  background: linear-gradient(160deg, var(--tint), #ffffff);
  border-color: var(--accent);
}
.stat-label {
  width: 100%;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-done .stat-value { color: var(--accent-strong); }
.stat-unit {
  color: var(--text-muted);
  font-size: 0.85rem;
}
/* 数字が変わったときだけ、ぽんと弾ませる */
.stat-value.bump { animation: bump 0.42s ease; }
@keyframes bump {
  40% { transform: scale(1.28) rotate(-3deg); }
  100% { transform: scale(1); }
}

/* ---------- レイアウト ---------- */
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.panel h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.98rem;
  margin: 26px 0 14px;
  padding-bottom: 10px;
  color: var(--accent-strong);
  border-bottom: 2px solid var(--accent-soft);
}
.panel h2:first-child { margin-top: 0; }
.h-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  flex: none;
}
.h-icon svg { width: 17px; height: 17px; }
.count {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.82rem;
}

.panel-wide { margin-top: 18px; }

/* ---------- 最新の振り返り（ダッシュボード内） ---------- */
.review-highlight {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #ffffff, var(--accent-soft));
  border: 1px solid var(--accent);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}
.rh-icon {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-strong);
  color: #fff;
}
.rh-icon svg { width: 22px; height: 22px; }
.rh-body { flex: 1; min-width: 0; }
.rh-head {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-strong);
}
.rh-week {
  margin-left: 8px;
  font-weight: 400;
  color: var(--text-muted);
}
.rh-text {
  margin: 3px 0 0;
  /* 長い振り返りは2行までにして、続きは下の一覧で読む */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
}
.rh-text.rh-empty { color: var(--text-muted); }

.btn-ghost {
  flex: none;
  padding: 8px 16px;
  font-size: 0.82rem;
  background: var(--panel);
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 600;
}
.btn-ghost:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
}

/* ---------- 振り返りの記録 ---------- */
.review-list li {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-strong);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 11px;
}
.review-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.badge-week {
  background: var(--accent-strong);
  color: #fff;
  border-color: var(--accent-strong);
}
.hint {
  margin: -4px 0 0;
  font-size: 0.78rem;
  color: var(--pending);
}

/* ---------- フォーム ---------- */
.form { display: flex; flex-direction: column; gap: 13px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 0.8rem; color: var(--text-muted); }

input[type="text"],
textarea,
select {
  width: 100%;
  padding: 11px 13px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
input[type="text"]::placeholder,
textarea::placeholder { color: var(--placeholder); }
input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: none;
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
select { cursor: pointer; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  padding: 10px 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}
.btn-icon { width: 17px; height: 17px; flex: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.btn-primary:active { transform: translateY(0); }

/* 丸アイコンだけのボタン（完了・戻す・削除） */
.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  transform: scale(1.08);
}
.icon-btn.danger:hover {
  border-color: var(--danger);
  background: #fdeceb;
  color: var(--danger);
}

/* 左端の丸いチェックボタン */
.check {
  flex: none;
  width: 30px;
  height: 30px;
  margin-top: 1px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--muted-edge);
  background: #fff;
  color: transparent;
  cursor: pointer;
  transition: all 0.16s ease;
}
.check svg { width: 18px; height: 18px; }
.check:hover {
  border-color: var(--accent);
  color: var(--accent-soft);
  transform: scale(1.1);
}
.task-done .check {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  border-color: var(--accent-strong);
  color: #fff;
}

/* ---------- 一覧（共通） ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list:empty { display: none; }

.item-title {
  font-weight: 600;
  word-break: break-word;
}
.item-body {
  margin: 6px 0 0;
  color: var(--text-body);
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.item-meta {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.76rem;
  color: var(--text-muted);
}

/* ---------- メモ＝付箋 ---------- */
.note-wall li {
  position: relative;
  background: var(--note-bg, var(--note-1));
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-top: 4px solid var(--note-edge, var(--note-1-edge));
  border-radius: 4px 4px 12px 12px;
  padding: 16px 16px 12px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.note-wall li:hover {
  transform: rotate(-0.6deg) translateY(-2px);
  box-shadow: var(--shadow-md);
}
/* 上辺に貼ったマスキングテープ */
.note-wall li::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%) rotate(-1.6deg);
  width: 78px;
  height: 17px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.note-wall .item-meta { color: #7a7256; }

/* ---------- タスク ---------- */
#task-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 14px;
  padding: 13px 14px;
  margin-bottom: 11px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
#task-list li:hover {
  transform: translateX(2px);
  box-shadow: var(--shadow-sm);
}
.task-main { flex: 1; min-width: 0; }
.task-actions { display: flex; gap: 6px; flex: none; }

.task-done {
  border-left-color: var(--muted-edge) !important;
  background: var(--panel-done) !important;
}
.task-done .item-title {
  text-decoration: line-through;
  text-decoration-color: var(--strike);
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.71rem;
  font-weight: 600;
}
.badge-done {
  background: var(--done);
  color: #fff;
  border-color: var(--done);
}
.badge-open {
  /* 完了バッジと色で見分けられるよう、未完了だけ琥珀色にする */
  background: #fff5e0;
  color: var(--pending);
  border-color: #e8c58a;
}

/* 追加・完了した項目だけを、ふわっと目立たせる */
.flash { animation: flash-in 0.5s ease; }
@keyframes flash-in {
  0% { opacity: 0; transform: translateY(-8px) scale(0.96); }
  60% { transform: translateY(0) scale(1.02); }
  100% { opacity: 1; transform: none; }
}

/* ---------- 空のとき ---------- */
.empty {
  text-align: center;
  padding: 14px 0 6px;
  color: var(--text-muted);
  font-size: 0.88rem;
}
.empty p { margin: 6px 0 0; }
.empty-art { width: 116px; height: 92px; }
.empty-art .e-paper { fill: #fff; stroke: var(--muted-edge); stroke-width: 2.4; }
.empty-art .e-line { stroke: var(--empty-line); stroke-width: 3; stroke-linecap: round; fill: none; }
.empty-art .e-spark { fill: #ffd166; }
.empty-art .e-pot { fill: #ffd9b8; stroke: #e8b48a; stroke-width: 2; stroke-linejoin: round; }
.empty-art .e-stem { stroke: var(--accent); stroke-width: 2.6; stroke-linecap: round; fill: none; }
.empty-art .e-leaf { fill: var(--accent); opacity: 0.85; }

/* ---------- そのほか ---------- */
.foot-note {
  margin: 26px 0 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.error {
  margin: 0 0 16px;
  padding: 11px 16px;
  background: #fdeceb;
  border: 1px solid var(--danger);
  border-radius: 12px;
  color: var(--danger);
  font-size: 0.88rem;
}

/* ---------- レスポンシブ ---------- */
@media (max-width: 820px) {
  .columns { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .dashboard { grid-template-columns: 1fr; }
  .review-highlight { flex-wrap: wrap; }
  .btn-ghost { width: 100%; justify-content: center; }
  .stat { padding: 12px 14px 12px 62px; }
  .stat-value { font-size: 1.7rem; }
  .app-header { min-height: 160px; }
  body.has-hero-photo .app-header { min-height: 200px; }
  .app-header h1 { font-size: 1.5rem; }
}

/* 動きが苦手な人向け。OSの設定でアニメーションを止める */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
  .stat:hover,
  .note-wall li:hover,
  #task-list li:hover,
  .btn-primary:hover,
  .icon-btn:hover,
  .check:hover { transform: none; }
}
