:root {
  --bg: #f4f5fb;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --border: rgba(15, 23, 42, 0.07);
  --text: #0f172a;
  --muted: #64748b;
  --subtle: #94a3b8;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(99, 102, 241, 0.1);
  --danger: #ef4444;
  --success: #10b981;
  --warn: #f59e0b;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 2px 4px rgba(15, 23, 42, 0.05), 0 14px 32px rgba(15, 23, 42, 0.1);
  --radius: 18px;
  --input-bg: rgba(241, 245, 249, 0.8);

  --c-default: #cbd5e1;
  --c-blue: #60a5fa;
  --c-green: #34d399;
  --c-yellow: #fbbf24;
  --c-pink: #f472b6;
  --c-purple: #a78bfa;
}

:root[data-theme="dark"] {
  --bg: #0b0d14;
  --surface: rgba(24, 27, 38, 0.78);
  --surface-solid: #181b26;
  --border: rgba(255, 255, 255, 0.07);
  --text: #e8eaf2;
  --muted: #9aa3b5;
  --subtle: #6b7385;
  --accent-soft: rgba(129, 140, 248, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.3), 0 14px 32px rgba(0, 0, 0, 0.4);
  --input-bg: rgba(255, 255, 255, 0.05);
  --c-default: #475569;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Inter", "Noto Sans JP", system-ui, -apple-system, "Hiragino Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
  overflow-x: hidden;
}

svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}

button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }

/* 背景の光 */
.bg-orb {
  position: fixed; border-radius: 50%; filter: blur(90px);
  opacity: 0.45; z-index: -1; pointer-events: none;
}
.orb-1 { width: 520px; height: 520px; background: #c7d2fe; top: -180px; left: -120px; }
.orb-2 { width: 460px; height: 460px; background: #f5d0fe; bottom: -160px; right: -100px; }
:root[data-theme="dark"] .orb-1 { background: #312e81; opacity: 0.35; }
:root[data-theme="dark"] .orb-2 { background: #581c87; opacity: 0.25; }

.container { max-width: 1240px; margin: 0 auto; padding: 32px 24px 48px; }

/* ヘッダー */
.header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 20px; flex-wrap: wrap; margin-bottom: 28px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center; font-size: 22px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
}
.greeting { font-size: 13px; color: var(--muted); }
.title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }

.header-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.clock { display: flex; flex-direction: column; align-items: flex-end; margin-right: 6px; }
#clock-time { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.clock-date { font-size: 12px; color: var(--muted); }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 0 14px; height: 42px; width: 280px;
  backdrop-filter: blur(12px); color: var(--subtle);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search input { border: none; outline: none; background: none; font: inherit; font-size: 14px; color: var(--text); width: 100%; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border);
  backdrop-filter: blur(12px); color: var(--muted); transition: all 0.2s;
}
.icon-btn:hover { color: var(--accent); transform: translateY(-1px); }
.icon-btn .moon { display: none; }
:root[data-theme="dark"] .icon-btn .sun { display: none; }
:root[data-theme="dark"] .icon-btn .moon { display: block; }

/* ダッシュボード */
.dashboard {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 28px;
}
.stat-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px;
  box-shadow: var(--shadow); backdrop-filter: blur(16px);
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.stat-icon {
  width: 46px; height: 46px; border-radius: 13px;
  display: grid; place-items: center; flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.memo-ic { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.task-ic { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.todo-ic { background: rgba(245, 158, 11, 0.14); color: #f59e0b; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.stat-value.small { font-size: 16px; font-weight: 600; margin-top: 2px; }
.stat-sub { font-size: 11.5px; color: var(--danger); font-weight: 500; min-height: 0; }
.stat-sub:empty { display: none; }

.ring { position: relative; width: 56px; height: 56px; flex-shrink: 0; }
.ring svg { width: 56px; height: 56px; transform: rotate(-90deg); stroke-width: 4.5; }
.ring-bg { stroke: var(--accent-soft); }
.ring-fg {
  stroke: var(--accent);
  stroke-dasharray: 113.1; stroke-dashoffset: 113.1;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
.ring span {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* カラム */
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding-left: 4px; }
.panel-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.badge {
  font-size: 12px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); padding: 2px 10px; border-radius: 99px;
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.form-card { padding: 18px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }

.input {
  width: 100%; font: inherit; font-size: 14px; color: var(--text);
  background: var(--input-bg); border: 1px solid transparent;
  border-radius: 12px; padding: 11px 14px; outline: none; resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.input::placeholder { color: var(--subtle); }
.input:focus { border-color: var(--accent); background: var(--surface-solid); box-shadow: 0 0 0 4px var(--accent-soft); }
.title-input { font-weight: 600; font-size: 15px; }

.form-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; border-radius: 12px; font-size: 14px; font-weight: 600;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s, opacity 0.2s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; stroke-width: 2.5; }
.btn:active { transform: scale(0.97); }
.btn.primary {
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.3);
}
.btn.primary:hover { box-shadow: 0 8px 22px rgba(99, 102, 241, 0.42); transform: translateY(-1px); }
.btn.ghost { color: var(--muted); background: var(--input-bg); }
.btn.ghost:hover { color: var(--text); }
.btn.danger { color: #fff; background: var(--danger); }
.btn.danger:hover { opacity: 0.9; }

/* カラー選択 */
.color-picker { display: flex; gap: 8px; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--surface-solid);
  box-shadow: 0 0 0 1px var(--border); transition: transform 0.15s, box-shadow 0.15s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { box-shadow: 0 0 0 2px var(--accent); }

/* 優先度・期限 */
.task-options { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.segmented { display: inline-flex; background: var(--input-bg); border-radius: 10px; padding: 3px; }
.segmented button {
  padding: 5px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted);
  transition: all 0.15s;
}
.segmented button.active { background: var(--surface-solid); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.segmented button[data-value="high"].active { color: var(--danger); }
.segmented button[data-value="low"].active { color: var(--success); }

.date-input {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--input-bg); border-radius: 10px; padding: 5px 10px; color: var(--muted);
}
.date-input svg { width: 15px; height: 15px; }
.date-input input {
  border: none; outline: none; background: none; font: inherit; font-size: 13px; color: var(--text);
  color-scheme: light;
}
:root[data-theme="dark"] .date-input input { color-scheme: dark; }

/* ツールバー */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.tabs { display: inline-flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.tabs button { padding: 6px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); transition: all 0.15s; }
.tabs button.active { background: var(--accent); color: #fff; }
.text-btn { font-size: 12.5px; color: var(--subtle); font-weight: 500; }
.text-btn:hover { color: var(--danger); }

/* リスト */
.list { display: flex; flex-direction: column; gap: 10px; }

.memo-item {
  position: relative; padding: 16px 18px 14px 22px; overflow: hidden;
  animation: pop 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  transition: transform 0.2s, box-shadow 0.2s;
}
.memo-item::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--memo-color, var(--c-default));
}
.memo-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.memo-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.memo-title { font-size: 15px; font-weight: 700; word-break: break-word; display: flex; align-items: center; gap: 6px; }
.memo-title .pin-mark { color: var(--accent); font-size: 12px; }
.memo-content {
  margin-top: 6px; font-size: 13.5px; color: var(--muted);
  white-space: pre-wrap; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.memo-item.expanded .memo-content { -webkit-line-clamp: unset; display: block; }
.meta { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12px; color: var(--subtle); flex-wrap: wrap; }
.meta svg { width: 13px; height: 13px; }

.actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.2s; flex-shrink: 0; }
.memo-item:hover .actions, .task-item:hover .actions, .actions:focus-within { opacity: 1; }
.act {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--subtle);
  transition: all 0.15s;
}
.act svg { width: 16px; height: 16px; }
.act:hover { background: var(--input-bg); color: var(--text); }
.act.del:hover { color: var(--danger); background: rgba(239, 68, 68, 0.1); }
.act.on { color: var(--accent); }

.task-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 14px 14px 16px;
  animation: pop 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.3s;
}
.task-item:hover { transform: translateY(-1px); box-shadow: var(--shadow-hover); }

.check {
  width: 22px; height: 22px; border-radius: 7px; margin-top: 1px;
  border: 2px solid var(--subtle); display: grid; place-items: center; flex-shrink: 0;
  transition: all 0.2s;
}
.check svg { width: 14px; height: 14px; stroke: #fff; stroke-width: 3; opacity: 0; transform: scale(0.5); transition: all 0.2s; }
.check:hover { border-color: var(--accent); }
.task-item.done .check { background: var(--success); border-color: var(--success); }
.task-item.done .check svg { opacity: 1; transform: scale(1); }

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14.5px; font-weight: 500; word-break: break-word; transition: color 0.2s; }
.task-item.done .task-title { color: var(--subtle); text-decoration: line-through; }
.task-item.done { opacity: 0.72; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 6px;
}
.tag.status-done { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.tag.status-todo { background: rgba(148, 163, 184, 0.15); color: var(--muted); }
.tag.p-high { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.tag.p-medium { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.tag.p-low { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.tag.due { background: var(--accent-soft); color: var(--accent); }
.tag.due.overdue { background: rgba(239, 68, 68, 0.12); color: var(--danger); }
.tag.due.today { background: rgba(245, 158, 11, 0.14); color: #d97706; }
.dot { color: var(--border); }

.empty {
  text-align: center; padding: 40px 20px; color: var(--subtle); font-size: 13.5px;
  border: 1.5px dashed var(--border); border-radius: var(--radius);
}
.empty .emoji { font-size: 28px; display: block; margin-bottom: 6px; }

mark { background: rgba(250, 204, 21, 0.4); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- 週次の振り返り ---------- */
.latest-review {
  display: flex; align-items: center; gap: 20px;
  padding: 18px 22px; margin: -12px 0 28px;
  position: relative; overflow: hidden;
}
.latest-review::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}
.lr-icon {
  width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.lr-icon svg { width: 22px; height: 22px; }
.lr-body { flex: 1; min-width: 0; }
.lr-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lr-head .stat-label { font-weight: 600; }
.lr-week { font-size: 12.5px; color: var(--subtle); }
.lr-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 6px; }
.lr-col { min-width: 0; }
.lr-col p {
  font-size: 13.5px; color: var(--text); white-space: pre-wrap; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lr-col p.none { color: var(--subtle); }
.lr-empty { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.latest-review .btn { flex-shrink: 0; }

.kpt { font-style: normal; font-size: 9px; margin-right: 6px; vertical-align: 2px; }
.kpt.k { color: var(--success); }
.kpt.p { color: var(--warn); }
.kpt.t { color: var(--accent); }

.review-panel { margin-top: 36px; }
.review-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.review-grid .form-card { margin-bottom: 0; gap: 12px; }

.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.icon-btn.small { width: 34px; height: 34px; border-radius: 10px; }
.icon-btn:disabled { opacity: 0.35; cursor: default; transform: none; }
.week-label { text-align: center; display: flex; flex-direction: column; }
.week-label strong { font-size: 15.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.week-status { font-size: 12px; color: var(--muted); }
.week-status.saved { color: var(--success); font-weight: 600; }

.week-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ws-item { background: var(--input-bg); border-radius: 12px; padding: 8px 12px; text-align: center; }
.ws-item b { display: block; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ws-item span { font-size: 11.5px; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.rating-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stars { display: inline-flex; gap: 2px; }
.star { font-size: 22px; line-height: 1; color: var(--c-default); padding: 2px; transition: transform 0.15s, color 0.15s; }
.star:hover { transform: scale(1.15); }
.star.on { color: #fbbf24; }
.stars-static { color: #fbbf24; font-size: 13px; letter-spacing: 1px; }
.stars-static .off { color: var(--c-default); }
.form-row.end { justify-content: flex-end; }
.form-row.end .text-btn { margin-right: auto; }

.review-item { padding: 16px 18px; cursor: pointer; animation: pop 0.35s cubic-bezier(0.22, 1, 0.36, 1); transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s; }
.review-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.review-item.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.ri-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.ri-week { font-size: 14.5px; font-weight: 700; }
.ri-week small { font-weight: 500; color: var(--accent); margin-left: 6px; font-size: 12px; }
.ri-row { display: flex; gap: 8px; font-size: 13.5px; margin-top: 4px; }
.ri-row .kpt { margin: 0; vertical-align: 0; line-height: 1.9; }
.ri-row p { white-space: pre-wrap; word-break: break-word; color: var(--text); flex: 1; }

/* ダイアログ */
.dialog {
  margin: auto; border: 1px solid var(--border); border-radius: 22px;
  background: var(--surface-solid); color: var(--text);
  width: min(560px, calc(100% - 32px)); padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}
.dialog.small { width: min(380px, calc(100% - 32px)); }
.dialog::backdrop { background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(4px); }
.dialog[open] { animation: pop 0.25s cubic-bezier(0.22, 1, 0.36, 1); }
.dialog form { display: flex; flex-direction: column; gap: 12px; }
.dialog h3 { font-size: 17px; font-weight: 700; }
.muted { color: var(--muted); font-size: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* トースト */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translate(-50%, 20px);
  background: #0f172a; color: #fff; padding: 11px 20px; border-radius: 12px;
  font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
:root[data-theme="dark"] .toast { background: #e8eaf2; color: #0f172a; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

.footer { text-align: center; margin-top: 40px; font-size: 12px; color: var(--subtle); }
.footer code { font-family: ui-monospace, monospace; background: var(--input-bg); padding: 2px 6px; border-radius: 5px; }

@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* レスポンシブ */
@media (max-width: 1000px) {
  .dashboard { grid-template-columns: repeat(2, 1fr); }
  .columns { grid-template-columns: 1fr; }
  .review-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .latest-review { flex-wrap: wrap; }
  .lr-cols { grid-template-columns: 1fr; gap: 6px; }
  .latest-review .btn { width: 100%; justify-content: center; }
}
@media (max-width: 640px) {
  .container { padding: 20px 16px 40px; }
  .header-right { width: 100%; }
  .clock { display: none; }
  .search { flex: 1; width: auto; }
  .dashboard { gap: 10px; }
  .stat-card { padding: 14px; gap: 12px; }
  .stat-icon { width: 38px; height: 38px; }
  .stat-value { font-size: 22px; }
  .actions { opacity: 1; }
}
@media (hover: none) { .actions { opacity: 1; } }
