:root {
  /* オレンジ基調のパレット */
  --orange-700: #b8500a;
  --orange-600: #d9620a;
  --orange-500: #f07818;
  --orange-400: #f79338;
  --orange-100: #fdeada;
  --orange-050: #fff6ec;

  --ink: #2b1e15;
  --ink-soft: #6d5748;
  --muted: #9b8474;
  --line: #f1e2d3;
  --line-strong: #e6d0bb;
  --surface: #ffffff;
  --surface-soft: #fffaf4;
  --danger: #c8503a;
  --success: #6f8f4a;
  --done: #b6a698;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(122, 74, 26, 0.05);
  --shadow: 0 1px 2px rgba(122, 74, 26, 0.05), 0 10px 24px -16px rgba(122, 74, 26, 0.35);
  --ease: 140ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  padding: 14px 18px 16px;
  font-family: "Segoe UI", "Yu Gothic UI", "Hiragino Sans", Meiryo, system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 12% -10%, #fff2e2 0%, rgba(255, 242, 226, 0) 62%),
    linear-gradient(180deg, #fdf6ee 0%, #faeee2 100%);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* 画面の高さに収める */
}

/* ---------- ヘッダー ---------- */

.topbar {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto 12px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--orange-400), var(--orange-600));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 14px -6px rgba(216, 98, 10, 0.75);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-title { font-size: 17px; font-weight: 700; letter-spacing: 0.01em; }
.brand-sub { font-size: 11.5px; color: var(--muted); }

.today {
  font-size: 12px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

main {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

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

.stat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--orange-050);
  color: var(--orange-600);
}
.stat-icon svg { width: 17px; height: 17px; }

.stat-text { display: flex; flex-direction: column; line-height: 1.2; }
.stat-label { font-size: 11.5px; color: var(--muted); letter-spacing: 0.02em; }
.stat-value { font-size: 25px; font-weight: 700; font-variant-numeric: tabular-nums; }

.stat-accent {
  background: linear-gradient(135deg, #fff8f0, var(--orange-100));
  border-color: var(--orange-100);
}
.stat-accent .stat-icon { background: rgba(255, 255, 255, 0.8); }
.stat-accent .stat-value { color: var(--orange-700); }
.stat-accent .stat-label { color: var(--orange-700); opacity: 0.75; }

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

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
  flex: none;
}
.panel-icon { width: 15px; height: 15px; color: var(--orange-500); flex: none; }

.list-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 9px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  flex: none;
}
.list-head h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: var(--muted);
}

.pill {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--orange-700);
  background: var(--orange-050);
  border: 1px solid var(--orange-100);
  border-radius: 999px;
  padding: 0 8px;
  font-variant-numeric: tabular-nums;
}

/* ---------- フォーム ---------- */

.form { display: flex; flex-direction: column; gap: 7px; flex: none; }
.form-inline { flex-direction: row; }
.form-inline input { flex: 1; min-width: 0; }

input, textarea {
  font: inherit;
  width: 100%;
  padding: 8px 11px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}
textarea { resize: none; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #bda995; }

input:hover, textarea:hover { border-color: var(--orange-400); }
input:focus, textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--orange-500);
  box-shadow: 0 0 0 3px rgba(240, 120, 24, 0.16);
}

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  transition: background var(--ease), color var(--ease), box-shadow var(--ease), transform var(--ease), border-color var(--ease);
}
button:focus-visible { outline: 2px solid var(--orange-600); outline-offset: 2px; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  color: #fff;
  background: linear-gradient(180deg, var(--orange-500), var(--orange-600));
  box-shadow: 0 6px 14px -8px rgba(216, 98, 10, 0.9);
  white-space: nowrap;
}
.btn-primary svg { width: 14px; height: 14px; }
.btn-primary:hover { background: linear-gradient(180deg, var(--orange-400), var(--orange-500)); }
.btn-primary:active { transform: translateY(1px); box-shadow: none; }

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

.list {
  list-style: none;
  margin: 0;
  padding: 1px 6px 2px 1px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.list::-webkit-scrollbar { width: 8px; }
.list::-webkit-scrollbar-track { background: transparent; }
.list::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
.list::-webkit-scrollbar-thumb:hover { background: var(--orange-400); }

.item {
  position: relative;
  flex: none;
  padding: 9px 11px 9px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}
.item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--orange-400), var(--orange-600));
  transition: background var(--ease);
}
.item:hover {
  border-color: var(--line-strong);
  box-shadow: 0 2px 4px rgba(122, 74, 26, 0.06), 0 12px 22px -18px rgba(122, 74, 26, 0.6);
}

.item-head { display: flex; align-items: flex-start; gap: 9px; }
.item-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  word-break: break-word;
  transition: color var(--ease);
}
.item-body {
  margin: 5px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
}
.item-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* 完了済みタスク */
.task-done { background: var(--surface-soft); }
.task-done::before { background: var(--done); }
.task-done .item-title { color: var(--done); text-decoration: line-through; text-decoration-thickness: 1px; }

/* 完了トグル（丸いチェック） */
.check {
  width: 19px;
  height: 19px;
  flex: none;
  margin-top: 1px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  border: 1.6px solid var(--line-strong);
  color: transparent;
}
.check svg { width: 11px; height: 11px; }
.check:hover { border-color: var(--orange-500); color: var(--orange-400); }
.check[aria-pressed="true"] {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.check[aria-pressed="true"]:hover { background: #7ea055; border-color: #7ea055; color: #fff; }

.badge {
  display: inline-block;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-open { color: var(--orange-700); background: var(--orange-050); border: 1px solid var(--orange-100); }
.badge-done { color: var(--success); background: #f3f6ec; border: 1px solid #e2ebd3; }

/* 削除ボタン（普段は控えめ、ホバーで赤） */
.btn-icon {
  width: 22px;
  height: 22px;
  flex: none;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: #cdb8a5;
  border-radius: 7px;
}
.btn-icon svg { width: 13px; height: 13px; }
.btn-icon:hover { background: #fdeeea; color: var(--danger); }

.empty {
  margin: 4px 0 0;
  padding: 18px 10px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
}

.error {
  flex: none;
  margin: 0;
  padding: 8px 13px;
  font-size: 12.5px;
  color: #9c3b26;
  background: #fdeee9;
  border: 1px solid #f2c7bb;
  border-radius: var(--radius-sm);
}

/* ---------- 画面サイズ対応 ---------- */

/* 高さが足りないときは自動で省スペース化 */
@media (max-height: 660px) {
  .brand-sub, .today { display: none; }
  .topbar { margin-bottom: 8px; }
  .stat { padding: 8px 13px; }
  .stat-value { font-size: 21px; }
  .list-head { margin: 11px 0 7px; padding-top: 9px; }
}

/* 幅が狭いときは縦積み（このときだけページ全体をスクロール） */
@media (max-width: 800px) {
  body { overflow: auto; }
  .columns { grid-template-columns: 1fr; }
  .list { overflow-y: visible; }
  .dashboard { grid-template-columns: 1fr 1fr; }
  .stat-accent { grid-column: span 2; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
