/* =========================================================================
   テーマ：CSS変数だけ差し替えれば全体が変わる。data-theme で切替。
   ========================================================================= */
:root,
[data-theme="ink"] {
  --bg:        #f3f2ee;
  --surface:   #fbfbf9;
  --surface-2: #f6f5f1;
  --line:      #e3e1d9;
  --ink:       #1f1e1b;
  --ink-soft:  #6b6860;
  --accent:    #3b4ba8;
  --accent-ink:#ffffff;
  --danger:    #b03a3a;
  --ghost:     rgba(31,30,27,.06);
}
[data-theme="slate"] {
  --bg:        #14161a;
  --surface:   #1d2026;
  --surface-2: #23272e;
  --line:      #2e333c;
  --ink:       #e7e9ec;
  --ink-soft:  #9aa0aa;
  --accent:    #4cc4d6;
  --accent-ink:#08222a;
  --danger:    #e07a7a;
  --ghost:     rgba(255,255,255,.06);
}
[data-theme="moss"] {
  --bg:        #eef1e8;
  --surface:   #f8faf3;
  --surface-2: #eef2e4;
  --line:      #d9e0cc;
  --ink:       #232a1d;
  --ink-soft:  #5f6b52;
  --accent:    #4a7a3f;
  --accent-ink:#ffffff;
  --danger:    #a8493a;
  --ghost:     rgba(35,42,29,.06);
}
[data-theme="plum"] {
  --bg:        #f3edf0;
  --surface:   #fcf8fa;
  --surface-2: #f4ecf0;
  --line:      #e6d8e0;
  --ink:       #2a1f27;
  --ink-soft:  #74616c;
  --accent:    #8a3f6b;
  --accent-ink:#ffffff;
  --danger:    #b0413f;
  --ghost:     rgba(42,31,39,.06);
}

/* グループ（フェーズ）タグの色。data-phase の頭文字で割り当て */
.tag[data-hue="1"]{ --t:#c98a2b; }
.tag[data-hue="2"]{ --t:#3f8a9a; }
.tag[data-hue="3"]{ --t:#5a6bd0; }
.tag[data-hue="4"]{ --t:#9a5fb0; }
.tag[data-hue="5"]{ --t:#c05a7a; }
.tag[data-hue="0"]{ --t:var(--ink-soft); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
[hidden] { display: none !important; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- トップバー ---------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { color: var(--accent); font-weight: 700; font-size: 20px; }
.brand h1 { font-size: 16px; margin: 0; letter-spacing: .04em; font-weight: 650; }
.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.select {
  appearance: none;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 28px 7px 10px; font: inherit; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
                    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: right 12px center, right 7px center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.btn {
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--ghost); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; }
.btn .danger, .danger { color: var(--danger); }

.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn { background: transparent; border: 0; padding: 7px 12px; font: inherit; color: var(--ink-soft); cursor: pointer; }
.seg-btn.is-active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }

.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; min-width: 180px; z-index: 30;
  display: flex; flex-direction: column;
}
.menu-pop button, .file-label {
  text-align: left; background: transparent; border: 0; border-radius: 6px;
  padding: 9px 10px; font: inherit; color: var(--ink); cursor: pointer;
}
.menu-pop button:hover, .file-label:hover { background: var(--ghost); }

/* ---- ボード -------------------------------------------------------------- */
.board {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  padding: 20px; align-items: start;
}
.col { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; min-height: 120px; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 6px; }
.col-head h2 { font-size: 13px; margin: 0; letter-spacing: .06em; color: var(--ink-soft); font-weight: 650; }
.count { margin-left: auto; font-size: 12px; color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--line); border-radius: 20px; padding: 1px 9px; }
.col-body { padding: 6px 10px 14px; min-height: 60px; display: flex; flex-direction: column; gap: 8px; }

/* ---- カード -------------------------------------------------------------- */
.card {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; cursor: grab; position: relative;
}
.card:active { cursor: grabbing; }
.card-top { display: flex; align-items: flex-start; gap: 8px; }
.card-title { font-weight: 550; flex: 1; word-break: break-word; }
.card.done .card-title { color: var(--ink-soft); text-decoration: line-through; text-decoration-thickness: 1px; }
.card-detail { color: var(--ink-soft); font-size: 12.5px; margin-top: 6px; white-space: pre-wrap; word-break: break-word; }
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 9px; flex-wrap: wrap; }

.tag {
  font-size: 11px; padding: 1px 8px; border-radius: 20px;
  color: var(--t); border: 1px solid color-mix(in srgb, var(--t) 35%, transparent);
  background: color-mix(in srgb, var(--t) 12%, transparent); white-space: nowrap;
}
.done-at { font-size: 11px; color: var(--ink-soft); margin-left: auto; }
.icon-btn {
  background: transparent; border: 0; color: var(--ink-soft); cursor: pointer;
  font-size: 13px; padding: 2px 4px; border-radius: 6px; line-height: 1;
}
.icon-btn:hover { background: var(--ghost); color: var(--ink); }

/* ドラッグ中の見た目 */
.sortable-ghost { opacity: .35; }
.sortable-chosen { box-shadow: 0 6px 18px rgba(0,0,0,.16); }
.col-body.drag-over { background: var(--ghost); border-radius: 10px; }

/* ---- 完了ログ ------------------------------------------------------------ */
.log { padding: 20px; max-width: 820px; margin: 0 auto; }
.log-group { margin-bottom: 22px; }
.log-group h2 { font-size: 13px; color: var(--ink-soft); letter-spacing: .05em; margin: 0 0 8px; }
.log-item {
  display: flex; align-items: baseline; gap: 12px;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; margin-bottom: 6px;
}
.log-item .t { flex: 1; }
.log-item .d { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.empty { color: var(--ink-soft); padding: 40px 0; text-align: center; }

/* ---- モーダル ------------------------------------------------------------ */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px; width: 100%; max-width: 460px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-card h3 { margin: 0 0 14px; font-size: 16px; }
.modal-card label { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 12px; }
.modal-card input, .modal-card textarea, .modal-card select {
  width: 100%; margin-top: 5px; padding: 9px 10px; font: inherit; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
}
.modal-card textarea { resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.modal-actions .spacer { flex: 1; }

/* ---- トースト ------------------------------------------------------------ */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: 13px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

/* ---- レスポンシブ -------------------------------------------------------- */
@media (max-width: 760px) {
  .board { grid-template-columns: 1fr; }
  .topbar { gap: 10px; }
  .row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: no-preference) {
  .card, .btn, .seg-btn { transition: background .12s ease, box-shadow .12s ease; }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
