/* ===========================================================
   秘書アプリ スタイル
   色は :root にまとめてあります。好みで数値を変えれば
   アプリ全体の印象がまとめて変わります。
   =========================================================== */

:root {
  color-scheme: light;

  /* 面（背景 → パネル → 一覧の項目、と少しずつ明るさを変えて層を作る） */
  --bg: #f1f3f7;
  --bg-glow: #e4e9f5;
  --surface: #ffffff;
  --surface-sunken: #f7f9fc;
  --surface-hover: #f0f4fa;

  /* 文字 */
  --text: #101828;
  --text-soft: #475467;
  --muted: #8a94a6;

  /* 線 */
  --border: #e5e9f0;
  --border-strong: #d7dde8;

  /* アクセント */
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef1ff;
  --accent-line: #c7cdfb;

  --done: #0f9d6e;
  --done-soft: #e7f6f0;
  --done-line: #b6e3d2;

  --danger: #dc3d55;
  --danger-soft: #fdecef;

  /* 影 */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 2px 4px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
  --shadow-accent: 0 2px 6px rgba(79, 70, 229, 0.24);

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

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #0e1117;
    --bg-glow: #161c2a;
    --surface: #171b24;
    --surface-sunken: #1d222d;
    --surface-hover: #232936;

    --text: #e9edf5;
    --text-soft: #b3bccc;
    --muted: #8b95a6;

    --border: #262c38;
    --border-strong: #333a48;

    --accent: #818cf8;
    --accent-hover: #949dfa;
    --accent-soft: #1e2338;
    --accent-line: #3b4372;

    --done: #34d399;
    --done-soft: #16281f;
    --done-line: #2c5344;

    --danger: #f2708a;
    --danger-soft: #2c1a20;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.35);
    --shadow-accent: 0 2px 8px rgba(129, 140, 248, 0.28);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 20px 40px;
  min-height: 100vh;
  background:
    radial-gradient(1100px 460px at 12% -10%, var(--bg-glow), transparent 62%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic UI",
    "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 1060px; margin: 0 auto; }

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 34px 4px 24px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(150deg, var(--accent), #7c69f5);
  color: #fff;
  box-shadow: var(--shadow-accent);
}
.brand-mark svg { width: 23px; height: 23px; }

.brand-text h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.brand-text p { margin: 1px 0 0; color: var(--muted); font-size: 0.83rem; }

.today {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

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

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

.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 16px;
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "icon label"
    "icon value";
  column-gap: 14px;
  align-items: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
  grid-area: icon;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  color: var(--text-soft);
}
.stat-icon svg { width: 21px; height: 21px; }

.stat-label {
  grid-area: label;
  font-size: 0.79rem;
  color: var(--muted);
  letter-spacing: 0.03em;
}
.stat-value {
  grid-area: value;
  font-size: 2.05rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* 未完了タスクだけ強調する */
.stat.accent {
  background: linear-gradient(155deg, var(--accent-soft), var(--surface) 70%);
  border-color: var(--accent-line);
}
.stat.accent .stat-icon {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-accent);
}
.stat.accent .stat-value { color: var(--accent); }

/* 進捗バー */
.progress-card {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 20px 17px;
  box-shadow: var(--shadow-sm);
}
.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 9px;
}
.progress-title { font-size: 0.83rem; font-weight: 600; color: var(--text-soft); }
.progress-text { font-size: 0.79rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #7c69f5);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-bar.full { background: linear-gradient(90deg, var(--done), #4ade80); }

/* 最新の振り返り（ダッシュボード） */
.latest-review {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 15px 20px 17px;
  box-shadow: var(--shadow-sm);
}
.latest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.latest-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-soft);
}
.latest-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
}
.latest-icon svg { width: 15px; height: 15px; }
.latest-week {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  padding: 2px 11px;
  font-variant-numeric: tabular-nums;
}
.latest-comment {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  /* 長い振り返りは3行までにして、続きは一覧で読む */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.latest-review.is-empty { border-left-color: var(--border-strong); }
.latest-review.is-empty .latest-comment { color: var(--muted); font-size: 0.86rem; }

/* ---------------- お知らせ ---------------- */

.message {
  margin: 0 0 18px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 0.88rem;
  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(--border);
  border-radius: var(--radius);
  padding: 4px 22px 24px;
  box-shadow: var(--shadow-sm);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 0 16px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.01em;
}
.head-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
}
.head-icon svg { width: 17px; height: 17px; }

.sub-head {
  margin: 0 0 10px;
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 26px 0 12px;
}
.list-head .sub-head { margin: 0; }

.pill {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 11px;
  font-variant-numeric: tabular-nums;
}

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

.form { display: flex; flex-direction: column; gap: 9px; }
.form.row { flex-direction: row; }
.form.row input { flex: 1; min-width: 0; }

input, textarea, button { font: inherit; }

input[type="text"], textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
input[type="text"]::placeholder, textarea::placeholder { color: var(--muted); }
input[type="text"]:focus, textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 76px; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-accent);
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.55; cursor: default; box-shadow: none; }
.btn-icon { width: 15px; height: 15px; flex: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 振り返りパネルは横幅いっぱいに置く */
.panel-wide { grid-column: 1 / -1; }

.week-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.week-label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-soft);
  flex: none;
}
.select {
  padding: 9px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  min-width: 250px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.week-state {
  font-size: 0.78rem;
  color: var(--muted);
}
.form-actions { display: flex; justify-content: flex-end; }

.text-btn {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 11px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.text-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

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

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

.item {
  position: relative;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.item:hover {
  background: var(--surface-hover);
  transform: translateX(2px);
  box-shadow: var(--shadow-sm);
}

.item-head { display: flex; align-items: center; gap: 9px; }
.item-title {
  font-weight: 650;
  font-size: 0.95rem;
  word-break: break-word;
  flex: 1;
  min-width: 0;
}
.item-body {
  margin: 5px 0 0;
  color: var(--text-soft);
  font-size: 0.89rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.item-meta {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-strong);
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.item-meta .spacer { flex: 1; }

/* 追加された項目だけ、そっと現れる */
.item.is-new { animation: rise 0.24s cubic-bezier(0.2, 0.8, 0.3, 1); }
@keyframes rise {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

/* 空のとき */
.empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 26px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.empty svg { width: 26px; height: 26px; opacity: 0.5; }

.item.review .item-body { color: var(--text); margin-top: 7px; }
.item.review .item-title { font-size: 0.88rem; color: var(--text-soft); }

/* ---------------- タスク ---------------- */

.task-row { display: flex; align-items: flex-start; gap: 11px; }
.task-main { flex: 1; min-width: 0; }

/* チェックボックスを丸みのある四角に作り替える */
.check { position: relative; flex: none; width: 21px; height: 21px; margin-top: 2px; }
.check input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.check-mark {
  position: absolute;
  inset: 0;
  border: 1.8px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  transition: background 0.15s ease, border-color 0.15s ease;
  pointer-events: none;
}
.check-mark::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2.5px;
  width: 5px;
  height: 9.5px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0.5);
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.check input:hover + .check-mark { border-color: var(--accent); }
.check input:checked + .check-mark { background: var(--done); border-color: var(--done); }
.check input:checked + .check-mark::after { opacity: 1; transform: rotate(45deg) scale(1); }
.check input:focus-visible + .check-mark { outline: 2px solid var(--accent); outline-offset: 2px; }
.check input:disabled { cursor: default; }

/* 完了したタスクは沈ませる */
.task.done {
  background: var(--done-soft);
  border-color: var(--done-line);
  border-left-color: var(--done);
}
.task.done:hover { background: var(--done-soft); }
.task.done .item-title { text-decoration: line-through; color: var(--muted); font-weight: 500; }

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  flex: none;
  letter-spacing: 0.02em;
}
.badge.open { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.badge.done { color: var(--done); background: var(--surface); border-color: var(--done-line); }

/* 削除ボタン（アイコン） */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 27px;
  height: 27px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { color: var(--danger); background: var(--danger-soft); border-color: var(--danger); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }

/* ---------------- フッター ---------------- */

.foot {
  margin-top: 26px;
  text-align: center;
  color: var(--muted);
  font-size: 0.76rem;
}
.foot code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 0.95em;
}

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

@media (max-width: 900px) {
  .columns { grid-template-columns: 1fr; }
  .dashboard { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  body { padding: 0 14px 32px; }
  .topbar { padding: 24px 2px 18px; }
  .dashboard { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-value { font-size: 1.75rem; }
  .panel { padding: 4px 16px 20px; }
  .form.row { flex-wrap: wrap; }
  .select { min-width: 0; width: 100%; }
  .form-actions { justify-content: stretch; }
  .form-actions .btn-primary { width: 100%; }
}

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