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

body {
  font-family: "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: #f0f4f8;
  color: #2d3748;
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }

/* ── Layout ───────────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

header {
  text-align: center;
  margin-bottom: 1.5rem;
  position: relative;
}
header h1 { font-size: 2rem; color: #2b6cb0; }
.subtitle  { color: #718096; margin-top: .25rem; font-size: .9rem; }
.header-actions {
  margin-top: .5rem;
}

/* ── Card ─────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

/* ── Form (collapsible) ──────────────────────────────── */
.form-card { margin-bottom: 1rem; padding: 1rem 1.5rem; }
.form-card h2 { font-size: 1.1rem; margin-bottom: 0; color: #4a5568; }
.form-toggle { cursor: pointer; user-select: none; display: flex; justify-content: space-between; align-items: center; }
.form-toggle:hover { color: #2b6cb0; }
#addForm { margin-top: .75rem; }

.form-row { margin-bottom: .75rem; }
.form-row input[type="text"],
.form-row textarea {
  width: 100%;
  padding: .65rem .9rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color .2s;
  font-family: inherit;
  resize: vertical;
}
.form-row input[type="text"]:focus,
.form-row textarea:focus { outline: none; border-color: #4299e1; }

.form-row--split {
  display: flex; align-items: flex-end; gap: .75rem; flex-wrap: wrap;
}
.form-row--split label {
  display: flex; flex-direction: column; font-size: .85rem; color: #718096; gap: .25rem;
}
.form-row--split select,
.form-row--split input[type="date"] {
  padding: .55rem .75rem; border: 1.5px solid #e2e8f0; border-radius: 8px;
  font-size: .95rem; background: #fff; cursor: pointer;
}

/* ── Button ───────────────────────────────────────────── */
.btn {
  padding: .6rem 1.2rem; border: none; border-radius: 8px; cursor: pointer;
  font-size: .95rem; font-weight: 600; transition: opacity .2s, transform .1s;
  display: inline-flex; align-items: center; gap: .3rem;
}
.btn:hover   { opacity: .85; }
.btn:active  { transform: scale(.97); }
.btn--primary   { background: #4299e1; color: #fff; }
.btn--secondary { background: #e2e8f0; color: #4a5568; }
.btn--danger    { background: #fc8181; color: #fff; }
.btn--edit      { background: #f6e05e; color: #744210; }
.btn--small     { font-size: .8rem; padding: .35rem .65rem; }
.btn--outline   { background: transparent; border: 1.5px solid #4299e1; color: #4299e1; }
.btn--outline:hover { background: #ebf8ff; }
.btn--thread    { background: #ebf4ff; color: #2b6cb0; }
.btn--thread:hover { background: #bee3f8; }

/* ── Search Input ────────────────────────────────────── */
.search-input {
  padding: .35rem .75rem; border: 1.5px solid #e2e8f0; border-radius: 20px;
  font-size: .85rem; width: 180px; transition: border-color .2s, width .2s;
}
.search-input:focus { outline: none; border-color: #4299e1; width: 240px; }

/* ── Filter bar ───────────────────────────────────────── */
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
  margin-bottom: 1.25rem; font-size: .85rem;
}
.filter-label { color: #718096; font-weight: 600; }
.filter-btn {
  padding: .3rem .75rem; border-radius: 20px; background: #edf2f7;
  color: #4a5568; transition: background .15s;
}
.filter-btn:hover { background: #bee3f8; }
.filter-btn.active { background: #4299e1; color: #fff; }

/* ── Kanban Board ─────────────────────────────────────── */
.kanban-board {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; min-height: 400px;
}
.kanban-column {
  background: #edf2f7; border-radius: 12px; padding: .75rem; min-height: 300px;
  transition: background .2s;
}
.kanban-column.drag-over { background: #dbeafe; outline: 2px dashed #4299e1; }

.kanban-column-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: .6rem .8rem; border-radius: 8px; margin-bottom: .75rem;
  font-weight: 700; font-size: .95rem;
}
.kanban-header--todo        { background: #e2e8f0; color: #4a5568; }
.kanban-header--in_progress { background: #bee3f8; color: #2b6cb0; }
.kanban-header--done        { background: #c6f6d5; color: #276749; }

.kanban-count {
  background: rgba(255,255,255,.6); padding: .15rem .55rem; border-radius: 12px; font-size: .8rem;
}
.kanban-cards { display: flex; flex-direction: column; gap: .6rem; }

/* ── Kanban Card ──────────────────────────────────────── */
.kanban-card {
  background: #fff; border-radius: 10px; padding: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.06); border-left: 4px solid #e2e8f0;
  transition: transform .15s, box-shadow .15s, opacity .2s;
  cursor: grab;
}
.kanban-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.kanban-card.dragging { opacity: .5; }
.kanban-card--high   { border-left-color: #fc8181; }
.kanban-card--medium { border-left-color: #f6e05e; }
.kanban-card--low    { border-left-color: #68d391; }

/* 完了カードはグレーアウト */
.kanban-card--done { opacity: .6; border-left-color: #cbd5e0; }
.kanban-card--done .kanban-card-title { text-decoration: line-through; color: #a0aec0; }

/* 期限切れ・もうすぐ */
.kanban-card--overdue { background: #fff5f5; }
.kanban-card--soon    { background: #fffff0; }

.kanban-card-link {
  display: block; padding: .85rem .85rem .4rem; color: inherit;
}
.kanban-card-link:hover { color: inherit; }

.kanban-card-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: .35rem;
}
.kanban-card-title { font-size: .95rem; font-weight: 600; margin-bottom: .3rem; line-height: 1.4; }
.kanban-card-detail {
  font-size: .8rem; color: #718096; margin-bottom: .4rem; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; white-space: pre-wrap;
}
.kanban-card-meta {
  display: flex; gap: .6rem; font-size: .75rem; color: #a0aec0; flex-wrap: wrap;
}
.kanban-card-actions {
  display: flex; align-items: center; gap: .4rem;
  padding: .4rem .85rem .85rem; border-top: 1px solid #f0f4f8;
}
.kanban-empty { text-align: center; padding: 2rem .5rem; color: #a0aec0; font-size: .9rem; }

/* ── Due Date Badges ─────────────────────────────────── */
.due-badge {
  font-size: .65rem; padding: .1rem .45rem; border-radius: 8px; font-weight: 600;
}
.due-overdue { color: #c53030; font-weight: 700; }
.due-badge.due-overdue { background: #fff5f5; }
.due-soon    { color: #b7791f; font-weight: 700; }
.due-badge.due-soon    { background: #fffff0; }
.due-none { color: #cbd5e0; }

/* ── Priority Badge ───────────────────────────────────── */
.priority-badge {
  font-size: .7rem; padding: .15rem .5rem; border-radius: 12px;
  white-space: nowrap; font-weight: 600;
}
.priority-badge--high   { background: #fff5f5; color: #c53030; }
.priority-badge--medium { background: #fffff0; color: #b7791f; }
.priority-badge--low    { background: #f0fff4; color: #276749; }

.status-select {
  padding: .3rem .5rem; border: 1.5px solid #e2e8f0; border-radius: 6px;
  font-size: .8rem; background: #fff; cursor: pointer;
}

/* ── List View ───────────────────────────────────────── */
.task-table {
  width: 100%; border-collapse: collapse; background: #fff;
  border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.task-table th {
  background: #edf2f7; text-align: left; padding: .65rem .85rem;
  font-size: .8rem; color: #718096; font-weight: 600;
}
.task-table td { padding: .65rem .85rem; font-size: .88rem; border-top: 1px solid #f0f4f8; }
.task-row--done { opacity: .5; }
.task-row--done .task-link { text-decoration: line-through; }
.task-row--overdue { background: #fff5f5; }
.task-row--soon    { background: #fffff0; }
.task-link { color: #2b6cb0; font-weight: 600; }
.task-link:hover { text-decoration: underline; }

/* ── Modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,.4); display: flex; align-items: center;
  justify-content: center; z-index: 1000;
}
.modal-content { width: 90%; max-width: 520px; animation: modalIn .2s ease; }
@keyframes modalIn {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal-content h2 { font-size: 1.1rem; margin-bottom: 1rem; color: #4a5568; }
.modal-actions { display: flex; gap: .75rem; margin-top: 1rem; }

/* ── Thread Page ──────────────────────────────────────── */
.thread-back { display: inline-block; margin-bottom: 1rem; color: #4299e1; font-size: .9rem; font-weight: 600; }
.thread-back:hover { text-decoration: underline; }
.thread-task-header { margin-bottom: 1.5rem; }
.thread-list { display: flex; flex-direction: column; gap: .75rem; margin-bottom: 1.5rem; }
.thread-comment {
  background: #fff; border-radius: 10px; padding: .85rem 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06); border-left: 4px solid #e2e8f0;
}
.thread-comment--log     { border-left-color: #4299e1; }
.thread-comment--summary { border-left-color: #9f7aea; }
.thread-comment--note    { border-left-color: #ed8936; }
.thread-comment-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; }
.thread-type-badge { font-size: .72rem; padding: .1rem .5rem; border-radius: 10px; font-weight: 600; }
.thread-type--log     { background: #ebf8ff; color: #2b6cb0; }
.thread-type--summary { background: #faf5ff; color: #6b46c1; }
.thread-type--note    { background: #fffaf0; color: #c05621; }
.thread-time { font-size: .72rem; color: #a0aec0; }
.thread-comment-body { font-size: .88rem; color: #4a5568; line-height: 1.6; white-space: pre-wrap; }
.thread-empty { text-align: center; padding: 2rem; color: #a0aec0; font-size: .9rem; }
.thread-form-card { position: sticky; bottom: 1rem; }
.thread-form-card textarea {
  width: 100%; padding: .65rem .9rem; border: 1.5px solid #e2e8f0; border-radius: 8px;
  font-size: .95rem; font-family: inherit; resize: vertical; margin-bottom: .5rem;
}
.thread-form-card textarea:focus { outline: none; border-color: #4299e1; }
.thread-form-actions { display: flex; gap: .5rem; align-items: center; }
.thread-form-actions select {
  padding: .45rem .6rem; border: 1.5px solid #e2e8f0; border-radius: 8px;
  font-size: .85rem; background: #fff; cursor: pointer;
}

/* ── Dashboard ───────────────────────────────────────── */
.dash-summary {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem;
}
.dash-stat {
  background: #fff; border-radius: 12px; padding: 1.2rem; text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.dash-stat-num { font-size: 2rem; font-weight: 800; color: #2d3748; }
.dash-stat-label { font-size: .85rem; color: #718096; margin-top: .25rem; }
.dash-stat--todo .dash-stat-num { color: #4a5568; }
.dash-stat--progress .dash-stat-num { color: #2b6cb0; }
.dash-stat--done .dash-stat-num { color: #276749; }

.progress-bar {
  width: 100%; height: 24px; background: #edf2f7; border-radius: 12px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: linear-gradient(90deg, #48bb78, #38a169);
  border-radius: 12px; transition: width .5s ease;
}

.dash-priority-bars { display: flex; flex-direction: column; gap: .6rem; }
.dash-pbar-row { display: flex; align-items: center; gap: .75rem; }
.dash-pbar-label { width: 60px; font-size: .85rem; font-weight: 600; }
.dash-pbar-track { flex: 1; height: 20px; background: #edf2f7; border-radius: 10px; overflow: hidden; }
.dash-pbar-fill { height: 100%; border-radius: 10px; transition: width .5s ease; }
.dash-pbar-count { width: 30px; text-align: right; font-weight: 700; font-size: .9rem; }

.dash-urgent-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: .6rem 0; border-bottom: 1px solid #f0f4f8; font-size: .9rem;
}
.dash-urgent-item:last-child { border-bottom: none; }
.dash-urgent-item a { color: #2b6cb0; font-weight: 600; }
.dash-urgent-item a:hover { text-decoration: underline; }

/* ── Weekly Chart ────────────────────────────────────── */
.weekly-chart {
  display: flex; justify-content: space-around; align-items: flex-end;
  gap: 1rem; padding: .5rem 0; min-height: 160px;
}
.weekly-col { display: flex; flex-direction: column; align-items: center; flex: 1; }
.weekly-bars { display: flex; gap: 4px; align-items: flex-end; min-height: 130px; }
.weekly-bar {
  width: 28px; border-radius: 4px 4px 0 0; min-height: 4px;
  position: relative; transition: height .4s ease;
}
.weekly-bar--created { background: #4299e1; }
.weekly-bar--activity { background: #9f7aea; }
.weekly-bar-val {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  font-size: .7rem; font-weight: 700; color: #4a5568; white-space: nowrap;
}
.weekly-label { font-size: .75rem; color: #718096; margin-top: .4rem; font-weight: 600; }
.weekly-legend {
  display: flex; justify-content: center; gap: 1.5rem; margin-top: .75rem;
  font-size: .78rem; color: #718096;
}
.weekly-legend-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px;
  margin-right: .3rem; vertical-align: middle;
}

/* ── Mascot (応援キャラ) ─────────────────────────────── */
.mascot {
  position: fixed; bottom: 10px; right: 10px; z-index: 10000;
  cursor: pointer; user-select: none;
  animation: mascot-idle 3s ease-in-out infinite;
}
.mascot-body {
  width: 220px; height: 220px;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,.22));
  transition: transform .25s;
}
.mascot-body svg { width: 100%; height: 100%; }
.mascot:hover .mascot-body { transform: scale(1.1) rotate(-5deg); }
.mascot:active .mascot-body { transform: scale(.93); }

/* 踊りアニメーション */
.mascot.dancing { animation: mascot-dance .4s ease-in-out 8; }
.mascot.dancing .mascot-body { animation: mascot-spin .5s ease-in-out 6; }

.mascot-bubble {
  position: absolute; bottom: 100%; right: 0; margin-bottom: 10px;
  background: #fff; border: 2.5px solid #e2e8f0; border-radius: 18px;
  padding: .65rem 1.1rem; font-size: 1.05rem; font-weight: 600; color: #4a5568;
  white-space: nowrap; box-shadow: 0 4px 18px rgba(0,0,0,.1);
  opacity: 0; transform: translateY(8px) scale(.9);
  transition: opacity .3s, transform .3s; pointer-events: none;
}
.mascot-bubble.show {
  opacity: 1; transform: translateY(0) scale(1);
}
.mascot-bubble::after {
  content: ''; position: absolute; top: 100%; right: 28px;
  border: 10px solid transparent; border-top-color: #fff;
}
.mascot-bubble::before {
  content: ''; position: absolute; top: 100%; right: 26px;
  border: 12px solid transparent; border-top-color: #e2e8f0;
}
@keyframes mascot-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes mascot-dance {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-18px) rotate(-12deg); }
  50% { transform: translateY(-4px) rotate(0deg); }
  75% { transform: translateY(-18px) rotate(12deg); }
}
@keyframes mascot-spin {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.15) rotate(-10deg); }
  50% { transform: scale(1) rotate(0deg); }
  75% { transform: scale(1.15) rotate(10deg); }
}

/* ── Load More ────────────────────────────────────────── */
.load-more-wrap {
  text-align: center; padding: 1rem 0;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .kanban-board { grid-template-columns: 1fr; }
  .kanban-column { min-height: auto; }
  .dash-summary { grid-template-columns: repeat(2, 1fr); }
  .search-input { width: 100%; }
  .search-input:focus { width: 100%; }
}
