/* ------------------------------------------------------------------
   カラートークン（ライト / ダークはここだけ差し替える）
------------------------------------------------------------------ */
:root {
  --bg: #f2f4f7;
  --bg-tint: rgba(99, 102, 241, 0.07);
  --surface: #ffffff;
  --surface-sunken: #f7f8fb;
  --surface-hover: #f1f3f8;
  --border: #e6e8ee;
  --border-strong: #d6dae3;
  --text: #1a1c22;
  --muted: #6b7280;
  --faint: #9aa1ad;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --note: #6366f1;
  --review: #0ea5e9;
  --review-soft: rgba(14, 165, 233, 0.12);
  --review-text: #0369a1;
  --todo: #f59e0b;
  --todo-soft: rgba(245, 158, 11, 0.12);
  --todo-text: #92400e;
  --done: #10b981;
  --done-soft: rgba(16, 185, 129, 0.12);
  --done-text: #047857;
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 16px -4px rgba(16, 24, 40, 0.1), 0 1px 2px rgba(16, 24, 40, 0.04);
  --ring: 0 0 0 3px var(--accent-soft);
  --radius: 14px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1015;
    --bg-tint: rgba(99, 102, 241, 0.13);
    --surface: #171a21;
    --surface-sunken: #1d212a;
    --surface-hover: #232833;
    --border: #272c37;
    --border-strong: #333a48;
    --text: #e9ecf2;
    --muted: #98a1b1;
    --faint: #6f7889;
    --accent: #7c7cf7;
    --accent-hover: #8f8ff9;
    --accent-soft: rgba(124, 124, 247, 0.18);
    --note: #818cf8;
    --review: #38bdf8;
    --review-soft: rgba(56, 189, 248, 0.14);
    --review-text: #7dd3fc;
    --todo: #fbbf24;
    --todo-soft: rgba(251, 191, 36, 0.14);
    --todo-text: #fcd34d;
    --done: #34d399;
    --done-soft: rgba(52, 211, 153, 0.14);
    --done-text: #6ee7b7;
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 20px -6px rgba(0, 0, 0, 0.55), 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

/* ------------------------------------------------------------------
   ベース
------------------------------------------------------------------ */
* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 40px 24px 80px;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 50% -160px, var(--bg-tint), transparent 70%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1040px; margin: 0 auto; }

/* ヘッダー */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}

.page-header h1 {
  margin: 0;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.saved-hint {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 12px 4px 24px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  position: relative;
  cursor: default;
}

.saved-hint::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--done);
}

/* ------------------------------------------------------------------
   ダッシュボード
------------------------------------------------------------------ */
.dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.stat {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px 18px;
  box-shadow: var(--shadow-sm);
}

/* カード上端の細いアクセントライン */
.stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--border-strong);
}

.stat-accent::before { background: linear-gradient(90deg, var(--todo), var(--accent)); }

.stat-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.stat-value {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-unit { font-size: 13px; color: var(--faint); margin-left: 4px; }
.stat-accent .stat-value { color: var(--todo-text); }

/* 最新の振り返り */
.latest {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px 16px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}

.latest::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--review);
}

.latest-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.latest-week { font-size: 12.5px; font-weight: 600; color: var(--review); }

.latest-comment {
  margin: 4px 0 0;
  font-size: 14.5px;
  white-space: pre-wrap;
  word-break: break-word;
  /* 長い振り返りは3行までにたたむ */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.latest-comment.is-empty { color: var(--faint); font-size: 13.5px; }

/* ------------------------------------------------------------------
   レイアウト / パネル
------------------------------------------------------------------ */
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px 24px;
  box-shadow: var(--shadow-md);
}

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

.panel-head { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: 0.01em; }
.panel-note { margin-left: auto; font-size: 12px; color: var(--faint); }

.panel-mark { width: 4px; height: 17px; border-radius: 2px; background: var(--faint); }
.panel-mark-note { background: var(--note); }
.panel-mark-task { background: var(--todo); }
.panel-mark-review { background: var(--review); }

/* ------------------------------------------------------------------
   入力欄
------------------------------------------------------------------ */
.form {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px;
  margin-bottom: 18px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.form-inline { flex-direction: row; }
.form-inline input { flex: 1; min-width: 0; }
.form-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.form-hint { margin-right: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }

.field { display: flex; align-items: center; gap: 10px; }
.field-label { flex-shrink: 0; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field select { max-width: 320px; }

input, textarea, select {
  font: inherit;
  width: 100%;
  padding: 9px 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder, textarea::placeholder { color: var(--faint); }
select { cursor: pointer; }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

textarea { resize: vertical; min-height: 74px; }

/* ------------------------------------------------------------------
   ボタン
------------------------------------------------------------------ */
button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 18px;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, transform 0.06s, box-shadow 0.15s;
}

button:hover { background: var(--accent-hover); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-small {
  font-size: 12.5px;
  font-weight: 500;
  padding: 4px 11px;
  background: var(--surface);
  color: var(--muted);
  border-color: var(--border-strong);
  box-shadow: none;
}

.btn-small:hover { background: var(--surface-hover); color: var(--text); }

.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

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

.item {
  position: relative;
  padding: 13px 15px 13px 18px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

/* 左端のアクセント（種類・状態を色で示す） */
.item::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 13px;
  bottom: 13px;
  width: 3px;
  border-radius: 2px;
  background: var(--faint);
}

.item:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

#note-list .item::before { background: var(--note); }
#task-list .item::before { background: var(--todo); }
#review-list .item::before { background: var(--review); }
#task-list .task-done::before { background: var(--done); }
#task-list .task-done { opacity: 0.72; }

.item-head { display: flex; align-items: flex-start; gap: 9px; }
.item-title { flex: 1; font-weight: 600; letter-spacing: 0.01em; word-break: break-word; }

.item-body {
  margin: 9px 0 0;
  padding-top: 9px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.item-meta {
  margin-top: 9px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.item-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* 操作ボタンは普段控えめ、カードに触れたときにはっきり見せる */
.item-actions button { opacity: 0.55; }
.item:hover .item-actions button, .item-actions button:focus-visible { opacity: 1; }

.badge {
  flex-shrink: 0;
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 9px;
  margin-top: 2px;
  border-radius: 999px;
  background: var(--todo-soft);
  color: var(--todo-text);
}

.badge-done { background: var(--done-soft); color: var(--done-text); }
.badge-week { background: var(--review-soft); color: var(--review-text); }

/* 振り返りは本文が主役なので、週の表記は控えめに */
#review-list .item-title { font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
#review-list .item-body { margin-top: 8px; color: var(--text); font-size: 14.5px; }

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

.empty {
  margin: 0;
  padding: 22px 0;
  text-align: center;
  color: var(--faint);
  font-size: 13.5px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------------
   エラー表示
------------------------------------------------------------------ */
.error {
  margin: 0 0 18px;
  padding: 11px 16px;
  font-size: 14px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------------
   レスポンシブ
------------------------------------------------------------------ */
@media (max-width: 820px) {
  body { padding: 28px 16px 64px; }
  .columns { grid-template-columns: 1fr; }
  .page-header { align-items: flex-start; }
}

@media (max-width: 560px) {
  .dashboard { grid-template-columns: 1fr; gap: 10px; }
  .field { align-items: stretch; flex-direction: column; gap: 5px; }
  .field select { max-width: none; }
  .panel-note { display: none; }
  .stat { padding: 12px 16px 14px; }
  .stat-value { font-size: 28px; }
  .saved-hint { display: none; }
}

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