/* ============================================================
   マイ秘書 — 配色とデザイントークン
   ============================================================ */

:root {
  --bg: #f2f4f8;
  --bg-glow: #dfe6f5;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --text: #171a20;
  --text-soft: #4a515e;
  --muted: #79808f;
  --line: #e3e7ef;
  --line-strong: #d3d9e4;

  --accent: #4a5cf0;
  --accent-soft: #eceefd;
  --accent-text: #3b49c9;
  --danger: #d6455a;
  --danger-soft: #fdedef;
  --warn: #b8730c;
  --warn-soft: #fdf2df;
  --success: #12805c;
  --success-soft: #e6f5ef;

  --shadow-sm: 0 1px 2px rgba(20, 26, 45, 0.05);
  --shadow-md: 0 6px 20px -8px rgba(20, 26, 45, 0.18);
  --shadow-lg: 0 18px 44px -20px rgba(20, 26, 45, 0.32);

  --radius: 14px;
  --radius-sm: 9px;
  --ease: cubic-bezier(0.32, 0.72, 0.28, 1);
}

:root[data-theme="dark"] {
  --bg: #0e1016;
  --bg-glow: #191f33;
  --surface: #161a23;
  --surface-2: #1c212c;
  --text: #e9ecf3;
  --text-soft: #b7bfcf;
  --muted: #8a93a5;
  --line: #262c39;
  --line-strong: #333b4b;

  --accent: #7d8bff;
  --accent-soft: #232842;
  --accent-text: #a3adff;
  --danger: #f4788a;
  --danger-soft: #35222a;
  --warn: #e6ac4e;
  --warn-soft: #33291a;
  --success: #4bc79b;
  --success-soft: #16302a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px -10px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 20px 48px -22px rgba(0, 0, 0, 0.85);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1016;
    --bg-glow: #191f33;
    --surface: #161a23;
    --surface-2: #1c212c;
    --text: #e9ecf3;
    --text-soft: #b7bfcf;
    --muted: #8a93a5;
    --line: #262c39;
    --line-strong: #333b4b;

    --accent: #7d8bff;
    --accent-soft: #232842;
    --accent-text: #a3adff;
    --danger: #f4788a;
    --danger-soft: #35222a;
    --warn: #e6ac4e;
    --warn-soft: #33291a;
    --success: #4bc79b;
    --success-soft: #16302a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px -10px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 20px 48px -22px rgba(0, 0, 0, 0.85);
  }
}

/* ============================================================
   ベース
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  padding: 36px 20px 72px;
  font-family: "Inter", "Segoe UI Variable Text", "Segoe UI", "Yu Gothic UI",
               "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 15% -8%, var(--bg-glow), transparent 70%),
    radial-gradient(700px 380px at 92% 4%, var(--bg-glow), transparent 66%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2 { margin: 0; letter-spacing: -0.015em; }

/* ============================================================
   ヘッダー
   ============================================================ */

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

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

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), #8b5cf6);
  box-shadow: var(--shadow-md);
}

.brand-text h1 { font-size: 1.45rem; font-weight: 700; }
.today { margin: 1px 0 0; font-size: 0.82rem; color: var(--muted); }

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: color .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}

.icon-btn:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }

.icon-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* テーマに応じて太陽 / 月を出し分ける */
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
  :root[data-theme="light"] .icon-sun { display: block; }
  :root[data-theme="light"] .icon-moon { display: none; }
}

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

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

.stat {
  position: relative;
  overflow: hidden;
  padding: 16px 18px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}

.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--line-strong);
}

.stat-done::before { background: var(--accent); }
.stat-open::before { background: var(--warn); }
.stat-overdue::before { background: var(--danger); }

.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

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

.stat-value {
  font-size: 2.05rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-unit { margin-left: 3px; font-size: 0.78rem; color: var(--muted); }
.stat-done .stat-value { color: var(--accent-text); }
.stat-open .stat-value { color: var(--warn); }
.stat-overdue .stat-value { color: var(--danger); }
.stat-overdue.is-zero .stat-value { color: var(--text); }
.stat-overdue.is-zero::before { background: var(--line-strong); }

/* ============================================================
   最新の振り返り（ダッシュボード）
   ============================================================ */

.latest {
  position: relative;
  overflow: hidden;
  padding: 17px 20px 18px;
  margin-bottom: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, var(--accent-soft), transparent 62%),
    var(--surface);
  box-shadow: var(--shadow-sm);
}

.latest::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), #8b5cf6);
}

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

.latest-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-text);
}

.latest-label svg {
  width: 15px; height: 15px;
  fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}

.latest-week {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.latest-comment {
  margin: 0;
  color: var(--text-soft);
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.latest.is-empty .latest-comment { color: var(--muted); }
.latest #latest-jump { margin-top: 9px; padding-left: 0; }
.latest #latest-jump:hover { background: none; text-decoration: underline; }

/* ============================================================
   パネル
   ============================================================ */

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

.panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
}

.panel-head h2 { font-size: 1.06rem; font-weight: 700; }

.chip {
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

/* ============================================================
   入力フォーム
   ============================================================ */

.composer {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  margin-bottom: 16px;
}

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

.hint { font-size: 0.74rem; color: var(--muted); }

.due-field { display: flex; align-items: center; gap: 7px; }
.due-field input { padding: 6px 9px; font-size: 0.85rem; }

input, textarea, select {
  width: 100%;
  font: inherit;
  color: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}

textarea { resize: vertical; min-height: 62px; }

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

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

input[type="date"] { width: auto; }
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.75); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.75); }
}

/* 検索欄 */
.search { position: relative; margin-bottom: 12px; }

.search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  stroke-linecap: round;
  pointer-events: none;
}

.search input { padding-left: 34px; }
.search input::-webkit-search-cancel-button { cursor: pointer; }

/* ============================================================
   ボタン
   ============================================================ */

.btn {
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
  color: var(--text-soft);
  transition: background .16s var(--ease), color .16s var(--ease),
              border-color .16s var(--ease), transform .12s var(--ease);
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost { border-color: var(--line-strong); background: var(--surface); }
.btn-ghost:hover { border-color: var(--danger); color: var(--danger); }

.btn-sm { padding: 5px 11px; font-size: 0.79rem; }

.btn-quiet { color: var(--muted); }
.btn-quiet:hover { background: var(--surface-2); color: var(--accent-text); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }

/* 絞り込みタブ */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.segmented button {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 13px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: background .16s var(--ease), color .16s var(--ease);
}

.segmented button:hover { color: var(--text); }

.segmented button.is-active {
  color: var(--accent-text);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   一覧
   ============================================================ */

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

.card {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
  animation: rise .24s var(--ease) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }

.card-title { font-weight: 650; word-break: break-word; }
.card-body { margin: 5px 0 0; color: var(--text-soft); white-space: pre-wrap; word-break: break-word; }

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* 操作ボタンは普段は控えめ、カードに触れると出る */
.card-actions {
  display: flex;
  gap: 4px;
  margin-top: 9px;
  opacity: 0.55;
  transition: opacity .18s var(--ease);
}

.card:hover .card-actions, .card:focus-within .card-actions { opacity: 1; }

/* タスク */
.task { display: flex; align-items: flex-start; gap: 11px; }
.task-main { flex: 1; min-width: 0; }
.task .card-actions { margin-top: 0; flex-shrink: 0; }

.check {
  flex-shrink: 0;
  width: 21px;
  height: 21px;
  margin-top: 2px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1.8px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
  color: transparent;
  transition: all .18s var(--ease);
}

.check:hover { border-color: var(--accent); }

.check svg {
  width: 12px; height: 12px;
  fill: none; stroke: currentColor;
  stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round;
}

.task-done .check { background: var(--accent); border-color: var(--accent); color: #fff; }
.task-done .card-title { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1.5px; }

/* バッジ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.badge-due { color: var(--text-soft); background: var(--surface-2); border: 1px solid var(--line); }
.badge-today { color: var(--warn); background: var(--warn-soft); border: 1px solid transparent; }
.badge-over { color: var(--danger); background: var(--danger-soft); border: 1px solid transparent; }
.badge-done { color: var(--success); background: var(--success-soft); border: 1px solid transparent; }

/* 週次の振り返り */
.panel-wide { margin-top: 20px; }

.week-field { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.week-field input { width: auto; padding: 6px 9px; font-size: 0.85rem; }

.week-range {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.review-week {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.review-no { font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.card-current { border-color: var(--accent); }

/* 編集フォーム */
.editor { display: flex; flex-direction: column; gap: 9px; }
.editor-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.editor-foot .due-field { margin-right: auto; }
.card.is-editing { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* 空の状態 */
.empty {
  padding: 26px 12px;
  text-align: center;
  font-size: 0.86rem;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

/* ============================================================
   トースト
   ============================================================ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 20;
  padding: 10px 18px;
  border-radius: 11px;
  font-size: 0.86rem;
  font-weight: 600;
  color: #fff;
  background: #22262f;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translate(-50%, 14px);
  pointer-events: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease);
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); }
.toast.is-success { background: var(--success); }

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

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

/* 5 枚横並びだとラベルが折り返す幅から 3 列に切り替える */
@media (max-width: 860px) {
  .dashboard { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 620px) {
  body { padding: 22px 14px 56px; }
  .dashboard { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 1.75rem; }
  .card-actions { opacity: 1; }
}

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