:root {
  --bg: #f3f2fb;
  --bg-accent-1: #eef0ff;
  --bg-accent-2: #f7eefc;
  --panel-bg: #ffffff;
  --panel-bg-soft: #fbfaff;
  --border: #e8e6f5;
  --border-strong: #d9d6ee;
  --text: #211f36;
  --text-muted: #767391;
  --text-faint: #a6a3c2;

  --accent: #6c5ce7;
  --accent-2: #a78bfa;
  --accent-soft: rgba(108, 92, 231, 0.1);
  --accent-soft-strong: rgba(108, 92, 231, 0.18);

  --success: #17a673;
  --success-soft: rgba(23, 166, 115, 0.12);

  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);

  --danger: #ef4462;
  --danger-soft: rgba(239, 68, 98, 0.12);

  --shadow-sm: 0 1px 2px rgba(40, 30, 90, 0.05);
  --shadow-md: 0 6px 20px rgba(56, 40, 120, 0.08);
  --shadow-lg: 0 14px 34px rgba(56, 40, 120, 0.14);

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131320;
    --bg-accent-1: #17182a;
    --bg-accent-2: #1b1830;
    --panel-bg: #1b1c2e;
    --panel-bg-soft: #202135;
    --border: #2c2d47;
    --border-strong: #37395a;
    --text: #edecf7;
    --text-muted: #a09dc2;
    --text-faint: #6b6890;

    --accent: #8b7cf6;
    --accent-2: #c4a4ff;
    --accent-soft: rgba(139, 124, 246, 0.16);
    --accent-soft-strong: rgba(139, 124, 246, 0.28);

    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.16);

    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.16);

    --danger: #fb7185;
    --danger-soft: rgba(251, 113, 133, 0.16);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.45);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  background:
    radial-gradient(900px 420px at 12% -8%, var(--bg-accent-1), transparent),
    radial-gradient(900px 460px at 100% 0%, var(--bg-accent-2), transparent),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */

.app-header {
  background: linear-gradient(120deg, #6c5ce7 0%, #8b6ef0 45%, #a78bfa 100%);
  color: #fff;
  padding: 30px 24px 60px;
  box-shadow: 0 10px 30px rgba(108, 92, 231, 0.25);
}

.header-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  flex-shrink: 0;
}

.brand-icon svg {
  width: 24px;
  height: 24px;
  color: #fff;
}

.app-header h1 {
  margin: 0;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.subtitle {
  margin: 2px 0 0;
  opacity: 0.88;
  font-size: 13px;
  font-weight: 500;
}

.header-date {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.9;
  background: rgba(255, 255, 255, 0.14);
  padding: 7px 14px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- Layout ---------- */

.container {
  max-width: 980px;
  margin: -34px auto 0;
  padding: 0 20px 60px;
  position: relative;
}

.dashboard {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
}

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

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

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

@media (max-width: 760px) {
  .stat-cards {
    grid-template-columns: 1fr;
  }
  .columns {
    grid-template-columns: 1fr;
  }
  .header-date {
    display: none;
  }
}

/* ---------- Stat cards ---------- */

.stat-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-md);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

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

.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex-shrink: 0;
  color: var(--accent);
  background: var(--accent-soft);
}

.stat-icon svg {
  width: 22px;
  height: 22px;
}

.stat-notes .stat-icon {
  color: var(--accent);
  background: var(--accent-soft);
}

.stat-tasks .stat-icon {
  color: var(--success);
  background: var(--success-soft);
}

.stat-completed .stat-icon {
  color: var(--success);
  background: var(--success-soft);
}

.stat-incomplete .stat-icon {
  color: var(--warning);
  background: var(--warning-soft);
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.stat-label {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---------- Latest reflection card ---------- */

.latest-reflection {
  background: linear-gradient(120deg, var(--accent-soft), var(--accent-soft-strong));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-md);
}

.lr-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex-shrink: 0;
  color: var(--accent);
  background: var(--panel-bg);
  box-shadow: var(--shadow-sm);
}

.lr-icon svg {
  width: 20px;
  height: 20px;
}

.lr-body {
  flex: 1;
  min-width: 0;
}

.lr-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.lr-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.lr-week {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--panel-bg);
  padding: 2px 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.lr-comment {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ---------- Panels ---------- */

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-md);
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 16.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  flex-shrink: 0;
}

.panel-icon svg {
  width: 16px;
  height: 16px;
}

.icon-note {
  color: var(--accent);
  background: var(--accent-soft);
}

.icon-task {
  color: var(--success);
  background: var(--success-soft);
}

.icon-reflection {
  color: var(--accent-2);
  background: var(--accent-soft);
}

.reflection-week-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

/* ---------- Forms ---------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px dashed var(--border-strong);
}

.form input,
.form textarea {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  background: var(--panel-bg-soft);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form input::placeholder,
.form textarea::placeholder {
  color: var(--text-faint);
}

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

.form button {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--accent-soft-strong);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.form button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.form button:active {
  transform: translateY(0);
}

/* ---------- Lists ---------- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 2px;
}

.list::-webkit-scrollbar {
  width: 8px;
}

.list::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

.list .empty {
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  padding: 34px 0 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.list .empty svg {
  width: 34px;
  height: 34px;
  opacity: 0.6;
}

.note-item,
.task-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--panel-bg-soft);
  border-left: 3px solid var(--accent);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.note-item:hover,
.task-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: var(--border-strong);
}

.note-item .note-title {
  font-weight: 700;
  margin-bottom: 4px;
  font-size: 14px;
}

.note-item .note-body {
  font-size: 13px;
  color: var(--text-muted);
  white-space: pre-wrap;
  margin-bottom: 8px;
  line-height: 1.5;
}

.note-item .meta,
.task-item .meta {
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 5px;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-left-color: var(--success);
}

.task-item.completed {
  border-left-color: var(--text-faint);
  opacity: 0.72;
}

/* Checkbox toggle */

.task-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 2px solid var(--border-strong);
  background: var(--panel-bg);
  flex-shrink: 0;
  margin-top: 1px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.task-checkbox:hover {
  border-color: var(--success);
}

.task-checkbox svg {
  width: 12px;
  height: 12px;
}

.task-item.completed .task-checkbox {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

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

.task-item .task-title {
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
}

.task-item.completed .task-title {
  text-decoration: line-through;
  color: var(--text-muted);
  font-weight: 500;
}

.task-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 7px;
  vertical-align: middle;
}

.task-badge.done {
  background: var(--success-soft);
  color: var(--success);
}

.task-badge.pending {
  background: var(--warning-soft);
  color: var(--warning);
}

.task-item .meta {
  margin-top: 5px;
}

.task-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-faint);
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn.delete-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-btn.edit-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-btn.save-btn:hover {
  background: var(--success-soft);
  color: var(--success);
}

.icon-btn.cancel-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- Item edit mode ---------- */

.item-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.item-row .note-title {
  flex: 1;
}

.item-row .edit-btn {
  flex-shrink: 0;
  margin: -4px -4px 0 0;
}

.edited-badge {
  color: var(--text-faint);
  font-style: italic;
  margin-left: 6px;
}

.note-item.editing,
.task-item.editing {
  border-left-color: var(--accent);
  background: var(--panel-bg);
}

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.edit-form input,
.edit-form textarea {
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  resize: vertical;
  background: var(--panel-bg);
  color: var(--text);
}

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

.edit-actions {
  display: flex;
  gap: 4px;
  align-self: flex-end;
}

.edit-form-inline {
  flex-direction: row;
  align-items: center;
}

.edit-form-inline .edit-actions {
  align-self: center;
}
