* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --s900: #0f172a; --s800: #1e293b; --s700: #334155; --s500: #64748b;
  --s400: #94a3b8; --s200: #e2e8f0; --s100: #f1f5f9; --s50: #f8fafc;
  --teal: #0d9488; --teal-d: #0f766e; --green: #059669; --red: #dc2626; --amber: #d97706;
}
html { -webkit-text-size-adjust: 100%; }
body { font-family: 'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic', sans-serif; background: var(--s50); color: var(--s800); -webkit-tap-highlight-color: rgba(0,0,0,.06); }
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 9px 12px;
  border: 1px solid var(--s200); border-radius: 10px; outline: none; background: #fff;
}
input:focus, textarea:focus { border-color: var(--s500); }
textarea { width: 100%; line-height: 1.7; resize: vertical; }
.btn-primary {
  background: var(--s900); color: #fff; border: none; border-radius: 10px;
  padding: 9px 18px; font-size: 14px; font-weight: 600; text-decoration: none; display: inline-block;
}
.btn-primary:hover { background: var(--s700); }
.btn-secondary {
  background: #fff; color: var(--s700); border: 1px solid var(--s200); border-radius: 10px;
  padding: 8px 14px; font-size: 13px; font-weight: 600;
}
.btn-secondary:hover { background: var(--s100); }
.btn-secondary:disabled { opacity: .5; }
.mini-btn { background: none; border: 1px solid var(--s200); border-radius: 8px; padding: 3px 10px; font-size: 12px; color: var(--s500); }
.mini-btn:hover { background: var(--s100); }
.mini-btn.danger { color: var(--red); border-color: #fecaca; }
.mini-btn.danger:hover { background: #fef2f2; }

/* ログイン */
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; background: var(--s900); }
.login-card { background: #fff; border-radius: 16px; padding: 40px 44px; text-align: center; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 24px; color: var(--s900); }
/* 会社ロゴ(TARTE INC.)。gen-icon.js がビルド時に /logo.png を生成する */
.login-logo { width: 208px; max-width: 74vw; height: auto; align-self: center; margin-bottom: 2px; }
.login-card p { font-size: 13px; color: var(--s500); }
.login-note { font-size: 11px !important; color: var(--s400) !important; }

/* トップバー */
.topbar {
  display: flex; align-items: center; gap: 24px; background: var(--s900); color: #fff;
  padding: 0 24px; height: 56px; position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 16px; white-space: nowrap; }
.brand-logo { height: 15px; width: auto; display: block; }
.brand-os { letter-spacing: .01em; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button {
  background: none; border: none; color: var(--s400); font-size: 14px; padding: 18px 14px;
  border-bottom: 2px solid transparent;
}
.tabs button:hover { color: #fff; }
.tabs button.active { color: #fff; border-bottom-color: var(--teal); }
.top-right { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.top-right a { color: var(--s400); text-decoration: none; }
.top-right a:hover { color: #fff; }
#userName { color: var(--s200); }
#logout { background: none; border: 1px solid var(--s700); color: var(--s400); border-radius: 8px; padding: 5px 12px; font-size: 12px; }
#logout:hover { color: #fff; border-color: var(--s500); }

/* コンテンツ */
.content { max-width: 1100px; margin: 0 auto; padding: 28px 24px 60px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.sec-head h2 { font-size: 20px; color: var(--s900); }
.year-sel { padding: 7px 10px; font-size: 13px; }
.panel { background: #fff; border: 1px solid var(--s200); border-radius: 14px; padding: 18px 20px; margin-bottom: 16px; }
.panel h3 { font-size: 14px; color: var(--s900); margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.panel.empty { color: var(--s400); font-size: 13px; text-align: center; padding: 32px; }
.form-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 160px; }
.muted { color: var(--s400); font-size: 12px; }
.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--red); font-weight: 600; }

/* カード */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.card { background: #fff; border: 1px solid var(--s200); border-radius: 14px; padding: 18px 20px; }
.card-num { font-size: 22px; font-weight: 800; color: var(--s900); font-variant-numeric: tabular-nums; }
.card-num.pos { color: var(--green); }
.card-num.neg { color: var(--red); }
.card-label { font-size: 12px; color: var(--s500); margin-top: 4px; }

/* テーブル */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--s500); font-size: 11px; font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--s200); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--s100); font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.dim { opacity: .45; }
.tag { font-size: 10px; padding: 2px 8px; border-radius: 999px; background: var(--s100); color: var(--s500); font-weight: 600; }
.tag-rev { background: #ecfdf5; color: var(--green); }
.tag-exp { background: #fff7ed; color: var(--amber); }

/* 進捗バー */
.progress-wrap { height: 14px; background: var(--s100); border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--teal-d), var(--teal)); border-radius: 999px; transition: width .4s; }
.progress-bar.bar-neg { background: var(--red); }

/* 会議 */
.meeting-row { display: flex; align-items: center; gap: 10px; }
.mt-title { font-weight: 700; font-size: 14px; color: var(--s900); }

@media (max-width: 700px) {
  .content { padding: 18px 12px 50px; }
  .meeting-row { flex-wrap: wrap; }
}

/* ---------- 追加モジュール ---------- */
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { white-space: nowrap; }
/* grid の 1fr は minmax(auto,1fr) と同じで、中身が広いと列が画面幅を超えて膨らむ。
   スマホで横にはみ出す原因になるので、伸縮する列は minmax(0,1fr) で指定する。 */
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-bottom: 12px; }
.form-grid .span2 { grid-column: span 2; }
.form-grid label { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.note-line { margin-top: 10px; line-height: 1.7; }
.row-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.approve-card {
  display: flex; align-items: center; gap: 10px; padding: 12px;
  border: 1px solid var(--s200); border-radius: 12px; margin-bottom: 10px; background: var(--s50);
}
.approve-card input { width: 160px; }
.ap-detail { font-size: 12px; color: var(--s700); margin-top: 4px; white-space: pre-wrap; }
.tbl input, .tbl select { padding: 4px 8px; font-size: 13px; border-radius: 8px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: minmax(0, 1fr); } .form-grid .span2 { grid-column: span 1; } .approve-card { flex-wrap: wrap; } }

/* ---------- AI分析レポート ---------- */
.report-item { border: 1px solid var(--s200); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; background: var(--s50); }
.report-item summary { cursor: pointer; font-size: 13px; }
.report-body { white-space: pre-wrap; font-family: inherit; font-size: 13px; line-height: 1.8; margin-top: 10px; color: var(--s700); }

/* ---------- 給与・料率表 ---------- */
.tbl-scroll { overflow-x: auto; }
.tbl-scroll .tbl { min-width: 1150px; }
.tax-import h4 { font-size: 13px; color: var(--s900); margin: 14px 0 10px; }
details.panel summary { cursor: pointer; font-size: 14px; }

/* ============================================================
   プロジェクト司令塔
   ============================================================ */
.tag-danger { background: #fef2f2; color: var(--red); }
.tag-warn { background: #fffbeb; color: var(--amber); }
.tag-human { background: #fffbeb; color: var(--amber); }
.tag-claude { background: #f0fdfa; color: var(--teal-d); }

.pj-row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.pj-link { font-size: 11px; color: var(--teal-d); text-decoration: none; margin: 0 6px; }
.pj-link:hover { text-decoration: underline; }
.pj-progress-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.pj-progress { width: 220px; margin: 0; }
.pj-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pj-status { font-size: 13px; padding: 6px 8px; }
.pj-status-1 { border-color: #a7f3d0; background: #ecfdf5; }
.pj-status-2 { border-color: #fecaca; background: #fef2f2; }
.pj-status-3 { background: var(--s100); color: var(--s500); }

/* タスク分担レーン */
.lane-heading { margin: 18px 0 8px; }
.lanes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-top: 10px; }
@media (max-width: 800px) { .lanes { grid-template-columns: minmax(0, 1fr); } }
.lane { border: 1px solid var(--s200); border-radius: 12px; overflow: hidden; background: #fff; }
.lane-human { border-top: 3px solid var(--amber); }
.lane-claude { border-top: 3px solid var(--teal); }
.lane-head { padding: 10px 14px; font-weight: 700; font-size: 13px; background: var(--s50); border-bottom: 1px solid var(--s100); }
.lane-head .muted { font-weight: 400; font-size: 11px; margin-left: 6px; }
.task-row { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--s100); flex-wrap: wrap; }
.task-row .grow { min-width: 180px; flex-basis: 55%; }
.task-row:last-child { border-bottom: none; }
.task-row .pj-done-btn { margin-left: auto; white-space: nowrap; font-weight: 600; color: #15803d; border-color: #bbf7d0; }
.task-row .pj-done-btn:hover { background: #f0fdf4; }
/* タスクタブの表でも同じ「完了にする」ボタンを使う(行の右端・操作セル内) */
.pa-actions .pj-done-btn { white-space: nowrap; font-weight: 600; color: #15803d; border-color: #bbf7d0; }
.pa-actions .pj-done-btn:hover { background: #f0fdf4; }
.task-row input[type="date"] { padding: 4px 6px; font-size: 12px; }
.task-title { font-size: 13.5px; }
.task-meta { font-size: 11.5px; margin-top: 2px; }
.task-done .task-title { text-decoration: line-through; color: var(--s400); }
.empty-lane { padding: 14px; font-size: 12px; }

/* 詳細Markdown */
.md-view { line-height: 1.75; font-size: 13.5px; color: var(--s700); }
.md-view .md-h { margin: 16px 0 6px; font-size: 14px; color: var(--s900); }
.md-view p { margin: 6px 0; }
.md-view a { color: var(--teal-d); overflow-wrap: anywhere; }
.md-quote { border-left: 4px solid #99f6e4; background: #f0fdfa; padding: 7px 12px; border-radius: 0 8px 8px 0; margin: 8px 0; }
.md-ul { list-style: none; margin: 6px 0; }
.md-ul li { display: flex; align-items: flex-start; gap: 8px; padding: 2px 0; }
/* 行の本文は必ず1つの塊にする。li は display:flex なので、本文を1要素にまとめないと
   **太字** や `コード` の前後で別のフレックス項目に分かれ、各塊が細い柱に潰れて
   変な位置で折り返す(2026-08 のAI回答の表示崩れの原因)。min-width:0 は
   長いURL・型番があってもはみ出させないため。 */
.md-ul li > .md-li { flex: 1 1 auto; min-width: 0; }
.md-bullet { color: var(--s400); flex-shrink: 0; }
.md-checkbox { background: none; border: none; font-size: 15px; line-height: 1.5; padding: 0; }
.md-checkbox:hover { transform: scale(1.2); }
.md-done { text-decoration: line-through; color: var(--s400); }
.md-mktask { opacity: 0; transition: opacity .15s; }
.md-ul li:hover .md-mktask { opacity: 1; }
.md-tbl { margin: 8px 0; font-size: 12.5px; }

/* Markdown拡張: 見出しの階層 / コード / 番号付き / 水平線 / 静的チェック */
.md-h.md-h1 { font-size: 16.5px; margin-top: 18px; }
.md-h.md-h2 { font-size: 15px; }
.md-h.md-h3 { font-size: 13.8px; }
.md-h.md-h4 { font-size: 13px; color: var(--s700); }
.md-code { background: var(--s100); color: var(--s800); border-radius: 4px; padding: 1px 5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }
.md-pre { background: var(--s900); color: var(--s200); border-radius: 10px; padding: 10px 12px; margin: 8px 0; overflow-x: auto; }
.md-pre code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.6; white-space: pre; }
.md-hr { border: none; border-top: 1px solid var(--s200); margin: 12px 0; }
.md-ol li { align-items: baseline; }
.md-num { color: var(--s400); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.md-cb { color: var(--s400); font-size: 15px; line-height: 1.5; flex-shrink: 0; }
.md-view strong { color: var(--s900); }
.md-view em { font-style: italic; }
.md-view del { color: var(--s400); }
.md-view > *:first-child { margin-top: 0; }
.pj-task-detail { margin-top: 4px; }
.pj-task-detail summary { cursor: pointer; }
.pj-task-detail .md-view { border-left: 2px solid var(--s200); padding: 2px 0 2px 10px; margin: 4px 0 6px; }

/* ガントチャート */
.gantt-wrap { margin-top: 12px; overflow-x: auto; }
.gantt-months { display: flex; margin-left: 180px; border-bottom: 1px solid var(--s200); }
.gantt-months span { flex: 1; font-size: 11px; color: var(--s400); text-align: center; padding-bottom: 4px; border-left: 1px dashed var(--s100); }
.gantt-row { display: flex; align-items: center; min-height: 34px; border-bottom: 1px solid var(--s50); }
.gantt-label { width: 180px; flex-shrink: 0; font-size: 12px; color: var(--s700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 10px; }
.gantt-track { position: relative; flex: 1; height: 30px; background: repeating-linear-gradient(to right, transparent 0, transparent calc(100% / 12 - 1px), var(--s100) calc(100% / 12 - 1px), var(--s100) calc(100% / 12)); }
.gantt-bar { position: absolute; top: 5px; height: 12px; border-radius: 6px; }
.gb-active { background: var(--teal); }
.gb-stalled { background: var(--red); opacity: .7; }
.gb-plan { background: var(--s400); opacity: .6; }
.gb-noend { background: repeating-linear-gradient(45deg, var(--s400), var(--s400) 4px, transparent 4px, transparent 8px); }
.gantt-task { position: absolute; bottom: 4px; height: 5px; border-radius: 3px; }
.gt-human { background: var(--amber); }
.gt-claude { background: var(--teal-d); }
.gt-done { background: var(--s200); }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); opacity: .5; }

/* ============================================================
   チャット
   ============================================================ */
.chat-badge { background: var(--red); color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 6px; margin-left: 5px; vertical-align: 2px; }
/* ---- チャットはブラウザの横幅いっぱいに使う ----
   .content の 1100px 上限をチャットタブだけ外す(body[data-tab] は app.js の
   activateTab が付ける)。サイドバーは 250px 固定なので、残りすべてが本文(会話)に
   なり、窓幅を変えると本文がそのまま伸縮する。 */
body[data-tab="chat"] main.content { max-width: none; }
@media (min-width: 781px) {
  /* チャットタブは1画面で完結させる(2026-08): パネルの高さをブラウザの表示高さから決め、
     チャンネル一覧・DM一覧・会話はその中で内部スクロールする。ページ自体が伸びないので
     DM欄と注記が必ずサイドバーの下側に見える。
     168px = トップバー56 + .content上余白28 + 見出し46 + 下余白16 + 余裕22 */
  body[data-tab="chat"] main.content { padding-bottom: 16px; }
  body[data-tab="chat"] .chat-wrap { height: calc(100dvh - 168px); min-height: 360px; }
  body[data-tab="chat"] .chat-wrap .chat-main { min-height: 0; }
  body[data-tab="chat"] .chat-wrap .chat-messages { max-height: none; }
}
.chat-wrap { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 0; padding: 0; overflow: hidden; min-height: 480px; }
@media (max-width: 760px) { .chat-wrap { grid-template-columns: minmax(0, 1fr); } .chat-users { border-right: none; border-bottom: 1px solid var(--s200); } }
.chat-users { border-right: 1px solid var(--s200); background: var(--s50); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat-users-head { padding: 12px 14px; font-weight: 700; font-size: 13px; border-bottom: 1px solid var(--s200); }
.chat-sec { padding: 12px 14px 6px; font-weight: 700; font-size: 11px; color: var(--s500); letter-spacing: .05em; flex: none; }
.chat-user { display: flex; align-items: center; gap: 9px; padding: 11px 14px; cursor: pointer; border-bottom: 1px solid var(--s100); }
.chat-user:hover { background: var(--s100); }
.chat-user.active { background: #fff; box-shadow: inset 3px 0 0 var(--teal); }
.chat-user-name { font-size: 13.5px; font-weight: 600; }
.chat-user-sub { font-size: 11px; }
.chat-unread { background: var(--red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
/* 会話を開いた時点で未読だった位置の区切り線(2026-09-04) */
.chat-unread-line { display: flex; align-items: center; gap: 8px; margin: 12px 2px 6px; color: var(--red); font-size: 11px; font-weight: 700; }
.chat-unread-line::before, .chat-unread-line::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--red); opacity: .45; }
.chat-unread-line span { flex: none; }
.chat-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--s200); flex-shrink: 0; }
.chat-dot.on { background: #22c55e; }
.chat-hash { color: var(--s400); font-weight: 800; width: 14px; text-align: center; flex-shrink: 0; }
/* チャンネル一覧はサイドバーの余りをすべて使う(2026-08: 240px固定で数件しか見えなかった)。
   flex-basis:0 にして「余りを全部取る」ようにしたので、下のDM一覧・注記は
   チャンネル件数に関係なく必ずサイドバーの下側に残る */
.chat-ch-list { flex: 1 1 0; min-height: 96px; overflow-y: auto; }
.chat-users > .chat-search-list { flex: 1 1 auto; min-height: 0; max-height: none; }
.chat-search-row { flex: none; }
/* DM一覧: 中身の高さまで。多いときはサイドバーの45%で頭打ちにして内部スクロール */
#chatUserList { flex: 0 1 auto; min-height: 72px; max-height: 45%; overflow-y: auto; }
.chat-note-box { flex: none; margin-top: auto; border-top: 1px solid var(--s200); }
.chat-note-box > summary { padding: 9px 14px; cursor: pointer; font-size: 11.5px; color: var(--s500); list-style: none; }
.chat-note-box > summary::-webkit-details-marker { display: none; }
.chat-note-box > summary:hover, .chat-note-box[open] > summary { color: var(--s700); }
.chat-note { padding: 0 14px 12px; margin-top: 0; max-height: 42vh; overflow-y: auto; font-size: 11.5px; }
.chat-main { display: flex; flex-direction: column; min-height: 480px; min-width: 0; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--s200); font-size: 14px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; max-height: 55vh; }
.chat-msg { max-width: min(72%, 1100px); }
.chat-msg.mine { align-self: flex-end; text-align: right; }
.chat-msg.theirs { align-self: flex-start; }
.chat-sender { font-size: 11px; color: var(--s500); margin: 0 2px 2px; font-weight: 600; }
.chat-bubble { display: inline-block; padding: 9px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.6; text-align: left; word-break: break-word; }
.mine .chat-bubble { background: var(--teal); color: #fff; border-bottom-right-radius: 4px; }
.theirs .chat-bubble { background: var(--s100); color: var(--s800); border-bottom-left-radius: 4px; }
.chat-time { font-size: 10px; margin-top: 3px; }
/* 既読の印(自分の投稿の時刻の左。押すと誰が読んだか出る) */
.chat-read { margin-right: 6px; color: var(--teal); font-weight: 600; cursor: pointer; }
.chat-input-row { display: flex; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--s200); }
/* スマホ用の「☰ 一覧 / 会話」切り替えバー(PCでは非表示。chat.jsが挿入) */
.chat-mobile-bar { display: none; }

/* ホーム(共同編集ホワイトボード) */
.chat-convo { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-home { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 14px 18px 18px; }
.chat-home-head { font-size: 12px; padding-bottom: 10px; }
.wb-editor .ds-blocks { min-height: 260px; }
.wb-editor .ds-title { background: transparent; border-color: transparent; }
.wb-editor .ds-title:hover, .wb-editor .ds-title:focus { border-color: var(--s200); background: #fff; }

/* プロジェクト詳細内チャット */
.pj-chat-messages { max-height: 380px; min-height: 180px; border: 1px solid var(--s200); border-radius: 12px; background: var(--s50); margin-bottom: 4px; }
#pjTab-chat .chat-input-row { border-top: none; padding: 8px 0 0; }

/* 司令塔: まとめ・タブ・履歴・スケジュール */
.pj-summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-bottom: 16px; }
@media (max-width: 860px) { .pj-summary { grid-template-columns: minmax(0, 1fr); } }
.pj-sum-row { display: flex; align-items: flex-start; gap: 9px; padding: 7px 2px; border-bottom: 1px solid var(--s100); }
.pj-sum-row:last-child { border-bottom: none; }
.pj-sum-ic { width: 22px; text-align: center; flex-shrink: 0; }
.pj-sum-t { font-size: 13px; }
.pj-sum-sub { font-size: 11px; }
.pj-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--s100); margin: 12px 0 14px; }
.pj-tabs button { background: none; border: none; padding: 8px 14px; font-size: 13px; color: var(--s500); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.pj-tabs button:hover { color: var(--s800); }
.pj-tabs button.active { color: var(--s900); font-weight: 700; border-bottom-color: var(--teal); }
.pj-tabhead { margin-bottom: 8px; }
.gantt-ms { position: absolute; top: -1px; font-size: 11px; color: var(--violet, #7c3aed); transform: translateX(-50%); color: #7c3aed; }
.gantt-ms.gm-done { color: var(--s400); }

/* ---------- 司令塔拡張2: まとめ / リポジトリ / 部品表 ---------- */
.pj-digest { border: 1px solid #99f6e4; background: #f0fdfa; border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; }
.pj-digest-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.pj-repos { margin-top: 20px; border-top: 1px solid var(--s100); padding-top: 12px; }
.repo-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 2px; border-bottom: 1px solid var(--s100); }
.repo-row:last-child { border-bottom: none; }
.repo-activity { font-size: 12px; margin-top: 4px; line-height: 1.8; }
.repo-commit code { background: var(--s100); border-radius: 4px; padding: 0 5px; font-size: 11px; }
.parts-tbl { width: 100%; }
.parts-tbl input, .parts-tbl select { padding: 4px 6px; font-size: 12.5px; border-radius: 6px; width: 100%; min-width: 70px; }
.parts-tbl .pa-num, .pa-num { width: 84px; text-align: right; }
.parts-tbl td { vertical-align: middle; }
.ta-r { text-align: right; }
.pa-actions { white-space: nowrap; }
.pa-st-1 { border-color: #fde68a; background: #fffbeb; }
.pa-st-2 { border-color: #a7f3d0; background: #ecfdf5; }
.pa-st-3 { background: var(--s100); color: var(--s500); }

/* ---------- タスクタブ: 作業内容の補足(Markdown表示 ⇄ 原文編集) ---------- */
.tk-detail-row td { background: var(--s50); white-space: normal; }
.tk-dhead { margin-bottom: 6px; }
.tk-dview { background: #fff; border: 1px solid var(--s200); border-radius: 10px; padding: 10px 12px; min-height: 42px; white-space: normal; }
.tk-dedit textarea { min-height: 150px; }
.tk-dbtns { margin-top: 8px; }

/* ---------- 司令塔拡張2: 共同編集ドキュメント ---------- */
.ds-head { align-items: center; }
.ds-title { font-weight: 700; font-size: 16px; }
.ds-presence { display: flex; gap: 4px; font-size: 12px; flex-wrap: wrap; }
.ds-user { background: #ecfdf5; border: 1px solid #a7f3d0; color: var(--teal-d); border-radius: 999px; padding: 2px 10px; }
.ds-blocks { border: 1px solid var(--s200); border-radius: 12px; background: #fff; padding: 12px 10px; min-height: 140px; }
.ds-block { display: flex; align-items: flex-start; gap: 6px; padding: 2px 4px; border-radius: 8px; }
.ds-block:hover { background: var(--s50); }
.ds-handle { cursor: grab; color: var(--s400); font-size: 13px; padding: 5px 2px 0; user-select: none; }
.ds-type { opacity: 0; font-size: 11px; padding: 2px 4px; max-width: 96px; transition: opacity .15s; }
.ds-block:hover .ds-type, .ds-block:hover .ds-del, .ds-type:focus { opacity: 1; }
.ds-del { opacity: 0; transition: opacity .15s; }
.ds-content { outline: none; padding: 4px 6px; min-height: 1.6em; line-height: 1.7; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.ds-content:focus { background: #fff; box-shadow: inset 0 0 0 1px var(--s200); border-radius: 6px; }
.ds-content[contenteditable="false"] { color: var(--s500); cursor: not-allowed; }
.ds-h1 { font-size: 20px; font-weight: 800; }
.ds-h2 { font-size: 17px; font-weight: 700; }
.ds-h3 { font-size: 15px; font-weight: 700; }
.ds-divider { border: none; border-top: 2px solid var(--s200); margin: 12px 0; }
.ds-lock { font-size: 11px; color: #b45309; background: #fffbeb; border: 1px solid #fde68a; border-radius: 999px; padding: 2px 8px; white-space: nowrap; margin-top: 5px; }
.ds-lockedrow { opacity: .75; }
.ds-dragging { opacity: .4; }
.ds-dropover { box-shadow: 0 2px 0 0 var(--teal); }

/* ブロックのMarkdown整形表示(クリックすると原文編集に切り替わる) */
.ds-md { padding: 4px 6px; min-height: 1.6em; line-height: 1.7; font-size: 14px; cursor: text; word-break: break-word; color: inherit; }
.ds-md:hover { background: #fff; box-shadow: inset 0 0 0 1px var(--s100); border-radius: 6px; }
.ds-md p { margin: 2px 0; }
.ds-md .md-h { margin: 4px 0 2px; }
.ds-md .md-ul, .ds-md .md-tbl { margin: 4px 0; }
.ds-md > *:first-child { margin-top: 0; }
.ds-md > *:last-child { margin-bottom: 0; }
.ds-md a { color: var(--teal-d); word-break: break-all; }
.ds-md strong { color: var(--s900); }
.ds-md em { font-style: italic; }
.ds-md del { color: var(--s400); }
.ds-ph { color: var(--s400); font-weight: 400; font-size: 13px; }
.ds-lockedrow .ds-md { cursor: not-allowed; }

/* 📝 Markdownモード(ドキュメント全体を1枚のMarkdownとして編集) */
.ds-mdwrap { border: 1px solid var(--s200); border-radius: 12px; background: #fff; padding: 12px; }
.ds-mdtext {
  width: 100%; box-sizing: border-box; min-height: 420px; resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans Mono CJK JP", monospace;
  font-size: 13px; line-height: 1.7; tab-size: 2;
  border: 1px solid var(--s200); border-radius: 8px; padding: 10px 12px; color: var(--s900);
}
.ds-mdtext:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 2px #ccfbf1; }
.ds-mdbtns { align-items: center; margin-top: 10px; }
.ds-mddl { text-decoration: none; }
.ds-mdwarn { white-space: normal; }
.ds-mdwrap .note-line code { background: var(--s100); border-radius: 4px; padding: 0 4px; }
@media (max-width: 780px) { .ds-mdtext { min-height: 300px; font-size: 12px; } }

/* ============================================================
   スマホ表示対応(レスポンシブ)
   ※ 後方の定義が優先されるため、必ずファイル末尾に置く
   ============================================================ */

/* ---- タブレット(横幅狭め)---- */
@media (max-width: 1000px) {
  .content { padding: 22px 16px 56px; }
  .tabs button { padding: 18px 10px; font-size: 13px; }
  .topbar { gap: 14px; padding: 0 16px; }
}

/* ---- スマホ ---- */
@media (max-width: 780px) {

  /* --- トップバー: 上段=ブランド+ユーザー / 下段=タブ横スクロール --- */
  .topbar {
    display: grid; align-items: center; gap: 0; height: auto; overflow: visible;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand right" "tabs tabs";
    padding: env(safe-area-inset-top) 0 0;
  }
  .brand { grid-area: brand; padding: 11px 12px; font-size: 15px; gap: 8px; }
  .brand-logo { height: 13px; }
  .top-right { grid-area: right; padding: 11px 12px; gap: 8px; font-size: 12px; }
  .top-right a { font-size: 12px; padding: 4px 2px; }
  #userName { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #logout { padding: 6px 10px; }
  .tabs {
    grid-area: tabs; flex: none; gap: 2px; padding: 0 8px;
    border-top: 1px solid var(--s700); overflow-x: auto;
    scroll-snap-type: x proximity;
  }
  .tabs button { padding: 11px 11px; font-size: 13px; scroll-snap-align: start; }

  /* --- 全体レイアウト --- */
  .content { padding: 14px 12px calc(40px + env(safe-area-inset-bottom)); }
  .sec-head { flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
  .sec-head h2 { font-size: 17px; }
  .sec-head > div { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  .panel { padding: 14px 13px; border-radius: 12px; margin-bottom: 12px; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
  .card { padding: 13px 14px; }
  .card-num { font-size: 18px; }
  .card-label { font-size: 11px; }
  .login-card { padding: 28px 22px; margin: 16px; width: 100%; max-width: 380px; }

  /* --- 入力・ボタン: iOSのフォーカス時ズーム防止(16px以上)+タップ領域確保 
--- */
  input, select, textarea { font-size: 16px; min-height: 42px; }
  input[type="checkbox"], input[type="radio"] { min-height: 0; width: 20px; height: 20px; }
  input[type="file"] { min-height: 0; padding: 8px; max-width: 100%; }
  .btn-primary, .btn-secondary { min-height: 42px; font-size: 14px; padding: 10px 16px; }
  .mini-btn { min-height: 34px; padding: 6px 11px; font-size: 12px; }
  .year-sel { font-size: 14px; min-height: 38px; padding: 6px 8px; }

  /* --- フォーム行: 1カラムに縦積み --- */
  .form-row { gap: 8px; }
  .form-row > input, .form-row > select, .form-row > textarea { flex: 1 1 100%; min-width: 0; }
  .form-row > label { flex: 1 1 100%; display: flex; align-items: center; gap: 8px; }
  .form-row > label input, .form-row > label select { flex: 1; min-width: 0; }
  .form-row > button { flex: 1 1 auto; }
  .form-row > span, .form-row > div { min-width: 0; }
  .grow { min-width: 0; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span2 { grid-column: span 1; }
  /* インラインstyleの margin-left:auto を無効化(縦積み時に崩れるため) */
  .form-row > [style*="margin-left:auto"], .form-row > [style*="margin-left: auto"] { margin-left: 0 !important; }
  #pjSpecEditBtn { margin-left: 0 !important; }
  textarea { min-height: 120px; }
  #pjDetailText, #pjSpecText, #minutesText { height: 44vh; }

  /* --- テーブル: 横スクロール化(セル内改行を止めてはみ出させる) --- */
  .tbl { display: block; width: 100%; overflow-x: auto; white-space: nowrap; font-size: 12.5px; }
  .tbl th { font-size: 10.5px; padding: 7px 8px; }
  .tbl td { padding: 8px 8px; }
  .tbl input, .tbl select { font-size: 16px; min-height: 34px; padding: 4px 6px; }
  /* 既に外側でスクロールしているものは元の挙動を維持 */
  .tbl-scroll .tbl { display: table; white-space: nowrap; }
  .parts-tbl input, .parts-tbl select { font-size: 16px; min-width: 84px; }
  .parts-tbl .pa-num, .pa-num { width: 92px; }
  .md-tbl { display: block; overflow-x: auto; white-space: nowrap; }
  /* 作業内容の補足は長文なので改行させる */
  .tk-detail-row td, .tk-dview, .tk-dedit { white-space: normal; }
  .tk-dview { font-size: 13px; }

  /* --- タスク一覧タブ: 9列の表は横スクロールが長くなりすぎるので、
         1件=1カードになるよう折り返す(横スクロールなし)
         ※列の並び(2026-09-02 実測): 1選択 / 2📝 / 3タスク名 / 4プロジェクト /
           5状態 / 6優先 / 7担当 / 8期限 / 9操作。
           もとは8列で、5列目に「状態」が入ったあともこの割り当てが8列のまま
           だったため、3列目(タスク名)に flex:0 0 auto が当たって縮まず、
           9列目(操作=ボタン5個・nowrap)にはどの規則も当たらず、行が端末幅を
           超えてタスク画面全体が横に広がっていた(#2619)。 --- */
  #tkList .tbl, #tkList .tbl tbody { display: block; overflow-x: visible; white-space: normal; }
  #tkList .tbl tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 10px 2px; border-bottom: 1px solid var(--s200); }
  #tkList .tbl td { display: block; border: none; padding: 0; white-space: normal; min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
  /* ヘッダ行は「すべて選択」だけ残す */
  #tkList .tbl tr:first-child { padding: 2px 2px 10px; }
  #tkList .tbl tr:first-child th { display: none; }
  #tkList .tbl tr:first-child th:first-child { display: flex; align-items: center; gap: 8px; border: none; padding: 0; font-size: 11.5px; }
  #tkList .tbl tr:first-child th:first-child::after { content: "表示中をすべて選択"; }
  /* 1行目: 選択 / 📝 / タスク名  2行目: プロジェクト  3行目: 状態・優先・担当・期限  4行目: 操作 */
  #tkList .tbl td:nth-child(1) { order: 1; flex: 0 0 auto; }
  #tkList .tbl td:nth-child(2) { order: 2; flex: 0 0 auto; }
  #tkList .tbl td:nth-child(3) { order: 3; flex: 1 1 60%; min-width: 0; font-size: 13.5px; line-height: 1.55; }
  #tkList .tbl td:nth-child(4) { order: 4; flex: 1 1 100%; min-width: 0; font-size: 11.5px; }
  #tkList .tbl td:nth-child(5) { order: 5; flex: 1 1 46%; min-width: 132px; }
  #tkList .tbl td:nth-child(6) { order: 6; flex: 1 1 46%; min-width: 110px; }
  #tkList .tbl td:nth-child(7) { order: 7; flex: 1 1 46%; min-width: 132px; }
  #tkList .tbl td:nth-child(8) { order: 8; flex: 1 1 46%; min-width: 132px; }
  #tkList .tbl td:nth-child(9) { order: 9; flex: 1 1 100%; min-width: 0; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; white-space: normal; }
  /* 補足(📝)・スレッド(💬)の展開行は横幅いっぱい */
  #tkList .tbl .tk-detail-row, #tkList .tbl .tk-chat-row { padding: 0 0 10px; }
  #tkList .tbl .tk-detail-row td:first-child, #tkList .tbl .tk-chat-row td:first-child { display: none; }
  #tkList .tbl .tk-detail-row td:last-child, #tkList .tbl .tk-chat-row td:last-child { order: 0; flex: 1 1 100%; min-width: 0; }
  /* 絞り込みセレクトは2列に(320px幅の端末でも2列が収まる下限にする) */
  #tkFilterRow > select { flex: 1 1 46%; min-width: 140px; }
  /* 列がまた増えても端末幅を超えないようにする最後の砦。
     overflow-x: clip はスクロール枠を作らないので sticky/fixed を壊さない */
  #tasksRoot { min-width: 0; max-width: 100%; overflow-x: clip; }

  /* --- プロジェクト司令塔 --- */
  .pj-row { gap: 10px; }
  .pj-progress-row { flex-wrap: wrap; }
  .pj-progress { width: 100%; }
  .pj-controls { width: 100%; }
  .pj-controls .pj-status { flex: 1 1 auto; }
  .pj-tabs { overflow-x: auto; scrollbar-width: none; gap: 0; }
  .pj-tabs::-webkit-scrollbar { display: none; }
  .pj-tabs button { white-space: nowrap; padding: 9px 10px; font-size: 12.5px; }
  .task-row { gap: 8px; padding: 10px 12px; }
  .task-row .grow { flex-basis: 100%; min-width: 0; }
  .task-row input[type="date"] { font-size: 16px; min-height: 34px; }
  .lane-head { font-size: 12.5px; }
  .lane-head .muted { display: block; margin-left: 0; margin-top: 2px; }
  .repo-row { flex-wrap: wrap; }
  .approve-card { flex-wrap: wrap; }
  .approve-card input { width: 100%; }
  .md-view { font-size: 13px; }
  .md-mktask { opacity: 1; }
  .md-pre code { font-size: 11.5px; }

  /* --- ガントチャート: ラベル幅を詰めて横スクロール --- */
  .gantt-wrap { padding-bottom: 8px; }
  .gantt-months { margin-left: 104px; min-width: 496px; }
  .gantt-months span { font-size: 10px; }
  .gantt-row { min-width: 600px; }
  .gantt-label { width: 104px; font-size: 11px; padding-right: 6px; }

  /* --- 共同編集ドキュメント: 常時操作可(hover非対応のため) --- */
  .ds-type, .ds-del { opacity: 1; }
  .ds-title { font-size: 15px; }
  .ds-content { font-size: 16px; }
  .ds-md { font-size: 16px; }
  .ds-h1 { font-size: 19px; }
  .ds-h2 { font-size: 17px; }

  /* --- チャット: 「一覧(縦スクロール)」⇄「会話」の切り替え表示 ---
     以前はチャンネル・DMを横並びの帯にしていたが、件数が増えると横スクロールが
     長くなりすぎて指で追えないため、縦一列に戻して画面を切り替える方式にした --- */
  .chat-wrap { display: block; min-height: 0; }
  .chat-mobile-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--s200); }
  .chat-mobile-bar .mini-btn { min-height: 36px; font-weight: 700; }
  .chat-users { display: none; flex-direction: column; border-right: none; border-bottom: none; overflow: visible; }
  .chat-wrap.chat-showlist .chat-users { display: flex; }
  .chat-wrap.chat-showlist .chat-main { display: none; }
  .chat-users-head { display: none; }
  .chat-sec { padding: 10px 12px 2px; }
  #chatUserList, #chatChannelList { display: block; overflow-x: visible; flex: none; max-height: none; overflow-y: visible; }
  .chat-ch-list { flex: none; max-height: none; overflow-y: visible; }
  /* 一覧を出しているときは、サイドバー全体を画面の高さに収める(2026-08)。
     以前はチャンネル一覧が全件伸びていたため、DM欄はページを下までスクロール
     しないと出てこなかった。チャンネル一覧だけを内側スクロールにして、
     DM欄と注記は常に画面内の下側に見えるようにする。
     150px = トップバー + 見出し + ☰バー + 検索欄 + 下余白の目安 */
  .chat-wrap.chat-showlist .chat-users {
    height: calc(100dvh - 150px); min-height: 320px; overflow: hidden;
  }
  .chat-wrap.chat-showlist #chatChannelList { flex: 1 1 0; min-height: 110px; overflow-y: auto; overscroll-behavior: contain; }
  .chat-wrap.chat-showlist #chatSearchList:not(.hidden) { flex: 1 1 0; min-height: 110px; overflow-y: auto; overscroll-behavior: contain; }
  .chat-wrap.chat-showlist #chatUserList { flex: 0 1 auto; min-height: 62px; max-height: 38%; overflow-y: auto; overscroll-behavior: contain; }
  .chat-wrap.chat-showlist .chat-note-box { flex: none; margin-top: 0; }
  .chat-user { border-bottom: 1px solid var(--s200); border-right: none; white-space: normal; padding: 12px; }
  .chat-user.active { box-shadow: inset 3px 0 0 var(--teal); }
  .chat-user-name, .chat-user-sub { word-break: break-word; }
  .chat-note-box { margin-top: 12px; }
  .chat-note { max-height: none; overflow-y: visible; }
  .chat-main { min-height: 60vh; }
  .chat-messages { max-height: none; padding: 12px; }
  .chat-msg { max-width: 86%; }
  .chat-input-row { padding: 10px; gap: 8px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .chat-input-row > input { flex: 1; min-width: 0; }
  .chat-input-row > button { flex: 0 0 auto; }
  .chat-home { padding: 10px 12px 14px; }
  .pj-chat-messages { max-height: 50vh; }
  #pjTab-chat .chat-input-row { padding: 8px 0 0; }
}

/* ---- 小型スマホ ---- */
@media (max-width: 400px) {
  .content { padding: 12px 10px calc(36px + env(safe-area-inset-bottom)); }
  .cards { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .card-num { font-size: 17px; }
  .panel { padding: 12px 11px; }
  .brand { font-size: 14px; }
  /* 幅が足りないので会社ロゴだけ残す */
  .brand-os { display: none; }
  #userName { max-width: 68px; }
  .top-right a { display: none; }
}

/* ---- タッチ端末: hover前提の隠し要素を常時表示 ---- */
@media (hover: none) {
  .md-mktask, .ds-type, .ds-del { opacity: 1; }
  .md-checkbox:hover { transform: none; }
  .ds-md:hover { background: none; box-shadow: none; }
}

/* ---- 印刷 ---- */
@media print {
  .topbar, .tabs, .form-row button, .mini-btn { display: none !important; }
  .content { padding: 0; max-width: none; }
  .panel { break-inside: avoid; border-color: #ccc; }
}

/* イベントCRM: 一覧の中でその場で直す小さな入力 */
.mini-sel { font-size: 12px; padding: 2px 4px; }
.mini-input { font-size: 12px; padding: 2px 4px; width: 120px; }

/* ============================================================
   タスク一覧タブ: ブラウザ幅に合わせて広げ、タスク名の列を広く取る(2026-08-07)
   ・.content の 1100px 上限をタスクタブだけ外す(チャットタブと同じ作法。
     body[data-tab] は app.js の activateTab が付ける)
   ・表は table-layout:fixed。チェック/状態/優先/担当/期限/操作を固定幅にし、
     余った幅をすべて「タスク」列(3列目)に回す。タスク名は折り返す
   ・780px以下は既存の「1件=1カード」表示のままなので触らない
   ============================================================ */
@media (min-width: 781px) {
  body[data-tab="tasks"] main.content { max-width: none; }
  #tkList .tbl { table-layout: fixed; width: 100%; }
  #tkList .tbl th:nth-child(1), #tkList .tbl td:nth-child(1) { width: 32px; }
  #tkList .tbl th:nth-child(2), #tkList .tbl td:nth-child(2) { width: 40px; }
  /* 3列目(タスク)は幅を指定しない = 残り幅をすべて受け取る */
  #tkList .tbl th:nth-child(4), #tkList .tbl td:nth-child(4) { width: 13%; }
  #tkList .tbl th:nth-child(5), #tkList .tbl td:nth-child(5) { width: 112px; }
  #tkList .tbl th:nth-child(6), #tkList .tbl td:nth-child(6) { width: 92px; }
  #tkList .tbl th:nth-child(7), #tkList .tbl td:nth-child(7) { width: 132px; }
  #tkList .tbl th:nth-child(8), #tkList .tbl td:nth-child(8) { width: 150px; }
  #tkList .tbl th:nth-child(9), #tkList .tbl td:nth-child(9) { width: 232px; }
  /* 固定幅にすると溢れるので、セルは折り返す(横スクロールを出さない) */
  #tkList .tbl td { white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
  #tkList .tbl td:nth-child(3) { line-height: 1.6; }
  #tkList .tbl td.pa-actions { white-space: normal; text-align: right; }
  #tkList .tbl td.pa-actions .mini-btn { margin: 1px 0 1px 2px; }
  /* 補足行・チャット行は colspan なので幅指定を効かせない */
  #tkList .tbl .tk-detail-row td, #tkList .tbl .tk-chat-row td { width: auto; }
}


/* タスクタブのダッシュボード: 担当カードの中のAI操作ボタン
   (🤖 Claudeの ▶即時実行 / 人・未割当の 🧾AI棚卸し・🤖AIで片付ける)
   カード自体はクリックで絞り込みになるので、ボタンは押せることが分かる見た目にする */
/* タスクタブの担当カードと、プロジェクトダッシュボードの担当レーンで共用する */
.tk-card-acts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tk-actbtn { flex: 1 1 auto; background: #fff; cursor: pointer; white-space: nowrap; }
.tk-actbtn:hover:not(:disabled) { background: var(--s100, #f1f5f9); color: var(--s900); }
.tk-actbtn:disabled { opacity: .55; cursor: default; }
.tk-card-note { font-size: 11px; margin-top: 4px; }
/* ダッシュボードのレーンでは一覧の上に置くので、下に余白を入れて行と離す */
.pd-lane-acts { margin: 0 0 8px; }
.pd-lane-acts .tk-card-acts { margin-top: 0; }
