:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #6b7584;
  --subtle: #9aa3b1;
  --border: #e6e9ef;
  --field: #f8f9fc;
  --hover: #f6f8fc;

  /* 色はそのまま（ボタン・完了・削除・未完了） */
  --primary: #2f6fdd;
  --primary-hover: #245ac0;
  --accent: #e8590c;
  --done: #2b8a3e;
  --danger: #c92a2a;

  --primary-tint: #eaf1fd;
  --task-tint: #e7f5ee;
  --accent-tint: #fdf0e7;
  --danger-tint: #fff0f0;

  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 30, 50, 0.04), 0 6px 20px rgba(20, 30, 50, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 360px at 50% -120px, #e3ecfb 0%, rgba(227, 236, 251, 0) 70%) no-repeat,
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- ヘッダー ---------- */
.app-header {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #3b7cf0, var(--primary-hover));
  box-shadow: 0 4px 12px rgba(47, 111, 221, 0.3);
}
.brand-mark svg { width: 22px; height: 22px; stroke-width: 2.2; }
.app-header h1 { margin: 0; font-size: 1.45rem; letter-spacing: 0.02em; line-height: 1.3; }
.greeting { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }
.today {
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.88rem;
  box-shadow: 0 1px 2px rgba(20, 30, 50, 0.04);
}

main { max-width: 1120px; margin: 0 auto; padding: 0 16px 48px; }

/* ---------- ダッシュボード ---------- */
.dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex: none;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon-memo { background: var(--primary-tint); color: var(--primary); }
.stat-icon-task { background: var(--task-tint); color: var(--done); }
.stat-icon-open { background: var(--accent-tint); color: var(--accent); }
.stat-text { display: flex; flex-direction: column; min-width: 0; }
.stat-label { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.stat-value {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.stat-accent { border-color: #f6dcc8; background: linear-gradient(135deg, #fff, #fffaf6); }
.stat-accent .stat-value { color: var(--accent); }

/* ---------- 2カラム・カード ---------- */
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.column { display: flex; flex-direction: column; gap: 24px; min-width: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 14px;
  font-size: 1.02rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-form { background: linear-gradient(180deg, #fbfcfe, #fff); }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  min-height: 32px;
}
.card-head h2 { margin: 0; }

.count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  background: #eff2f6;
  border-radius: 999px;
  padding: 1px 9px;
  font-variant-numeric: tabular-nums;
}

/* ---------- フォーム ---------- */
form { display: flex; flex-direction: column; gap: 6px; }
.inline-form { flex-direction: row; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; width: auto; }
label { font-size: 0.82rem; font-weight: 600; color: var(--muted); margin-top: 4px; }
input[type="text"], input[type="date"], input[type="time"], textarea {
  font: inherit;
  color: var(--text);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--field);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--subtle); }
textarea { resize: vertical; min-height: 104px; }
input[type="text"]:focus, input[type="date"]:focus, input[type="time"]:focus, textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 221, 0.15);
}

button {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(47, 111, 221, 0.25);
  transition: background 0.15s, box-shadow 0.15s, transform 0.05s;
}
button:hover { background: var(--primary-hover); box-shadow: 0 4px 12px rgba(47, 111, 221, 0.25); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 3px solid rgba(47, 111, 221, 0.35); outline-offset: 2px; }
form > button { align-self: flex-start; margin-top: 10px; }
.inline-form > button { margin-top: 0; }

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  flex: none;
  cursor: pointer;
  accent-color: var(--primary);
}

/* ---------- 一覧 ---------- */
.list { list-style: none; margin: 0 -10px; padding: 0; }
.list li {
  padding: 12px 10px;
  border-radius: 10px;
  position: relative;
  transition: background 0.15s;
}
.list li + li::before {
  content: "";
  position: absolute;
  top: 0;
  left: 10px;
  right: 10px;
  border-top: 1px solid var(--border);
}
.list li:hover { background: var(--hover); }
.list li:hover::before, .list li:hover + li::before { border-color: transparent; }

.empty {
  margin: 0;
  padding: 22px 12px;
  text-align: center;
  color: var(--subtle);
  font-size: 0.9rem;
  border: 1px dashed var(--border);
  border-radius: 12px;
}
.meta { color: var(--subtle); font-size: 0.78rem; }

.memo { display: flex; align-items: flex-start; gap: 12px; }
.memo-main { flex: 1; min-width: 0; }
.memo-title { font-weight: 700; margin: 0; overflow-wrap: anywhere; }
.memo-body { margin: 2px 0 4px; color: #3a4452; white-space: pre-wrap; overflow-wrap: anywhere; }

.task { display: flex; align-items: flex-start; gap: 12px; }
.task-main { flex: 1; min-width: 0; }
.task-text { margin: 0 0 2px; font-weight: 500; overflow-wrap: anywhere; }
.task.is-done .task-text { text-decoration: line-through; color: var(--subtle); }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.6;
  padding: 0 9px;
  border-radius: 999px;
  margin-right: 8px;
  border: 1px solid currentColor;
}
.badge-open { color: var(--accent); background: var(--accent-tint); }
.badge-done { color: var(--done); background: var(--task-tint); }

.delete-btn {
  background: #fff;
  color: var(--danger);
  border: 1px solid var(--border);
  padding: 3px 12px;
  font-size: 0.82rem;
  border-radius: 8px;
  box-shadow: none;
}
.delete-btn:hover { background: var(--danger-tint); border-color: #f3caca; box-shadow: none; }
.delete-btn:disabled { color: var(--subtle); cursor: default; background: #fff; border-color: var(--border); }
.delete-btn:disabled:active { transform: none; }
.task .delete-btn { opacity: 0.75; }
.task:hover .delete-btn, .task .delete-btn:focus-visible { opacity: 1; }

[hidden] { display: none !important; }

/* ---------- 現地調査の予定・確認 ---------- */
.survey-card { margin-bottom: 24px; }
.section-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--primary-tint);
  color: var(--primary);
}
.section-icon svg { width: 17px; height: 17px; }

.survey { display: flex; align-items: center; gap: 14px; }
.survey input[type="checkbox"] { margin-top: 0; }
.survey-when {
  flex: none;
  width: 92px;
  padding: 6px 0;
  border-radius: 10px;
  background: var(--primary-tint);
  color: var(--primary);
  text-align: center;
  line-height: 1.25;
}
.survey-day { display: block; font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.survey-sub { display: block; font-size: 0.75rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.survey-main { flex: 1; min-width: 0; }
.survey-site { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.survey-note { margin: 0; color: #3a4452; font-size: 0.9rem; overflow-wrap: anywhere; }
.survey-side { display: flex; align-items: center; gap: 4px; flex: none; }
.survey-side .badge { margin-right: 4px; }
.survey.is-checked .survey-when, .survey.is-past .survey-when { background: #eff2f6; color: var(--muted); }
.survey.is-checked .survey-site { color: var(--muted); }

.badge-soon { color: var(--primary); background: var(--primary-tint); }
.badge-later { color: var(--muted); background: #f3f5f8; }
.badge-past { color: var(--muted); background: #f3f5f8; border-style: dashed; }

.survey-form {
  display: grid;
  grid-template-columns: 170px 130px minmax(0, 1fr) minmax(0, 1.4fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { margin-top: 0; }
.survey-form > button { margin-top: 0; align-self: end; }

/* ---------- 確認ダイアログ ---------- */
.confirm-dialog {
  border: none;
  border-radius: 18px;
  padding: 24px;
  width: min(380px, calc(100vw - 32px));
  box-shadow: 0 20px 50px rgba(20, 30, 50, 0.25);
  color: var(--text);
}
.confirm-dialog[open] { animation: pop 0.15s ease-out; }
.confirm-dialog::backdrop { background: rgba(20, 30, 50, 0.4); backdrop-filter: blur(2px); }
.confirm-dialog p { margin: 0 0 20px; font-weight: 600; overflow-wrap: anywhere; }
.dialog-actions { display: flex; flex-direction: row; justify-content: flex-end; gap: 8px; }
.dialog-actions button { margin-top: 0; align-self: auto; }
.secondary-btn { background: #fff; color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.secondary-btn:hover { background: var(--bg); box-shadow: none; }
.danger-btn { background: var(--danger); box-shadow: 0 1px 2px rgba(201, 42, 42, 0.3); }
.danger-btn:hover { background: #a61e1e; box-shadow: 0 4px 12px rgba(201, 42, 42, 0.25); }

@keyframes pop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- お知らせ ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: #1c2430;
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.92rem;
  box-shadow: 0 10px 30px rgba(20, 30, 50, 0.25);
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- スマホ・狭い画面 ---------- */
@media (max-width: 980px) and (min-width: 761px) {
  .survey-form { grid-template-columns: 170px 130px minmax(0, 1fr) auto; }
  .field-site { grid-column: 3 / -1; }
  .field-note { grid-column: 1 / 4; }
}

@media (max-width: 760px) {
  .app-header { padding-top: 20px; }
  .columns { grid-template-columns: 1fr; gap: 16px; }
  .column { gap: 16px; }
  .dashboard { gap: 10px; margin-bottom: 16px; }
  .stat { padding: 14px; gap: 12px; }
  .stat-icon { width: 40px; height: 40px; border-radius: 12px; }
  .stat-icon svg { width: 20px; height: 20px; }
  .stat-value { font-size: 1.6rem; }
  .card { padding: 18px; }
  .survey-card { margin-bottom: 16px; }
  .survey-form { grid-template-columns: 1fr 1fr; }
  .field-site, .field-note, .survey-form > button { grid-column: 1 / -1; }
  .survey-form > button { justify-self: start; }
  .survey { flex-wrap: wrap; }
  .survey-main { flex-basis: 140px; }
  .survey-side { width: 100%; justify-content: flex-end; }
}

@media (max-width: 520px) {
  .stat { flex-direction: column; align-items: flex-start; gap: 8px; }
  .stat-icon { width: 32px; height: 32px; border-radius: 10px; }
  .stat-icon svg { width: 18px; height: 18px; }
  .stat-label { font-size: 0.75rem; }
}
