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

:root {
  /* 明暗どちらのテーマもこのCSSで面倒を見る、とブラウザに伝える
     （これが無いとダークモード時に入力欄などがブラウザ既定の色で上書きされる） */
  color-scheme: light dark;

  /* 背景・面 */
  --bg: #f6f7fb;
  --bg-tint: #eef1f8;
  --surface: #ffffff;
  --surface-sunken: #fafbfd;

  /* 文字 */
  --text: #171b26;
  --text-soft: #4a5266;
  --muted: #79809a;

  /* 線 */
  --line: #e6e9f2;
  --line-strong: #d6dbe8;

  /* アクセント */
  --memo: #5566f0;
  --memo-soft: #eef0fe;
  --task: #e08600;
  --task-soft: #fdf3e2;
  --done: #12876a;
  --done-soft: #e3f5ef;
  --review: #0f8f8a;
  --review-soft: #e3f4f3;
  --danger: #d9455a;
  --danger-soft: #fdedef;

  /* 影 */
  --shadow-sm: 0 1px 2px rgba(20, 26, 48, 0.05);
  --shadow-md: 0 6px 20px -8px rgba(20, 26, 48, 0.18), 0 1px 3px rgba(20, 26, 48, 0.05);
  --shadow-lg: 0 14px 34px -14px rgba(20, 26, 48, 0.26);

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

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101320;
    --bg-tint: #161a2b;
    --surface: #191d2e;
    --surface-sunken: #1f2437;

    --text: #eef0f8;
    --text-soft: #bcc2d6;
    --muted: #8d96b3;

    --line: #2a3045;
    --line-strong: #363d57;

    --memo: #8e9bff;
    --memo-soft: #232a4d;
    --task: #f0a93a;
    --task-soft: #3a2c12;
    --done: #4bcfa8;
    --done-soft: #14332b;
    --review: #55cfc9;
    --review-soft: #142f31;
    --danger: #ff7b8c;
    --danger-soft: #3a2029;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 20px -8px rgba(0, 0, 0, 0.6), 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 14px 34px -14px rgba(0, 0, 0, 0.7);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI",
               "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 12% -10%, var(--bg-tint), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

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

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

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 40px 4px 30px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, var(--memo), #7b6cf6);
  box-shadow: var(--shadow-md);
}
.brand-mark svg { width: 24px; height: 24px; }

.site-header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.35;
}
.tagline { margin: 0; font-size: 0.83rem; color: var(--muted); }

.today {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

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

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

.stat-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  align-items: baseline;
  justify-content: start;
  column-gap: 6px;
  padding: 18px 20px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
/* 上端のアクセントライン */
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: currentColor;
  opacity: 0.9;
}
.stat-card[data-tone="memo"] { color: var(--memo); }
.stat-card[data-tone="task"] { color: var(--task); }
.stat-card[data-tone="done"] { color: var(--done); }

.stat-label {
  grid-column: 1 / -1;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.stat-value {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat-card[data-tone="done"] .stat-value { color: currentColor; }
.stat-unit { font-size: 0.78rem; color: var(--muted); }

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

.latest {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 17px 20px 18px;
  margin-bottom: 26px;
  color: var(--review);
  background:
    linear-gradient(100deg, var(--review-soft), transparent 58%),
    var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid currentColor;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.latest-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  margin-top: 1px;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.latest-icon svg { width: 18px; height: 18px; }

.latest-body { min-width: 0; }
.latest-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.latest-label {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: currentColor;
}
.latest-week {
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.latest-comment {
  margin: 4px 0 0;
  font-size: 0.93rem;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.latest-comment.is-empty { color: var(--muted); font-size: 0.87rem; }

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

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

.panel {
  padding: 22px 22px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.panel-head h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.panel-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
}
.panel-icon svg { width: 17px; height: 17px; }
.panel-icon[data-tone="memo"] { color: var(--memo); background: var(--memo-soft); }
.panel-icon[data-tone="task"] { color: var(--task); background: var(--task-soft); }
.panel-icon[data-tone="review"] { color: var(--review); background: var(--review-soft); }

/* 2カラムの下に置く、幅いっぱいのパネル */
.panel-wide { margin-top: 22px; }

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

.input-block { display: flex; flex-direction: column; gap: 9px; margin-bottom: 22px; }

.field-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.field-label {
  font-size: 0.79rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.form-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.form-hint { margin: 0; font-size: 0.78rem; color: var(--muted); }
.form-foot .btn { flex-shrink: 0; }

select {
  font: inherit;
  font-size: 0.92rem;
  padding: 9px 12px;
  color: var(--text);
  background: var(--surface-sunken);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select:focus {
  outline: none;
  border-color: var(--review);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--review) 18%, transparent);
}

input[type="text"], textarea {
  width: 100%;
  padding: 10px 13px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface-sunken);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input[type="text"]::placeholder, textarea::placeholder { color: var(--muted); }
input[type="text"]:focus, textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--memo);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--memo) 18%, transparent);
}

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

.btn {
  font: inherit;
  font-size: 0.87rem;
  font-weight: 500;
  padding: 9px 15px;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s,
              box-shadow 0.15s, transform 0.1s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--memo) 22%, transparent);
}

.btn.primary {
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: linear-gradient(180deg, var(--memo), color-mix(in srgb, var(--memo) 82%, #000));
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}
.btn.primary:hover { filter: brightness(1.07); box-shadow: var(--shadow-md); }

.btn.small { padding: 4px 10px; font-size: 0.76rem; border-radius: 8px; }
.btn.ghost:hover { color: var(--text); border-color: var(--muted); background: var(--surface-sunken); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }

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

.list-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-top: 16px;
  margin-bottom: 12px;
  border-top: 1px solid var(--line);
}
.list-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.count-chip {
  min-width: 22px;
  padding: 0 7px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 19px;
  text-align: center;
  color: var(--text-soft);
  background: var(--bg-tint);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

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

.item {
  position: relative;
  padding: 13px 15px 12px 17px;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
}
/* 左端の色帯 */
.item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: currentColor;
}
.item:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

#memo-list .item { color: var(--memo); }
#task-list .item { color: var(--task); }
#task-list .item.done { color: var(--muted); }
#review-list .item { color: var(--review); }

/* 振り返り一覧は2列に並べる（横幅があるとき） */
#review-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 10px;
}
#review-list .empty { grid-column: 1 / -1; }

.week-range { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* 「今週」「先週」などの見出し横のラベル */
.week-chip {
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 700;
  color: var(--review);
  background: var(--review-soft);
  vertical-align: 1px;
  white-space: nowrap;
}

.item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.item-title {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}
.item-body {
  margin: 5px 0 0;
  font-size: 0.89rem;
  color: var(--text-soft);
  white-space: pre-wrap;
  word-break: break-word;
}
.item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
  font-size: 0.74rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.actions { display: flex; gap: 6px; flex-shrink: 0; }

/* 一覧の操作ボタンは、カーソルを乗せるまで控えめに */
.item .actions .btn { opacity: 0.55; }
.item:hover .actions .btn,
.item:focus-within .actions .btn { opacity: 1; }

/* ---------- タスクの完了状態 ---------- */

#task-list .item.done { background: var(--bg-tint); box-shadow: none; }
#task-list .item.done .item-title {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.badge.todo { color: var(--task); background: var(--task-soft); }
.badge.done { color: var(--done); background: var(--done-soft); }

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

.empty {
  padding: 26px 12px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--surface-sunken);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
}

/* ---------- 追加された項目のアニメーション ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.item { animation: rise 0.24s ease-out both; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .item:hover { transform: none; }
}

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

@media (max-width: 820px) {
  .columns { grid-template-columns: 1fr; }
  .dashboard { grid-template-columns: 1fr; }
  .shell { padding: 0 16px 56px; }
  .site-header { padding: 28px 2px 22px; }
  .stat-card { padding: 15px 17px 13px; }
  .stat-value { font-size: 1.8rem; }
}
