/* ===========================================================================
   マイ秘書 — スタイル
   色・角丸・影はすべて下の変数で管理しています。
   =========================================================================== */

:root {
  --page-width: 1060px;

  /* 背景と面 */
  --bg: #f1f3f9;
  --surface: #ffffff;
  --surface-2: #f7f8fc;   /* 一覧の項目 */
  --surface-3: #eff1f6;   /* 完了済みの項目 */

  /* 文字 */
  --text: #161a23;
  --text-2: #4c5466;
  --text-3: #6e7789;   /* 補助的な文字（以前より少し濃く） */

  /* 線 */
  --line: #e6e9f1;
  --line-2: #d7dce8;

  /* アクセント */
  --accent: #4a5fd0;
  --accent-hover: #3a4dbb;
  --accent-weak: #edf0fd;
  --accent-line: #ccd4f7;

  --success: #1d8050;
  --success-weak: #e9f5ee;
  --success-line: #bfe0cd;

  --danger: #cf4436;
  --danger-weak: #fdeeec;

  /* 角丸・影 */
  --r-lg: 18px;
  --r: 13px;
  --r-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(22, 27, 51, .05);
  --shadow: 0 10px 28px -14px rgba(22, 30, 70, .30), 0 1px 2px rgba(22, 27, 51, .04);
  --ring: 0 0 0 3px rgba(74, 95, 208, .18);
}

* { box-sizing: border-box; }

/* hidden 属性を付けた要素は必ず隠す（display 指定に負けないように） */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 32px 18px 72px;
  background:
    radial-gradient(900px 420px at 50% -160px, #e4e9fb 0%, rgba(228, 233, 251, 0) 70%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", Meiryo, system-ui, sans-serif;
  font-size: 14.5px;
  line-height: 1.75;
  font-feature-settings: "palt" 1;   /* 日本語の字間を詰めて読みやすく */
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--page-width); margin: 0 auto; }

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

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 46px;
  height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 23px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.page-head h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .01em;
  color: #0f131b;
}
.page-head .sub {
  margin: 1px 0 0;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.5;
}
.head-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.storage-badge {
  color: #5b45ab;
  background: #f0ecfb;
  border: 1px solid #ddd3f5;
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.today {
  margin: 0;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 6px 16px;
  box-shadow: var(--shadow-sm);
}

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

.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.stat {
  /* --c / --c-weak を差し替えてカードごとに色分けする */
  --c: var(--accent);
  --c-weak: var(--accent-weak);

  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--c);
  border-radius: var(--r-lg);
  padding: 15px 18px;
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 1px 13px;
}
.stat-icon {
  grid-row: 1 / span 2;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-size: 19px;
  background: var(--c-weak);
  border-radius: 12px;
}
.stat-label {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .03em;
  align-self: end;
}
.stat-num { display: flex; align-items: baseline; gap: 5px; align-self: start; }
.stat-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  color: var(--c);
}
.stat-unit { color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.stat-note {
  grid-column: 2;
  color: var(--c);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
}
.stat-note:empty { display: none; }

/* カードごとの色 */
.stat--memo { --c: #3f5bd1; --c-weak: #ebeefc; }
.stat--task { --c: #c2700a; --c-weak: #fdf0da; }
.stat--done {
  --c: var(--success);
  --c-weak: var(--success-weak);
  background: linear-gradient(180deg, #f2faf5 0%, var(--surface) 70%);
  border-top-color: var(--success-line);
  border-right-color: var(--success-line);
  border-bottom-color: var(--success-line);
}
.stat--active {
  --c: #c0392f;
  --c-weak: #fdecea;
  background: linear-gradient(180deg, #fff6f4 0%, var(--surface) 70%);
  border-top-color: #f3d3ce;
  border-right-color: #f3d3ce;
  border-bottom-color: #f3d3ce;
}

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

.latest {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid #7159c9;
  border-radius: var(--r-lg);
  padding: 14px 18px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}
.latest-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-size: 19px;
  background: #f0ecfb;
  border-radius: 12px;
}
.latest-body { min-width: 0; }
.latest-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.latest-label {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .03em;
}
.latest-week { color: #5b45ab; font-size: 12.5px; font-weight: 600; }
.latest-week.has-data { color: #5b45ab; }
.latest-comment {
  margin: 2px 0 0;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  /* 長い振り返りは2行まで表示 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.latest-comment.placeholder { color: var(--text-3); }
.btn.ghost {
  background: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--text-2);
}
.btn.ghost:hover { border-color: #7159c9; color: #5b45ab; background: #f7f4fd; }

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

.message {
  margin: 0 0 18px;
  padding: 11px 16px;
  border-radius: var(--r);
  background: var(--danger-weak);
  color: var(--danger);
  border: 1px solid #f3cfca;
  font-size: 13.5px;
  box-shadow: var(--shadow-sm);
}

/* ------------------------------------------------------------ パネル */

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px 22px 24px;
  box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.panel-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  font-size: 15px;
  background: var(--surface-2);
  border-radius: 9px;
}
.panel h2 { margin: 0; font-size: 16.5px; font-weight: 700; letter-spacing: .02em; }
.panel-wide { grid-column: 1 / -1; }
.panel-hint { margin-left: auto; color: var(--text-3); font-size: 12px; }

/* ---------------------------------------------------------- 入力欄 */

.form { display: flex; flex-direction: column; gap: 9px; }
.card-form {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 13px;
  margin-bottom: 4px;
}
.inline-form { display: flex; gap: 9px; }
.inline-form input { flex: 1; min-width: 0; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.form-note { color: var(--text-3); font-size: 12px; text-align: right; }
.form-note:empty { display: none; }

/* 振り返りの週選択 */
.week-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.week-label { color: var(--text-2); font-size: 13px; font-weight: 600; }
.week-range { color: var(--text-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
select {
  font: inherit;
  font-size: 13.5px;
  padding: 7px 11px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: inherit;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

input[type="text"], textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 14px;
  background: var(--surface);
  color: inherit;
  resize: vertical;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]::placeholder, textarea::placeholder { color: #a8afbe; }
input[type="text"]:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

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

button { font: inherit; cursor: pointer; border-radius: var(--r-sm); border: 1px solid transparent; }
button:focus-visible { outline: none; box-shadow: var(--ring); }

.btn {
  padding: 8px 18px;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s, box-shadow .15s, border-color .15s, color .15s;
}
.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px -3px rgba(74, 95, 208, .6);
}
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:active { transform: translateY(1px); }

/* 一覧の項目の中の小さなボタン */
.icon-btn {
  background: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--text-2);
  padding: 4px 11px;
  font-size: 12.5px;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-weak); }
.icon-btn.armed { background: var(--danger); border-color: var(--danger); color: #fff; }
.icon-btn.armed:hover { background: var(--danger); color: #fff; }
.icon-btn.complete { border-color: var(--success-line); color: var(--success); background: var(--success-weak); }
.icon-btn.complete:hover { background: var(--success); border-color: var(--success); color: #fff; }

/* -------------------------------------------------------- 一覧見出し */

.list-head {
  margin: 22px 0 11px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 8px;
}
/* 見出し全体が折りたたみボタン */
.head-toggle {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  text-align: left;
}
.head-toggle:hover { color: var(--accent); }
.head-toggle:hover .count { border-color: var(--accent-line); }
/* 開閉の三角マーク */
.caret {
  flex: none;
  width: 0;
  height: 0;
  font-size: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-3);
  transition: transform .15s;
}
.head-toggle.collapsed .caret { transform: rotate(-90deg); }
.head-toggle:hover .caret { border-top-color: var(--accent); }

.list-head .count {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
  padding: 0 7px;
  font-size: 11.5px;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

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

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }

.item {
  position: relative;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 12px 14px 11px 16px;
  background: var(--surface-2);
  transition: background .15s, box-shadow .15s, border-color .15s;
}
/* 左端のカラーバー */
.item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.item:hover {
  background: #fff;
  border-color: var(--accent-line);
  box-shadow: var(--shadow);
}

.item-head { display: flex; align-items: flex-start; gap: 9px; }
.item-title {
  font-weight: 600;
  font-size: 14.5px;
  flex: 1;
  min-width: 0;
  word-break: break-word;
  line-height: 1.6;
}
.item-body {
  margin: 7px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13.5px;
  color: var(--text-2);
}
.item-meta {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px dashed var(--line-2);
  font-size: 11.5px;
  color: var(--text-3);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}

/* 状態バッジ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #fff5e0;
  color: #8a6100;
  border: 1px solid #f0dcae;
}
.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.badge.done { background: var(--success-weak); color: var(--success); border-color: var(--success-line); }

/* 完了したタスク */
.item.done { background: var(--surface-3); border-color: var(--line); }
.item.done::before { background: #6fb98a; }
.item.done:hover { background: #fff; border-color: var(--success-line); }
.item.done .item-title { text-decoration: line-through; text-decoration-color: rgba(0, 0, 0, .25); color: var(--text-3); }

.task-check {
  margin: 4px 0 0;
  width: 17px;
  height: 17px;
  flex: none;
  cursor: pointer;
  accent-color: var(--accent);
}
.item.done .task-check { accent-color: var(--success); }

/* 振り返りの項目 */
.item.review::before { background: #7159c9; }
.item.review .item-title { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.week-badge {
  background: #f0ecfb;
  color: #5b45ab;
  border: 1px solid #ddd3f5;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 11.5px;
  font-weight: 700;
}
.week-text {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.item.review .item-body { color: var(--text); }
.edit-week { margin-bottom: 2px; }

/* ------------------------------------------------- メモの編集フォーム */

.item.editing { background: var(--surface); border-color: var(--accent); box-shadow: var(--shadow); }
.item.editing::before { background: var(--accent); }
.edit-form { gap: 9px; }
.edit-buttons { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.edit-buttons .icon-btn { padding: 8px 15px; font-size: 13.5px; }

/* --------------------------------------------- 「さらに◯件を表示」 */

.more-btn {
  width: 100%;
  margin-top: 9px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px dashed var(--line-2);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  transition: background .15s, border-color .15s, color .15s;
}
.more-btn:hover {
  background: var(--accent-weak);
  border-color: var(--accent-line);
  border-style: solid;
  color: var(--accent);
}

/* ---------------------------------------------------------- 空の表示 */

.empty {
  margin: 2px 0 0;
  padding: 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  background: var(--surface-2);
  border: 1px dashed var(--line-2);
  border-radius: var(--r);
}

/* ---------------------------------------------------------- 狭い画面 */

/* カードが4枚あるので、中くらいの幅では2列に */
@media (max-width: 980px) {
  .dashboard { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  body { padding: 22px 14px 56px; }
  .columns { grid-template-columns: 1fr; }
  .panel { padding: 18px 16px 20px; }
  .today { display: none; }
  .panel-hint { display: none; }
  .latest { grid-template-columns: auto 1fr; }
  .latest .btn.ghost { grid-column: 2; justify-self: start; }
}

/* 幅の狭い画面ではダッシュボードを1列・横並びの小さめ表示に */
@media (max-width: 560px) {
  .dashboard { grid-template-columns: 1fr; gap: 10px; }
  .stat {
    grid-template-columns: auto 1fr auto;
    align-items: center;
    padding: 11px 15px;
  }
  .stat-icon { grid-row: auto; width: 36px; height: 36px; font-size: 16px; }
  .stat-label { align-self: center; }
  .stat-num { align-self: center; }
  .stat-value { font-size: 26px; }
  .stat-note { grid-column: 2 / span 2; margin-top: -2px; }
}

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