:root {
  --bg: #f0f9ff;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --line: #cbd5e1;
  --accent: #f59e0b; /* ビタミン系オレンジでやる気UP */
  --ok: #16a34a;
  --danger: #dc2626;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.12), 0 12px 24px rgba(0, 0, 0, 0.08);
  --radius: 14px;
}

html,
body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden; /* 横スクロール抑止 */
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans JP",
    sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #fff7ed 0%, #f0f9ff 100%);
}

/* すべての幅計算をborder込みにして“はみ出し”を起こしにくく */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* 中央カラム */
.container {
  max-width: 920px;
  margin: 24px auto;
  padding: 0 16px;
}

/* ヘッダー */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ボタン */
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}
.btn.primary {
  color: #fff;
  background: linear-gradient(180deg, #fdba74, var(--accent));
  border-color: #fdba74;
  box-shadow: 0 10px 22px rgba(245, 158, 11, 0.25);
}
.btn.danger {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

/* 追加ボタン（少し控えめ） */
.btn.cta-add {
  font-weight: 800;
  font-size: 15px;
  padding: 10px 14px;
  min-width: 76px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.28);
}
.btn.cta-add:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(245, 158, 11, 0.36);
}
@media (min-width: 760px) {
  .btn.cta-add {
    font-size: 16px;
    padding: 11px 16px;
  }
}

/* リスト/行 */
.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: grab;
  max-width: 100%;
  overflow-x: hidden;
}
.row:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}
.row.row-overdue {
  border-left: 4px solid #dc2626;
}
.row.row-due-today {
  border-left: 4px solid var(--accent);
}
.delete-row-btn {
  font-size: 12px;
  padding: 2px 8px;
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.row:hover .delete-row-btn {
  opacity: 1;
}
.row.drag-over {
  outline: 2px dashed #7fb4ff;
  outline-offset: 0;
} /* はみ出し防止 */

/* 完了ボタン（円形） */
.done-cb {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 50%;
  border: 2px solid #94a3b8;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}
.done-cb:hover {
  border-color: var(--ok);
  background: rgba(22, 163, 74, 0.1);
}
.done-cb:checked {
  background: var(--ok);
  border-color: var(--ok);
}
.done-cb:checked::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 8px;
  width: 5px;
  height: 9px;
  border: 2.5px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(42deg);
}
.done-cb:focus-visible {
  outline: 2px solid rgba(22, 163, 74, 0.5);
  outline-offset: 2px;
}

/* 選択チェックボックス（ホバー時のみ表示） */
.select-cb {
  width: 16px;
  height: 16px;
  min-width: 16px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.row:hover .select-cb,
.select-cb:checked {
  opacity: 1;
}

.titleText {
  flex: 1;
  min-width: 0;
  font: 600 18px/1.5 inherit;
  color: var(--text);
  padding: 6px 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.muted {
  color: var(--muted);
  font-size: 12px;
}

/* 状態バッジ */
.pill {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
}
.pill.done {
  color: var(--ok);
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.pill.overdue {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
}

/* 詳細 */
details > summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  padding: 5px 12px;
  border-radius: 8px;
  background: #f1f5f9;
  border: 1px solid var(--line);
  list-style: none;
  transition: background 0.12s, color 0.12s;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; font-size: 10px; }
details[open] > summary::before { content: "▾"; }
details > summary:hover {
  background: #e2e8f0;
  color: var(--text);
}
details[open] > summary {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
}

/* 詳細パネル */
.panel {
  margin-top: 10px;
  padding: 22px 24px;
  border: 1px solid rgba(203, 213, 225, 0.7);
  border-radius: var(--radius);
  background: #f8fafc;
  display: grid;
  gap: 20px;
  max-width: 100%;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
.panel .grid {
  gap: 12px;
}
.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-panel {
  gap: 16px;
}

.detail-work-header,
.detail-footer-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.detail-title-block {
  display: grid;
  gap: 6px;
  flex: 1;
}

.detail-title-input {
  font-size: 18px;
  font-weight: 700;
}

.detail-header-side {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.save-state {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.save-state.saving,
.save-state.editing {
  color: #92400e;
  background: #fffbeb;
  border-color: #fcd34d;
}

.save-state.saved {
  color: #166534;
  background: #f0fdf4;
  border-color: #86efac;
}

.save-state.error {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fca5a5;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.detail-meta-item {
  border: none;
  background: #eef2f7;
  border-radius: 10px;
  padding: 10px 14px;
  display: grid;
  gap: 3px;
}

.detail-meta-item.done {
  background: #dcfce7;
}

.detail-meta-item.overdue {
  background: #fee2e2;
}

.detail-meta-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.detail-meta-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.detail-quick-row,
.detail-danger-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 2px;
}

.autosave-status {
  font-size: 12px;
  color: var(--muted);
  margin-right: auto;
  min-width: 60px;
}
.autosave-status--pending { color: #92400e; }
.autosave-status--saving  { color: var(--muted); }
.autosave-status--saved   { color: #15803d; }
.autosave-status--error   { color: #b91c1c; }

.detail-content-grid,
.detail-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.detail-work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr);
  gap: 14px;
}

.detail-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #fff;
}

.detail-card h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.detail-note {
  min-height: 84px;
  line-height: 1.75;
  white-space: normal;
  overflow-wrap: anywhere;
}

.detail-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
}

.detail-field {
  display: grid;
  gap: 6px;
}

.detail-field > span {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.detail-field-wide {
  grid-column: span 2;
}

.detail-memo-edit {
  min-height: 180px;
}

.detail-memo-main {
  min-height: 280px;
  font-size: 16px;
  line-height: 1.8;
}

.detail-card-side {
  display: grid;
  gap: 14px;
  align-content: start;
}

.detail-side-block {
  display: grid;
  gap: 8px;
}

.detail-section-label {
  font-size: 12px;
  color: var(--muted);
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.choice-chip.active {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.2);
}

.detail-mini-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-mini-meta .detail-meta-item {
  min-width: 140px;
}

/* 操作チップ */
.chip {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.chip:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}
.danger {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}

/* ドラッグ用ハンドル */
.dragHandle {
  border: none;
  background: transparent;
  color: #2563eb;
  cursor: grab;
  font-size: 18px;
  padding: 6px 8px;
  border-radius: 8px;
}
.dragHandle:active {
  cursor: grabbing;
}

/* 入力系 */
textarea.input {
  padding: 12px 14px !important;
  line-height: 1.8;
  font-size: 15px !important;
  letter-spacing: 0.2px;
  min-height: 160px;
  resize: vertical;
}
.search-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 0 12px;
  flex: 1;
  min-width: 0;
}
#search {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  outline: none;
  min-width: 0;
}
#search:focus {
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
}
.search-hint {
  font-size: 12px;
  color: var(--muted);
}
mark {
  background: #fde68a;
  padding: 0 2px;
  border-radius: 2px;
}

/* タグ */
.tag {
  display: inline-block;
  padding: 2px 8px;
  margin: 2px;
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--line);
}
.tag.active {
  outline: 2px solid var(--accent);
}

/* 優先度バッジ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  flex-shrink: 0;
}
.badge.high {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}
.badge.medium {
  background: #eef2ff;
  color: #3730a3;
  border-color: #c7d2fe;
}
.badge.low {
  background: #ecfeff;
  color: #155e75;
  border-color: #a5f3fc;
}

/* 期限チップ */
.due-chip {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  white-space: nowrap;
  flex-shrink: 0;
}
.due-chip.due-none {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  font-size: 11px;
}
.due-chip.due-normal {
  color: var(--muted);
  background: #f8fafc;
}
.due-chip.due-overdue {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
  font-weight: 700;
}
.due-chip.due-today {
  color: #92400e;
  background: #fefce8;
  border-color: #fde68a;
  font-weight: 700;
}
.due-chip.due-tomorrow {
  color: #78350f;
  background: #fff7ed;
  border-color: #fed7aa;
}

/* ===================== モーダル（1系統に統一） ===================== */
.modal.hidden {
  display: none;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
}
.modal-panel {
  position: relative;
  width: min(560px, 100%);
  max-width: 100vw;
  max-height: 100dvh; /* iPhoneの実表示高にフィット */
  overflow: auto; /* 中だけスクロール */
  margin: 0 auto;
  background: var(--card);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 16px 12px;
  -webkit-overflow-scrolling: touch;
}
/* iOSの自動ズーム抑止（16px以上） */
.modal-panel input,
.modal-panel select,
.modal-panel textarea,
.modal-panel button,
.modal-panel label,
.modal-panel small {
  font-size: 16px;
  line-height: 1.4;
  max-width: 100%;
  min-width: 0;
}
/* 長文折返し */
.modal-panel .title,
.modal-panel .field {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* モーダル中は背景を固定 */
body.modal-open {
  overflow: hidden;
  touch-action: none;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.icon-btn {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
}
.modal-body .field {
  display: block;
  margin: 12px 0;
}
.modal-body .field > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
}
.modal-body input[type="text"],
.modal-body input[type="datetime-local"],
.modal-body textarea,
.modal-body select {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

/* 入力系（共通スタイル） */
textarea.input,
input.input,
select.input {
  background: #eef2f7 !important;
  color: var(--text) !important;
  border: 1.5px solid transparent !important;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  width: 100%;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
textarea.input:focus,
input.input:focus,
select.input:focus {
  background: #fff !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
  outline: none;
}

/* ===== Dashboard ===== */
.dashboard {
  margin: 0 0 20px;
  display: grid;
  gap: 14px;
  color: var(--text);
  background: linear-gradient(135deg, #fffbeb 0%, #fff8f0 100%);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px 16px;
  box-shadow: 0 2px 12px rgba(245, 158, 11, 0.1);
}
.dash-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
@media (max-width: 860px) {
  .dash-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

.dash-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}
.dash-card h3 {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 6px;
}
.dash-card .num {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}
.chart {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.chart h4 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--text);
}
.chart svg {
  width: 100%;
  height: 160px;
  display: block;
}

.dash-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
}
.toggle-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
}
.toggle-btn.active {
  outline: 2px solid var(--accent);
}

/* open/close 可視制御 */
#dashboard .dash-body {
  display: none;
}
#dashboard.open .dash-body {
  display: grid;
  gap: 14px;
}
#dashboard .dash-extras {
  display: none;
}
#dashboard.open .dash-extras {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* 日付ピッカー */
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.8;
}
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* --- Login Hero (light) --- */
.hero {
  display: grid;
  place-items: center;
  min-height: min(72vh, 720px);
  margin-top: 10px;
  position: relative;
}
.hero .orb {
  position: absolute;
  inset: -10% -10% auto auto;
  width: 560px;
  height: 560px;
  background: radial-gradient(
      circle at 35% 35%,
      rgba(253, 230, 138, 0.22),
      transparent 60%
    ),
    radial-gradient(
      circle at 70% 55%,
      rgba(147, 197, 253, 0.22),
      transparent 65%
    );
  filter: blur(6px);
  animation: float 14s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes float {
  from {
    transform: translateY(-8px) translateX(6px);
  }
  to {
    transform: translateY(8px) translateX(-6px);
  }
}

.login-card {
  width: min(680px, 92vw);
  border-radius: 22px;
  padding: 28px;
  color: var(--text);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.86),
    rgba(255, 255, 255, 0.78)
  );
  border: 1px solid rgba(148, 163, 184, 0.35);
  backdrop-filter: blur(10px) saturate(1.05);
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.1),
    0 10px 22px rgba(245, 158, 11, 0.12);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.brand .logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: conic-gradient(from 220deg, #60a5fa, #34d399, #60a5fa);
  filter: saturate(1.2);
}
.brand h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.02em;
  color: var(--text);
}
.hero-lead {
  color: var(--muted);
  margin: 6px 0 14px;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 18px;
}
.hero-badge {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.login-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.btn.big {
  font-size: 16px;
  padding: 12px 16px;
  border-radius: 12px;
}
.muted-note {
  font-size: 12px;
  color: var(--muted);
}

/* ログイン状態クラス（保険） */
.hidden {
  display: none !important;
}
body.logged-out #appShell {
  display: none;
}
body.logged-in #hero {
  display: none;
}
html.booting #hero,
html.booting #appShell {
  display: none;
}

/* スマホ最適化：行の折返しと可読性 */
@media (max-width: 480px) {
  .rowHead {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
  }
  .rowHead .select-cb,
  .rowHead .done-cb {
    order: -2;
    flex: 0 0 auto;
  }
  .rowHead .titleText {
    order: -1;
    flex: 1 1 auto;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-break: loose;
    font-size: 14px;
  }
  .rowHead .muted {
    flex: 1 1 100%;
  }
  .rowHead .pill {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    max-width: max-content;
  }
  .rowHead .tagBox {
    flex: 1 1 100%;
    margin-bottom: 4px;
  }
  .rowHead .tagBox:empty {
    display: none;
  }
  .swipe-inner > details,
  .row > details {
    margin-top: 2px;
  }
}

/* PC の背景（任意） */
@media (min-width: 861px) {
  body.desktop-bg {
    background: #e7f5ff no-repeat center/cover fixed;
    position: relative;
    overflow-x: hidden;
  }
  body.desktop-bg::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.55) 0%,
      rgba(255, 255, 255, 0.35) 30%,
      rgba(255, 255, 255, 0.25) 100%
    );
    z-index: -1;
  }
  .container {
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(4px);
  }
}

.auth-box {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

/* ビュー切り替えタブ */
.view-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 0 10px;
}
.view-tab {
  padding: 6px 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.view-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.view-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* モバイル: タブ横スクロール */
@media (max-width: 860px) {
  .view-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  .view-tabs::-webkit-scrollbar {
    display: none;
  }
  .view-tab {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 10px 14px;
  }
  /* タップ領域拡大（Apple HIG 44px 最小） */
  .done-cb {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }
  .done-cb:checked::after {
    top: 10px;
    left: 15px;
    width: 9px;
    height: 16px;
  }
  .select-cb {
    opacity: 1;
    width: 22px;
    height: 22px;
    min-width: 22px;
  }
  .btn.delete-row-btn {
    min-height: 44px;
    padding: 10px 14px;
  }
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}

.filter-result-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-count {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.filters select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
}

.today-board {
  display: grid;
  gap: 12px;
  margin: 8px 0 18px;
}

/* モバイルトグル用ツールバー: PCでは非表示 */
.today-board-toolbar {
  display: none;
}

.today-board-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
}

.today-board-head h2 {
  margin: 0 0 4px;
}

.today-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.today-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.88));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.today-card-head {
  display: grid;
  gap: 8px;
}

.today-card-head h3 {
  margin: 0;
}

.today-card-list {
  display: grid;
  gap: 8px;
}

.today-item {
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  display: grid;
  gap: 4px;
}

.today-item span {
  color: var(--muted);
  font-size: 12px;
}

.bulk-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.bulk-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chart-wide {
  grid-column: span 2;
}


@media (max-width: 860px) {
  .today-grid,
  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filters {
    gap: 6px;
    margin: 8px 0 10px;
  }
  .filters select {
    padding: 6px 8px;
    font-size: 13px;
    border-radius: 8px;
  }
  .detail-work-grid {
    grid-template-columns: 1fr;
  }
  .detail-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* タスク行をコンパクトに */
  .list {
    gap: 8px;
  }
  .row {
    padding: 8px 10px;
  }
  .titleText {
    font: 600 15px/1.4 inherit;
    padding: 2px 0;
  }

  /* モバイル: ボタン→フィルタ→タブ→タスクの順 */
  #appBody {
    display: flex;
    flex-direction: column;
  }
  #today-board { order: 1; }
  #dashboard   { order: 2; }
  .filters     { order: 3; }
  #view-tabs   { order: 4; }
  #bulk-bar    { order: 5; }
  #list        { order: 6; }

  /* ダッシュボードの黄色装飾をモバイルでは除去 */
  #dashboard {
    background: none;
    border: none;
    border-left: none;
    box-shadow: none;
    padding: 0;
    margin: 0 0 16px;
  }

  /* トグルボタンをフィルタ・タブと区別して目立たせる */
  .today-board-toolbar .toggle-btn,
  #dashboard .toggle-btn {
    display: block;
    width: 100%;
    text-align: left;
    background: #fff7ed;
    border-color: #fdba74;
    color: #9a3412;
    font-weight: 600;
    padding: 10px 16px;
  }

  /* 設定・ログアウトをスティッキーヘッダーで常時表示 */
  .container > header {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(6px);
    z-index: 50;
    padding: 8px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--line);
  }
  .auth-box {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    gap: 6px;
  }
  .auth-box .btn {
    flex: 1;
    text-align: center;
    padding: 9px 8px;
    font-size: 14px;
  }
  #who {
    font-size: 12px;
    color: var(--muted);
    flex-shrink: 0;
    margin-left: auto;
    white-space: nowrap;
  }

  /* 今日のフォーカス: モバイルではトグルで折りたたむ */
  .today-board-toolbar {
    display: block;
  }
  #today-board .today-board-body {
    display: none;
  }
  #today-board.open .today-board-body {
    display: block;
  }
}

@media (max-width: 480px) {
  .today-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .today-card {
    padding: 8px;
    gap: 6px;
  }
  .today-item {
    padding: 6px 8px;
    border-radius: 8px;
    gap: 2px;
  }
  .today-item strong {
    font-size: 13px;
    line-height: 1.3;
  }
  .today-item span {
    font-size: 11px;
  }
  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-content-grid,
  .detail-work-grid {
    grid-template-columns: 1fr;
  }

  .detail-meta {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .detail-panel {
    padding: 14px 16px;
    gap: 10px;
  }

  .detail-meta-item {
    padding: 7px 10px;
  }

  .detail-meta-value {
    font-size: 12px;
  }

  .detail-form-grid {
    gap: 10px;
  }

  .detail-memo-edit {
    min-height: 100px;
  }

  .detail-actions {
    padding-top: 10px;
  }

  .detail-work-header,
  .detail-footer-bar {
    display: grid;
  }

  .bulk-bar,
  .today-board-head {
    display: grid;
  }

  .auth-box {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ===== スワイプジェスチャー ===== */
.swipe-host {
  position: relative;
  overflow-x: hidden;
}
.swipe-inner {
  position: relative;
  z-index: 1;
  background: var(--card);
}
.swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  opacity: 0;
  z-index: 0;
  pointer-events: none;
}
.swipe-bg-complete {
  background: #22c55e;
  padding-left: 20px;
  justify-content: flex-start;
}
.swipe-bg-delete {
  background: #ef4444;
  padding-right: 20px;
  justify-content: flex-end;
}
.swipe-bg-label {
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* ===== 設定ページ ===== */
.settings-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.settings-header h2 {
  margin: 0;
}
.settings-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}
.settings-section h3 {
  margin: 0;
  font-size: 16px;
}
.settings-toggle-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
