:root {
  --accent:  #2d6099;
  --green:   #10b981;
  --yellow:  #f59e0b;
  --red:     #ef4444;
  --cyan:    #06b6d4;
  --bg:      #f8fafc;
  --card:    #ffffff;
  --border:  #e5e7eb;
  --text:    #1f2937;
  --muted:   #9ca3af;
  --d-bg:    #000000;
  --d-card:  #111111;
  --d-border:#2a2a2a;
  --d-text:  #f1f5f9;
  --d-muted: #7c8fa6;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh; transition: background 0.3s, color 0.3s;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Dark mode ─── */
body.dark { background: var(--d-bg); color: var(--d-text); }
body.dark header { background: #0a0a0a; }
body.dark .active-bar,
body.dark .filters { background: var(--d-card); border-color: var(--d-border); }
body.dark .tc { background: var(--d-card); box-shadow: 0 1px 6px rgba(0,0,0,0.6); }
body.dark .tname { color: var(--d-text); }
body.dark .tmeta { color: var(--d-muted); }
body.dark .tc-detail-inner { border-color: var(--d-border); }
body.dark .detail-memo { background: #0a0a0a; color: #94a3b8; border: 1px solid var(--d-border); }
body.dark .progress-track { background: #2a2a2a; }
body.dark .det-btn { background: #1a1a1a; border-color: var(--d-border); color: #94a3b8; }
body.dark .det-btn:hover { border-color: #64748b; color: var(--d-text); }
body.dark .footer-nav { background: #0a0a0a; border-color: var(--d-border); }
body.dark .modal-sheet { background: #0f0f0f; border-top: 1px solid var(--d-border); }
body.dark .modal-title { color: var(--d-text); }
body.dark .form-input { background: #0a0a0a; border-color: var(--d-border); color: var(--d-text); }
body.dark .form-label { color: var(--d-muted); }
body.dark .assignee-chip { background: #1a1a1a; border-color: var(--d-border); }
body.dark .assignee-chip span { color: #94a3b8; }
body.dark .fb { background: #1a1a1a; border-color: var(--d-border); color: #94a3b8; }
body.dark .fb:hover:not(.on) { background: #222; color: #cbd5e1; }
body.dark .fb.on { background: #4d82b8; color: white; border-color: #4d82b8; }
body.dark .active-chip { background: rgba(6,182,212,0.12); border-color: rgba(6,182,212,0.3); }
body.dark .active-chip .ctask { color: var(--d-text); }
body.dark .card-edit { color: #64748b; }
body.dark .card-edit:hover { background: rgba(100,116,139,0.2); color: #cbd5e1; }
body.dark .card-del  { color: #64748b; }
body.dark .card-del:hover  { background: rgba(239,68,68,0.15); color: #f87171; }
body.dark .working-tag { background: rgba(6,182,212,0.15); border-color: rgba(6,182,212,0.35); color: #22d3ee; }
body.dark .alert-r { color: #f87171; }
body.dark .alert-y { color: #fbbf24; }
body.dark .empty-text { color: var(--d-text); }
body.dark .empty-sub { color: var(--d-muted); }

/* ─── Login ─── */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.login-card {
  text-align: center; padding: 40px 32px;
  background: white; border-radius: 20px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  width: 300px;
}
.login-title { font-size: 20px; font-weight: 700; color: #1e3a5f; margin-bottom: 8px; }
.login-sub { font-size: 13px; color: var(--muted); margin-bottom: 28px; }
.login-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px; border-radius: 12px;
  border: 1.5px solid var(--border); background: white;
  font-size: 14px; font-weight: 500; font-family: inherit;
  cursor: pointer; color: var(--text); transition: background 0.2s;
}
.login-btn:hover { background: var(--bg); }

/* ─── Header ─── */
header {
  background: #1e3a5f; padding: 16px 20px 13px; color: white;
  display: flex; align-items: flex-start; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
header h1 { font-size: 17px; font-weight: 700; }
header .sub { font-size: 12px; opacity: 0.6; margin-top: 3px; }
.header-right { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.add-btn {
  background: rgba(255,255,255,0.12); border: 1.5px solid rgba(255,255,255,0.3);
  color: white; padding: 7px 14px; border-radius: 20px;
  font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit;
  transition: background 0.2s;
}
.add-btn:hover { background: rgba(255,255,255,0.2); }
.dark-toggle {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.25);
  color: white; width: 32px; height: 32px; border-radius: 8px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.dark-toggle:hover { background: rgba(255,255,255,0.2); }

/* ─── Active bar ─── */
.active-bar {
  background: white; padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  overflow-x: auto; flex-shrink: 0;
}
.active-bar::-webkit-scrollbar { display: none; }
.active-label {
  font-size: 11px; color: var(--muted); white-space: nowrap;
  font-weight: 500; letter-spacing: 0.04em;
  display: flex; align-items: center; gap: 4px;
}
.active-none { font-size: 12px; color: var(--muted); }
.pulse {
  display: inline-block; width: 7px; height: 7px;
  background: var(--cyan); border-radius: 50%;
  animation: pulse 2s infinite; flex-shrink: 0;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.35} }
.active-chip {
  display: flex; align-items: center; gap: 6px;
  background: rgba(6,182,212,0.08); border: 1px solid rgba(6,182,212,0.25);
  border-radius: 20px; padding: 4px 10px 4px 4px;
  white-space: nowrap; flex-shrink: 0;
}
.av {
  width: 26px; height: 26px; border-radius: 50%;
  background: #1e293b; color: white; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.active-chip .ctask { font-size: 12px; color: #374151; }

/* ─── Filters ─── */
.filters {
  background: white; padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 7px; overflow-x: auto;
  flex-shrink: 0;
}
.filters::-webkit-scrollbar { display: none; }
.fb {
  padding: 5px 13px; border-radius: 14px;
  border: 1px solid var(--border); background: white;
  font-size: 12px; cursor: pointer; white-space: nowrap;
  color: #6b7280; font-family: inherit; transition: all 0.15s;
}
.fb.on { background: #2d6099; color: white; border-color: #2d6099; font-weight: 500; }
.fb:hover:not(.on) { background: var(--bg); }

/* ─── Task list ─── */
.task-scroll { overflow-y: auto; flex: 1; }

/* ─── Task card ─── */
.tc {
  background: white; border-radius: 9px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05); overflow: hidden;
  cursor: pointer; transition: box-shadow 0.15s;
  margin: 4px 12px;
}
.tc:first-child { margin-top: 10px; }
.tc:last-child { margin-bottom: 6px; }
.tc:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.tc.done { opacity: 0.4; }
.tc-main { display: flex; align-items: center; gap: 7px; padding: 7px 10px; }
.hdot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.tc.g .hdot { background: var(--green); }
.tc.y .hdot { background: var(--yellow); }
.tc.r .hdot { background: var(--red); }
.tc.done .hdot { background: #d1d5db; }
.ti { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.tname { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; flex-shrink: 0; }
.tc.done .tname { text-decoration: line-through; color: var(--muted); }
.tmeta { font-size: 10px; color: var(--muted); display: flex; gap: 5px; align-items: center; flex-wrap: nowrap; overflow: hidden; min-width: 0; }
.tmeta span { white-space: nowrap; flex-shrink: 0; }
.alert-r { color: var(--red); font-weight: 600; }
.alert-y { color: var(--yellow); font-weight: 600; }
.working-tag {
  display: inline-flex; align-items: center; gap: 2px;
  background: rgba(6,182,212,0.1); border: 1px solid rgba(6,182,212,0.3);
  color: var(--cyan); font-size: 9px; font-weight: 700;
  padding: 1px 5px; border-radius: 6px; flex-shrink: 0;
}
.check {
  width: 17px; height: 17px; border-radius: 50%;
  border: 1.5px solid #d1d5db; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: white; transition: all 0.2s; cursor: pointer;
}
.tc.done .check { background: var(--green); border-color: var(--green); }
.card-actions { opacity: 0; display: flex; gap: 2px; flex-shrink: 0; transition: opacity 0.15s; }
.tc:hover .card-actions { opacity: 1; }
.card-edit, .card-del {
  background: none; border: none; cursor: pointer;
  padding: 3px 5px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s; color: #9ca3af;
}
.card-edit:hover { background: rgba(156,163,175,0.15); color: #6b7280; }
.card-del:hover  { background: rgba(239,68,68,0.12); color: #ef4444; }
.tr { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.av-sm { width: 20px; height: 20px; border-radius: 50%; font-size: 8px; }

/* ─── Task detail (expand) ─── */
.tc-detail { max-height: 0; overflow: hidden; opacity: 0; transition: max-height 0.3s cubic-bezier(0.34,1.2,0.64,1), opacity 0.2s; }
.tc.open .tc-detail { max-height: 320px; opacity: 1; }
.tc-detail-inner { border-top: 1px solid #f3f4f6; margin: 0 13px; padding: 10px 0 12px; }
.detail-memo {
  font-size: 12px; color: #6b7280; background: #f9fafb;
  border-radius: 8px; padding: 8px 10px; line-height: 1.6;
  margin-bottom: 10px; white-space: pre-wrap;
}
.progress-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.progress-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.progress-track { flex: 1; height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.4s; }
.tc.g .progress-fill { background: var(--green); }
.tc.y .progress-fill { background: var(--yellow); }
.tc.r .progress-fill { background: var(--red); }
.progress-pct { font-size: 11px; font-weight: 700; white-space: nowrap; }
.tc.g .progress-pct { color: var(--green); }
.tc.y .progress-pct { color: var(--yellow); }
.tc.r .progress-pct { color: var(--red); }
.detail-actions { display: flex; gap: 7px; }
.det-btn {
  flex: 1; padding: 7px; border-radius: 9px;
  border: 1.5px solid var(--border); background: white;
  font-size: 12px; font-family: inherit; cursor: pointer;
  color: #6b7280; text-align: center; transition: all 0.15s;
}
.det-btn:hover { border-color: #374151; color: #374151; }
.det-btn.start { background: #2d6099; color: white; border-color: #2d6099; font-weight: 700; }
.det-btn.start:hover { background: #1f2937; }
.det-btn.stop  { background: #ef4444; color: white; border-color: #ef4444; font-weight: 700; }
.det-btn.stop:hover { background: #b91c1c; }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 200; display: none; align-items: flex-end;
}
.modal-overlay.show { display: flex; }
.modal-sheet {
  background: white; border-radius: 20px 20px 0 0;
  padding: 16px 20px 40px; width: 100%; max-height: 85vh;
  overflow-y: auto; animation: slideUp 0.25s ease;
}
@keyframes slideUp { from{transform:translateY(40px);opacity:0} to{transform:translateY(0);opacity:1} }
.modal-handle { width: 36px; height: 4px; background: #d1d5db; border-radius: 2px; margin: 0 auto 14px; }
.modal-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: #f3f4f6; border: none; border-radius: 50%; width: 28px; height: 28px; cursor: pointer; font-size: 13px; }
.form-row { margin-bottom: 12px; }
.form-row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.form-label { font-size: 11px; color: var(--muted); font-weight: 500; margin-bottom: 5px; display: block; }
.form-input {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 13px; font-family: inherit; outline: none;
  color: var(--text); transition: border-color 0.2s; background: white;
}
.form-input:focus { border-color: #374151; }
.assignee-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.assignee-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 5px; border: 1.5px solid var(--border);
  border-radius: 20px; cursor: pointer; background: white;
  font-family: inherit; transition: all 0.15s;
}
.assignee-chip .av { width: 22px; height: 22px; font-size: 9px; }
.assignee-chip span { font-size: 12px; color: #374151; }
.assignee-chip.sel { border-color: #374151; background: rgba(55,65,81,0.06); }
.form-submit {
  width: 100%; padding: 12px; background: #2d6099; color: white;
  border: none; border-radius: 12px; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit; margin-top: 4px; transition: background 0.2s;
}
.form-submit:hover { background: #1f2937; }

/* ─── Empty state ─── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 60px 20px; gap: 8px;
}
.empty-icon { font-size: 40px; }
.empty-text { font-size: 15px; font-weight: 700; color: var(--text); }
.empty-sub { font-size: 12px; color: var(--muted); }

/* ─── Utilities ─── */
.hidden { display: none !important; }
.spacer { height: 20px; }
