:root {
  --primary: #E8662A;
  --navy: #1E3A5F;
  --navy-light: #2a4f7a;
  --navy-dark: #152d4a;
  --gold: #D4AF37;
  --gold-pale: rgba(212,175,55,0.12);
  --bg: #f8fafc;
  --bg-card: #fff;
  --text: #0f172a;
  --text-sub: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.04);
  --radius: 8px;
  --radius-lg: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Noto Sans JP', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ─── Header ─────────────────────────────────────────── */
.header {
  background: #fff;
  color: var(--text);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 8px rgba(0,0,0,.04);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-logo { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.header-logo img { height: 32px; width: auto; display: block; }
.header-divider { width: 1px; height: 20px; background: var(--border); }
.header-title { font-size: 14px; font-weight: 600; color: var(--text-sub); }
.header-right { display: flex; align-items: center; gap: 10px; }
.header-datetime {
  display: flex; flex-direction: column; align-items: flex-end;
  line-height: 1.2; margin-right: 4px;
}
.header-datetime-date {
  font-size: 11px; font-weight: 500; color: var(--text-muted); letter-spacing: .3px;
}
.header-datetime-time {
  font-size: 14px; font-weight: 700; color: var(--primary); letter-spacing: .5px; font-variant-numeric: tabular-nums;
}
.user-badge {
  display: flex; align-items: center; gap: 8px;
  background: var(--border-light); border-radius: 20px;
  padding: 4px 12px 4px 6px; cursor: pointer; transition: background .15s;
  border: 1px solid var(--border);
}
.user-badge:hover { background: var(--border); }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }

/* ─── Nav tabs ──────────────────────────────────────── */
.nav-tabs {
  display: flex;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 56px;
  z-index: 90;
}
.nav-tab {
  padding: 10px 20px;
  border: none; background: none;
  font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-sub); cursor: pointer;
  border-bottom: 2px solid transparent;
  text-decoration: none;
  transition: all .15s;
}
.nav-tab:hover { color: var(--navy); }
.nav-tab.active { color: var(--navy); border-bottom-color: var(--gold); }

/* Nav tabs inside header */
.header-left .nav-tabs {
  position: static;
  background: transparent;
  border-bottom: none;
  padding: 0;
  align-self: stretch;
  margin-left: 8px;
}
.header-left .nav-tab {
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ─── Toolbar ──────────────────────────────────────── */
.toolbar {
  padding: 12px 24px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.toolbar-spacer { flex: 1; }

/* ─── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border: none; border-radius: var(--radius);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s; text-decoration: none;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-light); }
.btn-outline { background: transparent; color: var(--text-sub); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--border-light); border-color: var(--text-muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }

/* ─── Filter chips ─────────────────────────────────── */
.filter-group {
  display: flex; align-items: center; gap: 4px;
  background: var(--border-light); border-radius: var(--radius); padding: 2px;
}
.filter-btn {
  padding: 5px 12px; border: none; background: transparent;
  border-radius: 6px; font-family: inherit; font-size: 12px; font-weight: 500;
  color: var(--text-sub); cursor: pointer; transition: all .15s;
}
.filter-btn.active { background: var(--bg-card); color: var(--navy); box-shadow: var(--shadow-sm); font-weight: 600; }
.filter-btn:hover:not(.active) { color: var(--text); }

/* ─── Alert banner ─────────────────────────────────── */
.alert-banner {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 24px 0;
  padding: 10px 16px;
  background: var(--warning-bg); border: 1px solid #fcd34d;
  border-radius: var(--radius); font-size: 13px; color: #92400e;
  font-weight: 500;
}
.alert-banner .badge {
  background: var(--warning); color: #fff;
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px;
}

/* ─── Main layout ──────────────────────────────────── */
.main { padding: 20px 24px; max-width: 1200px; margin: 0 auto; }

/* ─── Project group ────────────────────────────────── */
.project-group { margin-bottom: 20px; }
.project-group-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; cursor: pointer; user-select: none;
}
.project-group-header:hover .group-label { color: var(--navy); }
.group-chevron { font-size: 11px; color: var(--text-muted); transition: transform .2s; }
.group-chevron.collapsed { transform: rotate(-90deg); }
.group-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.group-label { font-size: 13px; font-weight: 700; color: var(--text); transition: color .15s; }
.group-meta { font-size: 11px; color: var(--text-muted); }
.group-count {
  font-size: 11px; color: var(--text-muted);
  background: var(--border-light); padding: 1px 8px; border-radius: 10px; font-weight: 500;
}
.group-edit-btn {
  font-size: 11px; color: var(--text-muted); margin-left: 6px;
  padding: 2px 8px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: transparent;
  transition: background .15s, color .15s;
}
.group-edit-btn:hover { background: var(--border-light); color: var(--navy); }
.task-list-wrap { padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }

/* ─── Task row ─────────────────────────────────────── */
.task-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  transition: all .15s; position: relative;
}
.task-row:hover { border-color: var(--navy); box-shadow: var(--shadow); }
.task-row.done { opacity: .5; }
.task-row.overdue { border-left: 3px solid var(--danger); background: var(--danger-bg); }
.task-row.stuck { border-left: 3px solid var(--warning); background: var(--warning-bg); }

.task-check {
  width: 18px; height: 18px; flex-shrink: 0;
  border: 2px solid var(--border); border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .15s; background: var(--bg-card); font-size: 10px;
}
.task-check:hover { border-color: var(--navy); }
.task-check.checked { background: var(--navy); border-color: var(--navy); color: #fff; }

.task-expand {
  width: 16px; height: 16px; flex-shrink: 0;
  border: none; background: transparent; cursor: pointer;
  font-size: 9px; color: var(--text-muted); padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s;
}
.task-expand.open { transform: rotate(90deg); }
.task-expand-placeholder { width: 16px; flex-shrink: 0; }

.task-title-text {
  font-size: 13px; font-weight: 500; color: var(--text);
  cursor: pointer; min-width: 0; flex-shrink: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 260px;
}
.task-title-text:hover { color: var(--navy); }
.task-row.done .task-title-text { text-decoration: line-through; color: var(--text-muted); }

.task-status-badge {
  font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 10px;
  white-space: nowrap; flex-shrink: 0; cursor: pointer; transition: opacity .15s;
}
.task-status-badge:hover { opacity: .8; }

.task-due-badge {
  font-size: 11px; color: var(--text-sub); white-space: nowrap; flex-shrink: 0;
}
.task-due-badge.overdue { color: var(--danger); font-weight: 600; }
.task-due-badge.today { color: var(--warning); font-weight: 600; }

.task-assignee {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--navy); color: #fff;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

.task-memo-icon {
  font-size: 13px; color: var(--text-muted); cursor: pointer; flex-shrink: 0;
  opacity: 0; transition: opacity .15s;
}
.task-row:hover .task-memo-icon { opacity: 1; }
.task-memo-icon.has-memo { opacity: 1; color: var(--navy); }

.task-actions {
  display: flex; gap: 2px; opacity: 0; transition: opacity .15s; flex-shrink: 0;
}
.task-row:hover .task-actions { opacity: 1; }
.task-action-btn {
  width: 24px; height: 24px; border: none; background: transparent;
  border-radius: 4px; cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all .1s;
}
.task-action-btn:hover { background: var(--border-light); color: var(--navy); }
.task-action-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }

/* サブタスク */
.subtask-group { padding-left: 26px; margin-top: 3px; display: flex; flex-direction: column; gap: 3px; }
.task-row.subtask { background: var(--border-light); border-color: transparent; }
.task-row.subtask:hover { border-color: var(--navy); background: var(--bg-card); }

/* ─── Modal ────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.4); backdrop-filter: blur(4px);
  z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; visibility: hidden; transition: all .2s;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 85vh; overflow-y: auto;
  transform: translateY(8px); transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }

/* タスクモーダルはノンブロッキングなサイドパネルに */
#taskModal {
  background: transparent;
  backdrop-filter: none;
  pointer-events: none;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 130px 20px 0 0;
}
#taskModal.open { opacity: 1; visibility: visible; }
#taskModal .modal {
  pointer-events: auto;
  max-width: 360px;
  max-height: calc(100vh - 90px);
  box-shadow: 0 8px 40px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.06);
}

/* ガントタスクモーダルもノンブロッキングなサイドパネルに */
#ganttTaskModal {
  background: transparent;
  backdrop-filter: none;
  pointer-events: none;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 130px 20px 0 0;
}
#ganttTaskModal.open { opacity: 1; visibility: visible; }
#ganttTaskModal .modal {
  pointer-events: auto;
  max-width: 380px;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.06);
}

/* 担当者ピッカー */
.assignee-picker-popup {
  position: fixed; z-index: 9000;
  background: var(--bg-card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  min-width: 180px; overflow: hidden;
  display: none;
}
.assignee-picker-popup.open { display: block; }
.assignee-picker-list { padding: 6px; }
.assignee-picker-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 6px; cursor: pointer;
  font-size: 13px; transition: background 0.12s;
}
.assignee-picker-item:hover { background: var(--border-light); }
.assignee-picker-item.selected { background: var(--gold-pale); font-weight: 600; }
.assignee-picker-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}
.modal-header {
  padding: 20px 24px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--navy); }
.modal-close {
  width: 32px; height: 32px; border: none; background: transparent;
  border-radius: 6px; cursor: pointer; font-size: 18px; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--border-light); color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 0 24px 20px; display: flex; gap: 8px; justify-content: flex-end; }

.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-sub); margin-bottom: 5px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--bg); transition: border-color .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(30,58,95,.08);
}
.form-textarea { resize: vertical; min-height: 72px; }

/* ─── Status popup ─────────────────────────────────── */
.status-popup {
  position: fixed; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 4px; z-index: 300; display: none; min-width: 140px;
}
.status-popup.open { display: block; }
.status-option {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border: none; background: none;
  width: 100%; border-radius: 4px; font-family: inherit; font-size: 13px;
  color: var(--text); cursor: pointer; text-align: left;
}
.status-option:hover { background: var(--border-light); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ─── Memo popup ───────────────────────────────────── */
.memo-popup {
  position: fixed; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 10px; z-index: 300;
  min-width: 320px; width: auto; display: none;
}
.memo-popup.open { display: block; }
.memo-popup textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 9px; font-family: inherit; font-size: 12px; color: var(--text);
  resize: both; min-height: 160px; min-width: 280px; outline: none; background: var(--bg);
}
.memo-popup textarea:focus { border-color: var(--navy); }
.memo-popup-footer { display: flex; justify-content: flex-end; gap: 6px; margin-top: 7px; }

/* ─── Project sidebar ──────────────────────────────── */
.page-layout { display: flex; height: calc(100vh - 56px); overflow: hidden; position: relative; }
.sidebar {
  width: 220px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-card); overflow-y: auto;
  padding: 16px 0;
  transition: width .2s ease, padding .2s ease;
}
.sidebar.collapsed {
  width: 0; padding: 0; overflow: hidden;
}
.sidebar-toggle-btn {
  position: absolute; left: 220px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 48px; z-index: 10;
  border: 1px solid var(--border); border-left: none;
  background: var(--bg-card); color: var(--text-muted);
  cursor: pointer; border-radius: 0 6px 6px 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; transition: left .2s ease, background .15s;
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { background: var(--border-light); color: var(--navy); }
.sidebar.collapsed + .sidebar-toggle-btn { left: 0; }
.sidebar-title {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  padding: 0 16px 8px; text-transform: uppercase; letter-spacing: .5px;
  white-space: nowrap;
}
.sidebar-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; cursor: pointer; transition: background .15s;
  font-size: 13px; font-weight: 500; color: var(--text-sub);
  border: none; background: none; width: 100%; text-align: left;
  white-space: nowrap;
}
.sidebar-item:hover { background: var(--border-light); color: var(--text); }
.sidebar-item.active { background: var(--gold-pale); color: var(--navy); font-weight: 600; }
.sidebar-item-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sidebar-add {
  padding: 8px 16px; margin-top: 4px;
}

.project-content { flex: 1; overflow-y: auto; padding: 20px 24px; }

/* ─── Empty ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-sub); margin-bottom: 4px; }
.empty-desc { font-size: 13px; }

/* ─── Pencil button & inline title edit ─────────────── */
.task-pencil-btn {
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; font-size: 11px; padding: 1px 4px; border-radius: 3px;
  opacity: 0; transition: opacity .15s; flex-shrink: 0; line-height: 1;
}
.task-row:hover .task-pencil-btn, .task-pencil-btn:focus { opacity: 1; }
.task-pencil-btn:hover { color: var(--navy); background: var(--border-light); }
.task-title-input {
  border: none; background: transparent; font-family: inherit;
  font-size: 13px; font-weight: 500; color: var(--text);
  outline: none; border-bottom: 2px solid var(--navy);
  min-width: 60px; max-width: 260px; padding: 0 2px; flex-shrink: 1;
}

/* ─── Link popup ─────────────────────────────────────── */
.link-popup {
  position: fixed; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 10px; z-index: 400;
  width: 300px; display: none;
}
.link-popup.open { display: block; }
.link-popup-label { font-size: 11px; font-weight: 700; color: var(--text-sub); margin-bottom: 6px; }
.link-popup-footer { display: flex; justify-content: flex-end; gap: 6px; margin-top: 7px; }

/* ─── Subtask inline add ─────────────────────────────── */
.subtask-add-row {
  display: flex; gap: 6px; align-items: center;
  padding: 4px 0 2px; flex-shrink: 0;
}
.subtask-add-input {
  flex: 1; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; font-family: inherit; font-size: 12px;
  background: var(--bg-card); outline: none;
}
.subtask-add-input:focus { border-color: var(--navy); }

/* ─── Attach chips (task row) ───────────────────────── */
.task-attach-chips {
  flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px;
  padding: 2px 0 4px 26px;
}
.attach-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; background: var(--border-light);
  border-radius: 12px; font-size: 11px; color: var(--navy);
  text-decoration: none; transition: all .1s; white-space: nowrap;
}
.attach-chip:hover { background: var(--gold-pale); color: var(--navy-dark); }

/* ─── Link popup (redesign) ─────────────────────────── */
.link-chip-row {
  display: flex; align-items: center; gap: 4px; margin-bottom: 4px;
}
.link-chip-del {
  width: 18px; height: 18px; border: none; background: transparent;
  border-radius: 3px; cursor: pointer; color: var(--text-muted);
  font-size: 11px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.link-chip-del:hover { background: var(--danger-bg); color: var(--danger); }
.link-add-form { border-top: 1px solid var(--border-light); padding-top: 8px; margin-top: 4px; }

/* ─── Search box ────────────────────────────────────── */
.search-box {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0 10px; height: 34px;
  transition: border-color .15s; min-width: 200px;
}
.search-box:focus-within { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(30,58,95,.08); }
.search-box input {
  border: none; background: transparent;
  font-family: inherit; font-size: 13px; color: var(--text);
  outline: none; flex: 1; min-width: 0;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-clear {
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; font-size: 14px; padding: 0; line-height: 1; display: none;
}
.search-clear.show { display: block; }
.search-clear:hover { color: var(--text); }
.search-toggle {
  display: none; width: 34px; height: 34px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); font-size: 16px; cursor: pointer;
  align-items: center; justify-content: center;
}

/* ─── Stats bar ─────────────────────────────────────── */
.stats-bar {
  padding: 8px 24px; display: flex; gap: 16px;
  font-size: 12px; color: var(--text-sub);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg); flex-wrap: wrap; align-items: center;
}
.stat-item { display: flex; align-items: center; gap: 5px; }
.stat-dot { width: 8px; height: 8px; border-radius: 50%; }
.stat-count { font-weight: 700; color: var(--text); }

/* ─── Filter bar ────────────────────────────────────── */
.filter-bar {
  padding: 8px 24px; display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap; border-bottom: 1px solid var(--border-light);
  background: var(--bg); font-size: 12px; color: var(--text-muted);
}
.filter-bar.hidden { display: none; }
.filter-chip {
  padding: 3px 10px; border: 1.5px solid; border-radius: 12px;
  background: transparent; font-family: inherit; font-size: 11px;
  font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.filter-chip:hover { opacity: .75; }
.filter-chip.active-chip { color: #fff !important; border-color: transparent !important; }
.filter-bar-sep { width: 1px; height: 16px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
.assignee-select {
  border: 1.5px solid var(--border); border-radius: 12px;
  background: transparent; font-family: inherit; font-size: 11px;
  font-weight: 600; color: var(--text-sub); padding: 3px 8px;
  cursor: pointer; outline: none;
}
.assignee-select:focus { border-color: var(--navy); }

/* ─── Task title area & icons ───────────────────────── */
.task-title-area {
  display: flex; align-items: center; gap: 4px;
  flex: 0 1 auto; min-width: 0;
}
.task-icons {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0;
}
.task-icon-btn {
  height: 20px; padding: 0 7px;
  border: none; background: transparent; border-radius: 4px;
  cursor: pointer; font-size: 11px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 3px;
  color: var(--text-muted); transition: all .1s;
  text-decoration: none; white-space: nowrap; flex-shrink: 0;
}
.task-icon-btn:hover { background: var(--border-light); color: var(--navy); }
.task-icon-btn.has-memo { color: var(--navy); }
.task-icon-btn.has-link { color: var(--navy); }
.task-icon-btn.has-subtasks { color: var(--gold); }
.task-icon-btn.has-knowledge { color: #7C3AED; }
.task-icon-btn.has-priority-high { color: var(--danger); }
.task-icon-btn.has-priority-medium { color: var(--gold); }
.task-icon-btn.has-priority-low { color: #64748b; }
.task-icon-btn.has-priority-unset { color: var(--text-muted); }
.kn-related-chip-active { background: #dbeafe !important; font-weight: 700; }
.kn-panel-back-btn {
  background: none; border: none; color: rgba(255,255,255,0.85); cursor: pointer;
  font-size: 12px; padding: 0 8px 0 0; flex-shrink: 0; white-space: nowrap;
}
.kn-panel-back-btn:hover { color: #fff; text-decoration: underline; }
.kn-panel-list-item {
  padding: 10px 20px; cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.kn-panel-list-item:hover { background: var(--hover-bg, #f5f7fa); }
.kn-panel-list-title { font-size: 14px; font-weight: 600; color: var(--navy); }
.kn-panel-list-excerpt { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.5; }
.task-icon-empty { opacity: .35; }
.task-icon-empty:hover { opacity: 1; }
.task-hover-actions {
  display: flex; align-items: center; gap: 2px;
  opacity: 0; transition: opacity .15s; flex-shrink: 0;
}
.task-row:hover .task-hover-actions { opacity: 1; }

/* ─── Task tag ──────────────────────────────────────── */
.task-tag {
  font-size: 10px; font-weight: 600; padding: 1px 7px;
  border-radius: 10px; white-space: nowrap; flex-shrink: 0; cursor: pointer;
}

/* ─── Responsive ────────────────────────────────────── */
@media (max-width: 768px) {
  html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
  .header {
    height: 64px;
    padding: 0 8px;
    gap: 6px;
    overflow: hidden;
  }
  .header-left {
    flex: 1 1 auto;
    min-width: 0;
    align-self: stretch;
    gap: 6px;
    overflow: hidden;
  }
  .header-logo { flex: 0 0 34px; }
  .header-logo img { height: 30px; }
  .header-left .nav-tabs {
    flex: 1 1 auto;
    min-width: 0;
    align-self: stretch;
    margin-left: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .header-left .nav-tabs::-webkit-scrollbar { display: none; }
  .header-left .nav-tab {
    flex: 0 0 auto;
    min-width: 60px;
    height: 64px;
    padding: 0 8px;
    justify-content: center;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
    line-height: 1.1;
    white-space: nowrap;
    word-break: keep-all;
    writing-mode: horizontal-tb;
  }
  .header-left .nav-tab svg { width: 16px; height: 16px; }
  .header-right { flex: 0 0 auto; gap: 4px; }
  .header-datetime { display: none; }
  .backup-btn { width: 30px; height: 30px; }
  .user-badge { padding: 2px; gap: 0; }
  .user-avatar { width: 28px; height: 28px; }
  .user-name { display: none; }
  .toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 8px 10px;
    gap: 8px;
    align-items: center;
  }
  .toolbar .filter-group {
    grid-column: 1 / -1;
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .toolbar .filter-group::-webkit-scrollbar { display: none; }
  .filter-btn { flex: 0 0 auto; min-width: 64px; }
  .toolbar .form-select {
    grid-column: 1 / 2;
    width: 100% !important;
    min-width: 0;
    height: 36px;
    font-size: 13px !important;
  }
  .toolbar-spacer { display: none; }
  .search-toggle { grid-column: 2 / 3; width: 40px; height: 36px; }
  .search-box.mobile-open { grid-column: 1 / -1; display: flex; width: 100%; }
  .toolbar > .btn-primary {
    grid-column: 1 / -1;
    width: 100%;
    height: 38px;
    justify-content: center;
  }
  .main { padding: 10px; max-width: 100%; overflow-x: hidden; }
  .task-list-wrap { padding-left: 0; }

  /* タスク行：2行レイアウト（タスク名1行目、アイコン2行目） */
  .task-row { flex-wrap: wrap; align-items: flex-start; padding: 8px 8px 6px; gap: 6px; }
  .task-title-area {
    flex: 1 1 calc(100% - 52px);
    flex-wrap: wrap;
    align-items: flex-start;
    overflow: visible;
    min-width: 0;
  }
  .task-title-text {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: unset !important;
    max-width: 100% !important;
    word-break: break-word;
    flex: 1 1 100%;
    line-height: 1.4;
  }
  .task-pencil-btn { display: none; }
  .task-icons {
    flex-basis: 100% !important;
    flex-wrap: wrap;
    margin-top: 2px;
    row-gap: 2px;
  }
  .task-icon-btn { font-size: 10px; padding: 0 5px; height: 20px; }
  /* spacer非表示、ステータス/期限/担当者も2行目へ */
  .task-row > span[style*="flex:1"] { display: none; }
  .task-status-badge {
    display: inline-flex !important;
    font-size: 10px; padding: 1px 6px;
  }
  .task-due-badge { display: inline !important; font-size: 10px; }
  .task-assignee { width: 20px; height: 20px; font-size: 9px; }
  .task-hover-actions { display: none !important; }

  .task-row.subtask { padding-left: 4px; }
  .subtask-group { padding-left: 12px; }

  .task-status-badge, .task-due-badge { }  /* 上書きリセット */
  .task-row.overdue .task-due-badge, .task-row.stuck .task-due-badge { }

  .sidebar { width: 160px; }
  .sidebar-toggle-btn { left: 160px; }
  .sidebar.collapsed + .sidebar-toggle-btn { left: 0; }
  .project-content { padding: 12px; }

  .search-box { display: none; min-width: 0; flex: 1; }
  .search-box.mobile-open { display: flex; }
  .search-toggle { display: flex; }
  .stats-bar { padding: 6px 12px; }
  .filter-bar { padding: 6px 12px; }

  /* 顧客サイドバー */
  .customer-list-col { width: 220px; }
  .customer-layout { height: calc(100vh - 140px); }

  /* ノートパネル：横スクロールやツールバー幅に引きずられないよう全画面固定 */
  .note-panel,
  .task-drawer-panel {
    inset: 0 !important;
    width: 100dvw !important;
    max-width: 100dvw !important;
    height: 100dvh;
    transform: translateX(100%);
  }
  .note-panel.open { transform: translateX(0); }
  .note-panel-header {
    min-height: 48px;
    padding-top: env(safe-area-inset-top);
    height: calc(48px + env(safe-area-inset-top));
  }
  .task-drawer-tabs { padding: 8px 10px; overflow-x: auto; }
  .note-panel-body { padding: 10px; }
}

/* ─── Mobile search overlay ─────────────────────────── */
.mobile-search-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 9000;
  background: var(--bg-card);
  flex-direction: column;
}
.mobile-search-overlay.open { display: flex; }
.mobile-search-overlay-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.mobile-search-overlay-header input {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 12px; font-family: inherit; font-size: 16px; /* 16px prevents iOS zoom */
  color: var(--text); background: var(--bg); outline: none;
}
.mobile-search-overlay-header input:focus { border-color: var(--navy); }
.mobile-search-overlay-body { flex: 1; overflow-y: auto; padding: 12px 16px; }

/* ─── Gantt chart ──────────────────────────────────── */
/* 4分割グリッド（sticky/z-index不使用） */
.gantt-grid {
  display: grid;
  grid-template:
    "hd-left  hd-right"  auto
    "loc-left loc-right" auto
    "bd-left  bd-right"  1fr
    / 200px 1fr;
  overflow: hidden;
}
.gantt-hd-left   { grid-area: hd-left;   overflow: hidden; border-right: 2px solid var(--border); background: var(--bg); }
.gantt-hd-right  { grid-area: hd-right;  overflow: hidden; background: var(--bg); }
.gantt-loc-left  { grid-area: loc-left;  overflow: hidden; border-right: 2px solid var(--border); background: var(--bg-card); }
.gantt-loc-right { grid-area: loc-right; overflow: hidden; background: var(--bg-card); }
.gantt-bd-left   { grid-area: bd-left;   overflow: hidden; border-right: 2px solid var(--border); background: var(--bg-card); }
.gantt-bd-right  { grid-area: bd-right;  overflow: auto; }

.gantt-table { border-collapse: separate; border-spacing: 0; min-width: max-content; table-layout: fixed; }
.gantt-label-col {
  background: var(--bg-card);
  min-width: 200px; max-width: 200px; width: 200px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 12px; vertical-align: middle; box-sizing: border-box;
}
.gantt-project-row .gantt-label-col { background: var(--navy); color: #fff; font-weight: 700; font-size: 12px; }
.gantt-task-row .gantt-label-col { background: var(--bg-card); }
.gantt-task-row:hover .gantt-label-col { background: var(--border-light); }
.gantt-done-lbl .gantt-task-title { text-decoration: line-through; color: var(--text-muted); }
.gantt-task-label-inner { display: flex; align-items: center; gap: 6px; height: 100%; }
.gantt-task-status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.gantt-collapse-btn { font-size: 9px; color: var(--text-muted); cursor: pointer; flex-shrink: 0; width: 12px; text-align: center; user-select: none; }
.gantt-collapse-btn:hover { color: var(--navy); }
.gantt-collapse-btn-placeholder { width: 12px; flex-shrink: 0; }
.gantt-task-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.gantt-task-clickable { cursor: pointer; }
.gantt-task-clickable:hover { color: var(--navy); text-decoration: underline; }
.gantt-asgn {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--navy); color: #fff;
  font-size: 9px; font-weight: 700; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.gantt-note-btn {
  font-size: 10px; color: var(--text-muted); cursor: pointer;
  padding: 1px 3px; border-radius: 3px; flex-shrink: 0;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.gantt-note-btn:hover { background: var(--gold-pale); color: var(--navy); }
.gantt-note-btn.has-notes { color: var(--navy); font-weight: 600; }
.gantt-month-th {
  font-size: 11px; font-weight: 700; color: var(--text-sub);
  text-align: center; padding: 4px 0;
  background: var(--bg);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border-light);
}
.gantt-day-th {
  min-width: 30px; width: 30px;
  font-size: 10px; font-weight: 500; color: var(--text-muted);
  text-align: center; padding: 3px 0;
  border-right: 1px solid var(--border-light);
  border-bottom: 2px solid var(--border);
  background: var(--bg);
}
.gantt-day-th.gantt-weekend { color: #c0c8d4; background: #f1f5f9; }
.gantt-today-th { background: rgba(212,175,55,0.25) !important; color: var(--navy) !important; font-weight: 700 !important; }
.gantt-today-col { background: rgba(212,175,55,0.1) !important; }
.gantt-cell {
  min-width: 30px; width: 30px;
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  text-align: center; vertical-align: middle;
  padding: 2px 0; position: relative;
  overflow: hidden;
  box-sizing: border-box;
}
.gantt-project-row .gantt-cell { background: rgba(30,58,95,0.04); }
.gantt-task-row:hover .gantt-cell { background: rgba(30,58,95,0.02); }
.gantt-milestone {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #fff;
  cursor: grab; transition: transform .1s;
}
.gantt-milestone:hover { transform: scale(1.4); }
.gantt-out-range-l, .gantt-out-range-r { font-size: 9px; color: var(--text-muted); padding: 0 2px; }
/* バー/点の日付クリアボタン（ホバーで表示） */
.gantt-bar-clear-btn {
  display: none;
  position: absolute;
  top: 1px; right: 1px; /* セル内右上：overflow:hiddenでクリップされない位置 */
  transform: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: rgba(220,38,38,.9);
  color: #fff; font-size: 9px; font-weight: 700;
  align-items: center; justify-content: center;
  cursor: pointer; z-index: 20;
  line-height: 1; pointer-events: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.gantt-bar-clear-btn--dot {
  top: 1px; right: 1px;
  width: 12px; height: 12px;
  font-size: 8px;
}
tr:hover .gantt-bar-clear-btn { display: flex; }
tr:hover .gantt-bar-clear-btn:hover { background: #b91c1c; transform: scale(1.15); }
tr:hover .gantt-bar-clear-btn--dot:hover { background: #b91c1c; transform: scale(1.15); }
/* ガントバー */
.gantt-bar-segment {
  display: block;
  height: 12px;
  width: 100%;
  transition: filter .1s;
  position: relative;
  cursor: grab;
}
.gantt-bar-segment:hover { filter: brightness(1.15); }
.gantt-bar-segment.bar-no-drag { cursor: default !important; }
.bar-drag-handle {
  position: absolute; top: 0; bottom: 0; width: 10px;
  cursor: ew-resize; z-index: 2; transition: background 0.1s;
}
.bar-drag-handle-left  { left: 0; border-radius: 4px 0 0 4px; }
.bar-drag-handle-right { right: 0; border-radius: 0 4px 4px 0; }
.gantt-bar-segment:hover .bar-drag-handle { background: rgba(255,255,255,0.45); }
/* 日付未設定タスク行：カーソルを crosshair に */
.gantt-task-row td.gantt-cell:not(:has(.gantt-bar-segment)):not(:has(.gantt-milestone)) {
  cursor: crosshair;
}
body.gantt-dragging { cursor: grabbing !important; user-select: none !important; }
body.gantt-dragging * { cursor: inherit !important; }
#ganttDragTooltip {
  position: fixed; z-index: 9999;
  background: rgba(0,0,0,.82); color: #fff;
  padding: 4px 10px; border-radius: 6px;
  font-size: 12px; pointer-events: none;
  display: none; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
/* 孫タスクマーカー（バー上部の小▲） */
.gantt-gc-marker {
  display: inline-block;
  font-size: 7px;
  color: rgba(0,0,0,0.65);
  vertical-align: top;
  cursor: pointer;
  line-height: 1;
  margin-left: 1px;
  transition: color .1s, transform .1s;
}
.gantt-gc-marker:hover { color: var(--navy); transform: scale(1.3); }

/* 孫タスクポップアップ */
.gc-popup-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; cursor: pointer;
  transition: background .1s; font-size: 12px;
}
.gc-popup-item:hover { background: var(--border-light); }
.gc-popup-item.gc-done { opacity: .6; }
.gc-popup-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.gc-popup-info {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
}
.gc-popup-title {
  font-weight: 600; color: var(--navy);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gc-done .gc-popup-title { text-decoration: line-through; }
.gc-popup-sub {
  font-size: 10px; color: var(--text-sub);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gc-popup-arrow { color: var(--text-muted); font-size: 14px; flex-shrink: 0; }

/* ─── Location row ──────────────────────────────────── */
.gantt-location-row .gantt-loc-cell {
  cursor: crosshair;
}
.gantt-location-row .gantt-loc-cell:hover {
  background: rgba(30,58,95,0.05) !important;
}
/* ── 場所バー ── */
.gantt-loc-cell {
  position: relative;
  overflow: visible;
}
.gantt-loc-bar {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  right: 0;
  overflow: visible;
}
.gantt-loc-bar:hover { filter: brightness(1.12); }
.gantt-loc-bar-label {
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  pointer-events: auto;
  z-index: 10;
}
.gantt-loc-drag-preview { background: rgba(30,58,95,0.15) !important; }

/* ── 段ズレ防御：左右テーブルの行高さを強制一致 ── */
.gantt-bd-left table,
.gantt-bd-right table {
  border-collapse: collapse;
}
.gantt-bd-left tr,
.gantt-bd-right tr {
  box-sizing: border-box;
}
.gantt-bd-left td,
.gantt-bd-right td {
  padding: 0;
  box-sizing: border-box;
  line-height: 1;
  vertical-align: middle;
}
.gantt-label-col {
  padding: 0 8px !important;
  box-sizing: border-box;
}

/* ─── Location popup ─────────────────────────────────── */
.loc-popup {
  position: fixed; z-index: 9200;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 16px; width: 300px;
  display: none;
}
.loc-popup.open { display: block; }
.loc-color-swatch {
  width: 22px; height: 22px; border-radius: 50%;
  cursor: pointer; border: 2px solid transparent;
  transition: transform .1s, border-color .1s;
  display: inline-block;
}
.loc-color-swatch:hover { transform: scale(1.25); }
.loc-color-swatch.selected { border-color: var(--navy); box-shadow: 0 0 0 1px #fff inset; }

/* ─── Link tabs ─────────────────────────────────────── */
.link-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.link-tab {
  flex: 1; padding: 5px 8px;
  border: 1px solid var(--border); border-radius: 6px;
  background: transparent; font-family: inherit; font-size: 11px; font-weight: 600;
  color: var(--text-sub); cursor: pointer; transition: all .15s; text-align: center;
}
.link-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.link-tab:hover:not(.active) { background: var(--border-light); }

/* ─── File drop zone ─────────────────────────────────── */
.file-drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 14px 10px; text-align: center; cursor: pointer;
  transition: all .15s; background: var(--bg);
  font-size: 12px; color: var(--text-sub);
}
.file-drop-zone:hover, .file-drop-zone.drag-over {
  border-color: var(--navy); background: rgba(30,58,95,.04);
}

/* ─── Customer list ─────────────────────────────────── */
.customer-layout { display: flex; height: calc(100vh - 112px); overflow: hidden; position: relative; }
.customer-list-col {
  width: 280px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-card);
  display: flex; flex-direction: column;
  transition: width .2s ease; overflow: hidden;
}
.customer-list-col.collapsed { width: 0; }
.customer-list-toggle-btn {
  position: absolute; left: 280px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 48px; z-index: 10;
  border: 1px solid var(--border); border-left: none;
  background: var(--bg-card); color: var(--text-muted);
  cursor: pointer; border-radius: 0 6px 6px 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; transition: left .2s ease, background .15s;
  flex-shrink: 0;
}
.customer-list-toggle-btn:hover { background: var(--border-light); color: var(--navy); }
.customer-list-col.collapsed ~ .customer-list-toggle-btn { left: 0; }

/* タグバッジ */
.tag-badge { display:inline-block; font-size:10px; font-weight:600; padding:2px 8px; border-radius:10px; background:var(--border); color:var(--navy); }
.tag-badge-meeting { background:rgba(232,102,42,0.12); color:var(--primary,#E8662A); }

/* 検索結果セクション */
.search-section-header { font-size:10px; font-weight:700; color:var(--text-muted); padding:8px 12px 4px; border-bottom:1px solid var(--border-light); background:var(--bg); text-transform:uppercase; letter-spacing:.5px; }
.meeting-search-row { padding:8px 12px; cursor:pointer; border-bottom:1px solid var(--border-light); }
.meeting-search-row:hover { background:var(--border-light); }

/* ハイライト */
.meeting-row.search-highlight { background:rgba(232,102,42,0.06); border-left:3px solid var(--primary,#E8662A); }
.customer-card {
  padding: 10px 16px; cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background .15s;
}
.customer-card:hover { background: var(--border-light); }
.customer-card.active { background: var(--gold-pale); border-left: 3px solid var(--gold); }
.customer-card-name { font-size: 13px; font-weight: 700; color: var(--text); }
.customer-card-company { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.customer-card-meta { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.contract-badge {
  font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: 10px;
}
.contract-badge.none         { background: #f1f5f9; color: #64748b; }
.contract-badge.active       { background: #dbeafe; color: #1d4ed8; }
.contract-badge.subscription { background: #dcfce7; color: #15803d; }
.contract-badge.paused       { background: #fffbeb; color: #d97706; }
.contract-badge.ended        { background: #f1f5f9; color: #94a3b8; }

/* ─── Customer detail ───────────────────────────────── */
.customer-detail-col {
  flex: 1; overflow-y: auto; padding: 20px 24px;
}
.customer-detail-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.customer-detail-name { font-size: 20px; font-weight: 700; color: var(--navy); }
.detail-tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.detail-tab {
  padding: 8px 16px; border: none; background: none;
  font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all .15s;
}
.detail-tab:hover { color: var(--navy); }
.detail-tab.active { color: var(--navy); border-bottom-color: var(--gold); }

/* ─── Meeting list ──────────────────────────────────── */
.meeting-row {
  padding: 10px 12px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 6px;
}
.meeting-date { font-size: 11px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.meeting-content { font-size: 13px; color: var(--text); white-space: pre-wrap; }
.meeting-add-form {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-top: 12px;
}
.meeting-header {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none; padding: 2px 0;
}
.meeting-header:hover .meeting-date { color: var(--navy-light); }
.meeting-preview {
  flex: 1; font-size: 12px; color: var(--text-sub);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.meeting-chevron { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }
.meeting-body {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border-light);
}

/* ─── Date picker popup ──────────────────────────────── */
.datepicker-popup {
  position: fixed; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 12px; z-index: 500;
  width: 244px; display: none;
}
.datepicker-popup.open { display: block; }
.datepicker-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.datepicker-header-label { font-size: 13px; font-weight: 700; color: var(--navy); }
.datepicker-nav {
  width: 26px; height: 26px; border: none; background: transparent;
  border-radius: 4px; cursor: pointer; font-size: 12px; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
.datepicker-nav:hover { background: var(--border-light); color: var(--navy); }
.datepicker-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; margin-bottom: 4px;
}
.datepicker-weekdays span {
  font-size: 10px; color: var(--text-muted); font-weight: 600; padding: 2px 0;
}
.datepicker-days {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; gap: 2px;
}
.dp-day {
  font-size: 12px; padding: 5px 2px; border-radius: 4px;
  cursor: pointer; transition: all .1s; color: var(--text);
}
.dp-day:hover:not(.dp-empty) { background: var(--border-light); }
.dp-empty { cursor: default; }
.dp-today { font-weight: 700; color: var(--navy); }
.dp-selected { background: var(--navy) !important; color: #fff !important; }
.dp-weekend { color: #94a3b8; }
.dp-weekend.dp-selected { background: var(--navy) !important; color: #fff !important; }
/* 日付範囲ハイライト */
.dp-range-start { background: var(--navy) !important; color: #fff !important; border-radius: 50% 0 0 50% !important; }
.dp-range-end   { background: var(--color-primary, #E8662A) !important; color: #fff !important; border-radius: 0 50% 50% 0 !important; }
.dp-range-single { background: var(--navy) !important; color: #fff !important; border-radius: 50% !important; }
.dp-in-range    { background: rgba(30,58,95,0.1) !important; border-radius: 0 !important; color: var(--navy); }
.datepicker-input-row {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-light);
}
.datepicker-footer {
  display: flex; gap: 6px; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border-light);
}
.datepicker-footer .btn { flex: 1; font-size: 11px; justify-content: center; padding: 6px 4px; }
.datepicker-set-msg {
  font-size: 11px; color: var(--success); text-align: center;
  margin-top: 6px; min-height: 16px;
}

/* ─── Drag & Drop ─────────────────────────────────────── */
.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 14px;
  padding: 0 4px;
  opacity: 0;
  transition: opacity .15s;
  user-select: none;
  flex-shrink: 0;
}
.task-row:hover .drag-handle { opacity: 1; }
.task-row.dragging { opacity: 0.4; background: var(--border-light); }
.task-row.drag-over-top { border-top: 3px solid var(--navy) !important; background: rgba(30,58,95,0.04) !important; }
.task-row.drag-over-bottom { border-bottom: 3px solid var(--navy) !important; background: rgba(30,58,95,0.04) !important; }
.task-row.drag-over-into { background: var(--gold-pale) !important; outline: 1px dashed var(--gold); }
.customer-task-drop {
  border-radius: 8px;
  transition: background .15s, outline-color .15s;
}
.customer-task-drop.customer-drop-over {
  background: rgba(30,58,95,0.04);
  outline: 1px dashed var(--navy);
  outline-offset: 2px;
}

/* プロジェクトグループ末尾のタスク追加行 */
.add-task-row {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 6px;
  color: var(--text-muted); font-size: 12px;
  transition: background 0.15s, color 0.15s;
  margin-top: 2px;
}
.add-task-row:hover { background: var(--border-light); color: var(--text-sub); }
.add-task-input {
  flex: 1; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; font-family: inherit; font-size: 12px;
  background: var(--bg-card); color: var(--text); outline: none;
}
.add-task-input:focus { border-color: var(--navy); }

/* ─── Search highlight ────────────────────────────────── */
.task-row.search-hit {
  background: #fff0f3 !important;
  border-left: 3px solid #f9a8c9 !important;
}

/* ─── File Viewer Panel ───────────────────────────────── */
.file-viewer-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(640px, 52vw);
  background: #fff;
  box-shadow: -6px 0 32px rgba(0,0,0,0.18);
  z-index: 800;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
}
.file-viewer-panel.open { transform: translateX(0); }

.file-viewer-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: var(--navy);
  color: #fff;
  flex-shrink: 0;
  height: 44px;
}
.file-viewer-icon { font-size: 16px; flex-shrink: 0; }
.file-viewer-title {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.file-viewer-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  border-radius: 4px;
  padding: 3px 9px;
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
  line-height: 1.4;
}
.file-viewer-btn:hover { background: rgba(255,255,255,0.15); }
.file-viewer-panel.wide { width: min(1040px, 82vw); }
.file-viewer-body { flex: 1; display: flex; overflow: hidden; }
.file-viewer-frame { flex: 1; border: none; width: 100%; background: #f1f5f9; }
.file-viewer-img-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a1a;
  overflow: auto;
  padding: 20px;
}
.file-viewer-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  cursor: zoom-in;
}
.fv-zoom-controls {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0,0,0,0.65);
  border-radius: 20px;
  padding: 5px 12px;
  backdrop-filter: blur(6px);
  white-space: nowrap;
  z-index: 10;
}
.fv-zoom-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 7px;
  border-radius: 4px;
  line-height: 1.4;
}
.fv-zoom-btn:hover { background: rgba(255,255,255,0.2); }
.fv-zoom-label { color: #fff; font-size: 12px; min-width: 44px; text-align: center; }

/* Minimized tab */
.file-viewer-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--navy);
  color: #fff;
  border-radius: 8px 0 0 8px;
  padding: 14px 7px;
  cursor: pointer;
  z-index: 801;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: -3px 0 12px rgba(0,0,0,0.18);
  transition: background 0.15s;
}
.file-viewer-tab:hover { background: var(--navy-light); }
.file-viewer-tab.show { display: flex; }
.file-viewer-tab-icon { font-size: 18px; }
.file-viewer-tab-name {
  writing-mode: vertical-rl;
  font-size: 11px;
  max-height: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.85;
}

/* ── ノートパネル ── */
.note-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(480px, 92vw);
  background: var(--bg-card);
  box-shadow: -6px 0 32px rgba(0,0,0,0.18);
  z-index: 750;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1), visibility 0s linear 0.28s;
  visibility: hidden;
  pointer-events: none;
}
.task-drawer-panel { width: min(600px, 92vw); }
.note-panel.open { transform: translateX(0); visibility: visible; pointer-events: auto; transition-delay: 0s; }
.note-panel-header {
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px;
  background: var(--navy); color: #fff;
  flex-shrink: 0; height: 48px;
}
.note-panel-title { flex: 1; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-panel-close {
  background: none; border: none; color: #fff; font-size: 20px;
  cursor: pointer; line-height: 1; padding: 4px 6px; border-radius: 4px;
}
.note-panel-close:hover { background: rgba(255,255,255,0.15); }
.task-drawer-tabs {
  display: flex; gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}
.task-drawer-tab {
  height: 30px; padding: 0 12px;
  border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--text-sub);
  font-family: inherit; font-size: 12px; font-weight: 700;
  cursor: pointer;
}
.task-drawer-tab:hover { background: var(--border-light); color: var(--navy); }
.task-drawer-tab.active {
  border-color: var(--navy); background: #eff6ff; color: var(--navy);
}
.task-drawer-pane {
  display: none; flex: 1; min-height: 0; overflow: hidden;
}
.task-drawer-pane.active {
  display: flex; flex-direction: column;
}
.note-panel-body { flex: 1; overflow-y: scroll; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.note-panel-body::-webkit-scrollbar { width: 6px; }
.note-panel-body::-webkit-scrollbar-track { background: transparent; }
.note-panel-body::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
.note-panel-body::-webkit-scrollbar-thumb:hover { background: var(--text-sub); }
.note-add-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius);
  border: 2px dashed var(--border); background: none;
  color: var(--text-sub); font-size: 13px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.note-add-btn:hover { border-color: var(--navy); background: var(--gold-pale); color: var(--navy); }
@keyframes noteHighlight {
  0%   { box-shadow: 0 0 0 3px var(--navy); background: #eef2ff; }
  100% { box-shadow: none; background: var(--bg); }
}
.note-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); overflow: hidden;
  transition: box-shadow .15s;
}
.note-card.new-highlight { animation: noteHighlight 1.2s ease forwards; }
.note-card:focus-within { box-shadow: 0 0 0 2px var(--navy); border-color: var(--navy); }
.note-add-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.note-card-header {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px;
  background: var(--bg-card);
  cursor: pointer;
  user-select: none;
}
.note-card-toggle {
  font-size: 9px; color: var(--text-muted); flex-shrink: 0;
  transition: transform 0.15s; width: 12px; text-align: center;
}
.note-card-body { border-top: 1px solid var(--border); }
.note-card-body.collapsed { display: none; }
.note-title-input {
  flex: 1; border: none; outline: none;
  font-size: 13px; font-weight: 600; color: var(--text);
  background: transparent; padding: 0;
}
.note-title-input::placeholder { color: var(--text-muted); font-weight: 400; }
.note-date { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }
.note-delete-btn {
  background: none; border: none; color: var(--text-muted); font-size: 16px;
  cursor: pointer; line-height: 1; padding: 2px 4px; border-radius: 3px; flex-shrink: 0;
}
.note-delete-btn:hover { background: #fee2e2; color: var(--danger); }
.note-content-input {
  width: 100%; border: none; outline: none; resize: none;
  font-size: 14px; color: var(--text); line-height: 1.7;
  padding: 10px 12px; min-height: 80px;
  max-height: min(360px, calc(100vh - 340px));
  font-family: inherit; background: var(--bg);
  box-sizing: border-box; overflow-y: auto;
  overscroll-behavior: contain;
}
.note-card-resize-handle {
  height: 6px;
  cursor: ns-resize;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
  user-select: none;
}
.note-card-resize-handle:hover { background: var(--gold-pale); }
.note-card-resize-handle::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 28px; height: 2px;
  background: var(--text-muted);
  border-radius: 1px;
}
.note-saved-indicator {
  font-size: 10px; color: #22c55e; margin-left: 4px;
  opacity: 0; transition: opacity 0.5s;
}
.note-saved-indicator.show { opacity: 1; }
/* ノートパネル開放中のページスクロール禁止 */
body.no-scroll { overflow: hidden !important; }
/* タスクアイコンのノートボタン */
.has-notes { color: var(--navy) !important; font-weight: 600; }
/* ノートパネルのオーバーレイ */
.note-panel-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.15); z-index: 749;
  display: none;
}
.note-panel-overlay.open { display: block; }

/* ── ナレッジスライドパネル（顧客詳細 > ナレッジタブ） ── */
.kn-slide-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.15); z-index: 749;
  display: none;
}
.kn-slide-overlay.open { display: block; }
.kn-slide-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(600px, 92vw);
  background: var(--bg-card);
  box-shadow: -6px 0 32px rgba(0,0,0,0.18);
  z-index: 750;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
}
.kn-slide-panel.open { transform: translateX(0); }
.kn-slide-header {
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px;
  background: var(--navy); color: #fff;
  flex-shrink: 0; height: 48px;
  min-width: 0;
}
.kn-slide-title {
  flex: 1; font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.kn-slide-open-link {
  font-size: 11px; color: rgba(255,255,255,0.8); text-decoration: none;
  border: 1px solid rgba(255,255,255,0.35); border-radius: 4px;
  padding: 3px 9px; flex-shrink: 0; white-space: nowrap;
}
.kn-slide-open-link:hover { color: #fff; background: rgba(255,255,255,0.15); }
.kn-slide-close {
  background: none; border: none; color: #fff; font-size: 20px;
  cursor: pointer; line-height: 1; padding: 4px 6px; border-radius: 4px;
  flex-shrink: 0;
}
.kn-slide-close:hover { background: rgba(255,255,255,0.15); }
.kn-slide-tags {
  padding: 8px 16px 0;
  display: flex; flex-wrap: wrap; gap: 4px;
  flex-shrink: 0;
}
.kn-slide-body {
  flex: 1; overflow-y: auto; padding: 12px 20px 24px;
  font-size: 16px; line-height: 1.8; color: var(--text);
  outline: none; box-sizing: border-box;
  font-family: 'Noto Sans JP', sans-serif;
}
.kn-slide-body::-webkit-scrollbar { width: 6px; }
.kn-slide-body::-webkit-scrollbar-track { background: transparent; }
.kn-slide-body::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
.kn-slide-body h1 { font-size: 20px; font-weight: 700; color: var(--navy); margin: 20px 0 8px; }
.kn-slide-body h2 { font-size: 17px; font-weight: 700; color: var(--navy); margin: 16px 0 6px; }
.kn-slide-body h3 { font-size: 15px; font-weight: 600; color: var(--navy); margin: 12px 0 4px; }
.kn-slide-body p  { margin: 0 0 10px; }
.kn-slide-body ul, .kn-slide-body ol { margin: 0 0 10px; padding-left: 1.5em; }
.kn-slide-body li { margin-bottom: 2px; }
.kn-slide-body strong { font-weight: 700; }
.kn-slide-body a { color: var(--navy); }
.kn-slide-body table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.kn-slide-body td, .kn-slide-body th { border: 1px solid var(--border); padding: 6px 10px; min-width: 40px; vertical-align: top; }
.kn-slide-body mark { background: #fef08a; }
.kn-slide-body img { max-width: 100%; height: auto; border-radius: 4px; }
.kn-slide-body > :first-child { margin-top: 0; }
.kn-slide-body:focus { background: #fafffe; }
.kn-slide-save-status {
  font-size: 10px; color: rgba(255,255,255,0.65);
  flex-shrink: 0; white-space: nowrap; min-width: 48px; text-align: right;
}

/* ── 会議記録 長文折りたたみ（5行でクランプ） ── */
.meeting-expandable { position: relative; }
.meeting-expandable-inner {
  white-space: pre-wrap;
  line-height: 1.6;
}
.meeting-expandable.meeting-collapsed .meeting-expandable-inner {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
}
.meeting-expand-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 4px 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--navy);
  cursor: pointer;
  font-family: inherit;
  text-align: center;
}

/* ─── AIチャット ──────────────────────────────────────── */
.ai-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  border: none;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: background 0.15s;
}
.ai-chat-fab:hover { background: var(--navy-light); }

.ai-chat-panel {
  position: fixed;
  bottom: 84px;
  right: 24px;
  width: 360px;
  max-height: 520px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  display: flex;
  flex-direction: column;
  z-index: 999;
  overflow: hidden;
}
.ai-chat-panel.hidden { display: none; }

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--navy);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.ai-chat-header-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  opacity: 0.8;
}
.ai-chat-header-close:hover { opacity: 1; }

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-chat-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ai-chat-msg.user { align-items: flex-end; }
.ai-chat-msg.ai   { align-items: flex-start; }

.ai-chat-bubble {
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 12px;
  line-height: 1.6;
  max-width: 88%;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-chat-msg.user .ai-chat-bubble {
  background: var(--navy);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-chat-msg.ai .ai-chat-bubble {
  background: #f1f5f9;
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.ai-chat-msg.ai .ai-chat-bubble.error {
  background: #fee2e2;
  color: var(--danger);
}

.ai-chat-action-bar {
  margin-top: 6px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.ai-chat-action-confirm {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 6px;
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
}
.ai-chat-action-confirm:hover { opacity: 0.85; }
.ai-chat-action-cancel {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-sub);
  cursor: pointer;
  font-family: inherit;
}

.ai-chat-thinking {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 12px;
}

.ai-chat-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
}
.ai-chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  resize: none;
  background: var(--bg);
}
.ai-chat-input:focus { border-color: var(--navy); }
.ai-chat-send {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ai-chat-send:disabled { opacity: 0.4; cursor: default; }
.ai-chat-send:not(:disabled):hover { background: var(--navy-light); }
.meeting-expand-btn:hover { background: var(--border-light); }

/* ─── バックアップボタン ──────────────────────────────── */
.backup-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 15px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.backup-btn:hover { background: var(--border-light); }
.backup-btn.backup-ok  { border-color: var(--success); color: var(--success); }
.backup-btn.backup-warn { border-color: var(--warning); color: var(--warning); animation: backup-pulse 2s ease-in-out infinite; }
@keyframes backup-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ─── 通知バナー ──────────────────────────────────────── */
.notif-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  font-size: 12px;
  border-bottom: 1px solid transparent;
  flex-wrap: wrap;
}
.notif-banner.overdue {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}
.notif-banner.warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}
.notif-banner.info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}
.notif-banner-items {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}
.notif-banner-item {
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.notif-banner-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: inherit;
  opacity: 0.6;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.notif-banner-close:hover { opacity: 1; }

/* ─── 関連ナレッジ チップ ─────────────────────────────── */
.kn-related-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  color: #1d4ed8;
  cursor: pointer;
  transition: background .15s;
  line-height: 1.4;
}
.kn-related-chip:hover { background: #dbeafe; }
.kn-related-chip-x {
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 14px;
  line-height: 1;
  padding: 0 0 0 2px;
  display: flex;
  align-items: center;
}
.kn-related-chip-x:hover { color: #ef4444; }

/* ─── User settings panel ────────────────────────────── */
.user-settings-wrap { position: relative; display: flex; align-items: center; }
.user-avatar-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--navy); color: #fff;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: none; transition: opacity .15s;
  flex-shrink: 0;
}
.user-avatar-btn:hover { opacity: .85; }
.user-settings-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  width: 280px; z-index: 500;
  display: none; flex-direction: column;
}
.user-settings-panel.open { display: flex; }
.usp-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.usp-avatar-lg {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--navy); color: #fff;
  font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.usp-name { font-size: 14px; font-weight: 700; color: var(--text); }
.usp-email { font-size: 11px; color: var(--text-muted); word-break: break-all; }
.usp-section { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.usp-section:last-child { border-bottom: none; }
.usp-label { display: block; font-size: 11px; font-weight: 600; color: var(--text-sub); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.usp-toggle-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; padding: 3px 0; }
.usp-toggle-row input[type=checkbox] { accent-color: var(--navy); }

/* ─── Task comments ───────────────────────────────────── */
.task-comments-body {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 0;
}
.task-comments-input-wrap {
  padding: 12px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.task-comment-input {
  width: 100%; font-size: 13px; font-family: inherit;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; resize: vertical; line-height: 1.5;
  color: var(--text); background: var(--bg);
  box-sizing: border-box;
}
.task-comment-input:focus { outline: none; border-color: var(--navy); }
.task-comment-item { display: flex; gap: 10px; align-items: flex-start; }
.task-comment-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.task-comment-content { flex: 1; min-width: 0; }
.task-comment-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.task-comment-name { font-size: 12px; font-weight: 600; color: var(--navy); }
.task-comment-date { font-size: 11px; color: var(--text-muted); }
.task-comment-del { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 11px; margin-left: auto; padding: 0; }
.task-comment-del:hover { color: var(--danger); }
.task-comment-body { font-size: 13px; color: var(--text); line-height: 1.55; white-space: pre-wrap; word-break: break-word; }

/* ─── Mobile final overrides ───────────────────────────
   Keep these after shared drawer/button rules so mobile sizing wins. */
@media (max-width: 768px) {
  .backup-btn { width: 30px; height: 30px; }
  .note-panel,
  .task-drawer-panel {
    inset: 0 !important;
    width: 100dvw !important;
    max-width: 100dvw !important;
    height: 100dvh;
    transform: translateX(100%) !important;
  }
  .note-panel.open { transform: translateX(0) !important; }
  .note-panel-header {
    min-height: 48px;
    padding-top: env(safe-area-inset-top);
    height: calc(48px + env(safe-area-inset-top));
  }
}

