/* ══════════════════════════════════════════════════════════════════
   金継ぎ 追補スタイル — DIY施工管理（Cloudflare Workers版）
   2026-09-11 「現場手帳」への刷新ぶん。
   元のCSS（style.css）は1行も変更せず、このファイルを後ろに重ねて上書きする形にしている。
   読み込みは src/views/layout.ts の style.css の次の行（staticV("kintsugi-repair.css")）。

   並びは 「① トークン → ② 共通部品 → ③ 画面固有 → ④ レスポンシブ」 の4段。
   足したくなったら、まず①のトークンで足りないか考える。
   ══════════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════════════
   ① トークン（値だけ差し替える。変数名は style.css のものを引き継ぐ）
   ══════════════════════════════════════════════════════════════════ */
:root {
  /* ---- 面と文字 */
  --bg: #f4f3ed;            /* ページの地（温かい薄灰） */
  --bg2: #eeeee7;           /* 面の中の面 */
  --card: #ffffff;          /* 白い作業面 */
  --ink: #242923;           /* 墨色の文字 */
  --sub: #5b625a;           /* 補足 */
  --line: #d5d8cf;          /* 装飾的な区切り */
  --control-line: #858a82;  /* 入力欄・操作の境界（白地で約3.5:1） */

  /* ---- 操作と状態 */
  --accent: #17624a;        /* 主操作・進捗だけに使う深緑 */
  --accent-hover: #104c39;
  --accent2: #e7f0e9;
  --ok: #17624a;
  --blue: #245f8c;
  --bluebg: #e8f0f7;
  --warn: #8a4b13;
  --warnbg: #fff2df;
  --danger: #a12f28;
  --dangerline: #b9574d;
  --dangerbg: #fff0ee;
  --focus: #245f8c;

  /* ---- 文字（外部フォントは使わない。数字は等幅で揃える） */
  --font-ui: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo",
             system-ui, sans-serif;
  --fs: 16px;               /* 本文 */
  --fs-sm: 14px;            /* 補足 */
  --fs-xs: 13px;            /* バッジ・下タブ */
  --fs-h1: 24px;
  --fs-h2: 18px;            /* 作業名と同じ段 */
  --fs-h3: 16px;
  --fs-number: 32px;        /* 大きい数字 */
  --lh-body: 1.6;
  --lh-heading: 1.35;

  /* ---- 余白 */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;

  /* ---- 角丸・影（影は原則なし。シートだけ） */
  --r1: 6px;                /* 入力・ボタン */
  --r2: 10px;               /* 作業面 */
  --r-sheet: 16px;
  --r-pill: 999px;
  --sh1: none;
  --sh2: 0 12px 32px rgb(36 41 35 / 16%);

  /* ---- 操作寸法・レイアウト */
  --tap: 48px;
  --tap-compact: 44px;
  --tabbar-h: 64px;
  --content-form: 720px;
  --content-today: 1040px;
  --content-plan: 1280px;

  /* ---- ガントの列幅（PC。スマホは④で上書き） */
  --gname-w: 180px;
  --gday-w: 36px;
}

/* ══════════════════════════════════════════════════════════════════
   ② 共通部品
   ══════════════════════════════════════════════════════════════════ */

/* ---- 本文。数字は等幅にして桁を揃える */
body {
  font-family: var(--font-ui);
  font-size: var(--fs);
  line-height: var(--lh-body);
  font-variant-numeric: tabular-nums;
}

/* ---- 見出し */
h1 { font-size: var(--fs-h1); line-height: var(--lh-heading); font-weight: 700;
     margin: var(--s2) 0 var(--s3); }
h2 { font-size: var(--fs-h2); line-height: var(--lh-heading); font-weight: 700;
     margin: 0 0 var(--s2); }
h3 { font-size: var(--fs-h3); line-height: var(--lh-heading); font-weight: 700;
     margin: 0 0 var(--s2); }

/* ---- ヘッダー: 黒帯をやめて白＋下罫線に */
.topbar {
  background: var(--card);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  padding: var(--s2) var(--s4);
}
.topbar .brand { color: var(--ink); font-weight: 700; font-size: 17px; }
.topnav a { color: var(--sub); font-size: var(--fs-sm); }
.topnav a:hover { color: var(--ink); }

/* デモ帯は残す（環境の注意書きなので目立ってよい） */
.demobar { background-color: #242923; color: #ffe6c7; font-size: var(--fs-xs); }

/* ---- 物件名バー（右端に現在ページ名） */
.projnav { padding: var(--s2) var(--s4); }
.projrow { display: flex; align-items: baseline; gap: var(--s3); justify-content: space-between; }
.projname { font-weight: 700; font-size: 17px; line-height: 1.4; min-width: 0;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.projpage { font-size: var(--fs-sm); color: var(--sub); flex: 0 0 auto; }
.projlink { font-size: var(--fs-sm); min-height: var(--tap-compact); }

/* ---- 本文の幅は用途で分ける */
.wrap { max-width: 1000px; padding: var(--s4); }
.wrap[data-page="today"] { max-width: var(--content-today); }
.wrap[data-page="calendar"],
.wrap[data-page="gantt"],
.wrap[data-page="tasks"],
.wrap[data-page="kanban"],
.wrap[data-page="materials"] { max-width: var(--content-plan); }
.wrap[data-page="form"] { max-width: var(--content-form); }

/* ---- 面: 影をやめて、区切りは余白と罫線で作る */
.card {
  border-radius: var(--r2);
  box-shadow: none;
  padding: var(--s4);
  margin-bottom: var(--s5);
}
/* 枠も背景も持たない「素の入れ物」。中の作業カードを主役にしたいときに使う */
.card[data-plain="1"] {
  background: transparent; border: 0; padding: 0; box-shadow: none;
}

/* ---- 補足文字は役割ごとの段に（一律12pxの上書きはやめた） */
.muted, .jobsub, .kmeta, .kvendor, .moredesc, .picksub, .knote, .khint,
.streaknote, .weekdelta, .dphint, .dpmeta, .sheetsub, .sheethint {
  font-size: var(--fs-sm);
  color: var(--sub);
}
.badge, .tabitem, .tablabel, .badgeprog, .roomtabn, .counthint,
.jobroom, .pickroom, .sheetroom, .picknote { font-size: var(--fs-xs); }
.stat .lbl, .striplbl { font-size: var(--fs-xs); color: var(--sub); }

/* ---- 大きい数字 */
.housepct { font-size: var(--fs-number); }
.housepct small { font-size: var(--fs-sm); }
.weekval, .stat .val { font-size: 24px; }
.stripval { font-size: var(--fs-h2); }

/* ---- ボタンの階層。主＝深緑の塗り／補助＝白地＋境界線／危険＝白地＋赤文字 */
button, .btn {
  min-height: var(--tap);
  font-size: var(--fs-sm);
  border-radius: var(--r1);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
button:hover, .btn:hover { opacity: 1; background: var(--accent-hover);
                           border-color: var(--accent-hover); }
/* 補助（.btn.sub の指定漏れを埋める） */
.btn-sub, button.sub, .btn.sub, a.sub {
  background: var(--card); color: var(--ink); border-color: var(--control-line);
  font-weight: 400;
}
.btn-sub:hover, button.sub:hover, .btn.sub:hover, a.sub:hover {
  background: var(--bg2); color: var(--ink); border-color: var(--control-line); opacity: 1;
}
/* 危険 */
.btn-danger, button.danger, .btn.danger {
  background: var(--card); color: var(--danger); border-color: var(--dangerline);
  font-weight: 400;
}
.btn-danger:hover, button.danger:hover, .btn.danger:hover {
  background: var(--dangerbg); color: var(--danger); border-color: var(--dangerline);
}
/* 表の中の小さいボタンも、現場で押せる高さは確保する */
button.mini, .btn.mini {
  min-height: var(--tap-compact); padding: var(--s2) var(--s3); font-size: var(--fs-xs);
}

/* ---- 入力欄。境界をはっきりさせ、文字は16px（iOSの自動ズーム対策も兼ねる） */
input[type=text], input[type=number], input[type=date], input[type=search],
select, textarea {
  border-color: var(--control-line);
  font-size: var(--fs);
  min-height: var(--tap);
  border-radius: var(--r1);
}
label { font-size: var(--fs-sm); }
:root { --focus-ring: var(--focus); }
a:focus-visible, button:focus-visible, .btn:focus-visible, summary:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---- バッジ（角丸は状態ラベルだけ丸のまま） */
.badge { border-radius: var(--r-pill); padding: 2px 10px; }
.badge.done { border-color: #b6ddcb; color: var(--ok); background: var(--accent2); }
.badge.todo { background: var(--bg2); color: var(--sub); }

/* ---- 進捗バーの下地 */
.bar, .jobbar, .pickbar, .kline, .badgebar, .lbar { background-color: var(--line); }
.bar > span, .jobbar > span, .pickbar > span, .kfill, .kbarfill { background: var(--accent); }

/* ---- 罫線ぶんだけの区切り。角丸は 6/10/999 の3種に寄せる */
.roomdot { border-radius: var(--r-pill); }
.cal .chip, .cal .daybtn, .gtoday2, .ktag, .gseg, .info, .sheetchip { border-radius: var(--r1); }

/* ---- 作業カード（今日・工程表の日詳細・週ビューで共通） */
.jobcard {
  border-radius: var(--r2);
  box-shadow: none;
  border-color: var(--line);
  padding: var(--s4);
  gap: var(--s4);
}
.jobname {
  font-size: var(--fs-h2); font-weight: 700; line-height: var(--lh-heading);
  margin-top: var(--s1);
}
.jobsub { margin-top: var(--s1); }
.jobroom {
  color: var(--ok); background: var(--accent2); border-color: #b6ddcb;
  padding: 1px 10px; line-height: 1.6;
}
.jobbar { height: 8px; margin-top: var(--s2); }
.jobbtn .btn { min-height: var(--tap); padding: var(--s2) var(--s5); }
.jobcard.mini { padding: var(--s3); }
.jobcard.mini .jobname { font-size: var(--fs); font-weight: 600; }

/* ---- 空状態 */
.empty { border-radius: var(--r2); background: var(--bg2); }

/* ---- 「予定」のセグメント切替 */
.seg { min-height: var(--tap-compact); font-size: var(--fs-sm); }
.seg.on { box-shadow: none; border-radius: var(--r-pill); }

/* ---- 下タブ */
.tabbar { box-shadow: none; }
.tabitem { min-height: 60px; color: var(--sub); }
.tabitem.on { color: var(--accent); }

/* ---- 保存トースト: 下タブの上に出す */
.toast {
  background: #242923;
  border-radius: var(--r1);
  font-size: var(--fs-sm);
  box-shadow: var(--sh2);
  max-width: calc(100vw - 32px);
}
body.hasbottomnav .toast {
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
}

/* ---- シート: 100dvh フォールバック＋セーフエリア */
.sheet {
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: var(--sh2);
  max-height: 88vh;
  padding-bottom: calc(var(--s4) + env(safe-area-inset-bottom));
}
.dpbox {
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: var(--sh2);
  max-height: 82vh;
  padding-bottom: calc(var(--s5) + env(safe-area-inset-bottom));
}
@supports (height: 100dvh) {
  .sheet { max-height: calc(100dvh - 16px); }
  .dpbox { max-height: calc(100dvh - 16px); }
}
.sheetfoot { padding-bottom: var(--s3); }
.sheetsave { min-height: var(--tap); }
/* 閉じるボタンは指で押せる大きさに */
.sheetx, .dpx {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap-compact); height: var(--tap-compact); min-height: var(--tap-compact);
  background: none; border: 0; color: var(--sub); font-size: 26px; font-weight: 400;
}
.sheetx:hover, .dpx:hover { background: var(--bg2); color: var(--ink); }
.sheetchip { min-height: var(--tap-compact); font-size: var(--fs-sm); }
.sheettitle { font-size: 20px; }

/* ══════════════════════════════════════════════════════════════════
   ③ 画面固有
   ══════════════════════════════════════════════════════════════════ */

/* ---------------------------------------------------------------- 今日 */
/* 連続記録・週の振り返りは「評価」ではなく「事実」。警告色を外す */
.streakbar {
  background: transparent; border: 0; border-radius: 0; padding: 0;
  margin: 0 0 var(--s4); color: var(--sub);
}
.streakbar.on { background: transparent; border: 0; color: var(--sub); }
.streakbar .flame, .streakbar.on .flame { color: var(--sub); }
.streaknum { font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.streakbar.on .streaknum { color: var(--ink); }
.delta.down { color: var(--sub); font-weight: 400; }
.delta.up { color: var(--sub); font-weight: 400; }

/* 日付の見出しに添える件数 */
.todaycount { font-size: var(--fs-sm); color: var(--sub); font-weight: 400;
              margin-left: var(--s2); }

/* 予定外作業の入口。枠も背景も持たない小さな行にする */
.adhoccard { background: transparent; border: 0; box-shadow: none; padding: 0;
             margin-bottom: var(--s5); }
.sidelinks { display: flex; flex-direction: column; gap: var(--s2); }
.sidelinks .reportbox { margin-top: 0; border-top: 0; padding-top: 0; }
.sidelink { width: 100%; min-height: var(--tap); }
.sidelinknote { font-size: var(--fs-sm); color: var(--sub); margin: var(--s1) 0 0; }

.closebtn { min-height: 56px; font-size: 17px; }

/* ---------------------------------------------------------------- 工程表（共通の操作列） */
.calbar {
  display: flex; align-items: center; gap: var(--s2) var(--s3); flex-wrap: wrap;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: var(--s2) 0; margin-bottom: var(--s3);
}
.calnav { display: flex; gap: var(--s1); flex: 0 0 auto; }
.calnav .btn { min-height: var(--tap-compact); padding: var(--s2) var(--s3); }
.callabel { font-size: var(--fs-h2); font-weight: 700; flex: 1 1 auto; min-width: 0;
            line-height: var(--lh-heading); }
.calviews { display: flex; background: var(--bg2); border: 1px solid var(--line);
            border-radius: var(--r-pill); padding: 3px; flex: 0 0 auto; }
.calview {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap-compact); min-width: 52px; padding: 0 var(--s3);
  border-radius: var(--r-pill); font-size: var(--fs-sm); color: var(--sub);
}
.calview:hover { text-decoration: none; color: var(--ink); }
.calview.on { background: var(--card); color: var(--ink); font-weight: 700; }

/* 作業日の設定・予定の調整（カレンダー本体の下に畳んで置く） */
.calfolds { margin-top: var(--s5); }
.calfold { border: 1px solid var(--line); border-radius: var(--r2); background: var(--card);
           padding: var(--s3) var(--s4); margin-bottom: var(--s3); }
.calfold > summary { cursor: pointer; font-weight: 700; min-height: var(--tap);
                     display: flex; align-items: center; }
.calfoldbody { padding-top: var(--s3); }
/* カードの中に置いた折りたたみは、枠を重ねない */
.card .calfold { border: 0; border-radius: 0; padding: var(--s2) 0 0; background: transparent; }
.card .calfold + .calfold { border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- 工程表: 月 */
.cal td { height: auto; min-height: 110px; font-size: var(--fs-sm); }
.cal th { font-size: var(--fs-sm); padding: var(--s2) 2px; }
.cal .dnum { font-size: var(--fs-sm); display: flex; align-items: center; gap: var(--s1);
             flex-wrap: wrap; }
.cal .daybtn { font-size: var(--fs-sm); min-width: 32px; min-height: 32px; line-height: 30px; }
.cal .hlink { font-size: var(--fs-xs); }
.cal td.off .daybtn { color: var(--sub); }
.cal td.off .daybtn.on { color: #fff; }
.cal .chip { font-size: var(--fs-xs); padding: 2px 6px; margin-top: 3px; }
.callegend { font-size: var(--fs-sm); }
/* スマホ向けの要約（件数＋色ドット）。PCでは出さない */
.calsum { display: none; align-items: center; gap: var(--s1); flex-wrap: wrap;
          margin-top: var(--s1); font-size: var(--fs-xs); color: var(--sub); }
.caldot { display: inline-block; width: 8px; height: 8px; border-radius: var(--r-pill);
          background: var(--accent); }
.caldot.vendor { background: #d08b2c; }
.calmore { display: block; margin-top: var(--s2); font-size: var(--fs-sm); }

/* ---------------------------------------------------------------- 工程表: 週 */
.weekgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px;
            background: var(--line); border: 1px solid var(--line); border-radius: var(--r2);
            overflow: hidden; }
.weekcol { background: var(--card); min-height: 320px; padding: var(--s2); min-width: 0; }
.weekcol.rest { background: var(--bg2); }
.weekcol.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.weekhead { display: flex; align-items: baseline; gap: var(--s1); flex-wrap: wrap;
            padding-bottom: var(--s2); border-bottom: 1px solid var(--line);
            margin-bottom: var(--s2); }
.weekwd { font-size: var(--fs-xs); color: var(--sub); }
.weekdate { font-size: var(--fs); font-weight: 700; }
.weekdate a { color: var(--ink); }
.weekcap { font-size: var(--fs-xs); color: var(--sub); }
.weekitems { display: flex; flex-direction: column; gap: var(--s1); }
.weekitem {
  display: block; min-height: var(--tap); padding: var(--s2); border-radius: var(--r1);
  background: var(--accent2); border: 1px solid #b6ddcb; color: var(--ink);
  font-size: var(--fs-sm); line-height: 1.4; cursor: pointer;
}
.weekitem:hover { background: #d9e8de; text-decoration: none; }
.weekitem.vendor { background: var(--warnbg); border-color: #e6c6a8; }
.weekitemname { display: block; font-weight: 600; overflow-wrap: anywhere; }
.weekitemsub { display: block; font-size: var(--fs-xs); color: var(--sub); }
.weekrest { font-size: var(--fs-sm); color: var(--sub); }

/* ---------------------------------------------------------------- 工程表: 日 */
.dayview { background: var(--card); border: 1px solid var(--line); border-radius: var(--r2);
           padding: var(--s4); }
.dayviewdate { font-size: var(--fs-h1); margin: 0 0 var(--s1); }

/* ---------------------------------------------------------------- ガント */
.ganttwrap { border-radius: var(--r2); max-height: 72vh; overflow: auto;
             -webkit-overflow-scrolling: touch; }
.gantt {
  font-size: var(--fs-sm);
  width: 100%;
  min-width: calc(var(--gname-w) + var(--gdays, 30) * var(--gday-w));
}
.gantt col.gcname { width: var(--gname-w); }
.gantt col.gcday { width: var(--gday-w); }
.gantt .gname {
  width: var(--gname-w); min-width: var(--gname-w); max-width: var(--gname-w);
  font-size: var(--fs-sm); padding: var(--s2); z-index: 2;
}
.gantt thead th { position: sticky; top: 0; z-index: 3; }
.gantt thead th.gname { z-index: 4; }
.gantt .gmonth { font-size: var(--fs-sm); padding: var(--s1) var(--s2); background: #e8e3da; }
.gantt .gday {
  width: var(--gday-w); min-width: var(--gday-w); font-size: var(--fs-xs);
  padding: var(--s1) 0; background: #f2efe9;
}
.gantt .gday.gtoday { background: var(--accent2); color: var(--ink); font-weight: 700; }
.gantt .gwd { font-size: var(--fs-xs); color: var(--sub); }
.gantt td { height: var(--tap-compact); padding: 3px 2px; }
.gantt tr.gsub td { height: var(--tap-compact); }
.gantt .gtoggle { font-size: var(--fs-sm); min-height: var(--tap-compact); }
.gantt .gnum { font-size: var(--fs-xs); }
.gantt tr.gsub th.gsubname { font-size: var(--fs-sm); padding: var(--s1) var(--s2); }
.gantt .gsubv { font-size: var(--fs-xs); }
.gantt .gmark { font-size: var(--fs-xs); }
.gseg { height: 16px; border-radius: 3px; margin: 2px 0; position: relative; }
.gseg.done { background: var(--accent); }
.gseg.doing { background: var(--blue); }
.gseg.todo { background: #9a958c; }
.gseg.vendor { background: #c07d1f; }
/* 帯が3日以上つづくときだけ、帯の中に作業名を出す */
.gsegname {
  position: absolute; left: 5px; top: 0; height: 16px; line-height: 16px;
  font-size: var(--fs-xs); color: #fff; white-space: nowrap; pointer-events: none;
}
.ganttlegend { font-size: var(--fs-sm); }
.ganttlegend .gseg { width: 26px; height: 12px; }
.gantt .gtoday { border-left: 2px solid #c0392b; border-right: 2px solid #c0392b; }
.gtoday2 { font-size: var(--fs-xs); padding: 0 5px; }
/* 説明・凡例・並び替えは表の下へ（HTML側で並びを変えている） */
.ganttfoot { margin-top: var(--s4); }
.ganttfoot .calfold { margin-top: var(--s3); }

/* ---------------------------------------------------------------- 看板 */
.kboard { background: var(--bg2); border-radius: var(--r2); }
.kcol { background: var(--card); border: 1px solid var(--line); border-radius: var(--r2); }
.kcoltitle { font-size: var(--fs); color: var(--ink); font-weight: 700; }
.kcount { font-size: var(--fs-xs); color: var(--sub); background: var(--bg2); }
/* 「件数」と「工数＋バー」を2つの塊にして横並び。幅が足りない390px等では
   塊ごと自然に折り返す（塊の途中で改行して区切り記号だけ残る、という崩れを防ぐ） */
.ksum { font-size: var(--fs-sm); color: var(--ink); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
/* 元の区切り「／」要素はテストがid文字列を見るためDOMには残すが、画面には出さない。
   見た目の区切りは次の塊の頭に擬似要素で出し、塊と一体化させて行末に孤立させない */
.ksum .ksep { display: none; }
.ksum .ksumgrp { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
/* ::beforeはksumgrp自体ではなく中の文字spanに付ける。ksumgrpに付けると生成内容自体が
   独立したflexアイテム扱いになり、結局そこだけ折り返されて孤立し得るため */
.ksum .ksumgrp[data-grp="hours"] .ksumtext::before { content: "／"; color: var(--sub); margin-right: 8px; }
.kcard { border: 1px solid var(--line); border-radius: var(--r2); box-shadow: none; }
.kcard:hover { background: var(--bg2); }
/* 完了カードも薄くしない。状態は文字とチェックで読ませる */
.kcard.kfaded { opacity: 1; background: var(--bg2); }
.kcard.kfaded .kname { color: var(--sub); }
.pickcard.pickdone { opacity: 1; background: var(--bg2); }
/* 部屋名は色だけでなく文字でも読めるようにする */
.ktag {
  display: inline-block; width: auto; height: auto; font-size: var(--fs-xs);
  line-height: 1.5; padding: 1px 8px 1px 20px; margin-bottom: var(--s2);
  background: var(--bg2); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--r-pill); overflow: visible; position: relative;
  max-width: 100%; white-space: nowrap; text-overflow: ellipsis;
}
/* 部屋の色は左の小さな印だけに使う */
.ktag::before {
  content: ""; position: absolute; left: 7px; top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px; border-radius: var(--r-pill); background: #b3bac5;
}
.ktag.rc0::before { background: #0079bf; } .ktag.rc1::before { background: #4a9c3a; }
.ktag.rc2::before { background: #d98200; } .ktag.rc3::before { background: #9b59b6; }
.ktag.rc4::before { background: #d0402c; } .ktag.rc5::before { background: #0e93ad; }
.ktag.rc6::before { background: #b39400; } .ktag.rc7::before { background: #2fa86a; }
.ktag.rc8::before { background: #d1519a; } .ktag.rc9::before { background: #344563; }
.ktag.rcx::before { background: #b3bac5; }
/* 帯の背景色（元の指定）は打ち消す */
.ktag.rc0, .ktag.rc1, .ktag.rc2, .ktag.rc3, .ktag.rc4, .ktag.rc5,
.ktag.rc6, .ktag.rc7, .ktag.rc8, .ktag.rc9, .ktag.rcx { background: var(--bg2); }
.kcard .kname { font-size: var(--fs); color: var(--ink); font-weight: 600; }
.kbtns button { padding: var(--s1) var(--s2); font-size: var(--fs-xs);
                min-height: var(--tap-compact); }
.kfree input[type=number] { width: 84px; min-height: var(--tap-compact); font-size: var(--fs-sm); }

/* ---------------------------------------------------------------- 材料 */
/* 「これから買う分」を主数値にする */
.stat[data-main="1"] { background: var(--accent2); border-color: #b6ddcb; }
.stat[data-main="1"] .val { font-size: var(--fs-number); color: var(--accent); }
.stat[data-main="1"] .lbl { color: var(--ink); font-weight: 700; }
td[style*="line-through"] { color: var(--sub) !important; }

/* ---------------------------------------------------------------- その他 */
/* 外側カードと .morelist の二重枠は片方だけにする */
.card[data-list="1"] { background: transparent; border: 0; padding: 0; }
.morelist { background: var(--card); border-radius: var(--r2); }
.moreitem { min-height: 56px; padding: var(--s3) var(--s4); }
.morelabel { font-size: var(--fs); }
/* 削除の領域は他から離す */
.card[data-danger="1"] { margin-top: var(--s6); }

/* ---------------------------------------------------------------- フォームの列 */
/* 名前・メモは全幅、数量・単位は2列。150pxの自動詰め込みはやめる */
.row { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.row[data-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row .field[data-span="full"] { grid-column: 1 / -1; }

/* ---------------------------------------------------------------- 表 */
table { font-size: var(--fs-sm); }
th { background: #f2efe9; font-size: var(--fs-sm); }
/* 表は潰さず、最小幅を確保して .tablewrap の中で横スクロールさせる */
table[data-table="tasks"] { min-width: 880px; }
table[data-table="tasks"] td[data-col="name"] { min-width: 220px; }
table[data-table="shop"] { min-width: 560px; }
table[data-table="matrows"] { min-width: 640px; }
/* 表の中の小さいボタンは縦に割らない */
.tablewrap button.mini, .tablewrap .btn.mini { white-space: nowrap; }

/* ══════════════════════════════════════════════════════════════════
   ④ レスポンシブ
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 820px) {
  /* 物件内のページでは、黒かったアプリ名のバーを出さない（「その他」から行ける） */
  body.hasbottomnav .topbar { display: none; }
  body.hasbottomnav { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); }

  /* 物件名バーは画面上に貼り付ける */
  body.hasbottomnav .projnav {
    position: sticky; top: 0; z-index: 30;
    background: var(--card); border-bottom: 1px solid var(--line);
  }

  /* 工程表の操作列も物件名バーの直下に貼り付ける */
  .calbar { position: sticky; top: 44px; z-index: 20; background: var(--card);
            padding: var(--s2) 0; }
  .callabel { font-size: var(--fs); flex: 1 0 100%; order: -1; }

  /* 月カレンダー: 作業名チップは出さず、件数の要約にする */
  .cal td { min-height: 72px; }
  .cal .chip { display: none; }
  .calsum { display: flex; }
  .cal .daybtn { min-width: 40px; min-height: 40px; line-height: 38px; }

  /* 週ビュー: 7列ではなく、日ごとの縦セクションにする */
  .weekgrid { display: flex; flex-direction: column; gap: 1px; }
  .weekcol { min-height: 0; padding: var(--s3); }
  .weekitem { min-height: var(--tap); }

  /* ガント */
  :root { --gname-w: 128px; --gday-w: 40px; }
  .ganttwrap { max-height: none; }
  .gantt { font-size: var(--fs-xs); }
  .gantt thead th { position: static; }
  .gantt td, .gantt tr.gsub td { height: var(--tap-compact); }

  /* 看板: 隣の列を少し見せる */
  .kcol { flex: 0 0 min(82vw, 360px); width: min(82vw, 360px); }

  /* 買い物の表: 店頭で要る「買う」と「もの」を左に固定し、残りは横スクロールで読む */
  table[data-table="shop"] th:nth-child(1), table[data-table="shop"] td:nth-child(1) {
    position: sticky; left: 0; z-index: 1; width: 84px; min-width: 84px;
    background: var(--card);
  }
  table[data-table="shop"] th:nth-child(2), table[data-table="shop"] td:nth-child(2) {
    position: sticky; left: 84px; z-index: 1; width: 140px; min-width: 140px;
    background: var(--card); border-right: 1px solid var(--line);
  }
  table[data-table="shop"] th:nth-child(1), table[data-table="shop"] th:nth-child(2) {
    background: #f2efe9;
  }

  /* 作業リストの表: 横スクロールしても作業名が消えないよう左に固定する */
  table[data-table="tasks"] th:nth-child(2),
  table[data-table="tasks"] td[data-col="name"] {
    position: sticky; left: 0; z-index: 1;
    min-width: 180px; max-width: 200px;
    background: var(--card); border-right: 1px solid var(--line);
  }
  table[data-table="tasks"] th:nth-child(2) { background: #f2efe9; }
}

@media (min-width: 821px) {
  .wrap { padding: var(--s5); }
  /* 看板はPCの横幅を使い切る */
  .kcol { flex: 1 1 0; width: auto; min-width: 260px; }
  .sheet { border-radius: var(--r-sheet); }
}

@media (max-width: 640px) {
  /* 狭い画面ではフォームは1列（data-cols="2" の数量・単位だけ2列のまま） */
  .row { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 21px; }
  .wrap { padding: var(--s3) var(--s3); }
  .cal td { font-size: var(--fs-xs); }
  button.mini, .btn.mini { min-height: var(--tap-compact); padding: var(--s2) var(--s3); }
  table { font-size: var(--fs-sm); }
  /* 縦積みのときに中身が中央寄せになっていた（style.css の @media が .jobcard の
     基本指定より前にあるため align-items:center が後勝ちしていた）。左揃えに戻す */
  .jobcard { padding: var(--s3); align-items: stretch; }
}
