/* ===========================================================================
   カラーとトークン
   =========================================================================== */
:root {
  --bg: #f5f6f9;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --border: #e7e9f0;
  --border-strong: #d6dae5;

  --text: #1a1f2e;
  --text-2: #545d72;
  --muted: #8d95a8;

  --accent: #4c5fd7;
  --accent-hover: #3d4fc0;
  --accent-soft: #eef0fd;

  --ok: #15803d;
  --ok-bg: #e9f6ee;
  --ok-border: #c8e6d3;
  --warn: #96601a;
  --warn-bg: #fdf2df;
  --warn-line: #e0a44b;
  --danger: #c8412f;
  --danger-bg: #fdeceb;

  --shadow-sm: 0 1px 2px rgba(20, 26, 45, 0.05);
  --shadow: 0 1px 3px rgba(20, 26, 45, 0.05), 0 10px 28px -16px rgba(20, 26, 45, 0.22);
  --shadow-lift: 0 2px 6px rgba(20, 26, 45, 0.07), 0 16px 32px -18px rgba(20, 26, 45, 0.28);

  --radius: 14px;
  --radius-sm: 9px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1219;
    --surface: #171b25;
    --surface-2: #1b202b;
    --border: #272d3b;
    --border-strong: #333b4d;

    --text: #e7eaf1;
    --text-2: #aab2c4;
    --muted: #7d8697;

    --accent: #8092ff;
    --accent-hover: #93a2ff;
    --accent-soft: #212843;

    --ok: #74d99f;
    --ok-bg: #17281f;
    --ok-border: #2a5540;
    --warn: #eab364;
    --warn-bg: #2a2216;
    --warn-line: #b8863c;
    --danger: #ff9384;
    --danger-bg: #2e1c1a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 10px 28px -16px rgba(0, 0, 0, 0.7);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.45), 0 16px 32px -18px rgba(0, 0, 0, 0.8);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic UI",
    "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  font-feature-settings: "palt" 1;   /* 日本語の字間を詰めて読みやすくする */
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-soft); }

/* ===========================================================================
   ヘッダー
   =========================================================================== */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
}
.header-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.header h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.header .tagline {
  font-size: 12.5px;
  color: var(--muted);
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 20px 72px;
}

/* ===========================================================================
   ダッシュボード
   =========================================================================== */
.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 26px;
}
.stat {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px 14px;
}
.stat::before {           /* カード上端の細いアクセントライン */
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--border-strong);
}
.stat-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.stat-value {
  display: block;
  margin-top: 2px;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-unit { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }

.stat-accent::before { background: var(--accent); }
.stat-ok::before { background: var(--ok); }
.stat-ok .stat-value { color: var(--ok); }
.stat-alert::before { background: var(--warn-line); }
.stat-alert .stat-value { color: var(--warn); }

/* ダッシュボード：最新の振り返り */
.latest {
  margin: -12px 0 26px;
  padding: 15px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.latest-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.latest-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.latest-week {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.latest-open { margin-left: auto; }
.latest-body {
  margin: 8px 0 0;
  font-size: 13.5px;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;      /* 長い振り返りは3行までにとどめる */
  overflow: hidden;
}
.latest-empty {
  border-left-color: var(--border-strong);
}
.latest-empty .latest-body { color: var(--muted); }

/* ===========================================================================
   パネル
   =========================================================================== */
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.panel h2 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel h2 .h-icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--accent-soft);
  font-size: 13px;
}

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

/* 週の切り替え */
.week-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.week-current {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  text-align: center;
  justify-content: center;
}
.week-label {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}
.week-sub { font-size: 12px; color: var(--muted); }

.nav-btn {
  flex: none;
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 17px;
  line-height: 1;
  background: var(--surface);
  color: var(--text-2);
  border-color: var(--border-strong);
  box-shadow: none;
}
.nav-btn:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

/* 振り返りの保存行 */
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.form-hint { font-size: 12px; color: var(--muted); }

.review-item.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}
.review-item .item-title { font-size: 14px; font-variant-numeric: tabular-nums; }
.badge-week { background: var(--accent-soft); color: var(--accent); }

/* ===========================================================================
   入力欄
   =========================================================================== */
.form {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-bottom: 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.form-inline { flex-direction: row; }
.form-inline input { flex: 1; }

input, textarea {
  font: inherit;
  width: 100%;
  padding: 9px 12px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; line-height: 1.6; }
input:focus, textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s, color 0.15s, border-color 0.15s;
}
button:hover { background: var(--accent-hover); }
button:active { transform: translateY(1px); }
button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}

/* ===========================================================================
   一覧
   =========================================================================== */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
}
.item {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lift);
  transform: translateY(-1px);
}

.item-head { display: flex; align-items: flex-start; gap: 8px; }
.item-title {
  flex: 1;
  font-weight: 600;
  letter-spacing: 0.01em;
  word-break: break-word;
}
.item-body {
  margin: 7px 0 0;
  font-size: 13.5px;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.item-meta {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* 状態バッジ */
.badge {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  border-radius: 999px;
  padding: 2px 10px;
  background: var(--accent-soft);
  color: var(--text-2);
  white-space: nowrap;
}
.badge-open { background: var(--warn-bg); color: var(--warn); }
.badge-done { background: var(--ok-bg); color: var(--ok); }

/* 日時チップ（ラベル＋値） */
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 2px 9px 2px 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  white-space: nowrap;
}
.meta-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
}
.meta-value { color: var(--text-2); font-variant-numeric: tabular-nums; }
.meta-chip-done { border-color: var(--ok-border); }
.meta-chip-done .meta-label { background: var(--ok-bg); color: var(--ok); }
.meta-chip-done .meta-value { color: var(--ok); }

/* ===========================================================================
   タスク特有の表示
   =========================================================================== */
.task-item {
  border-left: 3px solid var(--warn-line);   /* 左端の色で未完了／完了を区別 */
}
.task-item .item-title { font-size: 15px; }
.task-mark {
  flex: none;
  width: 19px;
  height: 22px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ok);
}
.task-done {
  border-left-color: var(--ok);
  background: color-mix(in srgb, var(--ok-bg) 55%, var(--surface));
}
.task-done .item-title {
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent);
  color: var(--muted);
  font-weight: 500;
}

/* 行内のボタン */
.toggle-btn {
  padding: 3px 11px;
  font-size: 12.5px;
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-strong);
  box-shadow: none;
}
.toggle-btn:hover { background: var(--bg); color: var(--text); }
.toggle-btn-do {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok);
}
.toggle-btn-do:hover { background: var(--ok); border-color: var(--ok); color: #fff; }

.icon-btn {
  padding: 3px 9px;
  font-size: 12.5px;
  font-weight: 500;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}
.icon-btn:hover { background: var(--danger-bg); color: var(--danger); }

/* 空の状態 */
.empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 22px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ===========================================================================
   トースト
   =========================================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-lift);
}

/* ===========================================================================
   レスポンシブ
   =========================================================================== */
@media (max-width: 760px) {
  .columns { grid-template-columns: 1fr; }
  .dashboard { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 13px 14px 11px; }
  .stat-value { font-size: 27px; }
  .stat-label { font-size: 10.5px; letter-spacing: 0.05em; }
}

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

/* ダークテーマではアクセント色が明るいので、上に載る文字は暗くする */
@media (prefers-color-scheme: dark) {
  button { color: #131722; }
  .toggle-btn-do:hover { color: #131722; }
  .toast { color: #24100c; }
}
