/* ===========================================================================
   秘書アプリ  スタイル
   色はすべて :root の変数で管理しています。
   =========================================================================== */

:root {
  /* 背景・面 */
  --bg: #eef1f7;
  --bg-tint: #e4e9f4;
  --card: #ffffff;
  --item-bg: #f5f7fc;
  --item-bg-hover: #ffffff;

  /* 文字 */
  --text: #16203a;
  --text-soft: #4a566e;
  --muted: #7c879c;

  /* 罫線 */
  --line: #e3e8f2;
  --line-strong: #d3dbe9;

  /* アクセント */
  --accent: #4c6ef5;
  --accent-dark: #3b5bdb;
  --accent-soft: #eaefff;
  --warn: #e8963a;
  --warn-soft: #fdf3e6;
  --danger: #d9534f;
  --danger-soft: #fdf0ef;
  --done: #2f9e63;
  --done-soft: #ecf7f1;
  --review: #0f9b8e;
  --review-dark: #0b7a70;
  --review-soft: #e6f6f4;

  /* 影 */
  --shadow-sm: 0 1px 2px rgba(22, 32, 58, .05);
  --shadow-md: 0 2px 4px rgba(22, 32, 58, .05), 0 8px 20px rgba(22, 32, 58, .06);
  --shadow-lg: 0 4px 10px rgba(22, 32, 58, .07), 0 16px 32px rgba(22, 32, 58, .09);

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

* { box-sizing: border-box; }

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

body {
  margin: 0;
  padding: 0 20px 64px;
  min-height: 100vh;
  background:
    radial-gradient(1000px 520px at 12% -8%, #ffffff 0%, rgba(255, 255, 255, 0) 62%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-tint) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Segoe UI Variable Text", "Segoe UI", "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

main { max-width: 1080px; margin: 0 auto; }

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

.site-header {
  max-width: 1080px;
  margin: 0 auto;
  padding: 36px 0 26px;
}

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

.brand-mark {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, #6a8bff 0%, var(--accent-dark) 100%);
  box-shadow: 0 4px 12px rgba(76, 110, 245, .35);
}
.brand-mark svg { width: 24px; height: 24px; }

.site-header h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.subtitle {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: .84rem;
}

/* --- カード -------------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  margin: 0 0 18px;
  font-size: .98rem;
  font-weight: 700;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.h-icon {
  width: 17px;
  height: 17px;
  flex: none;
  color: var(--accent);
}

.count {
  margin-left: auto;
  min-width: 26px;
  text-align: center;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 1px 10px;
  font-size: .76rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

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

.dashboard {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 13px;
  align-items: center;
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--tone, var(--accent));
}
.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat[data-tone="memo"] { --tone: var(--accent);  --tone-soft: var(--accent-soft); }
.stat[data-tone="task"] { --tone: #7a5af5;        --tone-soft: #f0ecff; }
.stat[data-tone="done"] { --tone: var(--done);    --tone-soft: var(--done-soft); }
.stat[data-tone="open"] { --tone: var(--warn);    --tone-soft: var(--warn-soft); }

.stat-icon {
  grid-row: 1 / 3;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--tone-soft);
  color: var(--tone);
}
.stat-icon svg { width: 21px; height: 21px; }

.stat-label {
  align-self: end;
  font-size: .8rem;
  color: var(--muted);
  letter-spacing: .01em;
}
.stat-value {
  align-self: start;
  font-size: 1.95rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}

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

.latest-review {
  position: relative;
  padding: 18px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.latest-review::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--review);
}

.latest-head {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.latest-icon {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--review-soft);
  color: var(--review);
}
.latest-icon svg { width: 15px; height: 15px; }

.latest-title { font-size: .92rem; font-weight: 700; letter-spacing: -.01em; }

.latest-week {
  background: var(--review-soft);
  color: var(--review-dark);
  border-radius: 999px;
  padding: 1px 11px;
  font-size: .76rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.latest-link {
  margin-left: auto;
  font-size: .78rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.latest-link:hover { border-bottom-color: currentColor; }

.latest-comment {
  margin: 0;
  color: var(--text-soft);
  font-size: .93rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.latest-comment.is-empty { color: var(--muted); }

/* --- 2 カラム ------------------------------------------------------------ */

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

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

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

.form label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: .02em;
}

input[type="text"], input[type="week"], textarea {
  font: inherit;
  color: inherit;
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fbfcff;
  resize: vertical;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input[type="text"]::placeholder, textarea::placeholder { color: #a9b3c4; }
input[type="text"]:focus, input[type="week"]:focus, textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76, 110, 245, .16);
}

input[type="week"] { font-variant-numeric: tabular-nums; }

.hint {
  margin: 8px 0 0;
  font-size: .76rem;
  color: var(--muted);
}

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

.btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s, color .15s;
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(76, 110, 245, .3);
}

.btn.primary {
  margin-top: 10px;
  background: linear-gradient(180deg, #5b7bf7 0%, var(--accent) 100%);
  color: #fff;
  font-weight: 600;
  letter-spacing: .02em;
  box-shadow: 0 2px 6px rgba(76, 110, 245, .3);
}
.btn.primary:hover {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
  box-shadow: 0 4px 12px rgba(76, 110, 245, .36);
}
.btn.primary:active { transform: translateY(1px); box-shadow: var(--shadow-sm); }

.btn.small {
  padding: 4px 11px;
  font-size: .78rem;
  background: #fff;
  border-color: var(--line-strong);
  color: var(--text-soft);
  box-shadow: var(--shadow-sm);
}
.btn.small:hover { border-color: var(--muted); color: var(--text); }
.btn.small.danger:hover {
  background: var(--danger-soft);
  border-color: #eab6b4;
  color: var(--danger);
}

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

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

.list li {
  position: relative;
  background: var(--item-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 15px 13px 18px;
  margin-bottom: 10px;
  overflow: hidden;
  transition: background .16s, box-shadow .16s, transform .16s;
}
.list li::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--bar, var(--accent));
}
.list li:last-child { margin-bottom: 0; }
.list li:hover {
  background: var(--item-bg-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* 追加直後の項目を一瞬だけ光らせる */
.list li.is-new { animation: flash .9s ease-out; }
@keyframes flash {
  0%   { background: var(--accent-soft); box-shadow: 0 0 0 3px rgba(76, 110, 245, .18); }
  100% { background: var(--item-bg);     box-shadow: none; }
}

.item-title {
  font-weight: 600;
  letter-spacing: -.01em;
  word-break: break-word;
}
.item-body {
  margin: 5px 0 0;
  color: var(--text-soft);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .92rem;
}
.item-meta {
  margin-top: 8px;
  font-size: .76rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}

/* --- タスク項目 ---------------------------------------------------------- */

#task-list li { --bar: var(--warn); }
#task-list li.done { --bar: var(--done); }

.task-row { display: flex; align-items: flex-start; gap: 11px; }

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

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

.task-actions {
  display: flex;
  gap: 6px;
  flex: none;
  opacity: .55;
  transition: opacity .16s;
}
.list li:hover .task-actions,
.list li:focus-within .task-actions { opacity: 1; }

li.done { background: var(--done-soft); border-color: #cfe7db; }
li.done:hover { background: #f5fbf8; }
li.done .item-title { text-decoration: line-through; color: var(--muted); }

.badge {
  border-radius: 999px;
  padding: 1px 10px;
  font-size: .72rem;
  font-weight: 600;
  border: 1px solid;
}
.badge.open { color: #b4741f; border-color: #f0d9b8; background: var(--warn-soft); }
.badge.done { color: var(--done);  border-color: #c6e5d3; background: #f1faf5; }

/* --- 振り返り項目 -------------------------------------------------------- */

#review-list li { --bar: var(--review); }

.review-head {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.review-head .item-title {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.week-no {
  background: var(--review-soft);
  color: var(--review-dark);
  border-radius: 999px;
  padding: 0 9px;
  font-size: .72rem;
  font-weight: 700;
}

.review-head .task-actions { margin-left: auto; }

/* --- 空の状態 ------------------------------------------------------------ */

.empty {
  margin: 0;
  padding: 22px 12px;
  text-align: center;
  color: var(--muted);
  font-size: .86rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fafbfe;
}

/* --- トースト ------------------------------------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 16px);
  background: #1c2540;
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: .86rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

/* --- レスポンシブ -------------------------------------------------------- */

/* 幅が足りなくなったら 4 枚 → 2 枚 → 1 枚と折り返す */
@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 880px) {
  .columns { grid-template-columns: 1fr; }
  .dashboard { gap: 12px; }
  .stats { gap: 12px; }
  .stat { padding: 14px 16px; }
  .stat-value { font-size: 1.7rem; }
  .site-header { padding: 26px 0 20px; }
}

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

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