/* =========================================================
   秘書アプリ スタイル
   ========================================================= */

:root {
  /* 色 */
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-sunken: #f7f8fb;
  --text: #1c2233;
  --text-sub: #4a5368;
  --muted: #7a8296;
  --border: #e4e7ef;
  --border-strong: #cfd5e2;

  --primary: #4157d4;
  --primary-hover: #3346b8;
  --primary-soft: #eceffd;
  --primary-ring: rgba(65, 87, 212, 0.18);

  --danger: #d04a3f;
  --danger-soft: #fdeeec;
  --success: #23875a;
  --success-soft: #e5f4ec;
  --warning: #c27a12;
  --warning-soft: #fdf3e2;
  --review: #7650c9;
  --review-soft: #f1ecfb;

  /* 形 */
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(20, 27, 51, 0.05);
  --shadow-md: 0 1px 2px rgba(20, 27, 51, 0.04), 0 4px 16px rgba(20, 27, 51, 0.06);
  --shadow-lg: 0 2px 4px rgba(20, 27, 51, 0.05), 0 10px 28px rgba(20, 27, 51, 0.1);
}

* { box-sizing: border-box; }

/* 文字の基準サイズ（ブラウザ標準16px → 18px）。各所の rem はこれに比例して大きくなる */
html { font-size: 112.5%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Yu Gothic UI", "Hiragino Sans", "Meiryo", sans-serif;
  line-height: 1.65;
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
}

p, h1, h2, h3, h4 { margin: 0; }
html { scroll-behavior: smooth; }

svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

/* ---------- ヘッダー ---------- */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #5468e0, #3a4cc4);
  color: #fff;
  box-shadow: 0 4px 12px rgba(65, 87, 212, 0.3);
}
.brand h1 { font-size: 1.2rem; font-weight: 700; letter-spacing: 0.04em; line-height: 1.3; }
.brand-sub { color: var(--muted); font-size: 0.8rem; }

.greeting { text-align: right; }
.greeting-text { font-weight: 600; color: var(--text-sub); }
.greeting-date { color: var(--muted); font-size: 0.85rem; }

/* ---------- ダッシュボード ---------- */
.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.stat-icon {
  flex-shrink: 0;
  width: 2.6rem;
  height: 2.6rem;
  padding: 0.6rem;
  border-radius: var(--radius-md);
}
.stat-icon-memo { background: var(--primary-soft); color: var(--primary); }
.stat-icon-task { background: var(--surface-sunken); color: var(--text-sub); box-shadow: inset 0 0 0 1px var(--border); }
.stat-icon-pending { background: var(--warning-soft); color: var(--warning); }
.stat-icon-completed { background: var(--success-soft); color: var(--success); }

.stat-body { flex: 1; min-width: 0; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat-value small { margin-left: 4px; font-size: 0.85rem; font-weight: 500; color: var(--muted); }

.progress {
  height: 6px;
  margin-top: 10px;
  border-radius: 999px;
  background: var(--surface-sunken);
  box-shadow: inset 0 0 0 1px var(--border);
  overflow: hidden;
}
.progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #2fa36d, var(--success));
  transition: width 0.4s ease;
}
.progress-text { margin-top: 4px; color: var(--muted); font-size: 0.78rem; }
/* 最新の振り返り（ダッシュボードの横幅いっぱい） */
.stat-review { grid-column: 1 / -1; }
.stat-icon-review { background: var(--review-soft); color: var(--review); }
.latest-review-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 14px;
}
.latest-review-week { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.latest-review-box {
  margin: 8px 0 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--review-soft);
  color: var(--text-sub);
}
.latest-review-box.is-empty { background: var(--surface-sunken); color: var(--muted); }
/* 長いときは3行までにして、続きは一覧で読む（余白は外側の箱に持たせ、4行目がはみ出さないようにする） */
.latest-review-comment {
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.week-tag {
  flex-shrink: 0;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--review);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.7;
}

.text-link {
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}
.text-link:hover { text-decoration: underline; }

.stat-sub {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- レイアウト ---------- */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.column { display: flex; flex-direction: column; gap: 24px; }

.section { margin-top: 40px; scroll-margin-top: 16px; }
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 1.15rem;
  font-weight: 700;
}
.section-title::before {
  content: "";
  width: 4px;
  height: 1.1em;
  border-radius: 999px;
  background: var(--review);
}

.panel {
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 1.02rem;
  font-weight: 700;
}
.count-pill {
  min-width: 1.8em;
  padding: 0 0.6em;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- フォーム ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-inline { flex-direction: row; gap: 10px; }
.form-inline input { flex: 1; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { color: var(--text-sub); font-size: 0.85rem; font-weight: 600; }

input[type="text"], input[type="date"], textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]::placeholder, textarea::placeholder { color: #a6acbb; }
input[type="text"]:hover, input[type="date"]:hover, textarea:hover { border-color: #b6bed0; }
input[type="text"]:focus, input[type="date"]:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-ring);
}
textarea { resize: vertical; min-height: 6.5em; }
input[type="date"] { max-width: 14em; cursor: pointer; }

/* 振り返りフォームの「対象の週」表示 */
.week-info {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--review-soft);
}
.week-range { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-weight: 700; }
.week-stats { margin-top: 2px; color: var(--text-sub); font-size: 0.82rem; }
.form-note { color: var(--review); font-size: 0.85rem; }

.btn-ghost {
  flex-shrink: 0;
  padding: 4px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-sub);
  font-size: 0.82rem;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-ghost:hover, .btn-ghost:focus-visible {
  outline: none;
  color: var(--review);
  border-color: var(--review);
  background: var(--review-soft);
}

button { font: inherit; cursor: pointer; }

.btn-primary {
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.05em;
  box-shadow: 0 1px 2px rgba(20, 27, 51, 0.1), 0 4px 10px rgba(65, 87, 212, 0.22);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: translateY(1px); box-shadow: 0 1px 2px rgba(20, 27, 51, 0.12); }
.btn-primary:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--primary-ring); }

/* ---------- 一覧 ---------- */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* 1件ずつ枠つきのカードにして、パネルの背景と区別しやすくする */
.list > li {
  position: relative;
  padding: 14px 16px 14px 20px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
/* 左端の色帯（メモ：青、未完了：オレンジ、完了：緑） */
.list > li::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 12px;
  bottom: 12px;
  width: 4px;
  border-radius: 999px;
  background: var(--primary);
}
.list > li:hover {
  background: var(--surface);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}
.list > li.empty {
  padding: 28px 16px;
  background: transparent;
  border: 1.5px dashed var(--border-strong);
  box-shadow: none;
  color: var(--muted);
  text-align: center;
}
.list > li.empty::before { display: none; }

.meta { color: var(--muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.task .meta { display: flex; flex-wrap: wrap; column-gap: 1em; }
.task .meta > span { white-space: nowrap; }

/* メモ */
.memo h3 { font-size: 1rem; font-weight: 700; color: var(--text); }
.memo-body {
  margin-top: 6px;
  color: var(--text-sub);
  white-space: pre-wrap;
  word-break: break-word;
}
.memo .meta { margin-top: 10px; }

/* 振り返り */
.list > li.review::before { background: var(--review); }
.review-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.review-head h4 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 1rem; font-weight: 700; }
.review-comment { margin-top: 8px; color: var(--text-sub); white-space: pre-wrap; word-break: break-word; }
.meta-row { display: flex; flex-wrap: wrap; column-gap: 1em; margin-top: 10px; }
.meta-row > span { white-space: nowrap; }

/* タスク */
.task { display: flex; align-items: center; gap: 14px; }
.list > li.task::before { background: var(--warning); }
.list > li.task.is-done::before { background: var(--success); }
.list > li.task.is-done { background: #f3f8f5; }

.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.task-text { font-weight: 600; word-break: break-word; }
.task.is-done .task-text {
  color: var(--muted);
  font-weight: 500;
  text-decoration: line-through;
  text-decoration-color: rgba(122, 130, 150, 0.6);
}

/* 丸いチェックボックス */
.task input[type="checkbox"] {
  appearance: none;
  flex-shrink: 0;
  width: 1.4rem;
  height: 1.4rem;
  margin: 0;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface) center / 70% no-repeat;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.task input[type="checkbox"]:hover { border-color: var(--success); }
.task input[type="checkbox"]:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(35, 135, 90, 0.2); }
.task input[type="checkbox"]:checked {
  border-color: var(--success);
  background-color: var(--success);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}

/* 状態バッジ */
.badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-todo { background: var(--warning-soft); color: var(--warning); }
.badge-done { background: var(--success-soft); color: var(--success); }

/* 削除ボタン（普段は控えめ、マウスを乗せると赤） */
.btn-delete {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.btn-delete svg { width: 1em; height: 1em; }
.btn-delete:hover, .btn-delete:focus-visible {
  outline: none;
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(208, 74, 63, 0.25);
}

/* ---------- スマホなど狭い画面 ---------- */
/* ダッシュボードの件数カードは、中くらいの画面では 2 列に */
@media (max-width: 1100px) {
  .dashboard { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; }
  .dashboard { grid-template-columns: 1fr; gap: 10px; }
  .stat { padding: 14px 16px; align-items: center; }
  .stat-value { font-size: 1.6rem; }
  .greeting { text-align: left; }
  .panel { padding: 18px; }
}
/* タスクは「チェック＋内容」と「状態＋削除」の2段に分ける */
@media (max-width: 640px) {
  .task { flex-wrap: wrap; row-gap: 8px; }
  .task-main { flex-basis: calc(100% - 2.4rem); }
  .badge { margin-left: calc(1.4rem + 14px); }
  .btn-delete { margin-left: auto; }
}
