:root {
  --bg: #f4f6fa;
  --text: #1d232e;
  --muted: #7b8494;
  --faint: #a7aeba;
  --line: #e4e8ef;
  --line-soft: rgba(31, 37, 48, .08);
  --accent: #3563e9;
  --accent-soft: #eef2fe;
  --danger: #cf4339;
  --danger-soft: #fdeceb;
  --done: #17a06a;

  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 8px;

  --card-bg: rgba(255, 255, 255, .78);
  --card-edge: rgba(255, 255, 255, .92);
  --shadow: 0 1px 2px rgba(29, 35, 46, .04), 0 10px 28px rgba(29, 35, 46, .06);
  --shadow-sm: 0 1px 2px rgba(29, 35, 46, .04);

  --sans: "Segoe UI", "Hiragino Kaku Gothic ProN", "Meiryo", system-ui, sans-serif;
  --serif: "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "Noto Serif JP", "MS PMincho", serif;
}

* { box-sizing: border-box; }

/* 背景の抽象画が見えるよう、body は透明にして html 側を下地の色にする */
html { background: var(--bg); }

body {
  margin: 0;
  padding: 0 20px 64px;
  background: transparent;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* 背景の抽象画（いちばん後ろに固定） */
#bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  display: block;
}

main, .site-header { max-width: 980px; margin: 0 auto; }

/* ------------------------------------------------------------------ 見出し */

.site-header {
  padding: 34px 0 20px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.site-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: .06em;
}

.subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .02em;
}

/* ------------------------------------------------------ 今日（日付・暦） */

/* 今日のカードと格言を横に並べる（狭い画面では縦に積む） */
.today-row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.today {
  padding: 22px 26px 22px;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

.today-date {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  font-variant-numeric: tabular-nums;
}

.today-era {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 10px;
  border-radius: 999px;
  align-self: center;
}

.today-ymd {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .02em;
}

.today-dow { font-size: 16px; font-weight: 600; color: #4a5261; }
.today-dow.is-saturday { color: #2f6fd6; }
.today-dow.is-holiday { color: var(--danger); }

/* 暦（月名・干支・六曜・節気） */
.koyomi {
  margin: 14px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.koyomi div {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 4px 12px 5px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .6);
}

.koyomi dt {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--faint);
}

.koyomi dd {
  margin: 0;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .04em;
}

.today-label {
  margin: 18px 0 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .22em;
  color: var(--faint);
}

/* 今日は〇〇の日（箇条書き） */
.today-events {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 5px;
}

.event {
  position: relative;
  padding-left: 16px;
  font-weight: 500;
}

.event::before {
  content: '';
  position: absolute;
  left: 2px;
  top: .62em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .55;
}

.event-holiday { color: var(--danger); font-weight: 700; }
.event-holiday::before { background: var(--danger); opacity: .8; }
.event-season::before { background: var(--done); opacity: .8; }
.event-none { color: var(--faint); font-weight: 400; }
.event-none::before { background: var(--faint); }

.event-tag {
  margin-left: 8px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .06em;
  padding: 0 7px;
  border-radius: 999px;
  vertical-align: 1px;
  color: var(--done);
  background: #e9f7f1;
}
.event-holiday .event-tag { color: var(--danger); background: var(--danger-soft); }

/* ------------------------------------------------------------ 今日の格言 */

.quote {
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  margin: 0;
  padding: 26px 30px 22px;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* 左端の細い線。派手にせず、引用らしさだけ出す */
.quote::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), rgba(53, 99, 233, .25));
}

.quote-label {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .22em;
  color: var(--faint);
}

.quote-text {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(19px, 2.2vw, 25px);
  line-height: 1.8;
  letter-spacing: .03em;
  font-weight: 500;
}

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

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

.stat {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  color: var(--faint);
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}

.stat-accent .stat-value { color: var(--accent); }
.stat-habit .stat-value { color: var(--done); }
.stat-of { font-size: 18px; font-weight: 600; color: var(--faint); }

/* 最新の振り返り（ダッシュボードの横いっぱいを使う） */
.stat-review { grid-column: 1 / -1; }
.stat-review .empty { margin: 4px 0 0; }
.latest-week { margin-top: 4px; font-weight: 600; font-size: 14px; }
.latest-comment {
  margin: 4px 0 0;
  color: #414a58;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ------------------------------------------------------------ パネル */

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

.panel {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 22px 22px 24px;
}

.panel h2 {
  margin: 0 0 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .08em;
  display: flex;
  align-items: center;
  gap: 9px;
}

.panel h2::before {
  content: '';
  width: 3px;
  height: 15px;
  border-radius: 2px;
  background: var(--accent);
}

.panel-wide { margin-top: 18px; }

/* パネルの中の小見出し（習慣タスク / 通常タスク） */
.subsection + .subsection {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}

.subsection-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.subsection-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .1em;
  color: #4a5261;
}

.subsection-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.subsection-note {
  margin: 6px 0 12px;
  font-size: 11.5px;
  color: var(--faint);
}

/* 今日の達成度バー */
.progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(31, 37, 48, .07);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #6fcf9f, var(--done));
  transition: width .35s ease;
}

.progress-bar.is-complete { background: linear-gradient(90deg, var(--done), #0f8a5a); }

/* タスクの種類の切りかえ（通常 / 習慣） */
.segmented {
  display: inline-flex;
  align-self: flex-start;
  padding: 3px;
  gap: 3px;
  border-radius: var(--r-md);
  background: rgba(31, 37, 48, .06);
}

.segmented label { position: relative; cursor: pointer; }

.segmented input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.segmented span {
  display: block;
  padding: 5px 14px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  transition: background .15s, color .15s, box-shadow .15s;
}

.segmented input:checked + span {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ----------------------------------------------------------- 習慣の記録 */

.habit-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-card {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, .6);
}

.summary-label { font-size: 11px; font-weight: 600; letter-spacing: .14em; color: var(--faint); }
.summary-rate { font-size: 26px; font-weight: 700; color: var(--done); line-height: 1.2; font-variant-numeric: tabular-nums; }
.summary-rate small { font-size: 14px; margin-left: 2px; }
.summary-detail { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

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

.history-row details {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, .6);
  transition: background .15s;
}

.history-row details[open] { background: #fff; }

.history-row summary {
  display: grid;
  grid-template-columns: 9.5em minmax(0, 1fr) 4.5em;
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
  cursor: pointer;
  list-style: none;
  font-variant-numeric: tabular-nums;
}

.history-row summary::-webkit-details-marker { display: none; }

.history-date { font-weight: 600; white-space: nowrap; }

.history-today {
  margin-left: 6px;
  padding: 0 7px;
  font-size: 10.5px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
}

.history-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(31, 37, 48, .07);
  overflow: hidden;
}

.history-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #8fd3b0;
}

.history-row.is-complete .history-bar span { background: var(--done); }

.history-count { text-align: right; font-weight: 600; color: #4a5261; }
.history-row.is-complete .history-count { color: var(--done); }

.history-items {
  list-style: none;
  margin: 0;
  padding: 2px 14px 12px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.history-items li {
  padding: 2px 10px;
  font-size: 12px;
  border-radius: 999px;
  color: var(--faint);
  background: rgba(31, 37, 48, .05);
  text-decoration: line-through;
}

.history-items li.is-done {
  color: var(--done);
  background: #e9f7f1;
  text-decoration: none;
}

.history-items li.is-done::before { content: '✓ '; }

.btn-more { margin-top: 12px; }

/* -------------------------------------------------------------- 入力欄 */

.form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
}

.form-inline { display: flex; flex-direction: row; gap: 10px; }
.form-inline input { flex: 1; }

.field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--faint);
  margin-bottom: -4px;
}

.hint {
  margin: -3px 0 0;
  font-size: 12px;
  color: var(--accent);
}

input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  color: inherit;
  background: rgba(255, 255, 255, .75);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: border-color .15s, box-shadow .15s, background .15s;
}

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

textarea { resize: vertical; line-height: 1.7; }

input:hover, select:hover, textarea:hover { background: #fff; }

input:focus, select:focus, textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(53, 99, 233, .14);
}

/* -------------------------------------------------------------- ボタン */

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
  transition: filter .15s, background .15s, color .15s, border-color .15s;
}

button:hover { filter: brightness(1.07); }
button:active { filter: brightness(.96); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-small {
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(31, 37, 48, .05);
  color: #4a5261;
}
.btn-small:hover { background: rgba(31, 37, 48, .09); filter: none; }

.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fbdbd9; filter: none; }

/* 背景を変えるボタン（主張しすぎない見た目） */
.btn-ghost {
  background: rgba(255, 255, 255, .7);
  color: var(--muted);
  border: 1px solid var(--card-edge);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 15px;
}
.btn-ghost:hover {
  color: var(--accent);
  border-color: rgba(53, 99, 233, .35);
  background: #fff;
  filter: none;
}

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

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

.item {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  background: rgba(255, 255, 255, .68);
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.item:hover {
  background: #fff;
  border-color: #d8dee8;
  box-shadow: var(--shadow-sm);
}

.item-head { display: flex; align-items: flex-start; gap: 10px; }

.item-title {
  flex: 1;
  font-weight: 600;
  letter-spacing: .01em;
  word-break: break-word;
}

.item-body {
  margin: 7px 0 0;
  color: #414a58;
  white-space: pre-wrap;
  word-break: break-word;
}

.item-meta {
  margin-top: 9px;
  font-size: 11.5px;
  color: var(--faint);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}

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

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  padding: 1px 9px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.badge-open { color: var(--accent); background: var(--accent-soft); border-color: rgba(53, 99, 233, .25); }
.badge-done { color: var(--done); background: #e9f7f1; border-color: rgba(23, 160, 106, .25); }
.badge-habit { color: #8a6a1f; background: #fbf3de; border-color: rgba(176, 132, 30, .25); }

.item-habit .item-head { align-items: center; }
.item-habit input[type="checkbox"] { margin-top: 0; }

.task-done { background: rgba(255, 255, 255, .45); }
.task-done .item-title { text-decoration: line-through; color: var(--muted); }

input[type="checkbox"] {
  width: auto;
  margin-top: 4px;
  accent-color: var(--accent);
  cursor: pointer;
}

.empty { color: var(--faint); margin: 4px 0 0; }

/* ----------------------------------------------------------- メッセージ */

.message {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  padding: 11px 20px;
  border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(29, 35, 46, .18);
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.message-ok { background: var(--done); }

/* ------------------------------------------------------------- 画面が狭い時 */

@media (max-width: 760px) {
  body { padding: 0 14px 48px; }
  .site-header { padding: 24px 0 16px; }
  .columns { grid-template-columns: 1fr; }
  .today-row { grid-template-columns: 1fr; }
  .today { padding: 18px 20px; }
  .today-ymd { font-size: 19px; }
  .dashboard { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .habit-summary { grid-template-columns: 1fr 1fr; gap: 8px; }
  .history-row summary { grid-template-columns: 9em minmax(0, 1fr) 4em; gap: 10px; }
  .stat { padding: 13px 14px; }
  .stat-value { font-size: 26px; }
  .quote { padding: 22px 22px 18px; }
  .panel { padding: 18px; }
}

@media (max-width: 460px) {
  .dashboard { grid-template-columns: 1fr; }
  .form-inline { flex-direction: column; }
}
