/* ============================================
   デザイントークン
   ============================================ */
:root {
  /* スクロールバーやチェックボックスなどの標準UIもOSの配色に追従させる */
  color-scheme: light dark;

  --bg: #f5f6f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e7eaf0;
  --border-strong: #d9dfe8;

  --text: #16202e;
  --text-2: #5f6c7f;
  --text-3: #98a3b3;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0fe;

  --warn: #d97706;
  --warn-soft: #fff6e9;
  --ok: #059669;
  --ok-soft: #e9f9f2;
  --danger: #dc2626;
  --danger-soft: #fdeceb;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 2px 6px rgba(16, 24, 40, 0.04), 0 10px 28px rgba(16, 24, 40, 0.07);

  --radius: 16px;
  --radius-sm: 10px;
  --ring: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* ダークモード（OSの設定に自動追従） */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1320;
    --surface: #161d2c;
    --surface-2: #1b2333;
    --border: #263047;
    --border-strong: #33405c;

    --text: #e8ecf4;
    --text-2: #9daabf;
    --text-3: #6d7b92;

    --accent: #818cf8;
    --accent-hover: #a5b0ff;
    --accent-soft: #202744;

    --warn: #fbbf24;
    --warn-soft: #2c2413;
    --ok: #34d399;
    --ok-soft: #10291f;
    --danger: #f87171;
    --danger-soft: #2d1a1c;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.35);
    --ring: 0 0 0 3px rgba(129, 140, 248, 0.25);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   ヘッダー
   ============================================ */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(180%) blur(8px);
}

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

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

.brand-mark {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #7c6df2);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
}

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-sub {
  margin: 0;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.4;
}

.header-date {
  font-size: 13px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ============================================
   レイアウト
   ============================================ */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.dashboard {
  display: grid;
  /* 広い画面では4枚を横一列に並べる */
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

/* 中くらいの画面では 2×2 に折り返す（1枚だけ余るのを防ぐ） */
@media (max-width: 820px) {
  .dashboard {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

@media (max-width: 860px) {
  .columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .dashboard {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .header-inner,
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }
  .brand-sub {
    display: none;
  }
}

/* ============================================
   ダッシュボード
   ============================================ */
.stat {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  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 {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 19px;
  background: var(--accent-soft);
}

.icon-task {
  background: var(--ok-soft);
}

.icon-pending {
  background: var(--warn-soft);
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

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

.stat-label {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0.03em;
}

/* ============================================
   ダッシュボード: 最新の振り返り
   ============================================ */
.latest-review {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
}

.lr-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.lr-icon {
  font-size: 15px;
}

.lr-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-2);
}

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

.lr-comment {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.lr-empty {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-3);
}

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

/* 全幅パネル（週次の振り返り） */
.panel-wide {
  margin-top: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

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

/* ============================================
   フォーム
   ============================================ */
.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.02em;
}

.form input,
.form textarea {
  width: 100%;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.form input::placeholder,
.form textarea::placeholder {
  color: var(--text-3);
}

.form input:hover,
.form textarea:hover {
  border-color: var(--text-3);
}

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

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-primary:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn-plus {
  font-size: 13px;
  opacity: 0.9;
}

/* 週の選択行 */
.week-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.week-row input[type="week"] {
  width: auto;
  min-width: 190px;
  flex: 0 1 auto;
  font-variant-numeric: tabular-nums;
}

.btn-ghost {
  padding: 9px 14px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.btn-ghost:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.btn-ghost:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.form-note {
  margin: -4px 0 0;
  font-size: 12px;
  color: var(--text-3);
}

.review-week {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

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

.list li {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--surface-2);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  animation: item-in 0.22s ease both;
}

.list li:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

@keyframes item-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.memo-title {
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: 0.01em;
  word-break: break-word;
}

.memo-body {
  margin-top: 4px;
  font-size: 14px;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ============================================
   タスク
   ============================================ */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.task-item input[type="checkbox"] {
  flex: none;
  margin: 2px 0 0;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

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

.task-text {
  font-size: 14px;
  word-break: break-word;
  transition: color 0.16s ease;
}

/* 完了タスクは薄く＋取り消し線 */
.list li.task-item.done {
  background: transparent;
  border-style: dashed;
}

.task-item.done .task-text {
  color: var(--text-3);
  text-decoration: line-through;
  text-decoration-color: var(--text-3);
  text-decoration-thickness: 1.5px;
}

.task-item.done .meta {
  opacity: 0.6;
}

.badge {
  display: inline-block;
  vertical-align: middle;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 1px 8px;
  border-radius: 999px;
  margin-left: 6px;
  white-space: nowrap;
}

.badge.pending {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.complete {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge.current {
  background: var(--accent-soft);
  color: var(--accent);
}

/* 削除ボタン */
.delete-btn {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-3);
  font-size: 15px;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.list li:hover .delete-btn,
.delete-btn:focus-visible {
  opacity: 1;
}

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

.delete-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* タッチ端末ではホバーがないため常時表示 */
@media (hover: none) {
  .delete-btn {
    opacity: 1;
  }
}

/* ============================================
   空状態
   ============================================ */
.list li.empty {
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
  padding: 32px 16px;
  line-height: 1.7;
  animation: none;
}

.list li.empty:hover {
  border-color: var(--border-strong);
  box-shadow: none;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 20px;
  opacity: 0.75;
}

.empty-title {
  display: block;
  font-weight: 600;
  color: var(--text-2);
}

.empty-hint {
  display: block;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

/* 動きを減らす設定への配慮 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
