/* ===== デザイントークン =====
   韓国のカフェのような、生成り色と素焼きの土の色を基調にした配色 */
:root {
  --bg: #f4efe6;
  --bg-grad: radial-gradient(1100px 460px at 50% -240px, #e9ded0 0%, transparent 72%);
  --surface: #fffdf9;
  --surface-soft: #faf5ec;
  --text: #2f2823;
  --text-soft: #5d5248;
  --muted: #9b8e81;
  --border: #e8dfd1;
  --border-strong: #d7cab7;
  --accent: #ae6a4e;        /* テラコッタ */
  --accent-hover: #975740;
  --accent-soft: #f5eae1;
  --accent-border: #e5d2c4;
  --success: #6d8256;       /* オリーブ */
  --success-soft: #edf0e5;
  --danger: #b0534a;
  --danger-soft: #f8eae6;
  --shadow-sm: 0 1px 2px rgba(80, 60, 40, 0.05);
  --shadow-md: 0 4px 16px -6px rgba(80, 60, 40, 0.16);
  --radius: 10px;
  --radius-sm: 7px;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1714;
    --bg-grad: radial-gradient(1100px 460px at 50% -240px, #2b231c 0%, transparent 72%);
    --surface: #251f1a;
    --surface-soft: #2d2620;
    --text: #efe7db;
    --text-soft: #c8bbab;
    --muted: #95877a;
    --border: #39302a;
    --border-strong: #4b4038;
    --accent: #d2906f;
    --accent-hover: #e0a183;
    --accent-soft: #332620;
    --accent-border: #4d3a2e;
    --success: #9cb382;
    --success-soft: #23291c;
    --danger: #d58a81;
    --danger-soft: #35211e;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 6px 20px -8px rgba(0, 0, 0, 0.65);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic Medium",
    "Noto Sans JP", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg-grad), var(--bg);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
}

/* 見出しと数字は明朝体にして、カフェのメニューのような落ち着きを出す */
.brand-name,
.panel h2,
.stat-value,
.latest-week,
.item-title {
  font-family: var(--serif);
}

/* アイコン定義用（非表示） */
.sprite { display: none; }

svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ===== ヘッダー ===== */
.header {
  padding: 26px 20px 0;
}

.header-inner {
  max-width: 940px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fffdf9;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0;
  box-shadow: var(--shadow-md);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.4; }
.brand-name { font-size: 20px; font-weight: 600; letter-spacing: 0.08em; }
.brand-sub { font-size: 12px; color: var(--muted); letter-spacing: 0.06em; }

.today {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ===== レイアウト ===== */
.container {
  max-width: 940px;
  margin: 0 auto;
  padding: 22px 20px 72px;
}

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}

/* ===== ダッシュボード ===== */
.dashboard {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 17px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--muted);
}

.stat-icon svg { width: 19px; height: 19px; }

.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: 12px; color: var(--muted); letter-spacing: 0.08em; }
.stat-number { display: flex; align-items: baseline; gap: 4px; }

.stat-value {
  font-size: 28px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

.stat-unit { font-size: 12px; color: var(--muted); }

.stat-accent {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.stat-accent .stat-icon {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.stat-accent .stat-value { color: var(--accent); }

/* 最新の振り返り */
.latest {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 15px 17px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.latest-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--muted);
}

.latest-icon svg { width: 19px; height: 19px; }

.latest-body { min-width: 0; flex: 1; }

.latest-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 9px;
}

.latest-label { font-size: 12.5px; color: var(--muted); }

.latest-week {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.latest-text {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--text-soft);
  white-space: pre-wrap;
  word-break: break-word;
}

/* 振り返りがあるときは少し強調する */
.latest.has-review { background: var(--accent-soft); border-color: var(--accent-border); }
.latest.has-review .latest-icon { background: var(--accent); border-color: var(--accent); color: #fff; }
.latest.has-review .latest-text { color: var(--text); }

/* ===== パネル ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

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

.panel-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 15px;
}

.panel-head h2 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
}

.count {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px;
  font-variant-numeric: tabular-nums;
}

/* ===== フォーム ===== */
.form {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-bottom: 17px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.form-inline { flex-direction: row; }
.form-inline input { flex: 1; min-width: 0; }

/* 週の選択欄 */
.field { display: flex; align-items: center; gap: 10px; }

.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

select {
  font: inherit;
  font-size: 14px;
  flex: 1;
  min-width: 0;
  padding: 9px 34px 9px 13px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%239b8e81' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.hint:empty { display: none; }

/* その週に完了したタスク（振り返りを書くときの手がかり） */
.week-tasks {
  padding: 11px 13px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.week-tasks-head { font-size: 12.5px; font-weight: 600; color: var(--muted); }

.week-tasks-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.week-tasks-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13.5px;
}

.week-tasks-check {
  flex-shrink: 0;
  color: var(--success);
  line-height: 1;
  align-self: center;
}

.week-tasks-check svg { width: 13px; height: 13px; stroke-width: 2.6; display: block; }

.week-tasks-name { flex: 1; min-width: 0; word-break: break-word; }

.week-tasks-when {
  flex-shrink: 0;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* メモのその場編集 */
.item-editing { display: block; }
.item-editing .item-main { display: flex; flex-direction: column; gap: 8px; }
.editor-actions { display: flex; gap: 8px; }
.btn-compact { padding: 7px 16px; font-size: 13.5px; }

input[type="text"], textarea {
  font: inherit;
  width: 100%;
  padding: 10px 13px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

input[type="text"]::placeholder, textarea::placeholder { color: var(--muted); }

input[type="text"]:focus, textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.08s;
}

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
  border-color: var(--accent);
}

button:active { transform: translateY(1px); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  background: var(--accent);
  color: #fffdf9;
  white-space: nowrap;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-icon { width: 15px; height: 15px; stroke-width: 2.1; }

/* ===== 一覧 ===== */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--border);
}

.item:last-child { border-bottom: none; }

.item-main { flex: 1; min-width: 0; }

.item-title {
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.55;
  letter-spacing: 0.02em;
  word-break: break-word;
}

.item-body {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--text-soft);
  white-space: pre-wrap;
  word-break: break-word;
}

.item-meta {
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* 完了チェックボタン */
.check {
  width: 21px;
  height: 21px;
  flex-shrink: 0;
  margin-top: 3px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1.6px solid var(--border-strong);
  border-radius: 50%;
  background: transparent;
  color: transparent;
}

.check svg { width: 12px; height: 12px; stroke-width: 2.6; }
.check:hover { border-color: var(--accent); color: var(--accent); }

.check[aria-pressed="true"] {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.task-done .item-title { text-decoration: line-through; color: var(--muted); font-weight: 500; }

/* バッジ */
.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 0 8px;
  font-family: "Hiragino Sans", system-ui, sans-serif;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 17px;
  border-radius: 999px;
  vertical-align: 1.5px;
}

.badge-open { color: var(--accent); background: var(--accent-soft); }
.badge-done { color: var(--success); background: var(--success-soft); }

/* 操作ボタン */
.actions { display: flex; gap: 6px; flex-shrink: 0; }

.btn-ghost {
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover { color: var(--accent); background: var(--accent-soft); }
.btn-delete:hover { color: var(--danger); background: var(--danger-soft); }
.btn-delete.is-armed { color: var(--danger); background: var(--danger-soft); font-weight: 600; }

/* いいねボタン（未選択のときは色を抜いて控えめに） */
.like {
  padding: 2px 9px;
  font-size: 14px;
  line-height: 1.6;
  background: transparent;
  filter: grayscale(1);
  opacity: 0.5;
  transition: filter 0.15s, opacity 0.15s, background 0.15s, border-color 0.15s;
}

.like:hover { filter: none; opacity: 1; background: var(--surface-soft); }

.like.is-liked {
  filter: none;
  opacity: 1;
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

/* 追加された項目をそっと目立たせる */
@keyframes appear {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.item { animation: appear 0.22s ease-out; }

/* ===== 空状態・エラー ===== */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 26px 0 18px;
  font-size: 13px;
  color: var(--muted);
}

/* display 指定が hidden 属性に勝ってしまうため、明示的に打ち消す */
.empty[hidden] { display: none; }

.empty-icon { width: 26px; height: 26px; opacity: 0.45; stroke-width: 1.4; }

/* 画面のどこを操作していても見えるよう、下部に固定して表示する */
.error {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 50;
  max-width: min(560px, calc(100vw - 32px));
  margin: 0;
  padding: 12px 18px;
  font-size: 13.5px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid currentColor;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px -8px rgba(20, 24, 40, 0.3);
  animation: error-in 0.2s ease-out;
}

.error[hidden] { display: none; }

@keyframes error-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ===== レスポンシブ ===== */
@media (max-width: 760px) {
  .columns { grid-template-columns: 1fr; }
  .dashboard { gap: 10px; }

  /* 件数カードは縦に積まず、横3列のまま小さく並べる */
  .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { flex-direction: column; align-items: flex-start; gap: 2px; padding: 11px 12px; }
  .stat-icon { display: none; }
  .stat-label { font-size: 11.5px; line-height: 1.4; }
  .stat-value { font-size: 23px; }
  .field { flex-direction: column; align-items: stretch; gap: 6px; }
  .form-foot .btn-primary { width: 100%; }
  .stat-value { font-size: 24px; }
  .header-inner { flex-direction: column; align-items: flex-start; gap: 8px; }
  .container { padding: 18px 16px 56px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
