:root {
  --bg: #faf9f5;
  --surface: #ffffff;
  --surface-2: #f2f0e9;
  --border: #e2ded2;
  --text: #23262b;
  --text-muted: #6b6f78;
  --accent: #2f4b8f;
  --accent-strong: #1c3468;
  --accent-soft: #e9edf8;
  --danger: #b3401f;
  --danger-soft: #fbe9e2;
  --success: #3c5c34;
  --success-soft: #eef3ea;
  --shadow: 0 1px 2px rgba(35,38,43,0.05), 0 8px 24px -16px rgba(35,38,43,0.25);
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", "Zen Kaku Gothic New", "Yu Gothic", "Meiryo", "MS PGothic", system-ui, sans-serif;
  line-height: 1.6;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}

button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease;
}
button:hover { background: var(--surface-2); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover { background: var(--accent-strong); }
button.danger { color: var(--danger); }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover { background: var(--surface-2); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input[type="text"], input[type="password"], input[type="date"], select, textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
textarea { resize: vertical; min-height: 70px; }
label { font-size: 12px; color: var(--text-muted); font-weight: 500; display: block; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- App shell ---------- */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.app-header h1 {
  font-family: "Zen Kaku Gothic New", "Yu Gothic", "Meiryo", "MS PGothic", sans-serif;
  font-size: 18px;
  margin: 0;
  white-space: nowrap;
}
.app-header .spacer { flex: 1; }
.whoami { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.whoami select { width: auto; padding: 6px 10px; }

.app-main { max-width: 1080px; margin: 0 auto; padding: 24px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); font-weight: 500; }
.toolbar .right { margin-left: auto; display: flex; gap: 8px; }
.toolbar select { width: auto; }

/* ---------- Task table ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
table { border-collapse: collapse; width: 100%; min-width: 720px; font-size: 13.5px; }
thead th {
  text-align: left;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.overdue { border-left: 3px solid var(--danger); }
tbody tr.overdue td.due { color: var(--danger); font-weight: 600; }
.empty-row td { text-align: center; color: var(--text-muted); padding: 40px 16px; cursor: default; }
.empty-row:hover { background: none; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 100px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge.status-未着手 { background: var(--surface-2); color: var(--text-muted); }
.badge.status-進行中 { background: var(--accent-soft); color: var(--accent-strong); }
.badge.status-確認待ち { background: #fdf1dc; color: #8a5a15; }
.badge.status-完了 { background: var(--success-soft); color: var(--success); }
.badge.priority-高 { background: var(--danger-soft); color: var(--danger); }
.badge.priority-中 { background: var(--surface-2); color: var(--text-muted); }
.badge.priority-低 { background: var(--accent-soft); color: var(--accent-strong); opacity: 0.8; }

/* ---------- Dialogs ---------- */
dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(560px, 92vw);
  max-height: 88vh;
  box-shadow: var(--shadow);
  color: var(--text);
  background: var(--surface);
}
dialog::backdrop { background: rgba(20, 22, 26, 0.45); }
.dialog-inner { padding: 24px 26px; overflow-y: auto; max-height: 88vh; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.dialog-header h2 { font-family: "Zen Kaku Gothic New", "Yu Gothic", "Meiryo", "MS PGothic", sans-serif; font-size: 17px; margin: 0; }
.dialog-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.dialog-actions .right { display: flex; gap: 8px; margin-left: auto; }

.meta-line { font-size: 12px; color: var(--text-muted); margin-bottom: 18px; display: flex; gap: 14px; flex-wrap: wrap; }

.comments { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.comments h3 { font-size: 13px; margin: 0 0 12px; color: var(--text-muted); font-weight: 600; }
.comment-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; max-height: 220px; overflow-y: auto; }
.comment {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}
.comment .comment-head { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.comment .comment-head .author { font-weight: 600; color: var(--text); }
.comment-form { display: flex; gap: 8px; }
.comment-form textarea { min-height: 44px; }
.no-comments { color: var(--text-muted); font-size: 13px; margin-bottom: 14px; }

.member-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.member-row { display: flex; align-items: center; gap: 8px; }
.member-row input { flex: 1; }

@media (max-width: 640px) {
  .field-row { grid-template-columns: 1fr; }
  .app-header { padding: 12px 16px; }
  .app-main { padding: 16px; }
}
