/* =========================================================================
   マイ秘書アプリ - スタイル
   色は CSS 変数でまとめてあります。好みに合わせてここだけ変えれば全体に反映されます。
   ========================================================================= */

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --item: #f7f8fb;
  --item-hover: #eef1f7;
  --border: #e4e7ee;
  --border-strong: #d3d8e2;

  --text: #1f2430;
  --muted: #767f8f;
  --faint: #9aa3b2;

  --accent: #4c5fd7;
  --accent-soft: #eceffc;
  --done: #2f9268;
  --done-soft: #e7f3ed;
  --warn: #a8701c;
  --warn-soft: #fbf1e0;
  --danger: #c94a4a;
  --danger-soft: #fbeded;

  --shadow: 0 1px 2px rgba(24, 30, 44, 0.04), 0 6px 20px rgba(24, 30, 44, 0.05);
  --radius: 14px;
}

/* 端末がダークモードのときは、目に優しい配色に切り替える */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d;
    --card: #1c2027;
    --item: #232830;
    --item-hover: #2a3038;
    --border: #2c323c;
    --border-strong: #3a414d;

    --text: #e6e9ef;
    --muted: #98a1b0;
    --faint: #79828f;

    --accent: #8a99f0;
    --accent-soft: #262c44;
    --done: #5fc296;
    --done-soft: #1e3830;
    --warn: #d7a35c;
    --warn-soft: #3a2f1d;
    --danger: #e58a8a;
    --danger-soft: #3b2626;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }

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

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

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 24px 72px;
}

/* ------------------------------------------------------------------ ヘッダー */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--accent), #7b88e8);
  box-shadow: 0 3px 10px rgba(76, 95, 215, 0.28);
  flex-shrink: 0;
}

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

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

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

/* --------------------------------------------------------- ダッシュボード */

.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

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

/* カード上端の細いライン */
.stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--border-strong);
}
.stat-accent::before { background: linear-gradient(90deg, var(--accent), #7b88e8); }

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

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

.stat-unit {
  font-size: 13px;
  color: var(--faint);
  margin-left: 3px;
}

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

/* ------------------------------------- ダッシュボード: 最新の振り返り */

.latest {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px 18px;
  margin-bottom: 22px;
}

.latest-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}

.latest-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.latest-week {
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.latest-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14.5px;
  /* 長い振り返りは3行まで表示し、続きは一覧で読む */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.latest-body.is-empty { color: var(--faint); font-size: 14px; }

/* ------------------------------------------------------------ メッセージ */

.message {
  margin: 0 0 18px;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
}

/* ---------------------------------------------------------------- レイアウト */

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

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px 26px;
}

/* 振り返りのカードは2列の下に全幅で置く */
.card-wide { margin-top: 18px; }

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 30px 0 14px;
}
.section-title:first-child { margin-top: 0; }

.section-title h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* 見出しの右へ伸びる細い罫線 */
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.chip {
  order: 3;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--item);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 10px;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ フォーム */

.form { display: flex; flex-direction: column; gap: 10px; }
.form-row { display: flex; gap: 10px; }
.form-row input { flex: 1; }

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

.hint { font-size: 12px; color: var(--faint); }

.hint-inline { align-self: center; white-space: nowrap; }
.hint-inline.is-recorded { color: var(--done); font-weight: 600; }

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

select {
  cursor: pointer;
  width: auto;
  min-width: 230px;
  font-variant-numeric: tabular-nums;
}
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

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

textarea { resize: vertical; min-height: 92px; line-height: 1.6; }

/* ------------------------------------------------------------------ ボタン */

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 18px;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.08s, box-shadow 0.15s;
}
button:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 6px rgba(76, 95, 215, 0.25);
}
.btn-primary:hover { background: #4354c9; }

.btn-small {
  padding: 5px 11px;
  font-size: 12px;
  border-radius: 8px;
}

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

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

/* -------------------------------------------------------------------- 一覧 */

.list { list-style: none; margin: 0; padding: 0; }

.list li {
  position: relative;
  background: var(--item);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 15px 13px 18px;
  margin-bottom: 10px;
  transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
  animation: appear 0.22s ease-out;
}
.list li:last-child { margin-bottom: 0; }

/* 左端の色帯 */
.list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.list li:hover {
  background: var(--item-hover);
  border-color: var(--border-strong);
}

@keyframes appear {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

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

.item-title {
  font-weight: 600;
  word-break: break-word;
  letter-spacing: 0.01em;
}

.item-body {
  margin: 7px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  color: var(--text);
  opacity: 0.88;
}

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

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

/* ------------------------------------------------------------------ バッジ */

.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-right: 8px;
  vertical-align: 1.5px;
}
.badge-done { background: var(--done-soft); color: var(--done); }
.badge-open { background: var(--warn-soft); color: var(--warn); }
.badge-week { background: var(--accent-soft); color: var(--accent); }

/* 振り返りは本文が主役なので、少し広めに取る */
.review-item .item-body { margin-top: 9px; font-size: 14.5px; }

/* --------------------------------------------------------- 完了したタスク */

.task-done { background: transparent; }
.task-done::before { background: var(--done); opacity: 0.5; }
.task-done .item-title {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  color: var(--muted);
  font-weight: 500;
}

/* -------------------------------------------------------------- 空のとき */

.list li.empty {
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--faint);
  font-size: 13.5px;
  text-align: center;
  padding: 22px;
  animation: none;
}
.list li.empty::before { display: none; }
.list li.empty:hover { background: transparent; border-color: var(--border-strong); }

/* -------------------------------------------------------------- 画面が狭いとき */

@media (max-width: 820px) {
  .app { padding: 28px 16px 56px; }
  .columns { grid-template-columns: 1fr; }
  .dashboard { grid-template-columns: 1fr 1fr; }
  .today { display: none; }
}

@media (max-width: 520px) {
  .card { padding: 20px 18px 22px; }
  .stat { padding: 14px 16px 12px; }
  .stat-value { font-size: 28px; }
}

/* 動きを減らす設定の端末ではアニメーションを止める */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
