/* ===== CSS Variables ===== */
:root {
  --primary: #CC0033;
  --primary-dark: #A30029;
  --primary-light: #ff4d6d;
  --primary-bg: #fff0f3;
  /* 文字として使う主色。背景用の --primary とは分ける（ダークの暗い面でも 4.5:1 を満たすため #354） */
  --primary-text: #CC0033;
  --bg: #F2F3F5;
  --card-bg: #FFFFFF;
  --text: #1A1A1A;
  --text-sub: #525965;
  --border: #E5E7EB;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.13);
  --radius: 8px;
  --radius-sm: 4px;
  --sidebar-w: 220px;
  --header-h: 56px;

  --priority-high: #CC0033;
  --priority-high-bg: #fff0f3;
  --priority-medium: #B45309;
  --priority-medium-bg: #fffbeb;
  --priority-low: #4B5563;
  --priority-low-bg: #F3F4F6;

  --status-todo: #6B7280;
  --status-inprogress: #2563EB;
  --status-inprogress-bg: #EFF6FF;
  --status-done: #16A34A;
  --status-done-bg: #F0FDF4;
  --status-inprogress-text: #1D4ED8;
  --status-done-text: #15803D;
}

/* ===== Dark Theme ===== */
[data-theme="dark"] {
  --bg: #0F1117;
  --card-bg: #1A1D27;
  --text: #E8EAED;
  --text-sub: #9AA0AC;
  --border: #2D3142;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.55);
  --primary-bg: #2A0A12;
  --primary-text: #FF6B85;
  --priority-high: #FF6B85;
  --priority-medium: #F59E0B;
  --priority-low: #9CA3AF;
  --priority-high-bg: #2A0A12;
  --priority-medium-bg: #1F1800;
  --priority-low-bg: #1A1D27;
  --status-inprogress-bg: #0A1628;
  --status-done-bg: #071812;
  --status-inprogress-text: #93C5FD;
  --status-done-text: #86EFAC;
}
[data-theme="dark"] .filter-select,
[data-theme="dark"] .kanban-status-select,
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea { background: var(--card-bg); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .modal { background: var(--card-bg); }
[data-theme="dark"] .btn-secondary { background: var(--card-bg); }
[data-theme="dark"] .color-input { background: var(--card-bg); border-color: var(--border); }

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* スクリーンリーダー専用のラベル（視覚的には非表示） */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: inherit; text-decoration: none; }

/* ===== Header ===== */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  transition: box-shadow 0.25s ease;
  background: var(--primary);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 100;
  gap: 16px;
}
.header.elevated { box-shadow: 0 4px 20px rgba(0,0,0,0.28); }
.header-left { flex: 1; display: flex; align-items: center; }
.header-center { flex: 0 0 auto; }
.header-right { flex: 1; display: flex; justify-content: flex-end; align-items: center; gap: 8px; }

.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: #fff;
  min-width: 56px;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 12px;
  transition: background 0.2s, color 0.2s;
}
.sync-indicator:empty { padding: 0; }

/* state colors */
.sync-indicator.sync-syncing { background: rgba(255,255,255,0.12); }
.sync-indicator.sync-saved   { background: rgba(22,163,74,0.30); color: #fff; }
.sync-indicator.sync-error   {
  background: #ef4444;
  color: #fff;
  font-weight: 600;
}
.sync-indicator.sync-offline {
  background: #B45309; /* 白文字 5.0:1（旧 #d97706 は 3.1:1） */
  color: #fff;
  font-weight: 600;
}
/* 未同期（端末内のみ保存）：オフラインと別の見た目（濃い半透明）＋別アイコン(💾) #353 */
.sync-indicator.sync-pending { background: rgba(0, 0, 0, 0.32); font-weight: 600; }
.sync-indicator.sync-local {
  background: rgba(0, 0, 0, 0.32);
  color: #fff;
  font-weight: 600;
}

/* pulsing dot for syncing state */
.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  animation: syncPulse 1.1s ease-in-out infinite;
}
@keyframes syncPulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1.15); }
}

/* retry button inside error indicator */
.sync-retry-btn {
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.22);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  transition: background 0.12s;
}
.sync-retry-btn:hover  { background: rgba(255,255,255,0.36); }
.sync-retry-btn:active { background: rgba(255,255,255,0.5); }
.sync-retry-btn:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

.theme-toggle-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 22px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: rgba(255,255,255,0.95);
  transition: background 0.15s, transform 0.2s;
}
.theme-toggle-icon  { font-size: 18px; line-height: 1; }
.theme-toggle-label { font-weight: 500; }
.theme-toggle-btn:hover { background: rgba(255,255,255,0.18); }
.theme-toggle-btn:hover .theme-toggle-icon { transform: rotate(20deg) scale(1.1); transition: transform 0.2s; }

.logo {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
  white-space: nowrap; /* 狭い幅で「タ/スク」と折り返さない (#353) */
  flex-shrink: 0;
}
.logo-d {
  display: inline-block;
  width: 28px;
  height: 28px;
  background: #fff;
  color: var(--primary);
  border-radius: 50%;
  text-align: center;
  line-height: 28px;
  font-size: 18px;
  font-weight: 900;
  margin-right: 4px;
}

/* View Toggle */
.view-toggle {
  display: flex;
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 3px;
  gap: 2px;
}
.view-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 4px;
  color: #fff; /* 半透明の白は赤地で 3.4:1 しかなかった (#354) */
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
.view-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
.view-btn.active { background: #fff; color: var(--primary); }

/* ===== Layout ===== */
.app-layout {
  display: flex;
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
}
.sidebar-section {
  padding: 0 16px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.sidebar-section:last-child { border-bottom: none; }
.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
}
.sidebar-title-row .sidebar-title { margin-bottom: 0; }

/* Filters */
.filter-group { margin-bottom: 10px; }
.filter-group-check { margin-bottom: 14px; }
.filter-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s;
}
.filter-check:hover { background: var(--primary-bg); }
.filter-check input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}
.filter-label {
  display: block;
  font-size: 12px;
  color: var(--text-sub);
  margin-bottom: 4px;
}
.filter-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  appearance: auto;
}
.filter-select:focus { outline: 2px solid var(--primary); border-color: transparent; }

/* Category filter chips */
.category-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.category-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  text-align: left;
  width: 100%;
  transition: background 0.12s;
}
.category-chip:hover { background: var(--bg); }
.category-chip.active { background: var(--primary-bg); color: var(--primary-text); font-weight: 500; }
.category-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Category manage list */
.category-manage-list { display: flex; flex-direction: column; gap: 4px; }
.category-manage-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
/* 名前だけを伸ばす（span 全般に当てると色ドットまで横長の楕円になる #353） */
.category-manage-item .category-manage-name { flex: 1; font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.btn-delete-cat {
  color: var(--text-sub);
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
  transition: all 0.12s;
}
.btn-delete-cat:hover { color: var(--primary-text); background: var(--primary-bg); }

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  padding: 24px;
  min-width: 0;
}

/* ===== Search Bar ===== */
/* ===== Font Size Toggle (sidebar) ===== */
.fontsize-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.fontsize-label {
  font-size: 12px;
  color: var(--text-sub);
}
.fontsize-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--card-bg);
}
.fontsize-btn {
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--text-sub);
  background: transparent;
  transition: all 0.12s;
  min-width: 44px;
  min-height: 30px;
}
.fontsize-btn:hover  { background: var(--primary-bg); color: var(--primary-text); }
.fontsize-btn.active { background: var(--primary); color: #fff; font-weight: 600; }
.fontsize-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  position: relative;
  z-index: 1;
}

/* ===== 大きい文字サイズ（佐藤さん対応） ===== */
body[data-fontsize="large"] {
  font-size: 16px;
}
body[data-fontsize="large"] .task-title       { font-size: 17px; }
body[data-fontsize="large"] .task-desc        { font-size: 15px; }
body[data-fontsize="large"] .kanban-card-title{ font-size: 16px; }
body[data-fontsize="large"] .badge            { font-size: 12.5px; padding: 3px 9px; }
body[data-fontsize="large"] .tag-chip         { font-size: 12.5px; padding: 3px 9px; }
body[data-fontsize="large"] .badge-deadline,
body[data-fontsize="large"] .badge-recurrence { font-size: 12.5px; }
body[data-fontsize="large"] .form-label       { font-size: 14px; }
body[data-fontsize="large"] .filter-label     { font-size: 13px; }
body[data-fontsize="large"] .filter-check     { font-size: 14px; }
body[data-fontsize="large"] .filter-select    { font-size: 14px; padding: 8px 10px; }
body[data-fontsize="large"] .form-input,
body[data-fontsize="large"] .form-select,
body[data-fontsize="large"] .form-textarea    { font-size: 16px; }
body[data-fontsize="large"] .quick-add-input  { font-size: 17px; }
body[data-fontsize="large"] .search-input     { font-size: 16px; }
body[data-fontsize="large"] .empty-state p    { font-size: 17px; }
body[data-fontsize="large"] .empty-sub        { font-size: 14.5px; }
body[data-fontsize="large"] .empty-tip        { font-size: 14px; }
body[data-fontsize="large"] .preset-chip      { font-size: 14px; padding: 8px 16px; }
body[data-fontsize="large"] .category-chip    { font-size: 14px; }
body[data-fontsize="large"] .toast            { font-size: 15px; }
body[data-fontsize="large"] .btn-primary,
body[data-fontsize="large"] .btn-secondary    { font-size: 15px; }

/* ===== Preset Chips（今日/今週/期限切れ） ===== */
.preset-chips {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.preset-chip {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text-sub);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.12s;
}
.preset-chip:hover {
  border-color: var(--primary);
  color: var(--primary-text);
  background: var(--primary-bg);
}
.preset-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(204,0,51,0.25);
}
.preset-chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ===== Quick Add ===== */
.quick-add-wrap { margin-bottom: 12px; }
.quick-add-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius);
  padding: 4px 4px 4px 14px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.quick-add-bar:focus-within {
  box-shadow: 0 0 0 3px rgba(204,0,51,0.15);
}
.quick-add-icon {
  color: var(--primary-text);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}
.quick-add-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 10px 0;
  font-size: 15px;
  outline: none;
  min-width: 0;
}
.quick-add-input::placeholder { color: var(--text-sub); }

/* Meta chips (高/今日/明日) */
.quick-add-bar { flex-wrap: wrap; row-gap: 6px; }
.quick-add-meta {
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0;
}
.quick-add-chip {
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 500;
  min-height: 30px;
  transition: all 0.12s;
}
.quick-add-chip:hover { border-color: var(--primary); color: var(--primary-text); }
.quick-add-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.quick-add-chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.quick-add-detail-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary-bg);
  color: var(--primary-text);
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.12s;
}
.quick-add-detail-btn:hover { background: var(--primary); color: #fff; }
.quick-add-detail-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
@media (max-width: 767px) {
  .quick-add-detail-btn { padding: 8px 10px; font-size: 12px; }
  .quick-add-chip { padding: 5px 9px; font-size: 11.5px; }
}

.search-bar-wrap { margin-bottom: 12px; }
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-bar:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(204,0,51,0.1); }
.search-icon { font-size: 14px; color: var(--text-sub); flex-shrink: 0; }
.search-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 10px 8px;
  font-size: 14px;
  outline: none;
}
.search-input::placeholder { color: var(--text-sub); }
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-sub);
  color: #fff;
  font-size: 11px;
  flex-shrink: 0;
  transition: background 0.12s;
}
.search-clear:hover { background: var(--primary); }

/* ===== Stats Bar ===== */
.stats-bar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.stats-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.stats-text { font-size: 13px; color: var(--text-sub); font-weight: 500; }
.stats-pct { font-size: 13px; font-weight: 700; color: var(--primary-text); }
.stats-track { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.stats-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary-light), var(--primary));
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  width: 0%;
}

/* ===== View Containers ===== */
.view-container { width: 100%; }
.hidden { display: none !important; }

/* ===== Task List ===== */
.task-list { display: flex; flex-direction: column; gap: 10px; }

.task-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, transform 0.18s ease, opacity 0.18s ease;
  animation: cardIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: var(--card-i, 0ms);
  will-change: transform, opacity;
}
.task-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  border-color: rgba(204,0,51,0.15);
}
/* 完了カードは opacity で薄くしない（バッジ・文字が合成後に AA を割るため #354）。タイトルと説明の色で落ち着かせる */
.task-card.done-card .task-title,
.task-card.done-card .task-desc { color: var(--text-sub); }
.task-card.removing {
  animation: cardOut 0.24s ease forwards !important;
  pointer-events: none;
}

/* Checkbox */
.task-check {
  width: 20px; height: 20px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 1px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  background: #fff;
  line-height: 1;
}
.task-check:hover { border-color: var(--primary); }
.task-check:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.task-check.checked {
  background: var(--primary);
  border-color: var(--primary);
  animation: checkBounce 0.38s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
.task-check.checked::after {
  content: '✓';
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  animation: checkmark 0.2s ease 0.1s both;
}
@keyframes checkmark {
  from { opacity: 0; transform: scale(0.5) rotate(-10deg); }
  to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* Task body */
.task-body { flex: 1; min-width: 0; }
.task-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
  word-break: break-word;
}
.task-card.done-card .task-title {
  text-decoration: line-through;
  transition: text-decoration 0.2s;
}
.task-desc {
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}
.task-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-high { background: var(--priority-high-bg); color: var(--priority-high); }
.badge-medium { background: var(--priority-medium-bg); color: var(--priority-medium); }
.badge-low { background: var(--priority-low-bg); color: var(--priority-low); }
/* ステータス：優先度「低」と見分けがつくよう、未着手は枠線のみ・進行中/完了は色付き (#353) */
.badge-status { border: 1px solid transparent; }
.badge-status-todo { background: transparent; color: var(--text-sub); border-color: var(--text-sub); }
.badge-status-inprogress { background: var(--status-inprogress-bg); color: var(--status-inprogress-text); }
.badge-status-done { background: var(--status-done-bg); color: var(--status-done-text); }
/* プロジェクト色バッジ：ライト/ダーク用の背景・文字色を app.js が CSS 変数で渡し、テーマはここで切替える (#354) */
.badge-category {
  background: var(--cat-bg-l, var(--bg));
  color: var(--cat-fg-l, var(--text-sub));
  font-weight: 500;
}
[data-theme="dark"] .badge-category {
  background: var(--cat-bg-d, var(--bg));
  color: var(--cat-fg-d, var(--text-sub));
}
.badge-deadline {
  font-size: 11px;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 3px;
}
.badge-deadline.overdue { color: var(--primary-text); font-weight: 600; }

/* Task actions */
.task-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.task-card:hover .task-actions,
.task-card:focus-within .task-actions { opacity: 1; }
.btn-action {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
  font-size: 14px;
  transition: all 0.12s;
}
.btn-action:hover { background: var(--bg); color: var(--text); }
.btn-action:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn-action.delete:hover { background: var(--primary-bg); color: var(--primary-text); }
.btn-action.skip:hover { background: var(--status-inprogress-bg); color: var(--status-inprogress); }

/* 操作メニュー(⋮) トリガー：常時表示（ホバー非依存＝タッチ/キーボードの正規ルート #111） */
.card-menu-btn {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
  font-size: 20px;
  line-height: 1;
  transition: all 0.12s;
}
.card-menu-btn:hover { background: var(--bg); color: var(--text); }
.card-menu-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
/* list カードの ⋮ は task-actions の右隣に常時表示 */
.task-card > .card-menu-btn { align-self: flex-start; }

/* 操作メニュー ポップアップ（body直下の単一要素・ビュー非依存） */
.card-menu {
  position: fixed;
  z-index: 200;
  min-width: 168px;
  padding: 6px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: fadeIn 0.12s ease both;
}
.card-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  text-align: left;
  white-space: nowrap;
}
.card-menu-item:hover:not([disabled]),
.card-menu-item:focus-visible { background: var(--primary-bg); color: var(--primary-text); outline: none; }
.card-menu-item.danger:hover:not([disabled]) { background: var(--primary-bg); color: var(--primary-text); }
.card-menu-item[disabled] { opacity: 0.4; cursor: default; }
body[data-fontsize="large"] .card-menu-item { font-size: 15.5px; }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-sub);
  animation: fadeInView 0.4s ease both;
}
.empty-icon {
  font-size: 52px;
  margin-bottom: 16px;
  display: block;
  animation: floatIcon 3.5s ease-in-out infinite;
}
.empty-state p { font-size: 15px; margin-bottom: 4px; }
.empty-sub { font-size: 13px; color: var(--text-sub); line-height: 1.7; }
.empty-tip {
  margin-top: 14px;
  padding: 8px 14px;
  display: inline-block;
  font-size: 12.5px;
  color: var(--text-sub);
  background: var(--primary-bg);
  border-radius: 12px;
}
.empty-tip code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  color: var(--primary-text);
  font-weight: 500;
}
/* 達成（ご褒美）空状態：今日のタスク完了時 */
.today-done-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary-text);
  margin-bottom: 8px;
}

/* ===== Kanban Board ===== */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  align-items: start;
}
.kanban-column {
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 3px solid transparent;
}
.todo-header { border-bottom-color: var(--status-todo); }
.inprogress-header { border-bottom-color: var(--status-inprogress); }
.done-header { border-bottom-color: var(--status-done); }
.col-title { font-size: 13px; font-weight: 700; color: var(--text); }
.col-count {
  background: var(--border);
  color: var(--text-sub);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s;
}
.col-count.bump { animation: countBump 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.kanban-cards {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 80px;
}

/* Kanban card */
.kanban-card {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 12px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, transform 0.18s ease;
  animation: cardIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: var(--card-i, 0ms);
}
.kanban-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.kanban-card.removing {
  animation: cardOut 0.22s ease forwards !important;
  pointer-events: none;
}
.kanban-card-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
  word-break: break-word;
}
.kanban-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}
.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.kanban-status-select {
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  flex: 1;
}
.kanban-actions { display: flex; gap: 2px; }

/* ===== Buttons ===== */
.btn-primary {
  background: var(--primary);
  color: #fff;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s, transform 0.12s, box-shadow 0.15s;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 2px 10px rgba(204,0,51,0.35); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: #fff;
  color: var(--primary-text);
  border: 1px solid var(--primary);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}
.btn-secondary:hover { background: var(--primary-bg); transform: translateY(-1px); }
.btn-secondary:active { transform: scale(0.97); }

/* Ripple */
.ripple-wave {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.38);
  transform: scale(0);
  animation: rippleAnim 0.55s linear;
  pointer-events: none;
}
.btn-secondary .ripple-wave { background: rgba(204,0,51,0.15); }

.btn-icon-small {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.12s;
}
.btn-icon-small:hover { background: var(--primary-dark); transform: scale(1.1); }
.btn-icon-small:active { transform: scale(0.92); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
  animation: slideUp 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal-sm { max-width: 360px; }

@keyframes slideUp {
  from { transform: translateY(20px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--text); }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  color: var(--text-sub);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  position: sticky;
  bottom: 0;
  background: var(--card-bg);
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
}

/* ===== Form ===== */
.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.required { color: var(--primary-text); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(204, 0, 51, 0.1);
}
.form-textarea { resize: vertical; min-height: 72px; }

/* Color picker */
.color-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.color-input {
  width: 44px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 2px;
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: none; border-radius: 3px; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #C9CDD4; }

/* ===== Hamburger（デスクトップでは非表示） ===== */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  border-radius: var(--radius-sm);
  margin-right: 8px;
  flex-shrink: 0;
  transition: background 0.15s;
}
.hamburger:hover { background: rgba(255,255,255,0.15); }
.hamburger span {
  display: block;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* モバイル用アイコンのみのビュー切り替え（デスクトップでは非表示） */
.view-toggle-mobile { display: none; gap: 2px; }
.view-btn-icon {
  width: 36px; height: 36px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: all 0.15s;
}
.view-btn-icon:hover { color: #fff; background: rgba(255,255,255,0.1); }
.view-btn-icon.active { background: #fff; color: var(--primary); }

/* ===== サイドバーオーバーレイ ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 149;
  opacity: 0;
  transition: opacity 0.25s;
}
.sidebar-overlay.visible { opacity: 1; }

/* ===== FAB（モバイル＋タブレット用） ===== */
.fab {
  display: none;
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 32px;
  line-height: 1;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(204, 0, 51, 0.5);
  z-index: 120;
  transition: background 0.15s, transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s;
}
.fab:hover  { background: var(--primary-dark); transform: scale(1.08); box-shadow: 0 6px 24px rgba(204,0,51,0.6); }
.fab:active { transform: scale(0.94); }
.fab:focus-visible { outline: 3px solid #fff; outline-offset: 3px; box-shadow: 0 0 0 5px rgba(204,0,51,0.6); }

/* ===== 全keyframes ===== */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes cardOut {
  to { opacity: 0; transform: translateX(-14px) scale(0.96); }
}
@keyframes checkBounce {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.35); }
  70%  { transform: scale(0.88); }
  100% { transform: scale(1); }
}
@keyframes rippleAnim {
  to { transform: scale(4); opacity: 0; }
}
@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-12px); }
}
@keyframes countBump {
  0%, 100% { transform: scale(1); }
  40%      { transform: scale(1.45); }
  70%      { transform: scale(0.9); }
}
@keyframes fadeInView {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fabSpring {
  0%   { transform: scale(0) rotate(-45deg); opacity: 0; }
  60%  { transform: scale(1.15) rotate(5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ===== View entering ===== */
.view-entering { animation: fadeInView 0.22s cubic-bezier(0.22, 1, 0.36, 1); }

/* ===== タブレット（768px〜1023px） ===== */
@media (max-width: 1023px) and (min-width: 768px) {
  :root { --sidebar-w: 180px; }
  .main-content { padding: 16px 16px 96px; } /* FAB分の下余白 */

  /* カンバン：横スクロール対応 */
  .kanban-board {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
  }
  .kanban-column {
    min-width: 240px;
    flex: 1;
  }

  /* タスクカードのアクションを常に表示 */
  .task-actions { opacity: 1; }

  /* タブレットでもFABを表示（タッチデバイス想定） */
  .fab {
    display: flex;
    animation: fabSpring 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
  }
}

/* ===== モバイル（〜767px） ===== */
@media (max-width: 767px) {
  :root { --header-h: 52px; }

  /* ヘッダー */
  .hamburger { display: flex; }
  .header-center { display: none; }
  .view-toggle-mobile { display: flex; }
  .btn-primary#addTaskBtn { display: none; } /* FABで代替 */
  .theme-toggle-label { display: none; }     /* スマホはアイコンのみ（スペース節約） */
  .theme-toggle-btn { padding: 6px; min-width: 40px; }

  /* サイドバー：ドロワー化 */
  .sidebar-overlay { display: block; pointer-events: none; }
  .sidebar-overlay.visible { pointer-events: auto; }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    z-index: 150;
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
    transition: transform 0.25s ease;
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }

  /* メインコンテンツ */
  .main-content { padding: 12px 12px 80px; } /* FAB分の下余白 */

  /* タスクカード：タップしやすく */
  .task-card { padding: 12px; gap: 10px; }
  .task-check { width: 24px; height: 24px; flex-shrink: 0; }
  .task-actions { opacity: 1; } /* 常に表示 */
  .btn-action { width: 32px; height: 32px; font-size: 15px; }

  /* 同期表示：アイコンのみ（文言は読み上げ用に視覚的に隠す） */
  .sync-indicator { min-width: 0; padding: 4px; }
  .sync-label {
    position: absolute; width: 1px; height: 1px; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }

  /* カンバン：横スクロール */
  .kanban-board {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    grid-template-columns: none;
    scroll-snap-type: x mandatory;
  }
  /* 列幅は中身でなく画面幅で決める（長いカードで列が画面外まで伸び、件数バッジが切れていた #353）。
     次の列の端を覗かせ、横スクロールできることを示す */
  .kanban-column {
    flex: 0 0 min(85%, 320px);
    min-width: 0;
    scroll-snap-align: start;
  }
  .kanban-cards { min-height: 60px; }

  /* FAB表示 */
  .fab {
    display: flex;
    animation: fabSpring 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
  }

  /* モーダル：ボトムシート化 */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    border-radius: 16px 16px 0 0;
    max-width: 100%;
    max-height: 92dvh;
    animation: slideUpSheet 0.25s ease;
  }
  .modal-sm {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
  }
  @keyframes slideUpSheet {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  /* フォーム */
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .form-input, .form-select, .form-textarea {
    font-size: 16px; /* iOSズーム防止 */
    padding: 11px 12px;
  }
  .modal-footer { gap: 8px; }
  .btn-primary, .btn-secondary { padding: 11px 16px; font-size: 14px; }

  /* サイドバー内のタップターゲット拡大 */
  .category-chip { padding: 10px; }
  /* タップ領域の最小サイズ（総点検で 16〜26px だったもの #354） */
  .btn-icon-small { width: 36px; height: 36px; font-size: 20px; }
  .btn-delete-cat { min-width: 36px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; }
  .subtask-toggle, .subtask-toggle-empty { min-height: 32px; }
  .kanban-status-select { min-height: 36px; font-size: 13px; }
  .fontsize-btn { min-height: 36px; }
  .filter-select { padding: 10px 8px; font-size: 15px; }
}

/* 375px 未満はヘッダーに全ボタンが収まらないため、ロゴは「d」マークのみ（文字は読み上げ用に残す #353） */
@media (max-width: 374px) {
  .logo-text {
    position: absolute; width: 1px; height: 1px; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
}

/* ===== Swipe Gesture ===== */
.swipe-wrapper {
  position: relative;
  border-radius: var(--radius);
  /* overflow:hidden を削除 → カードが実際にスライドして見えるようになる */
}

/* 赤・緑の背景（カードが動いた後ろに見える） */
.swipe-bg-delete,
.swipe-bg-complete {
  position: absolute;
  top: 0; bottom: 0; width: 100%;
  display: flex;
  align-items: center;
  font-size: 22px;
  padding: 0 24px;
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.12s ease;
  pointer-events: none;
  user-select: none;
  z-index: 0;
}
.swipe-bg-delete {
  background: #ef4444;
  color: #fff;
  justify-content: flex-end;
}
.swipe-bg-complete {
  background: #16a34a;
  color: #fff;
  justify-content: flex-start;
}
.swipe-wrapper.swiping-left  .swipe-bg-delete  { opacity: 1; }
.swipe-wrapper.swiping-right .swipe-bg-complete { opacity: 1; }
.swipe-wrapper.trigger-delete   .swipe-bg-delete   { background: #dc2626; }
.swipe-wrapper.trigger-complete .swipe-bg-complete { background: #15803d; }

/* カードは必ず背景より前面 */
.swipe-wrapper > .task-card {
  position: relative;
  z-index: 1;
}

.task-card.is-swiping {
  animation: none !important; /* cardInアニメーションがinline transformを上書きするのを防ぐ */
  transition: box-shadow 0.2s ease;
}
.task-card.is-swiping:hover {
  transform: none; /* :hoverのtranslateY(-2px)がスワイプを邪魔しないように */
}
.task-card.snap-back {
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.2s ease, opacity 0.18s ease !important;
}

/* ===== Landscape Mobile Optimization ===== */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --header-h: 40px; }

  .header { padding: 0 12px; gap: 8px; }
  .logo { font-size: 16px; }
  .logo-d { width: 22px; height: 22px; font-size: 14px; line-height: 22px; }
  .sync-indicator { display: none; }
  .theme-toggle-btn {
    min-width: 36px; min-height: 36px;
    padding: 4px 6px;
    font-size: 13px;
  }
  .theme-toggle-label { display: none; } /* スペース節約 */

  .sidebar { width: 200px; }
  .sidebar-title { font-size: 10px; }
  .filter-label  { font-size: 11px; }
  .filter-select { font-size: 12px; padding: 6px; }
  .category-chip { padding: 7px 8px; font-size: 12px; }
  .sidebar-section { padding: 0 12px 14px; }

  .main-content {
    padding: 8px 10px max(68px, calc(60px + env(safe-area-inset-bottom)));
  }

  .fab {
    width: 48px;
    height: 48px;
    font-size: 24px;
    bottom: max(12px, env(safe-area-inset-bottom));
    right: max(14px, env(safe-area-inset-right));
  }

  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: 12px 12px 0 0;
    max-height: 85vh;
    max-height: 85dvh;
  }

  .task-card { padding: 8px 10px; gap: 8px; }
  .kanban-col-header { padding: 8px 12px; }
  .kanban-cards { padding: 8px; gap: 6px; }
}

/* ===== Tags ===== */
.task-tags,
.kanban-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.tag-chip {
  display: inline-block;
  font-size: 11px;
  color: var(--text-sub);
  background: var(--bg);
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  line-height: 1.4;
}
[data-theme="dark"] .tag-chip { background: var(--card-bg); }

/* ===== Subtasks (modal) ===== */
.subtask-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 6px;
}
.subtask-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.subtask-check {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.subtask-title-input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
  font-size: 13px;
}
.subtask-remove-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--text-sub);
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}
.subtask-remove-btn:hover {
  background: var(--priority-high-bg);
  color: var(--priority-high);
}
.subtask-add-btn {
  font-size: 12px;
  color: var(--primary-text);
  padding: 4px 0;
}
.subtask-add-btn:hover { text-decoration: underline; }

/* ===== Subtask progress (card) ===== */
.subtask-progress {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-sub);
}
.subtask-progress-bar {
  display: inline-block;
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.subtask-progress-fill {
  display: block;
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}

/* ===== Subtask inline expand (card) ===== */
.subtask-toggle {
  /* .subtask-progress の見た目を踏襲しつつ button 化 */
  background: transparent;
  border: 0;
  padding: 2px 6px;
  border-radius: 999px;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  /* font-size は .subtask-progress の 11px をそのまま使う */
}
.subtask-toggle:hover,
.subtask-toggle:focus-visible {
  background: var(--border);
  outline: none;
}
.subtask-toggle .chevron {
  font-size: 10px;
  line-height: 1;
  color: var(--text-sub);
  transition: transform 0.2s ease;
  margin-left: 2px;
}
.subtask-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }

/* 0件タスクの追加導線チップ */
.subtask-toggle-empty {
  font-size: 11px;
  color: var(--text-sub);
  border: 1px dashed var(--border);
  padding: 1px 8px;
}
.subtask-toggle-empty:hover,
.subtask-toggle-empty:focus-visible {
  color: var(--primary-text);
  border-color: var(--primary);
  background: var(--border);
}

.task-subtasks-inline {
  margin-top: 8px;
  padding: 8px 4px 4px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: subtasksSlideIn 0.18s ease-out;
}
@keyframes subtasksSlideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.subtask-inline-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  min-height: 32px; /* スマホ用タップ領域 */
  cursor: pointer;
  user-select: none;
}
.subtask-inline-check {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  cursor: pointer;
  accent-color: var(--primary);
}
.subtask-inline-title {
  font-size: 13px;
  line-height: 1.3;
  color: var(--text);
  cursor: text;
  padding: 2px 4px;
  border-radius: 4px;
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
}
.subtask-inline-title:hover {
  background: var(--border);
}
.subtask-inline-title:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.subtask-inline-title.done {
  text-decoration: line-through;
  color: var(--text-sub);
}

/* インライン編集／追加 input */
.subtask-inline-edit {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  line-height: 1.3;
  padding: 3px 6px;
  border: 1px solid var(--primary);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  font-family: inherit;
}
.subtask-inline-add-input { margin-left: 26px; } /* チェックボックス分のインデント */

/* "+ サブタスク追加" ボタン */
.subtask-inline-add {
  align-self: flex-start;
  margin-top: 2px;
  margin-left: 26px;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-sub);
  font-size: 12px;
  font-family: inherit;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.subtask-inline-add:hover,
.subtask-inline-add:focus-visible {
  border-color: var(--primary);
  color: var(--primary-text);
  background: var(--border);
  outline: none;
}

/* Kanban カード内では幅が狭いのでインデントとフォントを少し詰める */
.kanban-subtasks-inline {
  margin-top: 6px;
  padding: 6px 2px 2px;
}
.kanban-subtasks-inline .subtask-inline-row { min-height: 28px; padding: 2px; }
.kanban-subtasks-inline .subtask-inline-title { font-size: 12px; }
.kanban-subtasks-inline .subtask-inline-edit { font-size: 12px; padding: 2px 5px; }
.kanban-subtasks-inline .subtask-inline-add,
.kanban-subtasks-inline .subtask-inline-add-input { margin-left: 22px; }
.kanban-subtasks-inline .subtask-inline-add { font-size: 11px; padding: 3px 8px; }

/* ===== Recurrence badge ===== */
.badge-recurrence {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--status-inprogress-bg);
  color: var(--status-inprogress-text);
  font-weight: 500;
}

/* ===== Drag & Drop ===== */
.task-card.dragging,
.kanban-card.dragging {
  opacity: 0.4;
}
#taskList.drop-target,
.kanban-cards.drop-target {
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
  background: var(--primary-bg);
}
@media (hover: hover) {
  .task-card[draggable="true"],
  .kanban-card[draggable="true"] {
    cursor: grab;
  }
  .task-card.dragging,
  .kanban-card.dragging {
    cursor: grabbing;
  }
}

/* ===== Toast (Undo) ===== */
.toast-container {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
  width: min(92vw, 480px);
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #2D3142;
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  font-size: 14px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast.toast-in  { opacity: 1; transform: translateY(0); }
.toast.toast-out { opacity: 0; transform: translateY(20px); }
.toast-message { flex: 1; }
.toast-undo {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 6px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.12s;
}
.toast-undo:hover  { background: rgba(255,255,255,0.22); }
.toast-undo:active { background: rgba(255,255,255,0.32); }
.toast-undo:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* スマホでは画面いっぱい近くまで広げる */
@media (max-width: 767px) {
  .toast-container {
    bottom: calc(96px + env(safe-area-inset-bottom, 0px)); /* FABと被らないように */
    width: calc(100vw - 24px);
  }
}

/* ===== Shortcuts Help ===== */
.shortcuts-help-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.4);
  background: transparent;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.12s;
}
.shortcuts-help-btn:hover {
  background: rgba(255,255,255,0.18);
  transform: scale(1.05);
}
.shortcuts-help-btn:active { transform: scale(0.95); }
.shortcuts-help-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.shortcuts-table {
  width: 100%;
  border-collapse: collapse;
}
.shortcuts-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.shortcuts-table tr:last-child td { border-bottom: none; }
.shortcuts-table td:first-child {
  width: 80px;
  text-align: center;
}
.shortcuts-table kbd,
.shortcuts-note kbd {
  display: inline-block;
  min-width: 28px;
  padding: 3px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  line-height: 1.2;
  text-align: center;
}
.shortcuts-note {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.5;
}

/* ===== Current project badge (header) ===== */
.current-project-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.current-project-badge:hover { background: rgba(255,255,255,0.28); }
.current-project-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.current-project-close {
  font-size: 11px; /* opacity で薄くしない（赤地で 3.0:1 だった #354） */
  flex-shrink: 0;
}
