:root {
  --bg: #eef4f7;           /* 入力欄などの下地 */
  --card: rgba(255, 255, 255, 0.86);
  --card-solid: #ffffff;
  --item: #eef6fa;         /* 一覧の各項目の背景（カードより一段濃く） */
  --item-hover: #e3eff6;
  --text: #12222b;
  --muted: #566672;
  --line: #d8e4ea;
  --line-strong: #b9cdd8;  /* 項目の枠線（はっきり見せる） */
  --accent: #0a7ea4;
  --danger: #d64545;
  --done: #7c8a94;
  --running: #12876a;      /* 計測中の色 */
  --running-bg: #e2f5ee;
  --shadow: 0 1px 3px rgba(6, 45, 62, 0.10);
  --header-text: #f4feff;
  --header-shadow: 0 1px 3px rgba(3, 40, 58, 0.45);

  /* 沖縄の海（浅瀬の白砂 → エメラルド → 深い青） */
  --sea:
    radial-gradient(46% 24% at 50% 0%, rgba(255, 255, 255, 0.38), transparent 72%),
    linear-gradient(
      180deg,
      #8fe3ec 0%,
      #4ad2d2 10%,
      #13c0bb 22%,
      #04a9ac 34%,
      #058ba6 48%,
      #076c96 62%,
      #084f80 76%,
      #063765 88%,
      #05244a 100%
    );
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12222c;
    --card: rgba(16, 34, 45, 0.90);
    --card-solid: #102630;
    --item: #17303d;
    --item-hover: #1d3b4a;
    --text: #e6f2f6;
    --muted: #9fb4c0;
    --line: #21414f;
    --line-strong: #315563;
    --accent: #48c2e0;
    --danger: #ef6a6a;
    --done: #8195a1;
    --running: #3fc98d;
    --running-bg: #123a33;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --header-text: #dff4fa;
    --header-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);

    /* 夜の海 */
    --sea:
      radial-gradient(55% 34% at 50% 2%, rgba(150, 230, 240, 0.22), transparent 70%),
      linear-gradient(
        180deg,
        #0d3b4a 0%,
        #0b4655 16%,
        #0a4a58 30%,
        #073a4f 50%,
        #052a3f 72%,
        #03192a 100%
      );
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 24px 20px 60px;
  min-height: 100vh;
  background: var(--sea);
  /* 全レイヤーを画面に固定する（スクロールしても海が動かない） */
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.6;
}

.page-header { max-width: 1000px; margin: 0 auto 20px; }
.page-header h1 { margin: 0; font-size: 1.5rem; color: var(--header-text); text-shadow: var(--header-shadow); }
.subtitle { margin: 4px 0 0; color: var(--header-text); opacity: 0.85; font-size: 0.9rem; text-shadow: var(--header-shadow); }

/* ダッシュボード */
.dashboard {
  max-width: 1000px;
  margin: 0 auto 20px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat {
  background: var(--card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(4, 40, 60, 0.12);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label { color: var(--muted); font-size: 0.8rem; }
.stat-value { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-accent .stat-value { color: var(--accent); }
.stat-time { font-size: 1.5rem; letter-spacing: 0.01em; }
.stat-sub { color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }

.hint { margin: -4px 0 10px; color: var(--muted); font-size: 0.78rem; }

/* 最新の振り返り（ダッシュボード内） */
.latest {
  max-width: 1000px;
  margin: 0 auto 20px;
  background: var(--card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(4, 40, 60, 0.12);
  padding: 14px 16px;
}

.latest-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.latest-week { font-size: 0.85rem; font-weight: 600; }

.latest-comment {
  margin: 6px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  /* 長い振り返りは3行までにして、ダッシュボードが伸びすぎないようにする */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.latest-comment.is-empty { color: var(--muted); font-size: 0.9rem; }

.latest-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent);
  font-size: 0.8rem;
  text-decoration: none;
}
.latest-link:hover { text-decoration: underline; }

/* 振り返りの入力欄 */
.card-wide { max-width: 1000px; margin: 16px auto 0; }

.review-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.review-row select {
  font: inherit;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text);
  max-width: 100%;
}

.review-stats { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }

.review-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.review-actions .hint { margin: 0; }

.item-actions { display: flex; flex-direction: column; gap: 6px; }
.item.review { border-left-color: var(--accent); }

.error {
  max-width: 1000px;
  margin: 0 auto 16px;
  padding: 10px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  color: var(--danger);
  font-size: 0.9rem;
}

.columns {
  max-width: 1000px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.card {
  background: var(--card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(4, 40, 60, 0.14);
  padding: 18px;
}

.card h2 {
  font-size: 1rem;
  margin: 0 0 10px;
}

.card h2 + .form { margin-bottom: 24px; }

.count { color: var(--muted); font-weight: 400; font-size: 0.85rem; }

/* フォーム */
.form { display: flex; flex-direction: column; gap: 8px; }
.form-inline { flex-direction: row; }
.form-inline input { flex: 1; }

input, textarea, button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 9px 12px;
}

input, textarea {
  background: var(--bg);
  color: var(--text);
  width: 100%;
}

textarea { resize: vertical; }

input:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

button {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}

button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.6; cursor: default; }

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

.item {
  background: var(--item);
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 11px 13px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  transition: background 0.12s ease;
}

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

/* 完了したタスクは左帯と文字色で区別する（背景は他の項目と揃えて見やすさを保つ） */
.item.done {
  border-left-color: var(--done);
  box-shadow: none;
}

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

.item-title { font-weight: 600; word-break: break-word; }
.item-text { margin: 5px 0 0; color: var(--text); white-space: pre-wrap; word-break: break-word; font-size: 0.92rem; }
.item-meta {
  margin: 8px 0 0;
  padding-top: 6px;
  border-top: 1px dashed var(--line-strong);
  color: var(--muted);
  font-size: 0.78rem;
}

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

.badge {
  display: inline-block;
  margin-top: 3px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1.5;
  border: 1px solid transparent;
  color: #fff;
}
.badge.open { background: var(--accent); }
.badge.done { background: transparent; color: var(--done); border-color: var(--line-strong); }
.badge.running { background: var(--running); }

/* 作業時間 */
.timer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.clock {
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.timer-btn {
  background: var(--card-solid);
  color: var(--running);
  border: 1px solid var(--running);
  padding: 3px 12px;
  font-size: 0.8rem;
}
.timer-btn:hover { background: var(--running); color: #fff; filter: none; }
.timer-btn.stop { background: var(--running); color: #fff; border-color: transparent; }
.timer-btn.stop:hover { filter: brightness(1.08); }

/* 計測中のタスクを目立たせる */
.item.running {
  border-left-color: var(--running);
  background: var(--running-bg);
}
.item.running:hover { background: var(--running-bg); }
.item.running .clock { color: var(--running); }

.check { margin-top: 5px; width: 18px; height: 18px; flex: none; cursor: pointer; }

.icon-btn {
  background: var(--card-solid);
  color: var(--muted);
  border: 1px solid var(--line-strong);
  padding: 3px 9px;
  font-size: 0.8rem;
  font-weight: 400;
}
.icon-btn:hover { color: var(--danger); border-color: var(--danger); filter: none; }

.empty { color: var(--muted); font-size: 0.88rem; padding: 6px 2px; }

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

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