:root {
  color-scheme: light dark;
  --bg: #eef6f0;
  --panel-bg: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e2e5e9;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --list-bg: #eaf5ec;
  --list-border: #bfe0c6;
  --list-hover-bg: #ddeee0;
  --tartan-band1: rgba(110, 178, 132, 0.38);
  --tartan-band2: rgba(70, 145, 96, 0.30);
  --tartan-line1: rgba(255, 255, 255, 0.65);
  --tartan-line2: rgba(37, 94, 58, 0.40);
  --saturday-color: #2563eb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14201a;
    --panel-bg: #1f2228;
    --text: #e6e8eb;
    --muted: #9aa1ac;
    --border: #2c2f36;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --danger: #ef4444;
    --danger-hover: #f87171;
    --success: #22c55e;
    --list-bg: #1b2b20;
    --list-border: #2f4b37;
    --list-hover-bg: #22362a;
    --tartan-band1: rgba(58, 101, 72, 0.45);
    --tartan-band2: rgba(36, 70, 48, 0.40);
    --tartan-line1: rgba(150, 205, 168, 0.18);
    --tartan-line2: rgba(0, 0, 0, 0.25);
    --saturday-color: #60a5fa;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "BIZ UDPGothic", "BIZ UDGothic", "UD デジタル 教科書体 N-R", "Yu Gothic Medium", "Yu Gothic", "Hiragino Kaku Gothic ProN", "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(45deg, var(--tartan-band1) 0, var(--tartan-band1) 16px, transparent 16px, transparent 36px),
    repeating-linear-gradient(-45deg, var(--tartan-band2) 0, var(--tartan-band2) 16px, transparent 16px, transparent 36px),
    repeating-linear-gradient(45deg, transparent 0, transparent 26px, var(--tartan-line1) 26px, var(--tartan-line1) 29px, transparent 29px, transparent 36px),
    repeating-linear-gradient(-45deg, transparent 0, transparent 26px, var(--tartan-line2) 26px, var(--tartan-line2) 29px, transparent 29px, transparent 36px);
  background-attachment: fixed;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

h1 {
  font-size: 2.6rem;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.icon {
  display: inline-block;
  margin-right: 6px;
}

h1 .icon {
  font-size: 1.1em;
  margin-right: 0;
}

.text-holiday {
  color: var(--danger);
  font-weight: 700;
}

.text-saturday {
  color: var(--saturday-color);
  font-weight: 700;
}

.holiday-name {
  margin-left: 8px;
  font-size: 0.9em;
  color: var(--muted);
}

.calendar-panel {
  margin-bottom: 16px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}

.calendar-month-label {
  font-weight: 700;
  font-size: 1rem;
  min-width: 7em;
  text-align: center;
}

.btn-cal-nav,
.btn-cal-today {
  padding: 4px 10px;
  font-size: 0.8rem;
}

.btn-cal-today {
  background: var(--muted);
}
.btn-cal-today:hover {
  opacity: 0.85;
}

.calendar-weekday-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin: 0 auto 6px;
  max-width: 320px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  max-width: 320px;
  margin: 0 auto;
}

.cal-cell {
  align-self: stretch;
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 1px;
  border: 1px solid var(--list-border);
  border-radius: 6px;
  background: var(--list-bg);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  padding: 4px 1px 1px;
}

.cal-cell:hover {
  background: var(--list-hover-bg);
}

.cal-cell-empty {
  visibility: hidden;
  pointer-events: none;
  border: none;
  background: transparent;
}

.cal-day-number {
  font-size: 0.8rem;
  font-weight: 600;
}

.cal-day-holiday .cal-day-number {
  color: var(--danger);
}

.cal-day-saturday .cal-day-number {
  color: var(--saturday-color);
}

.cal-cell-today {
  border: 2px solid var(--success);
}

.cal-cell-selected,
.cal-cell-selected:hover {
  background: var(--success);
}

.cal-cell-selected .cal-day-number {
  color: #fff;
}

.cal-stamp {
  font-size: 1.6rem;
  line-height: 1;
}

.cal-cell .cal-stamp {
  position: absolute;
  right: -2px;
  bottom: -4px;
  font-size: 1.4rem;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}

.calendar-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--muted);
}

.day-review-today-badge {
  margin-left: 8px;
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.15);
  color: var(--success);
}

.day-review-group {
  margin-top: 14px;
}

.day-review-group h3 {
  font-size: 1rem;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.dashboard-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.dashboard-icon {
  font-size: 1.8rem;
  margin-bottom: 4px;
}

.dashboard-reflection {
  grid-column: 1 / -1;
  text-align: left;
}

.reflection-header {
  display: flex;
  align-items: center;
  font-weight: 700;
  margin-bottom: 6px;
}

.reflection-week {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.reflection-comment {
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.reflection-comment.empty-text {
  color: var(--muted);
  font-style: italic;
}

.reflection-current-week {
  color: var(--muted);
  font-size: 0.95rem;
  margin: -4px 0 10px;
}

.dashboard-value {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--success);
}

.dashboard-label {
  font-size: 1rem;
  color: var(--muted);
  margin-top: 4px;
}

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 1.3rem;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
}

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

input[type="text"], input[type="date"], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 1.05rem;
  font-family: inherit;
  resize: vertical;
}

input[type="date"] {
  max-width: 220px;
}

.field-label {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: -2px;
}

button {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
}

button:hover { background: var(--accent-hover); }

.error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
  margin: 6px 0 0;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
}

.list-item {
  background: var(--list-bg);
  border: 1px solid var(--list-border);
  border-radius: 8px;
  padding: 10px 12px;
  transition: background-color 0.15s ease;
}

.list-item:hover {
  background: var(--list-hover-bg);
}

.item-title {
  font-size: 1.1rem;
  font-weight: 600;
  word-break: break-word;
}

.item-body {
  margin-top: 4px;
  font-size: 1rem;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.item-meta {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.task-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.task-item .item-title {
  flex: 1;
}

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

.status-badge {
  font-size: 0.9rem;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-badge.done {
  background: rgba(22, 163, 74, 0.15);
  color: var(--success);
}

.status-badge.pending {
  background: rgba(107, 114, 128, 0.15);
  color: var(--muted);
}

.task-actions,
.item-actions {
  display: flex;
  gap: 6px;
}

.item-actions {
  margin-top: 8px;
}

.task-actions button,
.item-actions button {
  padding: 6px 12px;
  font-size: 0.92rem;
  white-space: nowrap;
}

.btn-complete,
.btn-add {
  background: var(--success);
}
.btn-complete:hover,
.btn-add:hover { opacity: 0.85; background: var(--success); }

.btn-edit {
  background: var(--muted);
}
.btn-edit:hover { opacity: 0.85; }

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

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 8px 0;
}
